Optimized code(again), TXLib added to resources, and compiling is in new thread now

This commit is contained in:
DarkCat09 2020-10-08 19:07:23 +04:00
parent 4d22e9dbbc
commit f5b399abf7
24 changed files with 9005 additions and 8619 deletions

View file

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication1
@ -47,29 +48,7 @@ namespace WindowsFormsApplication1
textBox2.Text += ("Компиляция " + codeFilename + " в " +
Path.GetFileNameWithoutExtension(codeFilename) + ".exe с помощью " +
mingwDir + "\\bin\\mingw32-g++.exe:" + Environment.NewLine + Environment.NewLine);
Process mingwp = new Process();
mingwp.StartInfo = new ProcessStartInfo()
{
FileName = mingwDir + "\\bin\\mingw32-g++.exe",
Arguments = codeFilename + " -o " + Path.GetDirectoryName(codeFilename) + "\\" +
Path.GetFileNameWithoutExtension(codeFilename) + ".exe",
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
StandardOutputEncoding = Encoding.GetEncoding(866),
StandardErrorEncoding = Encoding.GetEncoding(866),
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
mingwp.OutputDataReceived += new DataReceivedEventHandler(CompilerOutputHandler);
mingwp.ErrorDataReceived += new DataReceivedEventHandler(CompilerOutputHandler);
mingwp.Start();
mingwp.BeginOutputReadLine();
mingwp.BeginErrorReadLine();
mingwp.WaitForExit(10000);
_ = MessageBox.Show("Готово!");
new Thread(new ThreadStart(CompilingFunction)).Start();
}
catch (Exception ex)
{
@ -83,9 +62,34 @@ namespace WindowsFormsApplication1
}
}
private void CompilingFunction()
{
Process mingwp = new Process();
mingwp.StartInfo = new ProcessStartInfo()
{
FileName = mingwDir + "\\bin\\mingw32-g++.exe",
Arguments = codeFilename + " -o " + Path.GetDirectoryName(codeFilename) + "\\" +
Path.GetFileNameWithoutExtension(codeFilename) + ".exe",
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
StandardOutputEncoding = Encoding.GetEncoding(866),
StandardErrorEncoding = Encoding.GetEncoding(866),
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
mingwp.OutputDataReceived += new DataReceivedEventHandler(CompilerOutputHandler);
mingwp.ErrorDataReceived += new DataReceivedEventHandler(CompilerOutputHandler);
mingwp.Start();
mingwp.BeginOutputReadLine();
mingwp.BeginErrorReadLine();
mingwp.WaitForExit(20000);
textBox2.Invoke(new Action(() => { textBox2.AppendText("Готово!" + Environment.NewLine); }));
}
private void CompilerOutputHandler(object sendingProcess, DataReceivedEventArgs outputLine)
{
textBox2.Invoke(new Action(() => { textBox2.Text += (outputLine.Data + Environment.NewLine); }));
textBox2.Invoke(new Action(() => { textBox2.AppendText(outputLine.Data + Environment.NewLine); }));
}
}
}

View file

