public Form1() { this.SetStyle( System.Windows.Forms.ControlStyles.UserPaint | System.Windows.Forms.ControlStyles.AllPaintingInWmPaint | System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer, true); InitializeComponent(); askMeSave = false; foreach (Control item in this.groupBox1.Controls) { if (item != toolPipe && item != toolEdit && item != toolRemove) if (item.Name.ToLower().StartsWith("tool")) { PictureBox pb = item as PictureBox; item.Click += (x, y) => ActivateCreating(pb); } } theGrid = new Grid(grid); flowly = new SystemFlowly(theGrid, this, this); currentSelectedComponent = null; SetTrackBarVisibility(false); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (flowly.Grid != null) { // ask this if there are any changes! if (askMeSave == true) { DialogResult saveChanges = MessageBox.Show("Do you want to save before opening a new grid?", "Save before closing", MessageBoxButtons.YesNo); if (saveChanges == DialogResult.Yes) { //save and open if (theGrid.Name != null) { flowly.SaveGrid(theGrid, out nameForForm); // askMeSave = false; } else { flowly.SaveAsGrid(theGrid, out nameForForm); //askMeSave = false; } } askMeSave = false; if (nameForForm == "") { } else { this.Text = "Flowly - flow system / " + nameForForm; } flowly.NewFile(grid); this.Text = "Flowly - flow system / (New grid)"; } else { flowly.NewFile(grid); this.Text = "Flowly - flow system / (New grid)"; } } else { flowly.NewFile(grid); this.Text = "Flowly - flow system / (New grid)"; } theGrid = flowly.Grid; }