Инструментальная среда имитационного моделирования распределенных систем мобильных агентов



страница13/21
Дата24.11.2016
Размер2.3 Mb.
Просмотров4070
Скачиваний0
1   ...   9   10   11   12   13   14   15   16   ...   21

Приложение 22 FormVisual.cs


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.IO;

using System.Windows.Forms;
namespace Automata {

public partial class FormVisual : Form {

string dot_file_name;

Form1 main_form;

VisualNet net;

static MultyLanguage ml = MultyLanguage.get_MultyLanguage();

public FormVisual(Form1 i_form1, VisualNet i_net) {

InitializeComponent();

net = i_net;

set_text();

this.main_form = i_form1;

}

void set_text() {



if (net == VisualNet.system_net) {

this.Text = ml["title_SystemNet"];

}

if (net == VisualNet.automata_net) {



this.Text = ml["title_AutomataNet"];

}

btn_save_dot.Text = ml["save"];



}

public void new_dot(string i_file_name) {

dot_file_name = i_file_name + ".dot";

textBox2.Text = dot_file_name;

textBox1.Text = "";

}

public void write_dot(string ss){



textBox1.AppendText(ss + "\r\n");

}

private void btn_save_dot_Click(object sender, EventArgs e) {



SaveFileDialog d = new SaveFileDialog();

d.FileName = textBox2.Text;

if(d.ShowDialog() != DialogResult.OK) {

return;


}

dot_file_name = d.FileName;

textBox2.Text = dot_file_name;

save_dot_file();

}

void save_dot_file() {



using(StreamWriter sw = File.CreateText(dot_file_name)) {

sw.Write(textBox1.Text);

}

}
private void log(string ss){



toolStripStatusLabel1.Text = ss;

Form1.log(ss);

}

private void tabVisual_Enter(object sender, EventArgs e) {



log("tab_Visual_Enter fire at " + System.DateTime.Now);

draw_graph();

}

public void draw_graph() {



log("save_dot_file");

save_dot_file();

string jpg_file_name = dot_file_name + ".jpg";

log("jpg_file_name=" + jpg_file_name);

if(pictureBox1.Image != null) {

log("pictureBox1.Image.Dispose()");

pictureBox1.Image.Dispose();

}

try {



log("do delete_dot_file");

File.Delete(jpg_file_name);

log("posle delete_dot_file");

} catch(Exception e) {

log("Error while delete old jpg file " + jpg_file_name

+": "+e.Message

);

}

try {



string ss = "dot.exe -Tjpg -o\"" + jpg_file_name + "\" \"" + dot_file_name + "\"";
log("try begin. ss=" + ss);

System.Diagnostics.Process p = System.Diagnostics.Process.Start("dot.exe", ss);

log("in try. p=" + p);

p.WaitForExit();

int exit_code = p.ExitCode;

log("in try. p exit. exit_code="+exit_code);

p.Close();

} catch(Exception e) {

log("on run e=" + e.Message);

}

Image mem;



try{

Stream stream = File.Open(jpg_file_name, FileMode.Open);

// mem = Image.FromFile(jpg_file_name);

mem = Image.FromStream(stream);

stream.Close();

pictureBox1.Image = mem;


log("mem size = " + mem.Size

+" pbi size = " + pictureBox1.Image.Size

);

pictureBox1.Size = mem.Size;


// log("image size = " + pictureBox1.Size);

} catch(Exception e) {

log("on load e=" + e.Message);

}
}
private void FormVisual_FormClosing(object sender, FormClosingEventArgs e) {

main_form.set_visual(false, net);

e.Cancel = true;

}
private void FormVisual_Activated(object sender, EventArgs e) {

set_text();

}

}

}



Приложение 23 FormVisual.Designer.cs


