private void FileSaveAs() { CircuitView selected = null; if (tabControl.SelectedTab != null) { selected = tabControl.SelectedTab.Controls[0] as CircuitView; } if (selected == null) { return; } SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "Circuits"; sfd.Filter = "Circuit files(*.circuit)|*.circuit"; sfd.FilterIndex = 1; sfd.RestoreDirectory = true; if (sfd.ShowDialog() == DialogResult.OK) { selected.DumpToDisk(sfd.FileName); selected.FileName = sfd.FileName; tabControl.SelectedTab.Text = Path.GetFileNameWithoutExtension(sfd.FileName); } sfd.Dispose(); }
private void CreateNewTabPage(String currentFileName) { if (!File.Exists(currentFileName)) { MessageBox.Show("The file name received (" + currentFileName + ") points to an innexistent file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } NoMousewheelTabPage t = new NoMousewheelTabPage(GetNewTabPageName()); t.AutoScroll = true; t.BackColor = Settings.Default.CircuitBackColor; t.Text = Path.GetFileNameWithoutExtension(currentFileName); tabControl.TabPages.Add(t); CircuitView cv = new CircuitView(currentFileName); cv.OnGateSelected += new CircuitView.GateSelectedEvent(cv_OnGateSelected); cv.Location = new Point(0, 0); cv.Dock = DockStyle.Fill; t.Controls.Add(cv); tabControl.SelectedTab = t; }
//Verify the saved status for the current tab //returns false if the close tab event should be canceled private bool VerifySavedStatus() { CircuitView selected = null; if (tabControl.SelectedTab != null) { selected = tabControl.SelectedTab.Controls[0] as CircuitView; if (!selected.Saved) { String text = String.Format("The circuit '{0}' has not been saved. Do you want to save it?", tabControl.SelectedTab.Text); DialogResult result = MessageBox.Show( text, "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { FileSave(); } if (result == DialogResult.Cancel) { return(false); } } } return(true); }
private void FileSave() { CircuitView selected = null; if (tabControl.SelectedTab != null) { selected = tabControl.SelectedTab.Controls[0] as CircuitView; if (!String.IsNullOrEmpty(selected.FileName)) { selected.DumpToDisk(selected.FileName); } else { FileSaveAs(); } } }
private void FileNew() { CircuitView cv = new CircuitView(); NoMousewheelTabPage tp = new NoMousewheelTabPage(GetNewTabPageName()); tp.Size = tabControl.Size; cv.Size = tabControl.Size; tp.AutoScroll = true; tp.BackColor = Settings.Default.CircuitBackColor; tp.Controls.Add(cv); cv.Dock = DockStyle.Fill; cv.OnGateSelected += new CircuitView.GateSelectedEvent(cv_OnGateSelected); tabControl.TabPages.Add(tp); tabControl.SelectedTab = tp; }
public Simulate(CircuitView cw) : this(cw.circuit, cw) { }
public Simulate(Circuit c, CircuitView cw) : this(c) { this.cw = cw; }