public Editor() { #if TRIAL var form = new SplashForm(); form.ShowDialog(); #endif Load += new EventHandler(Editor_Load); InitializeComponent(); SetupEvents(); SetupTimer(); SetupBrowser(); SetupFontComboBox(); SetupFontSizeComboBox(); boldButton.CheckedChanged += delegate { if (BoldChanged != null) BoldChanged(); }; italicButton.CheckedChanged += delegate { if (ItalicChanged != null) ItalicChanged(); }; underlineButton.CheckedChanged += delegate { if (UnderlineChanged != null) UnderlineChanged(); }; orderedListButton.CheckedChanged += delegate { if (OrderedListChanged != null) OrderedListChanged(); }; unorderedListButton.CheckedChanged += delegate { if (UnorderedListChanged != null) UnorderedListChanged(); }; justifyLeftButton.CheckedChanged += delegate { if (JustifyLeftChanged != null) JustifyLeftChanged(); }; justifyCenterButton.CheckedChanged += delegate { if (JustifyCenterChanged != null) JustifyCenterChanged(); }; justifyRightButton.CheckedChanged += delegate { if (JustifyRightChanged != null) JustifyRightChanged(); }; justifyFullButton.CheckedChanged += delegate { if (JustifyFullChanged != null) JustifyFullChanged(); }; linkButton.CheckedChanged += delegate { if (IsLinkChanged != null) IsLinkChanged(); }; }
/// <summary> /// Called when the timer fires to synchronize the format buttons /// with the text editor current selection. /// SetupKeyListener if necessary. /// Set bold, italic, underline and link buttons as based on editor state. /// Synchronize the font combo box and the font size combo box. /// Finally, fire the Tick event to allow external components to synchronize /// their state with the editor. /// </summary> /// <param name="sender">the sender</param> /// <param name="e">EventArgs</param> private void timer_Tick(object sender, EventArgs e) { if (!init_timer) { ParentForm.FormClosed += new FormClosedEventHandler(ParentForm_FormClosed); init_timer = true; lastSplash = DateTime.Now; } // don't process until browser is in ready state. if (ReadyState != ReadyState.Complete) return; #if TRIAL if (DateTime.Now.Subtract(lastSplash).TotalMinutes > 10) { lastSplash = DateTime.Now; var dlg = new SplashForm(); dlg.ShowDialog(); } #endif SetupKeyListener(); boldButton.Checked = IsBold(); italicButton.Checked = IsItalic(); underlineButton.Checked = IsUnderline(); orderedListButton.Checked = IsOrderedList(); unorderedListButton.Checked = IsUnorderedList(); justifyLeftButton.Checked = IsJustifyLeft(); justifyCenterButton.Checked = IsJustifyCenter(); justifyRightButton.Checked = IsJustifyRight(); justifyFullButton.Checked = IsJustifyFull(); linkButton.Enabled = CanInsertLink(); UpdateFontComboBox(); UpdateFontSizeComboBox(); UpdateImageSizes(); if (Tick != null) Tick(); }