namespace Automata {

partial class FormVisual {

///

/// Требуется переменная конструктора.

///

private System.ComponentModel.IContainer components = null;


///

/// Освободить все используемые ресурсы.

///

///
истинно, если управляемый ресурс должен быть удален; иначе ложно.


protected override void Dispose(bool disposing) {

if(disposing && (components != null)) {

components.Dispose();

}

base.Dispose(disposing);



}
#region Код, автоматически созданный конструктором форм Windows
///

/// Обязательный метод для поддержки конструктора - не изменяйте

/// содержимое данного метода при помощи редактора кода.

///

private void InitializeComponent() {

this.tabControl1 = new System.Windows.Forms.TabControl();

this.tabVisual = new System.Windows.Forms.TabPage();

this.panel2 = new System.Windows.Forms.Panel();

this.pictureBox1 = new System.Windows.Forms.PictureBox();

this.tabDot = new System.Windows.Forms.TabPage();

this.textBox1 = new System.Windows.Forms.TextBox();

this.panel1 = new System.Windows.Forms.Panel();

this.btn_save_dot = new System.Windows.Forms.Button();

this.textBox2 = new System.Windows.Forms.TextBox();

this.statusStrip1 = new System.Windows.Forms.StatusStrip();

this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();

this.tabControl1.SuspendLayout();

this.tabVisual.SuspendLayout();

this.panel2.SuspendLayout();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

this.tabDot.SuspendLayout();

this.panel1.SuspendLayout();

this.statusStrip1.SuspendLayout();

this.SuspendLayout();

//

// tabControl1



//

this.tabControl1.Controls.Add(this.tabVisual);

this.tabControl1.Controls.Add(this.tabDot);

this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;

this.tabControl1.Location = new System.Drawing.Point(0, 0);

this.tabControl1.Name = "tabControl1";

this.tabControl1.SelectedIndex = 0;

this.tabControl1.Size = new System.Drawing.Size(430, 300);

this.tabControl1.TabIndex = 0;

//


// tabVisual

//


this.tabVisual.Controls.Add(this.panel2);

this.tabVisual.Location = new System.Drawing.Point(4, 25);

this.tabVisual.Name = "tabVisual";

this.tabVisual.Padding = new System.Windows.Forms.Padding(3);

this.tabVisual.Size = new System.Drawing.Size(422, 271);

this.tabVisual.TabIndex = 1;

this.tabVisual.Text = "visual";

this.tabVisual.UseVisualStyleBackColor = true;

this.tabVisual.Enter += new System.EventHandler(this.tabVisual_Enter);

//


// panel2

//


this.panel2.AutoScroll = true;

this.panel2.Controls.Add(this.pictureBox1);

this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;

this.panel2.Location = new System.Drawing.Point(3, 3);

this.panel2.Name = "panel2";

this.panel2.Size = new System.Drawing.Size(416, 265);

this.panel2.TabIndex = 1;

//


// pictureBox1

//


this.pictureBox1.Location = new System.Drawing.Point(0, 0);

this.pictureBox1.Name = "pictureBox1";

this.pictureBox1.Size = new System.Drawing.Size(0, 0);

this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;

this.pictureBox1.TabIndex = 0;

this.pictureBox1.TabStop = false;

//

// tabDot



//

this.tabDot.Controls.Add(this.textBox1);

this.tabDot.Controls.Add(this.panel1);

this.tabDot.Location = new System.Drawing.Point(4, 25);

this.tabDot.Name = "tabDot";

this.tabDot.Padding = new System.Windows.Forms.Padding(3);

this.tabDot.Size = new System.Drawing.Size(422, 271);

this.tabDot.TabIndex = 0;

this.tabDot.Text = "dot";

this.tabDot.UseVisualStyleBackColor = true;

//

// textBox1



//

this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;

this.textBox1.Location = new System.Drawing.Point(3, 3);

this.textBox1.Multiline = true;

this.textBox1.Name = "textBox1";

this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;

this.textBox1.Size = new System.Drawing.Size(416, 223);

this.textBox1.TabIndex = 0;

//

// panel1



//

this.panel1.Controls.Add(this.btn_save_dot);

this.panel1.Controls.Add(this.textBox2);

this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;

this.panel1.Location = new System.Drawing.Point(3, 226);

this.panel1.Name = "panel1";

this.panel1.Size = new System.Drawing.Size(416, 42);

this.panel1.TabIndex = 1;

//

// btn_save_dot



//

this.btn_save_dot.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));

this.btn_save_dot.Location = new System.Drawing.Point(307, 14);

this.btn_save_dot.Name = "btn_save_dot";

this.btn_save_dot.Size = new System.Drawing.Size(104, 23);

this.btn_save_dot.TabIndex = 1;

this.btn_save_dot.Text = "Save";

this.btn_save_dot.UseVisualStyleBackColor = true;

this.btn_save_dot.Click += new System.EventHandler(this.btn_save_dot_Click);

//


// textBox2

//


this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.textBox2.Location = new System.Drawing.Point(5, 15);

this.textBox2.Name = "textBox2";

this.textBox2.Size = new System.Drawing.Size(296, 22);

this.textBox2.TabIndex = 0;

//

// statusStrip1



//

this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {

this.toolStripStatusLabel1});

