protected override void OnClosing(CancelEventArgs e) { try { var textHasChanged = m_previous_script != m_texteditor.Text; if (_showClosePrompt && textHasChanged) { var result = MessageBox.Show("Do you want to apply before closing?", "Rhino.Python closing", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { SetDefinitionValue(false, true); } else if (result == DialogResult.Cancel) { e.Cancel = true; } } } catch (Exception ex) { LastHandleException(ex); } if (!e.Cancel) { if (_component != null) { var attributes = _component.Attributes; if (attributes != null) { attributes.DisableLinkedEditor(false); } //we need to remove origin hinting _component.OnDisplayExpired(true); //store last location _component.DefaultEditorLocation = Location; _component.DefaultEditorSize = (WindowState == FormWindowState.Normal) ? Size : RestoreBounds.Size; _component = null; } Grasshopper.Instances.DocumentEditor.Move -= PythonScriptForm_MoveResize; } base.OnClosing(e); }
public void Disable() { _showClosePrompt = false; SuspendLayout(); okButton.Enabled = false; testButton.Enabled = false; this.Text += " (disabled)"; mainStatusText.Text = "Window is disabled because linked component was deleted."; _component = null; ResumeLayout(true); }
public PythonScriptForm(ScriptingAncestorComponent linkedComponent) { InitializeComponent(); _component = linkedComponent; if (_component != null) { m_texteditor = _component.CreateEditorControl(OnPythonHelp); this.splitContainer.Panel1.Controls.Add(m_texteditor); m_texteditor.Dock = DockStyle.Fill; m_texteditor.Text = _component.Code; m_previous_script = m_texteditor.Text; } versionLabel.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
public PythonScriptForm(ScriptingAncestorComponent linkedComponent) { InitializeComponent(); this.KeyDown += ScriptForm_KeyDown; this.HelpRequested += rhinoscriptsyntaxHelp; _component = linkedComponent; if (_component != null) { _texteditor = _component.CreateEditorControl(OnPythonHelp); this.splitContainer.Panel1.Controls.Add(_texteditor); _texteditor.Dock = DockStyle.Fill; _texteditor.Text = _component.CodeInput; _hash.HashText(_texteditor.Text); } versionLabel.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); }