@ -239,78 +239,86 @@ namespace WindowsFormsApplication1
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
mainFilename = saveFileDialog1.FileName;
//Adding TXLibrary and pictures
File.Copy("TXLib.h", Path.GetDirectoryName(mainFilename) + "\\TXLib.h", true);
string dir_path = Path.GetDirectoryName(mainFilename) + "\\Pictures";
if (!Directory.Exists(dir_path))
try
{
Directory.CreateDirectory(dir_path);
}
mainFilename = saveFileDialog1.FileName;
if (addressBackground != dir_path + "\\" + Path.GetFileName(addressBackground))
{
File.Copy(addressBackground, dir_path + "\\" + Path.GetFileName(addressBackground), true);
}
Files.CreateStruct(mainFilename);
Files.OpenMain(mainFilename, PictureBoxBackground, addressBackground);
for (int nomer = 0; nomer < nomerPersa; nomer++)
{
File.Copy(persons[nomer].address, dir_path + "\\" + Path.GetFileName(persons[nomer].address), true);
//Adding TXLibrary and pictures
File.WriteAllText(Path.GetDirectoryName(mainFilename) + "\\TXLib.h", Properties.Resources.TXLib);
string dir_path = Path.GetDirectoryName(mainFilename) + "\\Pictures";
if (!Directory.Exists(dir_path))
{
Directory.CreateDirectory(dir_path);
}
if (dir_path == dir_path + "\\" + Path.GetFileName(persons[nomer].address))
if (addressBackground != dir_path + "\\" + Path.GetFileName(addressBackground))
{
File.Copy(addressBackground, dir_path + "\\" + Path.GetFileName(addressBackground), true);
}
Files.CreateStruct(mainFilename);
Files.OpenMain(mainFilename, PictureBoxBackground, addressBackground);
for (int nomer = 0; nomer < nomerPersa; nomer++)
{
File.Copy(persons[nomer].address, dir_path + "\\" + Path.GetFileName(persons[nomer].address), true);
if (dir_path == dir_path + "\\" + Path.GetFileName(persons[nomer].address))
{
File.Copy(persons[nomer].address, dir_path + "\\" + Path.GetFileName(persons[nomer].address), true);
}
if (persons[nomer].moveside == "Прямо")
{
Line.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Волнами")
{
Sinus.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Кругами")
{
Circle.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Диагонально")
{
Line.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
}
if (persons[nomer].moveside == "Прямо")
Files.OpenWhile(mainFilename, maxTime);
for (int nomer = 0; nomer < nomerPersa; nomer++)
{
Line.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Волнами")
{
Sinus.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Кругами")
{
Circle.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Диагонально")
{
Line.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
if (persons[nomer].moveside == "Прямо")
{
Line.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Волнами")
{
Sinus.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Кругами")
{
Circle.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Диагонально")
{
Line.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
}
Files.CloseWhile(mainFilename);
DeletePics(mainFilename, nomerPersa);
Files.Ending(mainFilename, checkBox1.Checked);
MessageBox.Show("Готово!");
}
Files.OpenWhile(mainFilename, maxTime);
for (int nomer = 0; nomer < nomerPersa; nomer++)
catch (Exception ex)
{
if (persons[nomer].moveside == "Прямо")
{
Line.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Волнами")
{
Sinus.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Кругами")
{
Circle.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Диагонально")
{
Line.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
_ = MessageBox.Show("Произошла ошибка!\n" + ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Files.CloseWhile(mainFilename);
DeletePics(mainFilename, nomerPersa);
Files.Ending(mainFilename, checkBox1.Checked);
MessageBox.Show("Готово!");
}
}
@ -344,11 +352,11 @@ namespace WindowsFormsApplication1
private void Char_Info_Click(object sender, EventArgs e)
{
this.leftPanel.Controls.Remove(persons[nomerPersa - 1].l1);
this.leftPanel.Controls.Remove(persons[nomerPersa - 1].l2);
this.leftPanel.Controls.Remove(persons[nomerPersa - 1].l3);
this.leftPanel.Controls.Remove(persons[nomerPersa - 1].b1);
this.leftPanel.Controls.Remove(persons[nomerPersa - 1].b2);
leftPanel.Controls.Remove(persons[nomerPersa - 1].l1);
leftPanel.Controls.Remove(persons[nomerPersa - 1].l2);
leftPanel.Controls.Remove(persons[nomerPersa - 1].l3);
leftPanel.Controls.Remove(persons[nomerPersa - 1].b1);
leftPanel.Controls.Remove(persons[nomerPersa - 1].b2);
nomerPersa--;
yPersa -= 30;
}

Binary file not shown.

Before

(image error) Size: 10 KiB

View file

@ -19,7 +19,7 @@ namespace WindowsFormsApplication1.Properties {
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@ -59,5 +59,20 @@ namespace WindowsFormsApplication1.Properties {
resourceCulture = value;
}
}
/// <summary>
/// Ищет локализованную строку, похожую на //=================================================================================================================
///// [These sections are for folding control in Code::Blocks]
/////{ [Best viewed with &quot;Fold all on file open&quot; option enabled] [best screen width is 115 chars]
/////=================================================================================================================
/////!
/////! @file TXLib.h
/////! @brief Библиотека Тупого Художника (The Dumb Artist Libr [остаток строки не уместился]&quot;;.
/// </summary>
internal static string TXLib {
get {
return ResourceManager.GetString("TXLib", resourceCulture);
}
}
}
}

View file

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@ -109,9 +112,13 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TXLib" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\TXLib.h;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1251</value>
</data>
</root>

View file

@ -94,6 +94,9 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="TXLib.h" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

Binary file not shown.

Before

(image error) Size: 10 KiB

View file

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]

View file

@ -0,0 +1 @@
a71191b9b8c49cadecaa2e05cc537d361f14ffd5

View file

@ -0,0 +1,11 @@
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojAssemblyReference.cache
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.CompileForm.resources
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.MainForm.resources
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.cache
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.CoreCompileInputs.cache
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
C:\Users\Acer\VisualStudio\source\repos\MultRedactor\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb