Optimized code and Added compiling functionally!

This commit is contained in:
DarkCat09 2020-10-06 13:32:17 +04:00
parent b4a7194358
commit 4d22e9dbbc
34 changed files with 717 additions and 353 deletions

Binary file not shown.

View file

@ -1,5 +1,21 @@
# MultRedactor
Редактор мультиков
Задачи
https://docs.google.com/spreadsheets/d/1ka-DjMCEskMYwHZOzJRvlgEZpGA5g-WNFh_pH3sF3y4/edit#gid=1972460334
## Что это?
_MultRedactor_ - удобный графический редактор мультфильмов. Вы создаёте персонажей, задаёте им параметры, а эта программка преобразует всё в исходный код C++, и, по нажатию соответствующей кнопки, скомпилирует его. Правда удобно?
## Как использовать?
1. Запустите приложение.
2. В левой части окна, в поле ввода, напишите название мультфильма.
3. Всё в той же левой части выберите фон.
4. Нажмите кнопку "Добавить персонажа".
5. Выберите вид движения, границы (```x,y``` начала и ```x,y``` конца), тайминг (в секундах) и картинку.
6. Назовите своего персонажа (необязательно) и нажмите кнопку "Сохранить персонажа".
7. Если нужно, добавьте ещё персонажей.
8. Нажмите кнопку "Сохранить мульт", выберите расположение файлов и введите название главного файла. Естественно, нужно нажать "Сохранить".
9. Через некоторое время появится сообщение "Готово!". Нажмите кнопку "Компилировать". В открывшемся окошечке всё и так понятно расписано, здесь пояснять ничего не буду.
10. По окончанию компиляции появится сообщение "Готово!". Да, теперь точно готово. Перейдите в каталог с мультфильмом - там найдёте *.exe-файл. Это готовый мультик.
## TODO
- Написать нормальную инструкцию с картинками
- Доделать код движения персонажей, т.к. сейчас это всё очень криво...
- https://docs.google.com/spreadsheets/d/1ka-DjMCEskMYwHZOzJRvlgEZpGA5g-WNFh_pH3sF3y4/edit#gid=1972460334