this.statusStrip1.Location = new System.Drawing.Point(0, 300);

this.statusStrip1.Name = "statusStrip1";

this.statusStrip1.Size = new System.Drawing.Size(430, 23);

this.statusStrip1.TabIndex = 0;

this.statusStrip1.Text = "statusStrip1";

//

// toolStripStatusLabel1



//

this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";

this.toolStripStatusLabel1.Size = new System.Drawing.Size(141, 18);

this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";

//

// FormVisual



//

this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(430, 323);

this.Controls.Add(this.tabControl1);

this.Controls.Add(this.statusStrip1);

this.Name = "FormVisual";

this.Text = "FormVisual";

this.Activated += new System.EventHandler(this.FormVisual_Activated);

this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormVisual_FormClosing);

this.tabControl1.ResumeLayout(false);

this.tabVisual.ResumeLayout(false);

this.panel2.ResumeLayout(false);

this.panel2.PerformLayout();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

this.tabDot.ResumeLayout(false);

this.tabDot.PerformLayout();

this.panel1.ResumeLayout(false);

this.panel1.PerformLayout();

this.statusStrip1.ResumeLayout(false);

this.statusStrip1.PerformLayout();

this.ResumeLayout(false);

this.PerformLayout();
}
#endregion
private System.Windows.Forms.TabControl tabControl1;

private System.Windows.Forms.TabPage tabDot;

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.TabPage tabVisual;

private System.Windows.Forms.Panel panel1;

private System.Windows.Forms.Button btn_save_dot;

private System.Windows.Forms.TextBox textBox2;

private System.Windows.Forms.StatusStrip statusStrip1;

private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;

private System.Windows.Forms.PictureBox pictureBox1;

private System.Windows.Forms.Panel panel2;

}

}





Каталог: data -> 2013
2013 -> Федеральное государственное автономное образовательное
2013 -> «Визуальный образ персонажей массового кинематогрфа в историческом контексте»
2013 -> 2 раздел анализ предметной области 5
2013 -> Магистерская диссертация
2013 -> Влияние вовлеченности на готовность платить за коллекционные товары
2013 -> Выражение гендерных характеристик в англоязычном "глянцевом" дискурсе
2013 -> Продакт Плейсмент и перспективы его развития в сети Интернет
2013 -> 1Лекции первого полугодия
2013 -> «Правовое рассмотрение компьютерного мошенничества», Ницца, 22 октября 1992 года, грамота «весьма достойно»


Поделитесь с Вашими друзьями:
1   ...   9   10   11   12   13   14   15   16   ...   21


База данных защищена авторским правом ©nethash.ru 2019
обратиться к администрации

войти | регистрация
    Главная страница


загрузить материал