private void menuItem_options_Click(object sender, EventArgs e) { PropertyGrid myGrid = new PropertyGrid { SelectedObject = Properties.Settings.Default, Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; int windowHight; int windowWidth; using (OKCancelForm myConfigurationForm = new OKCancelForm(Text + ":Option")) { UserControl myControl = new UserControl(); myControl.Controls.Add(myGrid); myConfigurationForm.SetUserControl = myControl; myConfigurationForm.CanBeAccepted(true); myConfigurationForm.ShowDialog(this); while (myConfigurationForm.DialogResult == DialogResult.Yes) { windowHight = myConfigurationForm.Height; windowWidth = myConfigurationForm.Width; myConfigurationForm.StartPosition = FormStartPosition.Manual; myGrid.SelectedObject = Properties.Settings.Default; myControl.Controls.Clear(); myControl.Controls.Add(myGrid); myConfigurationForm.SetUserControl = myControl; myConfigurationForm.Controls[0].Refresh(); myConfigurationForm.Height = windowHight; myConfigurationForm.Width = windowWidth; myConfigurationForm.ShowDialog(this); } } }
private void HelpConfigurationToolStripMenuItem_Click(object sender, EventArgs e) { myGrid = new PropertyGrid { SelectedObject = Properties.Settings.Default }; myGrid.SelectedGridItemChanged += new SelectedGridItemChangedEventHandler(myGrid_SelectedGridItemChanged); myGrid.SizeChanged += new EventHandler(myGrid_SizeChanged); myGrid.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; int windowHight; int windowWidth; OKCancelForm myConfigurationForm = new OKCancelForm(Resources.ConfigurationFormName); using (myConfigurationForm) { myConfigurationForm.AddButton("Reset", System.Windows.Forms.DialogResult.Ignore); UserControl myControl = new UserControl(); myControl.Controls.Add(myGrid); myConfigurationForm.SetUserControl = myControl; myConfigurationForm.CanBeAccepted(true); myConfigurationForm.AutoSize = false; myConfigurationForm.Height = 580; myConfigurationForm.Width = 620; System.Windows.Forms.DialogResult dr = myConfigurationForm.ShowDialog(this); while (dr == System.Windows.Forms.DialogResult.Ignore) { windowHight = myConfigurationForm.Height; windowWidth = myConfigurationForm.Width; myConfigurationForm.StartPosition = FormStartPosition.Manual; myGrid.SelectedObject = Properties.Settings.Default; myControl.Controls.Clear(); myControl.Controls.Add(myGrid); myConfigurationForm.SetUserControl = myControl; myConfigurationForm.Controls[0].Refresh(); myConfigurationForm.Height = windowHight; myConfigurationForm.Width = windowWidth; OnReset(); dr = myConfigurationForm.ShowDialog(this); if (dr == System.Windows.Forms.DialogResult.OK) { OnOk(); } else if (dr == System.Windows.Forms.DialogResult.Cancel) { OnCancel(); } } } }
/// <summary> /// Handles the Click event of the buttonTransition control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void buttonTransition_Click(object sender, EventArgs e) { selectedTransitionButton = sender as TransitionButton; if (((TransitionButton)sender).Image == null) //add new transition { OKCancelForm newTransitionForm = new OKCancelForm(newTransitionString); newTransitionForm.CanBeAccepted(true); PropertyGrid propertyGridTransition = new PropertyGrid { Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top), SelectedObject = selectedTransitionButton.TransitionData }; UserControl uc = new UserControl(); uc.Controls.Add(propertyGridTransition); newTransitionForm.SetUserControl = uc; if (newTransitionForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { OnAddTransition(); } else { newTransitionForm.Close(); } } else //show or delete transition { OKCancelForm showOrDeleteTransitionDataForm = new OKCancelForm(transitionDataString); showOrDeleteTransitionDataForm.CanBeAccepted(true); showOrDeleteTransitionDataForm.AddButton("Delete", System.Windows.Forms.DialogResult.Ignore); PropertyGrid propertyGridTransition = new PropertyGrid { Anchor = (AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top), SelectedObject = selectedTransitionButton.TransitionData }; UserControl uc = new UserControl(); uc.Controls.Add(propertyGridTransition); showOrDeleteTransitionDataForm.SetUserControl = uc; System.Windows.Forms.DialogResult dr = showOrDeleteTransitionDataForm.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { OnOk(); } else if (dr == System.Windows.Forms.DialogResult.Cancel) { Properties.Settings.Default.Reload(); } else if (dr == System.Windows.Forms.DialogResult.Ignore) { OnDelete(); } } }
private void m_OpenPortButton_Click(object sender, EventArgs e) { using (OKCancelForm okcan = new OKCancelForm("Data Provider Selector")) { AvailableDPTree c_AvailableDPTree; if (m_LastGuid.Equals(Guid.Empty)) { c_AvailableDPTree = new AvailableDPTree(@_CommonBusControl, okcan); } else { c_AvailableDPTree = new AvailableDPTree(@_CommonBusControl, okcan, m_LastSettings, m_LastGuid); } using ( c_AvailableDPTree ) { okcan.SetUserControl = c_AvailableDPTree; okcan.ShowDialog(); if (okcan.DialogResult != DialogResult.OK) { return; } m_DataProviderID = c_AvailableDPTree.GetSelectedDPID; } } using (AddObject <IDataProviderID> _DPSettings = new AddObject <IDataProviderID>()) { _DPSettings.Object = m_DataProviderID; _DPSettings.ShowDialog(); if (_DPSettings.DialogResult != DialogResult.OK) { return; } m_LastGuid = m_DataProviderID.GetDataProviderDescription.Identifier; m_LastSettings = m_DataProviderID.GetSettings(); } this.@_PortSettings.Text = "Protocol settings:\r\n" + m_DataProviderID.GetSettingsHumanReadableFormat(); @_StartMonitoringButton.Enabled = true; @_ResourceComboBox.Items.Clear(); IAddressSpaceDescriptor[] AvailiableAddressspaces = m_DataProviderID.GetAvailiableAddressspaces(); foreach (IAddressSpaceDescriptor item in AvailiableAddressspaces) { @_ResourceComboBox.Items.Add(item.Name); } if (@_ResourceComboBox.Items.Count > 0) { @_ResourceComboBox.SelectedIndex = 0; } }
private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { PropertyGrid myGrid = new PropertyGrid(); myGrid.SelectedObject = Properties.Settings.Default; myGrid.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; using (OKCancelForm myConfigurationForm = new OKCancelForm(Resources.ConfigurationFormName)) { UserControl myControl = new UserControl(); myControl.Controls.Add(myGrid); myConfigurationForm.SetUserControl = myControl; myConfigurationForm.CanBeAccepted(true); if (myConfigurationForm.ShowDialog(this) == DialogResult.OK) { Properties.Settings.Default.Save(); MessageBox.Show(Resources.ConfigurationForm_MessageAfterChange); } } }
private bool DisplayQuestionAboutConfiguration() { if (!Settings.Default.DisplayConfigurationQuestionAtStartup) { return(false); } bool _returnValue = false; using (OKCancelForm _questionForm = new OKCancelForm(Text)) { ConfigurationQuestionControl _configuration = new ConfigurationQuestionControl(); _questionForm.SetUserControl = _configuration; _questionForm.CanBeAccepted(true); if (_questionForm.ShowDialog(this) == DialogResult.OK) { Settings.Default.DisplayConfigurationQuestionAtStartup = _configuration.DisplayConfigurationQuestionAtStartup; Settings.Default.UseAlternativeConfiguration = _configuration.UseAlternativeConfiguration; Settings.Default.Save(); _returnValue = true; } } return(_returnValue); }