View file

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication1
{
@ -11,39 +7,43 @@ namespace WindowsFormsApplication1
{
public static void CreatePerson(string filename, string name, Person p)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " Person " + name + ";" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(p.adress) + "\");" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x = " + p.x1 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = " + p.y1 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x2 = " + p.x2 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y2 = " + p.y2 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".angle = 0;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(Environment.NewLine);
sw.Write(" Person " + name + ";" + Environment.NewLine);
sw.Write(" " + name + ".texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(p.address) + "\");" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Write(" " + name + ".x = " + p.x1 + "; " + Environment.NewLine);
sw.Write(" " + name + ".y = " + p.y1 + "; " + Environment.NewLine);
sw.Write(" " + name + ".x2 = " + p.x2 + "; " + Environment.NewLine);
sw.Write(" " + name + ".y2 = " + p.y2 + "; " + Environment.NewLine);
sw.Write(" " + name + ".angle = 0;" + Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra = 0;" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Close();
}
public static void MovePerson(string filename, string name, Person p)
{
File.AppendAllText(filename, " if ((myTime >= " + p.time1 + ") && (myTime <= " + p.time2 + ")) {" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".angle = " + name + ".angle + 360 / 20 * " + p.circles + " / (" + p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x = (" + p.x1 + " + " + p.x2 + ")/2 + (" + p.x1 + " - " + p.x2 + ")/2 * cos (" + name + ".angle * 3.1416 / 180);" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = (" + p.y1 + " + " + p.y2 + ")/2 + (" + p.y1 + " - " + p.y2 + ")/2 * sin (" + name + ".angle * 3.1416 / 180);" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), " + name + ".x, " + name + ".y, " +
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(" if ((myTime >= " + p.time1 + ") && (myTime <= " + p.time2 + ")) {" + Environment.NewLine);
sw.Write(" " + name + ".angle = " + name + ".angle + 360 / 20 * " + p.circles + " / (" + p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
sw.Write(" " + name + ".x = (" + p.x1 + " + " + p.x2 + ")/2 + (" + p.x1 + " - " + p.x2 + ")/2 * cos (" + name + ".angle * 3.1416 / 180);" + Environment.NewLine);
sw.Write(" " + name + ".y = (" + p.y1 + " + " + p.y2 + ")/2 + (" + p.y1 + " - " + p.y2 + ")/2 * sin (" + name + ".angle * 3.1416 / 180);" + Environment.NewLine);
sw.Write(" txTransparentBlt(txDC(), " + name + ".x, " + name + ".y, " +
p.width + "/" + p.sprite + ", " +
p.height + "," +
name + ".texture, " +
p.width + "/" + p.sprite + " * " + name + ".nomer_kadra, 0, RGB(255, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " if (" + name + ".nomer_kadra >= " + p.sprite + ")" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra++;" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Write(" if (" + name + ".nomer_kadra >= " + p.sprite + ")" + Environment.NewLine);
sw.Write(" {" + Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra = 0;" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Close();
}
}
}

View file

@ -0,0 +1,142 @@
namespace WindowsFormsApplication1
{
partial class CompileForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.button2 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(196, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Полный путь к каталогу MinGW";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 25);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(196, 20);
this.textBox1.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(214, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(74, 22);
this.button1.TabIndex = 2;
this.button1.Text = "Обзор...";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(12, 48);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(257, 13);
this.linkLabel1.TabIndex = 3;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "У меня нет установленного компилятора MinGW";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// button2
//
this.button2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button2.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.button2.Location = new System.Drawing.Point(0, 176);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(300, 28);
this.button2.TabIndex = 4;
this.button2.Text = "Старт!";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(12, 85);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox2.Size = new System.Drawing.Size(276, 82);
this.textBox2.TabIndex = 5;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label2.Location = new System.Drawing.Point(12, 69);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(127, 13);
this.label2.TabIndex = 6;
this.label2.Text = "Вывод компилятора";
//
// CompileForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 204);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button2);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CompileForm";
this.Text = "Компилировать";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label2;
}
}

View file

@ -0,0 +1,91 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class CompileForm : Form
{
private string codeFilename = "";
private string mingwDir = "";
public CompileForm(string _codeFilename)
{
InitializeComponent();
codeFilename = _codeFilename;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (MessageBox.Show("Для создания *.exe-файла мультфильма нужна специальная программа - компилятор.\n" +
"Мы используем компилятор MinGW. Чтобы его скачать, нажмите OK в этом диалоге,\n" +
"но учтите, что все нужные файлы весят ≈800МиБ!\n\n" +
"После загрузки Вам нужно распаковать архив в удобное Вам место,\n" +
"а затем, в этом окне, выбрать каталог mingw, который теперь лежит в \"удобном Вам месте\".",
"Скачать MinGW", MessageBoxButtons.OKCancel, MessageBoxIcon.Information).ToString() == "OK")
{
Process.Start("https://is.gd/Krp8r4");
}
}
private void button1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog().ToString() == "OK")
{
mingwDir = folderBrowserDialog1.SelectedPath;
}
textBox1.Text = mingwDir;
}
private void button2_Click(object sender, EventArgs e)
{
if (mingwDir != "")
{
try
{
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("Готово!");
}
catch (Exception ex)
{
_ = MessageBox.Show("Произошла ошибка!\n" + ex.Message);
}
}
else
{
_ = MessageBox.Show("Сначала укажите каталог с MinGW!", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CompilerOutputHandler(object sendingProcess, DataReceivedEventArgs outputLine)
{
textBox2.Invoke(new Action(() => { textBox2.Text += (outputLine.Data + Environment.NewLine); }));
}
}
}

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<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">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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" 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">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View file

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
@ -11,67 +9,81 @@ namespace WindowsFormsApplication1
public static void CreateStruct(string filename)
{
File.WriteAllText(filename, "");
File.AppendAllText(filename, "#include \"TXLib.h\"" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, "struct Person" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename, " double x;" + Environment.NewLine);
File.AppendAllText(filename, " double x2;" + Environment.NewLine);
File.AppendAllText(filename, " double y;" + Environment.NewLine);
File.AppendAllText(filename, " double y2;" + Environment.NewLine);
File.AppendAllText(filename, " double angle;" + Environment.NewLine);
File.AppendAllText(filename, " double nomer_kadra;" + Environment.NewLine);
File.AppendAllText(filename, " HDC texture;" + Environment.NewLine);
File.AppendAllText(filename, " int MID_x;" + Environment.NewLine);
File.AppendAllText(filename, " int MID_y;" + Environment.NewLine);
File.AppendAllText(filename, " int rad;" + Environment.NewLine);
File.AppendAllText(filename, " int skorost;" + Environment.NewLine);
File.AppendAllText(filename, " int gr_dvigx;" + Environment.NewLine);
File.AppendAllText(filename, " int gr_dvigy;" + Environment.NewLine);
File.AppendAllText(filename, " int nach_dv;" + Environment.NewLine);
File.AppendAllText(filename, " int ampl_y;" + Environment.NewLine);
File.AppendAllText(filename, " int ampl_x;" + Environment.NewLine);
File.AppendAllText(filename, " double BeginTime;" + Environment.NewLine);
File.AppendAllText(filename, " double EndTime;" + Environment.NewLine);
File.AppendAllText(filename, " double Time;" + Environment.NewLine);
File.AppendAllText(filename, "};" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
StreamWriter sw = new StreamWriter(filename);
sw.Write("#include \"TXLib.h\"" + Environment.NewLine);
sw.Write( Environment.NewLine);
sw.Write("struct Person" + Environment.NewLine);
sw.Write("{" + Environment.NewLine);
sw.Write(" double x;" + Environment.NewLine);
sw.Write(" double x2;" + Environment.NewLine);
sw.Write(" double y;" + Environment.NewLine);
sw.Write(" double y2;" + Environment.NewLine);
sw.Write(" double angle;" + Environment.NewLine);
sw.Write(" double nomer_kadra;" + Environment.NewLine);
sw.Write(" HDC texture;" + Environment.NewLine);
sw.Write(" int MID_x;" + Environment.NewLine);
sw.Write(" int MID_y;" + Environment.NewLine);
sw.Write(" int rad;" + Environment.NewLine);
sw.Write(" int skorost;" + Environment.NewLine);
sw.Write(" int gr_dvigx;" + Environment.NewLine);
sw.Write(" int gr_dvigy;" + Environment.NewLine);
sw.Write(" int nach_dv;" + Environment.NewLine);
sw.Write(" int ampl_y;" + Environment.NewLine);
sw.Write(" int ampl_x;" + Environment.NewLine);
sw.Write(" double BeginTime;" + Environment.NewLine);
sw.Write(" double EndTime;" + Environment.NewLine);
sw.Write(" double Time;" + Environment.NewLine);
sw.Write("};" + Environment.NewLine);
sw.Write( Environment.NewLine);
sw.Close();
}
public static void OpenMain(string filename, PictureBox PictureBoxBackground, String adressBackground)
public static void OpenMain(string filename, PictureBox PictureBoxBackground, String addressBackground)
{
File.AppendAllText(filename, "int main()" + Environment.NewLine);
File.AppendAllText(filename, "{" + Environment.NewLine);
File.AppendAllText(filename, " txCreateWindow(" +
StreamWriter sw = new StreamWriter(filename, true);
sw.Write("int main()" + Environment.NewLine);
sw.Write("{" + Environment.NewLine);
sw.Write(" txCreateWindow(" +
PictureBoxBackground.Image.Width.ToString() + ", " +
PictureBoxBackground.Image.Height.ToString() + ");" + Environment.NewLine);
File.AppendAllText(filename, " double myTime = 0;" + Environment.NewLine);
File.AppendAllText(filename, " HDC texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(adressBackground) + "\");" + Environment.NewLine);
sw.Write(" double myTime = 0;" + Environment.NewLine);
sw.Write(" HDC texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(addressBackground) + "\");" +
Environment.NewLine);
sw.Close();
}
public static void CloseWhile(string filename)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " myTime += 0.05;" + Environment.NewLine);
File.AppendAllText(filename, " txSleep(50);" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(Environment.NewLine);
sw.Write(" myTime += 0.05;" + Environment.NewLine);
sw.Write(" txSleep(50);" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Close();
}
public static void OpenWhile(string filename, int maxTime)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " while (myTime <= " + maxTime + ")" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " txSetColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txSetFillColor(TX_RED);" + Environment.NewLine);
File.AppendAllText(filename, " txBitBlt(txDC(), 0, 0, txGetExtentX(), txGetExtentY(), texture, 0, 0);" + Environment.NewLine);
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(Environment.NewLine);
sw.Write(" while (myTime <= " + maxTime + ")" + Environment.NewLine);
sw.Write(" {" + Environment.NewLine);
sw.Write(" txSetColor(TX_RED);" + Environment.NewLine);
sw.Write(" txSetFillColor(TX_RED);" + Environment.NewLine);
sw.Write(" txBitBlt(txDC(), 0, 0, txGetExtentX(), txGetExtentY(), texture, 0, 0);" +
Environment.NewLine);
sw.Close();
}
public static void Ending(string filename)
public static void Ending(string filename, bool autoexit = false)
{
File.AppendAllText(filename, " txDeleteDC(texture);" + Environment.NewLine);
File.AppendAllText(filename, " return 0;" + Environment.NewLine);
File.AppendAllText(filename, "}" + Environment.NewLine);
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(" txDeleteDC(texture);" + Environment.NewLine);
if (autoexit)
sw.Write(" txDisableAutoPause();");
sw.Write(" return 0;" + Environment.NewLine);
sw.Write("}" + Environment.NewLine);
sw.Close();
}
}
}

View file

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication1
{
@ -11,36 +7,45 @@ namespace WindowsFormsApplication1
{
public static void CreatePerson(string filename, string name, Person p)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " Person " + name + ";" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x = " + p.x1 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = " + p.y1 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x2 = " + p.x2 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y2 = " + p.y2 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(p.adress) + "\"); " + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(Environment.NewLine);
sw.Write(" Person " + name + ";" + Environment.NewLine);
sw.Write(" " + name + ".x = " + p.x1 + "; " + Environment.NewLine);
sw.Write(" " + name + ".y = " + p.y1 + "; " + Environment.NewLine);
sw.Write(" " + name + ".x2 = " + p.x2 + "; " + Environment.NewLine);
sw.Write(" " + name + ".y2 = " + p.y2 + "; " + Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra = 0; " + Environment.NewLine);
sw.Write(" " + name + ".texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(p.address) + "\"); " +
Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Close();
}
public static void MovePerson(string filename, string name, Person p)
{
File.AppendAllText(filename, " if ((myTime >= " + p.time1 + ") && (myTime <= " + p.time2 + ")) {" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x+= (" + name + ".x2 - " + name + ".x) / (" + p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y+= (" + name + ".y2 - " + name + ".y) / (" + p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), " + name + ".x, " + name + ".y, " +
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(" if ((myTime >= " + p.time1 + ") && (myTime <= " + p.time2 + ")) {" +
Environment.NewLine);
sw.Write(" " + name + ".x+= (" + name + ".x2 - " + name + ".x) / (" +
p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
sw.Write(" " + name + ".y+= (" + name + ".y2 - " + name + ".y) / (" +
p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
sw.Write(" txTransparentBlt(txDC(), " + name + ".x, " + name + ".y, " +
p.width + "/" + p.sprite + ", " +
p.height + "," +
name + ".texture, " +
p.width + "/" + p.sprite + " * " + name + ".nomer_kadra, 0, RGB(255, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " if (" + name + ".nomer_kadra >= " + p.sprite + ")" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra++;" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Write(" if (" + name + ".nomer_kadra >= " + p.sprite + ")" +
Environment.NewLine);
sw.Write(" {" + Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra = 0;" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Close();
}
}
}

View file

@ -33,6 +33,8 @@ namespace WindowsFormsApplication1
this.LabelName = new System.Windows.Forms.Label();
this.nazvanieTextBox = new System.Windows.Forms.TextBox();
this.leftPanel = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.Char_Stats = new System.Windows.Forms.Label();
this.Char_Info = new System.Windows.Forms.Label();
this.PictureBoxBackground = new System.Windows.Forms.PictureBox();
@ -42,6 +44,7 @@ namespace WindowsFormsApplication1
this.rightPanel = new System.Windows.Forms.Panel();
this.SaveCharButton = new System.Windows.Forms.Button();
this.personPanel = new System.Windows.Forms.Panel();
this.SpriteNumberTextBox = new System.Windows.Forms.NumericUpDown();
this.charNameBox = new System.Windows.Forms.TextBox();
this.circlesTextBox = new System.Windows.Forms.TextBox();
this.circlesLabel = new System.Windows.Forms.Label();
@ -64,13 +67,12 @@ namespace WindowsFormsApplication1
this.ButtonAddChar = new System.Windows.Forms.Button();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.SpriteNumberTextBox = new System.Windows.Forms.NumericUpDown();
this.leftPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxBackground)).BeginInit();
this.rightPanel.SuspendLayout();
this.personPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.openSpace)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.SpriteNumberTextBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.openSpace)).BeginInit();
this.SuspendLayout();
//
// LabelData
@ -110,6 +112,8 @@ namespace WindowsFormsApplication1
//
// leftPanel
//
this.leftPanel.Controls.Add(this.button1);
this.leftPanel.Controls.Add(this.checkBox1);
this.leftPanel.Controls.Add(this.Char_Stats);
this.leftPanel.Controls.Add(this.Char_Info);
this.leftPanel.Controls.Add(this.PictureBoxBackground);
@ -125,10 +129,31 @@ namespace WindowsFormsApplication1
this.leftPanel.Size = new System.Drawing.Size(297, 380);
this.leftPanel.TabIndex = 4;
//
// button1
//
this.button1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button1.Location = new System.Drawing.Point(0, 350);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(297, 30);
this.button1.TabIndex = 26;
this.button1.Text = "Компилировать";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(7, 193);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(245, 17);
this.checkBox1.TabIndex = 25;
this.checkBox1.Text = "Автозакрытие мультфильма по окончанию";
this.checkBox1.UseVisualStyleBackColor = true;
//
// Char_Stats
//
this.Char_Stats.AutoSize = true;
this.Char_Stats.Location = new System.Drawing.Point(12, 219);
this.Char_Stats.Location = new System.Drawing.Point(12, 240);
this.Char_Stats.Name = "Char_Stats";
this.Char_Stats.Size = new System.Drawing.Size(259, 13);
this.Char_Stats.TabIndex = 24;
@ -137,7 +162,7 @@ namespace WindowsFormsApplication1
// Char_Info
//
this.Char_Info.AutoSize = true;
this.Char_Info.Location = new System.Drawing.Point(48, 200);
this.Char_Info.Location = new System.Drawing.Point(44, 226);
this.Char_Info.Name = "Char_Info";
this.Char_Info.Size = new System.Drawing.Size(180, 13);
this.Char_Info.TabIndex = 23;
@ -146,6 +171,7 @@ namespace WindowsFormsApplication1
//
// PictureBoxBackground
//
this.PictureBoxBackground.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PictureBoxBackground.Location = new System.Drawing.Point(84, 111);
this.PictureBoxBackground.Name = "PictureBoxBackground";
this.PictureBoxBackground.Size = new System.Drawing.Size(117, 72);
@ -231,6 +257,18 @@ namespace WindowsFormsApplication1
this.personPanel.TabIndex = 2;
this.personPanel.Visible = false;
//
// SpriteNumberTextBox
//
this.SpriteNumberTextBox.Location = new System.Drawing.Point(128, 136);
this.SpriteNumberTextBox.Name = "SpriteNumberTextBox";
this.SpriteNumberTextBox.Size = new System.Drawing.Size(43, 20);
this.SpriteNumberTextBox.TabIndex = 22;
this.SpriteNumberTextBox.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// charNameBox
//
this.charNameBox.Location = new System.Drawing.Point(115, 84);
@ -265,9 +303,10 @@ namespace WindowsFormsApplication1
//
// openSpace
//
this.openSpace.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.openSpace.Location = new System.Drawing.Point(72, 203);
this.openSpace.Name = "openSpace";
this.openSpace.Size = new System.Drawing.Size(186, 72);
this.openSpace.Size = new System.Drawing.Size(192, 72);
this.openSpace.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.openSpace.TabIndex = 17;
this.openSpace.TabStop = false;
@ -416,13 +455,6 @@ namespace WindowsFormsApplication1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// SpriteNumberTextBox
//
this.SpriteNumberTextBox.Location = new System.Drawing.Point(128, 136);
this.SpriteNumberTextBox.Name = "SpriteNumberTextBox";
this.SpriteNumberTextBox.Size = new System.Drawing.Size(43, 20);
this.SpriteNumberTextBox.TabIndex = 22;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -441,8 +473,8 @@ namespace WindowsFormsApplication1
this.rightPanel.ResumeLayout(false);
this.personPanel.ResumeLayout(false);
this.personPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.openSpace)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SpriteNumberTextBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.openSpace)).EndInit();
this.ResumeLayout(false);
}
@ -486,5 +518,7 @@ namespace WindowsFormsApplication1
private System.Windows.Forms.TextBox circlesTextBox;
private System.Windows.Forms.Label circlesLabel;
private System.Windows.Forms.NumericUpDown SpriteNumberTextBox;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox1;
}
}

