private void Execute(CommandState commandState) { Debug.WriteLine("Execute \'" + commandState.CommandName + "\'."); if (commandState.IsEnabled) { foreach (ICommandTarget commandTarget in this.targets) { // commandTarget.QueryStatus(commandState); if (commandTarget.Execute(commandState)) { this.QueryStatus(); return; } } } }
public bool QueryStatus(CommandState commandState) { if (this.htmlControl.IsHandleCreated && this.htmlControl.IsReady) { CommandCheckBoxState checkBoxState = commandState as CommandCheckBoxState; switch (commandState.CommandName) { case "File.Print": commandState.IsEnabled = this.htmlControl.CanPrint; return true; case "File.PrintPreview": commandState.IsEnabled = this.htmlControl.CanPrintPreview; return true; case "Edit.Undo": commandState.IsEnabled = this.htmlControl.CanUndo; commandState.Text = "&Undo " + this.htmlControl.UndoDescription; return true; case "Edit.Redo": commandState.IsEnabled = this.htmlControl.CanRedo; commandState.Text = "&Redo " + this.htmlControl.RedoDescription; return true; case "Edit.Copy": commandState.IsEnabled = this.htmlControl.CanCopy; return true; case "Edit.Cut": commandState.IsEnabled = this.htmlControl.CanCut; return true; case "Edit.Paste": commandState.IsEnabled = this.htmlControl.CanPaste; return true; case "Edit.Delete": commandState.IsEnabled = this.htmlControl.CanDelete; return true; case "Edit.SelectAll": commandState.IsEnabled = this.htmlControl.CanSelectAll; return true; case "Edit.Find": case "Edit.FindNext": case "Edit.Replace": commandState.IsEnabled = true; return true; case "Edit.InsertHyperlink": case "Edit.InsertPicture": case "Edit.InsertDateTime": commandState.IsEnabled = this.htmlControl.CanInsertHtml; return true; case "Format.Font": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetFontName; (commandState as CommandComboBoxState).Value = this.htmlControl.TextFormatting.FontName; return true; case "Format.FontSize": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetFontSize; (commandState as CommandComboBoxState).Value = ((int)this.htmlControl.TextFormatting.FontSize).ToString(); return true; case "Format.Bold": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleBold; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsBold; return true; case "Format.Italic": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleItalic; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsItalic; return true; case "Format.Underline": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleUnderline; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsUnderline; return true; case "Format.Strikethrough": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleStrikethrough; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsStrikethrough; return true; case "Format.Subscript": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleSubscript; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsSubscript; return true; case "Format.Superscript": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleSuperscript; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsSuperscript; return true; case "Format.AlignLeft": commandState.IsEnabled = this.htmlControl.TextFormatting.CanAlign(HtmlAlignment.Left); checkBoxState.IsChecked = (this.htmlControl.TextFormatting.Alignment == HtmlAlignment.Left); return true; case "Format.AlignRight": commandState.IsEnabled = this.htmlControl.TextFormatting.CanAlign(HtmlAlignment.Right); checkBoxState.IsChecked = (this.htmlControl.TextFormatting.Alignment == HtmlAlignment.Right); return true; case "Format.AlignCenter": commandState.IsEnabled = this.htmlControl.TextFormatting.CanAlign(HtmlAlignment.Center); checkBoxState.IsChecked = (this.htmlControl.TextFormatting.Alignment == HtmlAlignment.Center); return true; case "Format.OrderedList": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetHtmlFormat; checkBoxState.IsChecked = (this.htmlControl.TextFormatting.HtmlFormat == HtmlFormat.OrderedList); return true; case "Format.UnorderedList": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetHtmlFormat; checkBoxState.IsChecked = (this.htmlControl.TextFormatting.HtmlFormat == HtmlFormat.UnorderedList); return true; case "Format.Indent": commandState.IsEnabled = this.htmlControl.TextFormatting.CanIndent; return true; case "Format.Unindent": commandState.IsEnabled = this.htmlControl.TextFormatting.CanUnindent; return true; case "Format.ForeColor": case "Format.ForeColor.Black": case "Format.ForeColor.Yellow": case "Format.ForeColor.Red": case "Format.ForeColor.Green": case "Format.ForeColor.Blue": case "Format.ForeColor.White": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetForeColor; return true; case "Format.BackColor": case "Format.BackColor.Black": case "Format.BackColor.Yellow": case "Format.BackColor.Red": case "Format.BackColor.Green": case "Format.BackColor.Blue": case "Format.BackColor.White": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetBackColor; return true; } } return false; }
public bool Execute(CommandState commandState) { if (this.htmlControl.IsHandleCreated && this.htmlControl.IsReady) { switch (commandState.CommandName) { case "File.Print": this.htmlControl.Print(); return true; case "File.PrintPreview": this.htmlControl.PrintPreview(); return true; case "Edit.Undo": this.htmlControl.Undo(); return true; case "Edit.Redo": this.htmlControl.Redo(); return true; case "Edit.Cut": this.htmlControl.Cut(); return true; case "Edit.Copy": this.htmlControl.Copy(); return true; case "Edit.Paste": this.htmlControl.Paste(); return true; case "Edit.Delete": this.htmlControl.Delete(); return true; case "Edit.SelectAll": this.htmlControl.SelectAll(); return true; case "Format.ForeColor.White": this.htmlControl.TextFormatting.ForeColor = Color.White; return true; case "Format.ForeColor.Red": this.htmlControl.TextFormatting.ForeColor = Color.Red; return true; case "Format.ForeColor.Green": this.htmlControl.TextFormatting.ForeColor = Color.FromArgb(0, 255, 0); return true; case "Format.ForeColor.Blue": this.htmlControl.TextFormatting.ForeColor = Color.Blue; return true; case "Format.ForeColor.Yellow": this.htmlControl.TextFormatting.ForeColor = Color.Yellow; return true; case "Format.ForeColor.Black": this.htmlControl.TextFormatting.ForeColor = Color.Black; return true; case "Format.ForeColor": { ColorDialog dialog = new ColorDialog(); dialog.Color = this.htmlControl.TextFormatting.ForeColor; if (dialog.ShowDialog() == DialogResult.OK) { this.htmlControl.TextFormatting.ForeColor = dialog.Color; } } return true; case "Format.BackColor.Black": this.htmlControl.TextFormatting.BackColor = Color.Black; return true; case "Format.BackColor.Red": this.htmlControl.TextFormatting.BackColor = Color.Red; return true; case "Format.BackColor.Green": this.htmlControl.TextFormatting.BackColor = Color.FromArgb(0, 255, 0); return true; case "Format.BackColor.Blue": this.htmlControl.TextFormatting.BackColor = Color.Blue; return true; case "Format.BackColor.Yellow": this.htmlControl.TextFormatting.BackColor = Color.Yellow; return true; case "Format.BackColor.White": this.htmlControl.TextFormatting.BackColor = Color.White; return true; case "Format.BackColor": { ColorDialog dialog = new ColorDialog(); dialog.Color = this.htmlControl.TextFormatting.BackColor; if (dialog.ShowDialog() == DialogResult.OK) { this.htmlControl.TextFormatting.BackColor = dialog.Color; } } return true; case "Format.Font": this.htmlControl.TextFormatting.FontName = (commandState as CommandComboBoxState).Value; return true; case "Format.FontSize": this.htmlControl.TextFormatting.FontSize = (HtmlFontSize)Int32.Parse((commandState as CommandComboBoxState).Value); return true; case "Format.Bold": this.htmlControl.TextFormatting.ToggleBold(); return true; case "Format.Italic": this.htmlControl.TextFormatting.ToggleItalics(); return true; case "Format.Underline": this.htmlControl.TextFormatting.ToggleUnderline(); return true; case "Format.Strikethrough": this.htmlControl.TextFormatting.ToggleStrikethrough(); return true; case "Format.Superscript": this.htmlControl.TextFormatting.ToggleSuperscript(); return true; case "Format.Subscript": this.htmlControl.TextFormatting.ToggleSubscript(); return true; case "Format.AlignLeft": this.htmlControl.TextFormatting.Alignment = HtmlAlignment.Left; return true; case "Format.AlignCenter": this.htmlControl.TextFormatting.Alignment = HtmlAlignment.Center; return true; case "Format.AlignRight": this.htmlControl.TextFormatting.Alignment = HtmlAlignment.Right; return true; case "Format.OrderedList": this.htmlControl.TextFormatting.HtmlFormat = HtmlFormat.OrderedList; return true; case "Format.UnorderedList": this.htmlControl.TextFormatting.HtmlFormat = HtmlFormat.UnorderedList; return true; case "Format.Indent": this.htmlControl.TextFormatting.Indent(); return true; case "Format.Unindent": this.htmlControl.TextFormatting.Unindent(); return true; case "Edit.InsertHyperlink": this.InsertHyperlink(); return true; case "Edit.InsertPicture": this.InsertPicture(); return true; case "Edit.InsertDateTime": this.InsertDateTime(); return true; case "Edit.Find": this.Find(); return true; case "Edit.FindNext": this.FindNext(); return true; case "Edit.Replace": this.Replace(); return true; } } return false; }
public bool QueryStatus(CommandState commandState) { this.UpdateText(); switch (commandState.CommandName) { case "File.New": case "File.Open": case "Application.Exit": case "Application.Feedback": case "Application.CheckForUpdates": case "Application.About": commandState.IsEnabled = true; return true; case "File.Save": commandState.IsEnabled = (this.document != null) && (this.document.IsDirty); return true; case "File.SaveAs": commandState.IsEnabled = (this.document != null); return true; case "File.FtpSetting": commandState.IsEnabled = true; return true; case "File.Publish": commandState.IsEnabled = (!this.ftpConfiguration.IsEmpty); return true; case "File.History.0": commandState.IsVisible = (this.fileHistory.Count > 0); commandState.Text = "&1 " + this.fileHistory[0]; return true; case "File.History.1": commandState.IsVisible = (this.fileHistory.Count > 1); commandState.Text = "&2 " + this.fileHistory[1]; return true; case "File.History.2": commandState.IsVisible = (this.fileHistory.Count > 2); commandState.Text = "&3 " + this.fileHistory[2]; return true; case "File.History.3": commandState.IsVisible = (this.fileHistory.Count > 3); commandState.Text = "&4 " + this.fileHistory[3]; return true; } return false; }
public bool Execute(CommandState commandState) { switch (commandState.CommandName) { case "File.New": this.FileNew(); return true; case "File.Open": this.FileOpen(); return true; case "File.Save": this.document.Save(); return true; case "File.SaveAs": this.document.SaveAs(); this.fileHistory.AddFile(this.document.Url); return true; case "File.FtpSetting": this.PublishSetting(); return true; case "File.Publish": this.Publish(); return true; case "Application.Exit": this.applicationWindow.Close(); return true; case "Application.About": this.About(); return true; case "File.History.0": this.LoadFile(this.fileHistory[0]); return true; case "File.History.1": this.LoadFile(this.fileHistory[1]); return true; case "File.History.2": this.LoadFile(this.fileHistory[2]); return true; case "File.History.3": this.LoadFile(this.fileHistory[3]); return true; } return false; }
private void QueryStatus(CommandState commandState) { foreach (ICommandTarget commandTarget in this.targets) { if (commandTarget.QueryStatus(commandState)) { return; } } commandState.IsEnabled = false; }
public bool QueryStatus(CommandState commandState) { if (this.htmlControl.IsHandleCreated && this.htmlControl.IsReady) { CommandCheckBoxState checkBoxState = commandState as CommandCheckBoxState; switch (commandState.CommandName) { case "File.Print": commandState.IsEnabled = this.htmlControl.CanPrint; return(true); case "File.PrintPreview": commandState.IsEnabled = this.htmlControl.CanPrintPreview; return(true); case "Edit.Undo": commandState.IsEnabled = this.htmlControl.CanUndo; commandState.Text = "&Undo " + this.htmlControl.UndoDescription; return(true); case "Edit.Redo": commandState.IsEnabled = this.htmlControl.CanRedo; commandState.Text = "&Redo " + this.htmlControl.RedoDescription; return(true); case "Edit.Copy": commandState.IsEnabled = this.htmlControl.CanCopy; return(true); case "Edit.Cut": commandState.IsEnabled = this.htmlControl.CanCut; return(true); case "Edit.Paste": commandState.IsEnabled = this.htmlControl.CanPaste; return(true); case "Edit.Delete": commandState.IsEnabled = this.htmlControl.CanDelete; return(true); case "Edit.SelectAll": commandState.IsEnabled = this.htmlControl.CanSelectAll; return(true); case "Edit.Find": case "Edit.FindNext": case "Edit.Replace": commandState.IsEnabled = true; return(true); case "Edit.InsertHyperlink": case "Edit.InsertPicture": case "Edit.InsertDateTime": commandState.IsEnabled = this.htmlControl.CanInsertHtml; return(true); case "Format.Font": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetFontName; (commandState as CommandComboBoxState).Value = this.htmlControl.TextFormatting.FontName; return(true); case "Format.FontSize": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetFontSize; (commandState as CommandComboBoxState).Value = ((int)this.htmlControl.TextFormatting.FontSize).ToString(); return(true); case "Format.Bold": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleBold; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsBold; return(true); case "Format.Italic": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleItalic; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsItalic; return(true); case "Format.Underline": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleUnderline; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsUnderline; return(true); case "Format.Strikethrough": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleStrikethrough; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsStrikethrough; return(true); case "Format.Subscript": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleSubscript; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsSubscript; return(true); case "Format.Superscript": commandState.IsEnabled = this.htmlControl.TextFormatting.CanToggleSuperscript; checkBoxState.IsChecked = this.htmlControl.TextFormatting.IsSuperscript; return(true); case "Format.AlignLeft": commandState.IsEnabled = this.htmlControl.TextFormatting.CanAlign(HtmlAlignment.Left); checkBoxState.IsChecked = (this.htmlControl.TextFormatting.Alignment == HtmlAlignment.Left); return(true); case "Format.AlignRight": commandState.IsEnabled = this.htmlControl.TextFormatting.CanAlign(HtmlAlignment.Right); checkBoxState.IsChecked = (this.htmlControl.TextFormatting.Alignment == HtmlAlignment.Right); return(true); case "Format.AlignCenter": commandState.IsEnabled = this.htmlControl.TextFormatting.CanAlign(HtmlAlignment.Center); checkBoxState.IsChecked = (this.htmlControl.TextFormatting.Alignment == HtmlAlignment.Center); return(true); case "Format.OrderedList": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetHtmlFormat; checkBoxState.IsChecked = (this.htmlControl.TextFormatting.HtmlFormat == HtmlFormat.OrderedList); return(true); case "Format.UnorderedList": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetHtmlFormat; checkBoxState.IsChecked = (this.htmlControl.TextFormatting.HtmlFormat == HtmlFormat.UnorderedList); return(true); case "Format.Indent": commandState.IsEnabled = this.htmlControl.TextFormatting.CanIndent; return(true); case "Format.Unindent": commandState.IsEnabled = this.htmlControl.TextFormatting.CanUnindent; return(true); case "Format.ForeColor": case "Format.ForeColor.Black": case "Format.ForeColor.Yellow": case "Format.ForeColor.Red": case "Format.ForeColor.Green": case "Format.ForeColor.Blue": case "Format.ForeColor.White": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetForeColor; return(true); case "Format.BackColor": case "Format.BackColor.Black": case "Format.BackColor.Yellow": case "Format.BackColor.Red": case "Format.BackColor.Green": case "Format.BackColor.Blue": case "Format.BackColor.White": commandState.IsEnabled = this.htmlControl.TextFormatting.CanSetBackColor; return(true); } } return(false); }
public bool Execute(CommandState commandState) { if (this.htmlControl.IsHandleCreated && this.htmlControl.IsReady) { switch (commandState.CommandName) { case "File.Print": this.htmlControl.Print(); return(true); case "File.PrintPreview": this.htmlControl.PrintPreview(); return(true); case "Edit.Undo": this.htmlControl.Undo(); return(true); case "Edit.Redo": this.htmlControl.Redo(); return(true); case "Edit.Cut": this.htmlControl.Cut(); return(true); case "Edit.Copy": this.htmlControl.Copy(); return(true); case "Edit.Paste": this.htmlControl.Paste(); return(true); case "Edit.Delete": this.htmlControl.Delete(); return(true); case "Edit.SelectAll": this.htmlControl.SelectAll(); return(true); case "Format.ForeColor.White": this.htmlControl.TextFormatting.ForeColor = Color.White; return(true); case "Format.ForeColor.Red": this.htmlControl.TextFormatting.ForeColor = Color.Red; return(true); case "Format.ForeColor.Green": this.htmlControl.TextFormatting.ForeColor = Color.FromArgb(0, 255, 0); return(true); case "Format.ForeColor.Blue": this.htmlControl.TextFormatting.ForeColor = Color.Blue; return(true); case "Format.ForeColor.Yellow": this.htmlControl.TextFormatting.ForeColor = Color.Yellow; return(true); case "Format.ForeColor.Black": this.htmlControl.TextFormatting.ForeColor = Color.Black; return(true); case "Format.ForeColor": { ColorDialog dialog = new ColorDialog(); dialog.Color = this.htmlControl.TextFormatting.ForeColor; if (dialog.ShowDialog() == DialogResult.OK) { this.htmlControl.TextFormatting.ForeColor = dialog.Color; } } return(true); case "Format.BackColor.Black": this.htmlControl.TextFormatting.BackColor = Color.Black; return(true); case "Format.BackColor.Red": this.htmlControl.TextFormatting.BackColor = Color.Red; return(true); case "Format.BackColor.Green": this.htmlControl.TextFormatting.BackColor = Color.FromArgb(0, 255, 0); return(true); case "Format.BackColor.Blue": this.htmlControl.TextFormatting.BackColor = Color.Blue; return(true); case "Format.BackColor.Yellow": this.htmlControl.TextFormatting.BackColor = Color.Yellow; return(true); case "Format.BackColor.White": this.htmlControl.TextFormatting.BackColor = Color.White; return(true); case "Format.BackColor": { ColorDialog dialog = new ColorDialog(); dialog.Color = this.htmlControl.TextFormatting.BackColor; if (dialog.ShowDialog() == DialogResult.OK) { this.htmlControl.TextFormatting.BackColor = dialog.Color; } } return(true); case "Format.Font": this.htmlControl.TextFormatting.FontName = (commandState as CommandComboBoxState).Value; return(true); case "Format.FontSize": this.htmlControl.TextFormatting.FontSize = (HtmlFontSize)Int32.Parse((commandState as CommandComboBoxState).Value); return(true); case "Format.Bold": this.htmlControl.TextFormatting.ToggleBold(); return(true); case "Format.Italic": this.htmlControl.TextFormatting.ToggleItalics(); return(true); case "Format.Underline": this.htmlControl.TextFormatting.ToggleUnderline(); return(true); case "Format.Strikethrough": this.htmlControl.TextFormatting.ToggleStrikethrough(); return(true); case "Format.Superscript": this.htmlControl.TextFormatting.ToggleSuperscript(); return(true); case "Format.Subscript": this.htmlControl.TextFormatting.ToggleSubscript(); return(true); case "Format.AlignLeft": this.htmlControl.TextFormatting.Alignment = HtmlAlignment.Left; return(true); case "Format.AlignCenter": this.htmlControl.TextFormatting.Alignment = HtmlAlignment.Center; return(true); case "Format.AlignRight": this.htmlControl.TextFormatting.Alignment = HtmlAlignment.Right; return(true); case "Format.OrderedList": this.htmlControl.TextFormatting.HtmlFormat = HtmlFormat.OrderedList; return(true); case "Format.UnorderedList": this.htmlControl.TextFormatting.HtmlFormat = HtmlFormat.UnorderedList; return(true); case "Format.Indent": this.htmlControl.TextFormatting.Indent(); return(true); case "Format.Unindent": this.htmlControl.TextFormatting.Unindent(); return(true); case "Edit.InsertHyperlink": this.InsertHyperlink(); return(true); case "Edit.InsertPicture": this.InsertPicture(); return(true); case "Edit.InsertDateTime": this.InsertDateTime(); return(true); case "Edit.Find": this.Find(); return(true); case "Edit.FindNext": this.FindNext(); return(true); case "Edit.Replace": this.Replace(); return(true); } } return(false); }