コード例 #1
0
ファイル: CommandManager.cs プロジェクト: kelvinninja1/writer
        private CommandState GetCommandState(string commandName, CommandBarControl control)
        {
            foreach (CommandState commandState in this.states)
            {
                if (commandName == commandState.CommandName)
                {
                    return(commandState);
                }
            }

            CommandBarButton button = control as CommandBarButton;

            if (button != null)
            {
                CommandButtonState commandState = new CommandButtonState(commandName);
                this.states.Add(commandState);
                return(commandState);
            }

            CommandBarCheckBox checkBox = control as CommandBarCheckBox;

            if (checkBox != null)
            {
                CommandCheckBoxState commandState = new CommandCheckBoxState(commandName);
                this.states.Add(commandState);
                return(commandState);
            }

            CommandBarComboBox comboBox = control as CommandBarComboBox;

            if (comboBox != null)
            {
                CommandComboBoxState commandState = new CommandComboBoxState(commandName);
                this.states.Add(commandState);
                return(commandState);
            }

            throw new NotSupportedException();
        }
コード例 #2
0
ファイル: CommandManager.cs プロジェクト: NickCorn/Writer
        private CommandState GetCommandState(string commandName, CommandBarControl control)
        {
            foreach (CommandState commandState in this.states)
            {
                if (commandName == commandState.CommandName)
                {
                    return commandState;
                }
            }

            CommandBarButton button = control as CommandBarButton;
            if (button != null)
            {
                CommandButtonState commandState = new CommandButtonState(commandName);
                this.states.Add(commandState);
                return commandState;
            }

            CommandBarCheckBox checkBox = control as CommandBarCheckBox;
            if (checkBox != null)
            {
                CommandCheckBoxState commandState = new CommandCheckBoxState(commandName);
                this.states.Add(commandState);
                return commandState;
            }

            CommandBarComboBox comboBox = control as CommandBarComboBox;
            if (comboBox != null)
            {
                CommandComboBoxState commandState = new CommandComboBoxState(commandName);
                this.states.Add(commandState);
                return commandState;
            }

            throw new NotSupportedException();
        }
コード例 #3
0
ファイル: Document.cs プロジェクト: vgrudenic/Writer
        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);
        }