View file

@ -1,20 +1,20 @@
using System;
using System.Drawing;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class MainForm : Form
{
Person[] persons = new Person[200];
int yPersa = 300;
Person[] persons = new Person[8];
int yPersa = 263;
int nomerPersa = 0;
int pNomer = 0;
int maxTime = 0;
PictureBox[] pic1 = new PictureBox[1000];
String adressBackground = "";
//PictureBox[] pic1 = new PictureBox[1000];
String addressBackground = "";
string mainFilename = "";
public MainForm()
{
@ -51,63 +51,14 @@ namespace WindowsFormsApplication1
personPanel.Visible = true;
if (pNomer == -120)
{
persons[nomerPersa] = AddRowToPersList(persons[nomerPersa]);
persons[nomerPersa].coord = TextBoxWall1.Text;
persons[nomerPersa].coord2 = TextBoxWall2.Text;
persons[nomerPersa].time1 = TextBoxTime1.Text;
persons[nomerPersa].time2 = TextBoxTime2.Text;
persons[nomerPersa].sprite = SpriteNumberTextBox.Text;
persons[nomerPersa].moveside = ComboBoxMove.Text;
persons[nomerPersa].nomer = nomerPersa;
persons[nomerPersa].charname = charNameBox.Text;
persons[nomerPersa].circles = circlesTextBox.Text;
persons[nomerPersa].l2.Text = charNameBox.Text;
String[] coordinatyNachala = TextBoxWall1.Text.Split(new String[] { "," }, StringSplitOptions.None);
if (coordinatyNachala.Length > 1)
{
persons[nomerPersa].x1 = coordinatyNachala[0];
persons[nomerPersa].y1 = coordinatyNachala[1];
}
String[] coordinatyKonza = TextBoxWall2.Text.Split(new String[] { "," }, StringSplitOptions.None);
if (coordinatyKonza.Length > 1)
{
persons[nomerPersa].x2 = coordinatyKonza[0];
persons[nomerPersa].y2 = coordinatyKonza[1];
}
persons[nomerPersa] = AddRowToPersList(persons[nomerPersa], false);
nomerPersa++;
yPersa += 30;
openSpace.Image = null;
}
else
{
persons[pNomer].coord = TextBoxWall1.Text;
persons[pNomer].coord2 = TextBoxWall2.Text;
persons[pNomer].time1 = TextBoxTime1.Text;
persons[pNomer].time2 = TextBoxTime2.Text;
persons[pNomer].sprite = SpriteNumberTextBox.Text;
persons[pNomer].moveside = ComboBoxMove.Text;
persons[pNomer].nomer = pNomer;
String[] coordinatyNachala = TextBoxWall1.Text.Split(new String[] { "," }, StringSplitOptions.None);
if (coordinatyNachala.Length > 1)
{
persons[pNomer].x1 = coordinatyNachala[0];
persons[pNomer].y1 = coordinatyNachala[1];
}
String[] coordinatyKonza = TextBoxWall2.Text.Split(new String[] { "," }, StringSplitOptions.None);
if (coordinatyKonza.Length > 1)
{
persons[pNomer].x2 = coordinatyKonza[0];
persons[pNomer].y2 = coordinatyKonza[1];
}
persons[pNomer].charname = charNameBox.Text;
persons[pNomer].circles = circlesTextBox.Text;
persons[pNomer].l2.Text = charNameBox.Text;
persons[pNomer] = AddRowToPersList(persons[pNomer], true);
}
for (int nomer = 0; nomer < nomerPersa; nomer++)
@ -121,65 +72,93 @@ namespace WindowsFormsApplication1
LabelLengh.Text = "Длительность: " + maxTime.ToString() + " секунд";
}
private Person AddRowToPersList(Person p)
private Person AddRowToPersList(Person p, bool use_pnumber = false)
{
p.l1 = new Label();
p.l1.Top = yPersa;
p.l1.Left = 30;
p.l1.Width = 20;
p.l1.Visible = true;
p.l1.Text = (nomerPersa + 1).ToString();
leftPanel.Controls.Add(p.l1);
if (!use_pnumber)
{
p.l1 = new Label();
p.l1.Top = yPersa;
p.l1.Left = 30;
p.l1.Width = 20;
p.l1.Visible = true;
p.l1.Text = (nomerPersa + 1).ToString();
leftPanel.Controls.Add(p.l1);
p.l2 = new Label();
p.l2.Top = yPersa;
p.l2.Left = 60;
p.l2.Width = 60;
p.l2.Visible = true;
p.l2.Text = "Перс" + (nomerPersa + 1).ToString();
leftPanel.Controls.Add(p.l2);
p.l2 = new Label();
p.l2.Top = yPersa;
p.l2.Left = 60;
p.l2.Width = 60;
p.l2.Visible = true;
p.l2.Text = "Перс" + (nomerPersa + 1).ToString();
leftPanel.Controls.Add(p.l2);
p.l3 = new Label();
p.l3.Top = yPersa;
p.l3.Left = 120;
p.l3.Width = 40;
p.l3.Visible = true;
p.l3.Text = "saved";
leftPanel.Controls.Add(p.l3);
p.l3 = new Label();
p.l3.Top = yPersa;
p.l3.Left = 120;
p.l3.Width = 40;
p.l3.Visible = true;
p.l3.Text = "saved";
leftPanel.Controls.Add(p.l3);
p.b1 = new Button();
p.b1.Top = yPersa;
p.b1.Left = 170;
p.b1.Width = 50;
p.b1.Visible = true;
p.b1.Text = "Edit";
p.b1.MouseClick +=
new MouseEventHandler(this.Char_Creator_Button_Click);
leftPanel.Controls.Add(p.b1);
p.b1 = new Button();
p.b1.Top = yPersa;
p.b1.Left = 170;
p.b1.Width = 50;
p.b1.Visible = true;
p.b1.Text = "Edit";
p.b1.MouseClick +=
new MouseEventHandler(Char_Creator_Button_Click);
leftPanel.Controls.Add(p.b1);
ToolTip tView = new ToolTip();
tView.IsBalloon = true;
tView.InitialDelay = 0;
tView.ShowAlways = true;
tView.AutoPopDelay = 2000;
tView.SetToolTip(p.b1, "View/edit person");
ToolTip tView = new ToolTip();
tView.IsBalloon = true;
tView.InitialDelay = 0;
tView.ShowAlways = true;
tView.AutoPopDelay = 2000;
tView.SetToolTip(p.b1, "View/edit person");
p.b2 = new Button();
p.b2.Top = yPersa;
p.b2.Left = 230;
p.b2.Width = 50;
p.b2.Visible = true;
p.b2.Text = "Del";
p.b2.Click +=
new System.EventHandler(this.Char_Info_Click);
leftPanel.Controls.Add(p.b2);
p.b2 = new Button();
p.b2.Top = yPersa;
p.b2.Left = 230;
p.b2.Width = 50;
p.b2.Visible = true;
p.b2.Text = "Del";
p.b2.Click +=
new EventHandler(Char_Info_Click);
leftPanel.Controls.Add(p.b2);
ToolTip tDelete = new ToolTip();
tDelete.IsBalloon = true;
tDelete.InitialDelay = 0;
tDelete.ShowAlways = true;
tDelete.AutoPopDelay = 2000;
tDelete.SetToolTip(p.b2, "Delete this person");
ToolTip tDelete = new ToolTip();
tDelete.IsBalloon = true;
tDelete.InitialDelay = 0;
tDelete.ShowAlways = true;
tDelete.AutoPopDelay = 2000;
tDelete.SetToolTip(p.b2, "Delete this person");
}
p.coord = TextBoxWall1.Text;
p.coord2 = TextBoxWall2.Text;
p.time1 = TextBoxTime1.Text;
p.time2 = TextBoxTime2.Text;
p.sprite = SpriteNumberTextBox.Text;
p.moveside = ComboBoxMove.Text;
p.nomer = (use_pnumber) ? pNomer : nomerPersa;
p.charname = charNameBox.Text;
p.circles = circlesTextBox.Text;
p.l2.Text = charNameBox.Text;
String[] coordinatyNachala = TextBoxWall1.Text.Split(new String[] { "," }, StringSplitOptions.None);
if (coordinatyNachala.Length > 1)
{
p.x1 = coordinatyNachala[0];
p.y1 = coordinatyNachala[1];
}
String[] coordinatyKonza = TextBoxWall2.Text.Split(new String[] { "," }, StringSplitOptions.None);
if (coordinatyKonza.Length > 1)
{
p.x2 = coordinatyKonza[0];
p.y2 = coordinatyKonza[1];
}
return p;
}
@ -191,13 +170,13 @@ namespace WindowsFormsApplication1
openSpace.Image = Image.FromFile(openFileDialog1.FileName);
if (pNomer == -120)
{
persons[nomerPersa].adress = openFileDialog1.FileName;
persons[nomerPersa].address = openFileDialog1.FileName;
persons[nomerPersa].width = openSpace.Image.Width.ToString();
persons[nomerPersa].height = openSpace.Image.Height.ToString();
}
else
{
persons[pNomer].adress = openFileDialog1.FileName;
persons[pNomer].address = openFileDialog1.FileName;
persons[pNomer].width = openSpace.Image.Width.ToString();
persons[pNomer].height = openSpace.Image.Height.ToString();
}
@ -208,7 +187,7 @@ namespace WindowsFormsApplication1
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
PictureBoxBackground.Image = Image.FromFile(openFileDialog1.FileName);
adressBackground = openFileDialog1.FileName;
addressBackground = openFileDialog1.FileName;
}
private void SaveMultButton_Click(object sender, EventArgs e)
@ -221,7 +200,7 @@ namespace WindowsFormsApplication1
for (int nomer = 0; nomer < nomerPersa; nomer++)
{
if (String.IsNullOrEmpty(persons[nomer].adress))
if (String.IsNullOrEmpty(persons[nomer].address))
{
MessageBox.Show("Картинка №" + (nomer + 1).ToString() + " пустая");
return;
@ -260,78 +239,78 @@ namespace WindowsFormsApplication1
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
mainFilename = saveFileDialog1.FileName;
//Adding TXLibrary and pictures
File.Copy("TXLib.h", Path.GetDirectoryName(filename) + "\\TXLib.h", true);
string dir_path = Path.GetDirectoryName(filename) + "\\Pictures";
File.Copy("TXLib.h", Path.GetDirectoryName(mainFilename) + "\\TXLib.h", true);
string dir_path = Path.GetDirectoryName(mainFilename) + "\\Pictures";
if (!Directory.Exists(dir_path))
{
Directory.CreateDirectory(dir_path);
}
if (adressBackground != dir_path + "\\" + Path.GetFileName(adressBackground))
if (addressBackground != dir_path + "\\" + Path.GetFileName(addressBackground))
{
File.Copy(adressBackground, dir_path + "\\" + Path.GetFileName(adressBackground), true);
File.Copy(addressBackground, dir_path + "\\" + Path.GetFileName(addressBackground), true);
}
Files.CreateStruct(filename);
Files.OpenMain(filename, PictureBoxBackground, adressBackground);
Files.CreateStruct(mainFilename);
Files.OpenMain(mainFilename, PictureBoxBackground, addressBackground);
for (int nomer = 0; nomer < nomerPersa; nomer++)
{
File.Copy(persons[nomer].adress, dir_path + "\\" + Path.GetFileName(persons[nomer].adress), true);
File.Copy(persons[nomer].address, dir_path + "\\" + Path.GetFileName(persons[nomer].address), true);
if (dir_path == dir_path + "\\" + Path.GetFileName(persons[nomer].adress))
if (dir_path == dir_path + "\\" + Path.GetFileName(persons[nomer].address))
{
File.Copy(persons[nomer].adress, dir_path + "\\" + Path.GetFileName(persons[nomer].adress), true);
File.Copy(persons[nomer].address, dir_path + "\\" + Path.GetFileName(persons[nomer].address), true);
}
if (persons[nomer].moveside == "Прямо")
{
Line.CreatePerson(filename, Person.PersonName(nomer), persons[nomer]);
Line.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Волнами")
{
Sinus.CreatePerson(filename, Person.PersonName(nomer), persons[nomer]);
Sinus.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Кругами")
{
Circle.CreatePerson(filename, Person.PersonName(nomer), persons[nomer]);
Circle.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Диагонально")
{
Line.CreatePerson(filename, Person.PersonName(nomer), persons[nomer]);
Line.CreatePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
}
Files.OpenWhile(filename, maxTime);
Files.OpenWhile(mainFilename, maxTime);
for (int nomer = 0; nomer < nomerPersa; nomer++)
{
if (persons[nomer].moveside == "Прямо")
{
Line.MovePerson(filename, Person.PersonName(nomer), persons[nomer]);
Line.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Волнами")
{
Sinus.MovePerson(filename, Person.PersonName(nomer), persons[nomer]);
Sinus.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Кругами")
{
Circle.MovePerson(filename, Person.PersonName(nomer), persons[nomer]);
Circle.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
else if (persons[nomer].moveside == "Диагонально")
{
Line.MovePerson(filename, Person.PersonName(nomer), persons[nomer]);
Line.MovePerson(mainFilename, Person.PersonName(nomer), persons[nomer]);
}
}
Files.CloseWhile(filename);
DeletePics(filename, nomerPersa);
Files.Ending(filename);
Files.CloseWhile(mainFilename);
DeletePics(mainFilename, nomerPersa);
Files.Ending(mainFilename, checkBox1.Checked);
MessageBox.Show("Successfully");
MessageBox.Show("Готово!");
}
}
@ -351,9 +330,9 @@ namespace WindowsFormsApplication1
charNameBox.Text = persons[nomer].charname;
circlesTextBox.Text = persons[nomer].circles;
if (!String.IsNullOrEmpty(persons[nomer].adress))
if (!String.IsNullOrEmpty(persons[nomer].address))
{
openSpace.Image = Image.FromFile(persons[nomer].adress);
openSpace.Image = Image.FromFile(persons[nomer].address);
}
else
{
@ -416,5 +395,17 @@ namespace WindowsFormsApplication1
circlesLabel.Visible = false;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(mainFilename))
{
new CompileForm(mainFilename).ShowDialog();
}
else
{
_ = MessageBox.Show("Сначала сохраните мультфильм!");
}
}
}
}

View file

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
@ -18,12 +14,12 @@ namespace WindowsFormsApplication1
public int nomer;
public String coord;
public String coord2;
//Dobavit polya
// TODO: Add fields
public String x1;
public String y1;
public String x2;
public String y2;
public String adress;
public String address;
public String time1;
public String time2;
public String sprite;

View file

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
@ -10,37 +7,45 @@ namespace WindowsFormsApplication1
{
public static void CreatePerson(string filename, string name, Person p)
{
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " Person " + name + ";" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(p.adress) + "\"); " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x = " + p.x1 + ";" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = " + p.y1 + ";" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x2 = " + p.x2 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y2 = " + p.y2 + "; " + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nach_dv = (" + p.y1 + "+" + p.y2 + ")/2;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".ampl_y = abs(" + p.y1 + "-" + name + ".nach_dv)/2;" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".ampl_x = 10;" + Environment.NewLine);
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(Environment.NewLine);
sw.Write(" Person " + name + ";" + Environment.NewLine);
sw.Write(" " + name + ".texture = txLoadImage(\"Pictures\\\\" + Path.GetFileName(p.address) + "\"); " +
Environment.NewLine);
sw.Write(" " + name + ".x = " + p.x1 + ";" + Environment.NewLine);
sw.Write(" " + name + ".y = " + p.y1 + ";" + Environment.NewLine);
sw.Write(" " + name + ".x2 = " + p.x2 + "; " + Environment.NewLine);
sw.Write(" " + name + ".y2 = " + p.y2 + "; " + Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra = 0;" + Environment.NewLine);
sw.Write(" " + name + ".nach_dv = (" + p.y1 + "+" + p.y2 + ")/2;" + Environment.NewLine);
sw.Write(" " + name + ".ampl_y = abs(" + p.y1 + "-" + name + ".nach_dv)/2;" + Environment.NewLine);
sw.Write(" " + name + ".ampl_x = 10;" + Environment.NewLine);
sw.Close();
}
public static void MovePerson(string filename, string name, Person p)
{
File.AppendAllText(filename, " if ((myTime >= " + p.time1 + ") && (myTime <= " + p.time2 + ")) {" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".x+= (" + name + ".x2 - " + name + ".x) / (" + p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y+= (" + name + ".y2 - " + name + ".y) / (" + p.time2 + "-" + p.time1 + ");" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".y = " + name + ".nach_dv + " + name + ".ampl_y * sin(" + name + ".x / " + name + ".ampl_x);" + Environment.NewLine);
File.AppendAllText(filename, " txTransparentBlt(txDC(), " + name + ".x, " + name + ".y, " +
StreamWriter sw = new StreamWriter(filename, true);
sw.Write(" if ((myTime >= " + p.time1 + ") && (myTime <= " + p.time2 + ")) {" + Environment.NewLine);
sw.Write(" " + name + ".x+= (" + name + ".x2 - " + name + ".x) / (" + p.time2 + "-" +
p.time1 + ");" + Environment.NewLine);
sw.Write(" " + name + ".y+= (" + name + ".y2 - " + name + ".y) / (" + p.time2 + "-" +
p.time1 + ");" + Environment.NewLine);
sw.Write(" " + name + ".y = " + name + ".nach_dv + " + name + ".ampl_y * sin(" + name +
".x / " + name + ".ampl_x);" + Environment.NewLine);
sw.Write(" txTransparentBlt(txDC(), " + name + ".x, " + name + ".y, " +
p.width + "/" + p.sprite + ", " +
p.height + "," +
name + ".texture, " +
p.width + "/" + p.sprite + " * " + name + ".nomer_kadra, 0, RGB(255, 255, 255));" + Environment.NewLine);
File.AppendAllText(filename, Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra++;" + Environment.NewLine);
File.AppendAllText(filename, " if (" + name + ".nomer_kadra >= " + p.sprite + ")" + Environment.NewLine);
File.AppendAllText(filename, " {" + Environment.NewLine);
File.AppendAllText(filename, " " + name + ".nomer_kadra = 0;" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
File.AppendAllText(filename, " }" + Environment.NewLine);
sw.Write(Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra++;" + Environment.NewLine);
sw.Write(" if (" + name + ".nomer_kadra >= " + p.sprite + ")" + Environment.NewLine);
sw.Write(" {" + Environment.NewLine);
sw.Write(" " + name + ".nomer_kadra = 0;" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Write(" }" + Environment.NewLine);
sw.Close();
}
}
}

View file

@ -49,6 +49,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Circle.cs" />
<Compile Include="CompileForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CompileForm.Designer.cs">
<DependentUpon>CompileForm.cs</DependentUpon>
</Compile>
<Compile Include="Files.cs" />
<Compile Include="Line.cs" />
<Compile Include="MainForm.cs">
@ -61,6 +67,9 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sinus.cs" />
<EmbeddedResource Include="CompileForm.resx">
<DependentUpon>CompileForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>

View file

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

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View file

@ -1,39 +0,0 @@
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.MainForm.resources
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.CoreCompileInputs.cache
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
C:\Users\user\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.MainForm.resources
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.CoreCompileInputs.cache
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
C:\Users\user\Desktop\Overnewing\vst\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.MainForm.resources
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.CoreCompileInputs.cache
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
C:\Users\Инженерка\Desktop\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.MainForm.resources
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.cache
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.CoreCompileInputs.cache
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
C:\Users\silan\OneDrive\Документы\MultRedactor-master\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb

View file

@ -1,9 +0,0 @@
1. "Картинка
добавить" не работает
2. Бесполезное сообщение при нажатии на "Открыть персонажа"
3. Неработающие кнопки изминения персонажа
4. Неработающие кнопки удаления персонажа
5. После main пустой код, при виде движения "волнами"
6. Бесполезная сообщение "complete"
7. При виде движения "кругами" некорректное заполнение данных
8. При виде движения "по диагонали" пустой main

Binary file not shown.