コード例 #1
0
ファイル: Controller.cs プロジェクト: Samin-Asnaashari/PROCP
        public static Controller getController()
        {
            if (instance == null)
            {
                instance = new Controller();
            }

            return instance;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Samin-Asnaashari/PROCP
        public bool OpenFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileStream fs = null;
                BinaryFormatter bf = null;

                openFileDialog.Filter = "SimulatorExtension files (*.simex)|*.simex";
                openFileDialog.FilterIndex = 1;
                openFileDialog.RestoreDirectory = true;

                fs = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read);
                bf = new BinaryFormatter();
                Controller loadController = (Controller)(bf.Deserialize(fs));
                this.controller = loadController;
                this.controller.Design.allcreatedcrossings = loadController.Design.allcreatedcrossings;
                //OverviewlistBox.Items.Clear();
                return true;
            }
            else
                return false;
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Samin-Asnaashari/PROCP
        private void gridbutton_Click(object sender, EventArgs e)
        {
            OverviewlistBox.Items.Clear();
            object obj = gridcomboBox.SelectedItem;
            string name = tbname.Text;
            DateTime time = dateTimePicker1.Value;

            if (obj != null && name != "")
            {
                string grid = gridcomboBox.SelectedItem.ToString();
                WorkspaceDesign D = new WorkspaceDesign(grid, name, time);
                this.controller = Controller.getController();
                this.controller.setSettings(this.workpanel.Width, this.workpanel.Height, D);

                if (D.Grid == "Small")
                {
                    //4*4
                    this.controller.lines = 4;
                }
                else if (D.Grid == "Medium")
                {
                    //3*3
                    this.controller.lines = 3;
                }
                else if (D.Grid == "Large")
                {
                    //2*2
                    this.controller.lines = 2;
                }
                selectedimage = null;
                selectedCrossinginpanel = null;
                showgrid = true;
                this.workpanel.Invalidate();
                StatuslistBox.Items.Clear();

                PBtype1.Enabled = true;
                PBtype2.Enabled = true;
                cursorbutton.Enabled = true;
                buttonremove.Enabled = true;
                buttonclear.Enabled = true;
                setbutton.Enabled = true;

                IsSet = false;
            }
            else
            {
                string s = "😜";
                StatuslistBox.Items.Add("First:Choose the Grid & Name & Time. " + s);
            }
        }
コード例 #4
0
        /// <summary>
        /// save as a design 
        /// </summary>
        /// <param name="stream"></param>
        public bool SaveAs(Controller controler)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.FileName = "Simulation1";
            dialog.Filter = "SimulatorExtension files (*.simex)|*.simex";
            dialog.FilterIndex = 1;
            dialog.RestoreDirectory = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                FileStream fs = null;
                BinaryFormatter bf = null;

                fs = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write);
                bf = new BinaryFormatter();
                this.savedFile = dialog.FileName;
                bf.Serialize(fs, controler);
                fs.Close();
                return true;

            }
            return false;
        }
コード例 #5
0
 /// <summary>
 /// save the design  
 /// </summary>
 public bool Save(Controller controler)
 {
     Stream saveStream = null;
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.FileName = savedFile;
     if ((saveStream = saveFileDialog.OpenFile()) != null)
     {
         IFormatter formater = new BinaryFormatter();
         formater.Serialize(saveStream, controler);
         saveStream.Close();
         return true;
     }
     else
         return false;
 }