public form_Viewer() { InitializeComponent(); _CategorySet = new SortedSet <string>(); _CheckedCategories = new SortedSet <string>(); _StatusFilterClickHandler = new EventHandler(Begin_Filter_Event); _CategoryFilterClickHandler = new ItemCheckEventHandler(clb_Categories_ItemCheck); }
private void DoItemCheck(int index, bool newValue) { ItemCheckEventHandler handler = this.ItemCheck; if (handler != null) { handler.Invoke(this, new ItemCheckEventArgs(index, newValue)); } }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// itemcheckeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this ItemCheckEventHandler itemcheckeventhandler, Object sender, ItemCheckEventArgs e, AsyncCallback callback) { if (itemcheckeventhandler == null) { throw new ArgumentNullException("itemcheckeventhandler"); } return(itemcheckeventhandler.BeginInvoke(sender, e, callback, null)); }
protected virtual void OnItemCheck(ItemCheckEventArgs ice) { ItemCheckEventHandler eh = (ItemCheckEventHandler)(Events [ItemCheckEvent]); if (eh != null) { eh(this, ice); } }
/// <summary> /// 状態変更時にメッセージボックスを表示する /// </summary> /// <param name="checkdListBox">チェックリストボックス</param> static void ItemCheckedEvent(CheckedListBox checkdListBox) { ItemCheckEventHandler handler = null; handler = delegate { MessageBox.Show(""); checkdListBox.BeginInvoke((MethodInvoker) delegate { checkdListBox.ItemCheck -= handler; }); }; checkdListBox.ItemCheck += handler; }
public FormArcPluginManager(FormMain mainLink) { this.mainLink = mainLink; var installedComponents = ArcDpsComponent.DeserialiseAll(ApplicationSettings.LocalDir); InitializeComponent(); Icon = Properties.Resources.AppIcon; var availableComponents = ArcDpsComponentHelperClass.All; var arcIsInstalled = true; var arcInstalledComponent = installedComponents.Where(x => x.Type.Equals(ArcDpsComponentType.ArcDps) && x.RenderMode.Equals(ApplicationSettings.Current.ArcUpdate.RenderMode)).Any(); if (arcInstalledComponent) { var arcdps = installedComponents.Where(x => x.Type.Equals(ArcDpsComponentType.ArcDps) && x.RenderMode.Equals(ApplicationSettings.Current.ArcUpdate.RenderMode)).First(); if (!arcdps.IsInstalled()) { arcIsInstalled = false; checkBoxModuleEnabled.Checked = false; ApplicationSettings.Current.GW2Location = string.Empty; ApplicationSettings.Current.Save(); } } else { arcIsInstalled = false; checkBoxModuleEnabled.Checked = false; ApplicationSettings.Current.GW2Location = string.Empty; ApplicationSettings.Current.Save(); } foreach (var component in availableComponents) { var installed = arcIsInstalled && installedComponents.Where(x => x.Type.Equals(component.Type) && x.RenderMode.Equals(ApplicationSettings.Current.ArcUpdate.RenderMode)).Any(); if (installed) { var installedComponent = installedComponents.Where(x => x.Type.Equals(component.Type) && x.RenderMode.Equals(ApplicationSettings.Current.ArcUpdate.RenderMode)).First(); if (!installedComponent.IsInstalled()) { installed = false; installedComponents.RemoveAll(x => x.Type.Equals(component.Type)); } } checkedListBoxArcDpsPlugins.Items.Add(component, installed); } itemCheckHandler = new ItemCheckEventHandler(CheckedListBoxArcDpsPlugins_ItemCheck); checkChangedHandler = new EventHandler(CheckBoxEnableNotifications_CheckedChanged); checkedListBoxArcDpsPlugins.ItemCheck += itemCheckHandler; checkBoxEnableNotifications.CheckedChanged += checkChangedHandler; radioButtonDX11.CheckedChanged += new EventHandler(RadioButtonDX11_CheckedChanged); ArcDpsComponent.SerialiseAll(ApplicationSettings.LocalDir); }
public HostTab() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); checkHandler = new System.Windows.Forms.ItemCheckEventHandler(this.CheckHostState); this.OnStart += delegate(object sender, EventArgs e) { }; System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; versionLabel.Text = version.ToString(); cbHeaderEncoding.SelectedIndex = 0; }
/// <summary> /// Constructor. creates event handlers /// </summary> public BoundCheckedListBox() { childListChangedHandler = new ListChangedEventHandler(dataManager_childListChanged); childPositionChangedHandler = new EventHandler(dataManager_childPositionChanged); parentListChangedHandler = new ListChangedEventHandler(dataManager_parentListChanged); parentPositionChangedHandler = new EventHandler(dataManager_parentPositionChanged); relationListChangedHandler = new ListChangedEventHandler(dataManager_relationListChanged); //childPositionChangedHandler = new EventHandler(dataManager_childPositionChanged); itemCheckChangesHandler = new ItemCheckEventHandler(BoundCheckedListBox_ItemCheck); this.ItemCheck += itemCheckChangesHandler; selectionChangedHandler = new EventHandler(BoundCheckedListBox_SelectedIndexChanged); this.SelectedIndexChanged += selectionChangedHandler; }
private void MyInitializeComponent(EnabledFeatures features) { Text = id > 0 ? _text : Environment.StringResources.GetString("DocumentSearch"); cbInFound.Visible = ((features & EnabledFeatures.SearchInFound) > 0); cbToFound.Visible = ((features & EnabledFeatures.AddToFound) > 0); cbInFound.Left = 8; cbToFound.Left = 8 + (cbToFound.Visible ? cbToFound.Width + 8 : 0); panel2.Size = new Size(520, cbInFound.Visible || cbToFound.Visible ? 24 : 0); bClear.Visible = ((features & EnabledFeatures.Clear) > 0); bSaveAs.Visible = ((features & EnabledFeatures.SaveAs) > 0); bSave.Visible = ((features & EnabledFeatures.Save) > 0); bSave.Visible = (bSave.Visible && id > 0 && !bSaveAs.Visible); bSaveAs.Text = (id == 0) ? Environment.StringResources.GetString("SaveInquiry") : Environment.StringResources.GetString("SaveAs") + " ..."; bSearch.Visible = ((features & EnabledFeatures.Search) > 0); bSearch.Left = 8; bCancel.Left = 8 + (bSearch.Visible ? bSearch.Width + 8 : 0); bSave.Left = 8 + (bSearch.Visible ? bSearch.Width + 8 : 0) + (bCancel.Visible ? bCancel.Width + 8 : 0); AcceptButton = (bSearch.Visible) ? bSearch : bSave; bSaveAs.Left = 8 + (bSearch.Visible ? bSearch.Width + 8 : 0) + (bCancel.Visible ? bCancel.Width + 8 : 0) + (bSave.Visible ? bSave.Width + 8 : 0); panel3.Width = 8 + (bSearch.Visible ? bSearch.Width + 8 : 0) + (bCancel.Visible ? bCancel.Width + 8 : 0) + (bSave.Visible ? bSave.Width + 8 : 0) + (bSaveAs.Visible ? bSaveAs.Width + 8 : 0); lv_ItemCheckEventHandler = lv_ItemCheck; lv.ItemCheck += lv_ItemCheckEventHandler; }
public ToDoView() { InitializeComponent(); _loadedEventHandler = (s, e) => Loaded?.Invoke(); _addButtonClickHandler = (s, a) => AddButtonClick?.Invoke(); _itemCheckedEventHandler = (s, e) => { if (!_isCheckedProgrammatically) { ToDoItemChecked?.Invoke(((TodoItem)chkListTodo.Items[e.Index]).Id.Value, e.NewValue == CheckState.Checked); } }; _exitButtonClickHandler = (s, e) => CloseButtonClick?.Invoke(); chkListTodo.ItemCheck += _itemCheckedEventHandler; btnAdd.Click += _addButtonClickHandler; btnExit.Click += _exitButtonClickHandler; Load += _loadedEventHandler; chkListTodo.DisplayMember = nameof(TodoItem.Title); }
/// <devdoc> /// Inserts a new ListViewItem into the list view itself. /// This only will be called when the Handle has been created for the list view. /// This method loops through the items, sets up their state then adds them. /// </devdoc> private int InsertItemsNative(int index, ListViewItem[] items) { if (items == null || items.Length == 0) { return 0; } Debug.Assert(IsHandleCreated, "InsertItemsNative precondition: list-view handle must be created"); // Much more efficient to call the native insert with max + 1, than with max. The + 1 // for the display index accounts for itemCount++ above. // if (index == itemCount - 1) { index++; } // Create and add the LVITEM NativeMethods.LVITEM lvItem = new NativeMethods.LVITEM(); int actualIndex = -1; IntPtr hGlobalColumns = IntPtr.Zero; int maxColumns = 0; this.listViewState1[LISTVIEWSTATE1_insertingItemsNatively] = true; try { // Set the count of items first. // SendMessage(NativeMethods.LVM_SETITEMCOUNT, itemCount, 0); // Now add the items. // for (int i = 0; i < items.Length; i++) { ListViewItem li = items[i]; Debug.Assert(this.Items.Contains(li), "Make sure ListView.Items contains this item before adding the native LVITEM. Otherwise, custom-drawing may break."); lvItem.Reset(); lvItem.mask = NativeMethods.LVIF_TEXT | NativeMethods.LVIF_IMAGE | NativeMethods.LVIF_PARAM | NativeMethods.LVIF_INDENT; lvItem.iItem = index + i; lvItem.pszText = li.Text; lvItem.iImage = li.ImageIndexer.ActualIndex; lvItem.iIndent = li.IndentCount; lvItem.lParam = (IntPtr)li.ID; if (GroupsEnabled) { lvItem.mask |= NativeMethods.LVIF_GROUPID; lvItem.iGroupId = GetNativeGroupId(li); #if DEBUG Debug.Assert(SendMessage(NativeMethods.LVM_ISGROUPVIEWENABLED, 0, 0) != IntPtr.Zero, "Groups not enabled"); Debug.Assert(SendMessage(NativeMethods.LVM_HASGROUP, lvItem.iGroupId, 0) != IntPtr.Zero, "Doesn't contain group id: " + lvItem.iGroupId.ToString(CultureInfo.InvariantCulture)); #endif } lvItem.mask |= NativeMethods.LVIF_COLUMNS; lvItem.cColumns = this.columnHeaders != null ? Math.Min(MAXTILECOLUMNS, this.columnHeaders.Length) : 0; // make sure that our columns memory is big enough. // if not, then realloc it. // if (lvItem.cColumns > maxColumns || hGlobalColumns == IntPtr.Zero) { if (hGlobalColumns != IntPtr.Zero) { Marshal.FreeHGlobal(hGlobalColumns); } hGlobalColumns = Marshal.AllocHGlobal(lvItem.cColumns * Marshal.SizeOf(typeof(int))); maxColumns = lvItem.cColumns; } // now build and copy in the column indexes. // lvItem.puColumns = hGlobalColumns; int[] columns = new int[lvItem.cColumns]; for(int c = 0; c < lvItem.cColumns; c++) { columns[c] = c + 1; } Marshal.Copy(columns, 0, lvItem.puColumns, lvItem.cColumns); // Inserting an item into a ListView with checkboxes causes one or more // item check events to be fired for the newly added item. // Therefore, we disable the item check event handler temporarily. // ItemCheckEventHandler oldOnItemCheck = onItemCheck; onItemCheck = null; int insertIndex; try { li.UpdateStateToListView(lvItem.iItem, ref lvItem, false); insertIndex = (int)UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.LVM_INSERTITEM, 0, ref lvItem); if (actualIndex == -1) { actualIndex = insertIndex; // and update our starting index. so we're going from the same point. // index = actualIndex; } } finally { // Restore the item check event handler. // onItemCheck = oldOnItemCheck; } if (-1 == insertIndex) { throw new InvalidOperationException(SR.GetString(SR.ListViewAddItemFailed)); } // add all sub items for (int nItem = 1; nItem < li.SubItems.Count; ++nItem) { SetItemText(insertIndex, nItem, li.SubItems[nItem].Text, ref lvItem); } // PERF. // Use StateSelected in order to avoid a call into the native list view. if (li.StateImageSet || li.StateSelected) { // lvItem.state and lvItem.stateMask are set when the lvItem is updated in UpdateStateToListView call. SetItemState(insertIndex, lvItem.state, lvItem.stateMask); } } } finally { if (hGlobalColumns != IntPtr.Zero) { Marshal.FreeHGlobal(hGlobalColumns); } this.listViewState1[LISTVIEWSTATE1_insertingItemsNatively] = false; } if (this.listViewState1[LISTVIEWSTATE1_selectedIndexChangedSkipped]) { // VSWhidbey 549967 - SelectedIndexChanged event was delayed this.listViewState1[LISTVIEWSTATE1_selectedIndexChangedSkipped] = false; OnSelectedIndexChanged(EventArgs.Empty); } if (this.FlipViewToLargeIconAndSmallIcon) { this.FlipViewToLargeIconAndSmallIcon = false; this.View = View.LargeIcon; this.View = View.SmallIcon; } return actualIndex; }
private void BuildView() { this.SuspendLayout(); this.StimulusClass1 = this.StimulusClass2 = null; // tab control var tabs = new CustomTabControl() { Dock = DockStyle.Fill }; tabs.DisplayStyleProvider = new TabStyleVisualStudioProvider(tabs) { ShowTabCloser = true }; tabs.TabClosing += (sender, args) => ((CustomTab)args.TabPage).RaiseClosingSafe(args); // start tab var startTab = new CustomTab() { Text = "Classes" }; // columns var cols = GUIUtils.CreateTable(new double[] { .33, .33, .33 }, Direction.Horizontal); // image config var imageConfig = ConfigurationPanel.Create <ImageDisplaySettings>(); // image panel var imagePanel = new ImagePanel() { Dock = DockStyle.Fill, UseNativeSize = false }; bool cycle = true; var rand = new Random(); Func <StimulusClass, string> getImageForClass = stimulusClass => { var tab = this.stimulusClassTabs.First(t => t.StimulusClass == stimulusClass); if (tab.StimulusClass.Stimuli.Count == 0) { return(null); } if (!((ImageDisplaySettings)imageConfig.GetConfiguredObject()).CycleThroughImages) { return((tab.SelectedStimulus ?? tab.StimulusClass.Stimuli.First()).PathOrText); } return(tab.StimulusClass.Stimuli.ElementAt(rand.Next(tab.StimulusClass.Stimuli.Count)).PathOrText); }; Action setImage = () => { imagePanel.ImagePath = this.StimulusClass1 == null ? null : getImageForClass(this.StimulusClass1); imagePanel.SecondaryImagePath = this.StimulusClass2 == null ? null : getImageForClass(this.StimulusClass2); }; setImage(); var timer = new Timer() { Interval = 2500, Enabled = true }; timer.Tick += (sender, args) => { // just return if we're not cycling to avoid flicker if (!cycle && !timer.Enabled) { return; } // if the form is valid, set a new image var activeTextBox = this.FindForm().ActiveControl as TextBox; if (activeTextBox == null || activeTextBox.IsValid()) { setImage(); } }; Action <ImageDisplaySettings> configurePanel = settings => { imagePanel.Configure(settings); if (settings.CycleThroughImages != cycle) { cycle = settings.CycleThroughImages; setImage(); } this.ImageDisplaySettings = settings; }; configurePanel((ImageDisplaySettings)imageConfig.GetConfiguredObject()); imageConfig.PropertyChanged += args => configurePanel((ImageDisplaySettings)imageConfig.GetConfiguredObject()); // class list var classList = new CheckedListBox() { Dock = DockStyle.Fill, AllowDrop = true, CheckOnClick = true }; classList.AddContextMenu(); ItemCheckEventHandler refreshSelectedClasses = (sender, args) => { // get the list of checked indices, including the possibly not-yet-changed item List <int> checkedIndices = classList.CheckedIndices.Cast <int>().ToList(); if (args != null) { if (args.NewValue == CheckState.Checked) { checkedIndices.Add(args.Index); checkedIndices.Sort(); } else { checkedIndices.Remove(args.Index); } } this.StimulusClass1 = this.StimulusClass2 = null; if (checkedIndices.Count > 0) { this.StimulusClass1 = ((StimulusClassTab)classList.Items[checkedIndices[0]]).StimulusClass; if (checkedIndices.Count > 1) { this.StimulusClass2 = ((StimulusClassTab)classList.Items[checkedIndices[1]]).StimulusClass; } } setImage(); }; Action <string> addClass = path => { StimulusClass stimulusClass; if (!StimulusClass.TryLoad(path, out stimulusClass)) { GUIUtils.Alert("Failed to load stimulus class from " + path, MessageBoxIcon.Error); } else if (this.stimulusClassTabs .Count(tp => tp.StimulusClass.SourceFolder.Equals(path, StringComparison.OrdinalIgnoreCase) || tp.StimulusClass.SavePath.Equals(path, StringComparison.OrdinalIgnoreCase)) > 0) { GUIUtils.Alert("A class from " + path + " is already loaded!", MessageBoxIcon.Exclamation); } else { // get a unique marker unless this was the load of a saved class if (!File.Exists(stimulusClass.SavePath)) { stimulusClass.Settings.Marker = this.stimulusClassTabs.Count == 0 ? 1 : this.stimulusClassTabs.Max(s => s.StimulusClass.Settings.Marker) + 1; } var classTab = new StimulusClassTab(stimulusClass); classTab.TextChanged += (sender, args) => classList.Invalidate(); classTab.Closing += (sender, args) => { this.stimulusClassTabs.Remove(classTab); classList.Items.Remove(classTab); refreshSelectedClasses(classList, null); }; this.stimulusClassTabs.Add(classTab); tabs.TabPages.Add(classTab); classList.Items.Add(classTab, true); refreshSelectedClasses(classList, null); } }; classList.ItemCheck += refreshSelectedClasses; classList.DragEnter += (sender, args) => { if (args.Data.GetDataPresent(DataFormats.FileDrop, false) && ((string[])args.Data.GetData(DataFormats.FileDrop)).Where(StimulusClass.IsValidLoadPath).Count() > 0) { args.Effect = DragDropEffects.All; } }; classList.DragDrop += (sender, args) => { // check that the form is in a valid state var activeTextBox = this.FindForm().ActiveControl as TextBox; if (activeTextBox != null && !activeTextBox.IsValid()) { GUIUtils.Alert("All entered data must be valid in order for drag and drop to be enabled", MessageBoxIcon.Error); return; } string[] data = (string[])args.Data.GetData(DataFormats.FileDrop); foreach (string path in data.Where(StimulusClass.IsValidLoadPath)) { addClass(path); } }; // button table var buttonTable = GUIUtils.CreateButtonTable(Direction.Horizontal, DockStyle.Bottom, GUIUtils.CreateFlatButton("New", b => { if (this.folderDialog.ShowDialog() == DialogResult.OK) { addClass(this.folderDialog.SelectedPath); } }, startTab.ToolTip, "Create a new stimulus class from a folder of images"), GUIUtils.CreateFlatButton("Load", b => { if (this.fileDialog.ShowDialog() == DialogResult.OK) { addClass(this.fileDialog.FileName); } }, startTab.ToolTip, "Load a previously saved stimulus class settings file")); startTab.Closing += (sender, args) => { args.Cancel = true; if (GUIUtils.IsUserSure("Reset stimulus classes?")) { this.stimulusClassTabs.Clear(); this.Controls.Remove(tabs); tabs.Dispose(); timer.Enabled = false; timer.Dispose(); this.BuildView(); this.OnSizeChanged(EventArgs.Empty); } }; // add all controls // left column var panel = new Panel() { Dock = DockStyle.Fill }; panel.Controls.Add(classList); panel.Controls.Add(buttonTable); cols.Controls.Add(panel, 0, 0); // middle column cols.Controls.Add(imageConfig, 1, 0); // right column cols.Controls.Add(imagePanel, 2, 0); startTab.Controls.Add(cols); tabs.Controls.Add(startTab); this.Controls.Add(tabs); this.ResumeLayout(false); }
/// <summary> /// Subscribing to any changes of the controls by type /// </summary> /// <param name="type"></param> /// <param name="control">where to look</param> /// <param name="callback"></param> /// <param name="except">Optional the exception list with names what should be ignored</param> public static void noticeAboutChanges(Type type, Form control, EventHandler callback, string[] except = null) { foreach (Control ctrl in getControls(control, c => c.GetType() == type && ( (except != null && !except.Contains(c.Name)) || except == null ) )) { if (type == typeof(CheckBox)) { ((CheckBox)ctrl).CheckedChanged -= callback; ((CheckBox)ctrl).CheckedChanged += callback; continue; } if (type == typeof(RadioButton)) { ((RadioButton)ctrl).CheckedChanged -= callback; ((RadioButton)ctrl).CheckedChanged += callback; continue; } if (type == typeof(TextBox)) { ((TextBox)ctrl).TextChanged -= callback; ((TextBox)ctrl).TextChanged += callback; continue; } if (type == typeof(ListBox)) { ((ListBox)ctrl).SelectedIndexChanged -= callback; ((ListBox)ctrl).SelectedIndexChanged += callback; continue; } if (type == typeof(ComboBox)) { ((ComboBox)ctrl).TextChanged -= callback; ((ComboBox)ctrl).TextChanged += callback; continue; } if (type == typeof(RichTextBox)) { ((RichTextBox)ctrl).TextChanged -= callback; ((RichTextBox)ctrl).TextChanged += callback; continue; } if (type == typeof(CheckedListBox)) { ItemCheckEventHandler call = (sender, e) => { callback(sender, (EventArgs)e); }; ((CheckedListBox)ctrl).ItemCheck -= call; ((CheckedListBox)ctrl).ItemCheck += call; continue; } if (type == typeof(DataGridView) || type == typeof(DataGridViewExt)) { DataGridViewCellEventHandler call = (sender, e) => { callback(sender, (EventArgs)e); }; ((DataGridView)ctrl).CellValueChanged -= call; ((DataGridView)ctrl).CellValueChanged += call; continue; } if (type == typeof(PropertyGrid)) { PropertyValueChangedEventHandler call = (sender, e) => { callback(sender, (EventArgs)e); }; ((PropertyGrid)ctrl).PropertyValueChanged -= call; ((PropertyGrid)ctrl).PropertyValueChanged += call; continue; } } }
private BindResult BindModelsAndControls() { var mo = this.controller.Model; var ma = this.controller.ManagerModel; var mc = this.controller.CertViewModel; // Model bindings BindResult init = default(BindResult); init += mo.TosLink.BindOnChanged(s => this.DataTipFor(this.lnkTos, s, ">,v,>v,>v,>^,<v,<^")); // controller bindings init += this.controller.Initialize(); // Control bindings: // These are relations between the controls on the form // and the bindable objects. init += mo.Email.BindControl(this.cmbRegistration); init += mo.Domain.BindControl(this.cmbDomain); init += mo.Challenge.BindControl(this.cmbChallenge); init += mo.Target.BindControl(this.txtChallengeTarget); init += mo.Key.BindControl(this.txtChallengeKey); init += mo.SiteRoot.BindControl(this.txtSiteRoot); init += mo.Certificate.BindControl(this.cmbCertificate, s => s?.StartsWith("[new] ") == true ? s.Substring(6) : s); init += mo.Issuer.BindControl(this.txtIssuer); init += mo.CertificateType.BindControl(this.cmbCertificateType, StringToCertTypeEnum, CertTypeEnumToString); init += mo.Password.BindControl(this.txtPassword); init += mo.ShowPassword.BindControl(this.chkShowPassword); init += mo.GitUserName.BindControl(this.txtGitUserName); init += mo.GitPassword.BindControl(this.txtGitPassword); init += mo.SavePath.BindControl(this.txtSavePath); init += mo.AutoRegister.BindControl(this.chkAutoRegister); init += mo.AutoAcceptTos.BindControl(this.chkAutoAcceptTos); init += mo.AutoAddDomain.BindControl(this.chkAutoAddDomain); init += mo.AutoSaveChallenge.BindControl(this.chkAutoSaveChallenge); init += mo.AutoCommitChallenge.BindControl(this.chkAutoCommit); init += mo.AutoTestChallenge.BindControl(this.chkAutoTest); init += mo.AutoValidateChallenge.BindControl(this.chkAutoValidate); init += mo.AutoUpdateStatus.BindControl(this.chkAutoUpdateStatus); init += mo.AutoCreateCertificate.BindControl(this.chkAutoCreateCertificate); init += mo.AutoSubmitCertificate.BindControl(this.chkAutoSubmit); init += mo.AutoGetIssuerCertificate.BindControl(this.chkAutoGetIssuerCert); init += mo.AutoSaveOrShowCertificate.BindControl(this.chkAutoSaveOrShowCertificate); init += mo.CurrentRegistration.Bind(this.lstRegistrations, (RegistrationItem i) => i?.RegistrationInfo); init += mo.CurrentRegistration.BindControl(this.cmbRegistration, (RegistrationItem i) => i?.RegistrationInfo); init += mo.Domain.BindControl(this.lstDomains); init += ma.Challenge.BindControl(this.lstChallenges); // Cert view controls init += mc.Certificate.BindControl(this.cmbAllCerts); init += mc.Certificates.Bind(() => this.cmbAllCerts.Items.OfType <string>().ToArray()); init += BindHelper.BindExpression(() => this.cmbAllCerts.SetItems(mc.Certificates.Value)); init += mc.CertificateType.BindControl(this.cmbCertViewType, StringToCertTypeEnum, CertTypeEnumToString); init += mc.Base64Data.BindControl(this.txtCertBase64Data); // init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnRegister, mo.AutoRegisterRetry.Value, mo.AutoRegisterTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnAcceptTos, mo.AutoAcceptTosRetry.Value, mo.AutoAcceptTosTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnAddDomain, mo.AutoAddDomainRetry.Value, mo.AutoAddDomainTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnSaveChallenge, mo.AutoSaveChallengeRetry.Value, mo.AutoSaveChallengeTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnCommitChallenge, mo.AutoCommitChallengeRetry.Value, mo.AutoCommitChallengeTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnTestChallenge, mo.AutoTestChallengeRetry.Value, mo.AutoTestChallengeTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnValidate, mo.AutoValidateChallengeRetry.Value, mo.AutoValidateChallengeTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnUpdateStatus, mo.AutoUpdateStatusRetry.Value, mo.AutoUpdateStatusTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnCreateCertificate, mo.AutoCreateCertificateRetry.Value, mo.AutoCreateCertificateTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnSubmit, mo.AutoSubmitCertificateRetry.Value, mo.AutoSubmitCertificateTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnGetIssuerCert, mo.AutoGetIssuerCertificateRetry.Value, mo.AutoGetIssuerCertificateTimer.Value)); init += BindHelper.BindExpression(() => this.RetryToolTip(this.btnSaveCertificate, mo.AutoSaveOrShowCertificateRetry.Value, mo.AutoSaveOrShowCertificateTimer.Value)); // Custom collection bindings: init += mo.Registrations.Bind( () => this.cmbRegistration.Items.AsArray((RegistrationItem x) => x.RegistrationInfo), v => this.cmbRegistration.SetItems(v.AsArray((RegistrationInfo x) => new RegistrationItem(x)))); init += mo.Registrations.Bind( () => this.lstRegistrations.Items.AsArray((RegistrationItem x) => x.RegistrationInfo), v => this.lstRegistrations.SetItems(v.AsArray((RegistrationInfo x) => new RegistrationItem(x)))); init += mo.Domains.Bind (() => this.cmbDomain.Items.AsArray((object o) => o.ToString()), v => this.cmbDomain.SetItems(v)); init += mo.Domains.Bind( () => this.lstDomains.Items.AsArray((object o) => o.ToString()), v => this.lstDomains.SetItems(v)); init += ma.Challenges.Bind( () => this.lstChallenges.Items.AsArray((object o) => o.ToString()), v => this.lstChallenges.SetItems(v)); init += ma.Challenges.BindOnChanged(fnames => { if (this.cmbChallenge.SelectedIndex < 0) { this.cmbChallenge.SelectedIndex = 0; } }); init += ma.Certificates.Bind( () => this.lstCertificates.Items.OfType <string>().ToArray(), v => this.lstCertificates.SetItems(v)); init += mo.Certificates.Bind(() => this.cmbCertificate.Items.OfType <string>().ToArray()); init += BindHelper.BindExpression( () => this.SetItemsOf_cmbCertificate(mo.Certificates.Value, mo.Domain.Value, mo.Date.Value)); init += mo.SsgName.BindControl(this.cmbSsg); init += mo.SsgTypes.Bind( () => this.cmbSsg.Items.OfType <string>().ToArray(), v => this.cmbSsg.SetItems(v)); init += mo.SsgTypes.BindOnChanged(fnames => { if (this.cmbSsg.SelectedIndex < 0) { this.cmbSsg.SelectedIndex = 0; } }); // Manual changed events: init += mo.CanRegister.BindOnChanged(v => this.btnRegister.Enabled = v); init += mo.CanAcceptTos.BindOnChanged(v => this.btnAcceptTos.Enabled = v); init += mo.IsRegistrationCreated.BindOnChanged(v => this.lnkTos.Enabled = v); init += mo.CanAddDomain.BindOnChanged(v => this.btnAddDomain.Enabled = v); init += mo.CanSaveChallenge.BindOnChanged(v => this.btnSaveChallenge.Enabled = v); init += mo.CanCommitChallenge.BindOnChanged(v => this.btnCommitChallenge.Enabled = v); init += mo.CanTestChallenge.BindOnChanged(v => this.btnTestChallenge.Enabled = v); init += mo.CanValidateChallenge.BindOnChanged(v => this.btnValidate.Enabled = v); init += mo.CanUpdateStatus.BindOnChanged(v => this.btnUpdateStatus.Enabled = v); init += mo.CanCreateCertificate.BindOnChanged(v => this.btnCreateCertificate.Enabled = v); init += mo.CanSubmitCertificate.BindOnChanged(v => this.btnSubmit.Enabled = v); init += mo.CanGetIssuerCertificate.BindOnChanged(v => this.btnGetIssuerCert.Enabled = v); init += mo.CanSaveCertificate.BindOnChanged(v => this.btnSaveCertificate.Enabled = v); init += mo.CanShowCertificate.BindOnChanged(v => this.btnShowCertificate.Enabled = v); init += mo.ShowPassword.BindOnChanged(b => this.txtPassword.UseSystemPasswordChar = !b); init += mo.IsPasswordEnabled.BindOnChanged(v => this.txtPassword.Enabled = this.chkShowPassword.Enabled = v); init += mo.Files.BindOnChanged(this.UpdateFiles); init += mo.CurrentAuthState.BindOnChanged(this.CurrentAuthState_Changed); init += mo.CurrentIdentifier.BindOnChanged(s => this.tableCertDomains.Hide()); init += mo.CurrentSsg.BindOnChanged(this.CurrentSsg_Changed); init += mo.X509Certificate.BindOnChanged(this.X509Certificate_Changed); ItemCheckEventHandler lstCertDomainsOnItemCheck = (s, a) => { if (this.lstCertDomains.Items[a.Index].ToString() == mo.Domain.Value) { a.NewValue = CheckState.Checked; } }; init += new BindResult( () => this.lstCertDomains.ItemCheck += lstCertDomainsOnItemCheck, () => this.lstCertDomains.ItemCheck -= lstCertDomainsOnItemCheck); return(init); }
public static System.Windows.Forms.CheckedListBox Create(EventHandler selectedIndexChanged, EventHandler doubleClick, ItemCheckEventHandler itemCheck) { System.Windows.Forms.CheckedListBox checkBox = new System.Windows.Forms.CheckedListBox(); checkBox.Location = new System.Drawing.Point(0, 0); checkBox.Dock = DockStyle.Fill; checkBox.SelectedIndexChanged += new EventHandler(selectedIndexChanged); checkBox.DoubleClick += new EventHandler(doubleClick); checkBox.ItemCheck += new ItemCheckEventHandler(itemCheck); return(checkBox); }
private void UnregisterItemCheckEvent(ItemCheckEventHandler itemCheckEventHandler) { chcLstLabels.ItemCheck -= itemCheckEventHandler; }