コード例 #1
0
        void commandMargin_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
        {
            Command command = (Command)sender;

            int value = Convert.ToInt32(args.GetDecimal(command.CommandId.ToString()));
            Debug.WriteLine(command.LabelTitle + ": " + value);

            if (command.CommandId == commandLeftMargin.CommandId)
            {
                marginValue.Left = value;
                commandLeftMargin.Value = value;
            }
            else if (command.CommandId == commandRightMargin.CommandId)
            {
                marginValue.Right = value;
                commandRightMargin.Value = value;
            }
            else if (command.CommandId == commandBottomMargin.CommandId)
            {
                marginValue.Bottom = value;
                commandBottomMargin.Value = value;
            }
            else if (command.CommandId == commandTopMargin.CommandId)
            {
                marginValue.Top = value;
                commandTopMargin.Value = value;
            }

            FireMarginChanged();
        }
コード例 #2
0
        public void Dispatch(PropertyKey key, ExecuteEventHandlerArgs args)
        {
            ExecuteWithArgsDelegate executeWithArgsDelegate = commands[key] as ExecuteWithArgsDelegate;

            if (executeWithArgsDelegate != null)
            {
                executeWithArgsDelegate(args);
                return;
            }

            CommandId commandId = (CommandId)commands[key];
            Command command = CommandManager.Get(commandId);
            command.PerformExecuteWithArgs(args);
        }
コード例 #3
0
            void command_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
            {
                Command command = (Command)sender;
                Debug.Assert(command.CommandId == _widthId || command.CommandId == _heightId);

                int value = Convert.ToInt32(args.GetDecimal(command.CommandId.ToString()));

                if (command.CommandId == _widthId)
                {
                    sizeValue.Width = value;
                }
                else if (command.CommandId == _heightId)
                {
                    sizeValue.Height = value;
                }

                FireSizeChanged();
            }
コード例 #4
0
 /// <summary>
 /// Private helper to raise an EventHandler event.
 /// </summary>
 /// <param name="eventKey">The event key of the event to raise.</param>
 /// <param name="e">An EventArgs that contains the event data.</param>
 private bool RaiseEvent(object eventKey, ExecuteEventHandlerArgs e)
 {
     ExecuteEventHandler eventHandler = Events[eventKey] as ExecuteEventHandler;
     if (eventHandler != null)
     {
         eventHandler(this, e);
         return true;
     }
     return false;
 }
コード例 #5
0
 /// <summary>
 /// Raises the Execute event.
 /// </summary>
 /// <param name="e">An EventArgs that contains the event data.</param>
 protected virtual void OnExecute(ExecuteEventHandlerArgs args)
 {
     try
     {
         bool executed = RaiseEvent(ExecuteWithArgsEventKey, args);
         Debug.Assert(executed || Events[ExecuteEventKey] == null, "Command " + CommandId + " was executed with args, but only non-arg handlers were registered");
     }
     catch (Exception ex)
     {
         UnexpectedErrorMessage.Show(ex);
     }
 }
コード例 #6
0
 protected virtual void PerformExecuteWithArgs(CommandExecutionVerb verb, ExecuteEventHandlerArgs args)
 {
     if (verb == CommandExecutionVerb.Execute)
     {
         if (On && Enabled)
         {
             OnExecute(args);
         }
         else
         {
             Debug.Fail("Command state error.", "It is illogical to execute a command that is not on and enabled.");
         }
     }
     else
     {
         Debug.Fail("Expected execute verb on " + CommandId);
     }
 }
コード例 #7
0
 /// <summary>
 /// This method can be called to raise the Execute event.
 /// </summary>
 public void PerformExecuteWithArgs(ExecuteEventHandlerArgs args)
 {
     if (On && Enabled)
     {
         OnExecute(args);
     }
     else
     {
         Debug.Fail("Command state error.", "It is illogical to execute a command that is not on and enabled.");
     }
 }
コード例 #8
0
 protected override void PerformExecuteWithArgs(CommandExecutionVerb verb, ExecuteEventHandlerArgs args)
 {
     _command.PerformExecuteWithArgs(args);
 }
コード例 #9
0
        private void commandInsertEmoticon_Execute(object sender, ExecuteEventHandlerArgs args)
        {
            EmoticonsGalleryCommand galleryCommand = (EmoticonsGalleryCommand)sender;
            int newSelectedIndex = args.GetInt(galleryCommand.CommandId.ToString());
            Emoticon emoticon = galleryCommand.Items[newSelectedIndex].Cookie;

            EmoticonsManager.AddToRecent(emoticon);
            using (EditorUndoUnit undo = new EditorUndoUnit(_currentEditor))
            {
                FocusBody();
                InsertHtml(EmoticonsManager.GetHtml(emoticon), HtmlInsertionOptions.MoveCursorAfter);
                undo.Commit();
            }
        }
コード例 #10
0
        void imageEffectsGalleryCommand_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
        {
            ImageEffectsGalleryCommand galleryCommand = (ImageEffectsGalleryCommand)sender;
            int newSelectedIndex = args.GetInt(galleryCommand.CommandId.ToString());
            string newDecoratorId = galleryCommand.Items[newSelectedIndex].Cookie;
            ImageDecorator newDecorator = _imageEditingContext.DecoratorsManager.GetImageDecorator(newDecoratorId);

            Debug.Assert(newDecorator != null);

            if (galleryCommand.SelectedItem != newDecorator.Id)
            {
                ImagePropertiesInfo.ImageDecorators.AddDecorator(newDecorator);

                if (!ImagePropertiesInfo.IsEditableEmbeddedImage())
                {
                    // If this is a web image, calling ApplyImageDecorations will keep properties up to date but won't
                    // actually do any decorating, so do it manually. Only borders should be manually decorated.
                    SimpleImageDecoratorContext context = new SimpleImageDecoratorContext(ImagePropertiesInfo);
                    newDecorator.Decorate(context);
                }

                ApplyImageDecorations();
            }
        }
コード例 #11
0
        void imageSizeCommand_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
        {
            SpinnerCommand command = (SpinnerCommand)sender;
            int newValue = Convert.ToInt32(args.GetDecimal(command.CommandId.ToString()));

            using (IUndoUnit undo = _editorContext.CreateUndoUnit())
            {
                if (command.CommandId == CommandId.FormatImageAdjustWidth && newValue != ImagePropertiesInfo.InlineImageWidth)
                {
                    ImagePropertiesInfo.InlineImageWidth = newValue;
                    ApplyImageDecorations(ImagePropertyType.InlineSize, ImageDecoratorInvocationSource.Command);
                    undo.Commit();
                }
                else if (command.CommandId == CommandId.FormatImageAdjustHeight && newValue != ImagePropertiesInfo.InlineImageHeight)
                {
                    ImagePropertiesInfo.InlineImageHeight = newValue;
                    ApplyImageDecorations(ImagePropertyType.InlineSize, ImageDecoratorInvocationSource.Command);
                    undo.Commit();
                }
            }
        }
コード例 #12
0
 void commandInsertablePlugins_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
 {
     string pluginId = commandInsertablePlugins.Items[args.GetInt(commandInsertablePlugins.CommandId.ToString())].Cookie;
     Command command = CommandManager.Get(pluginId);
     command.PerformExecute();
 }
コード例 #13
0
 void commandSemanticHtml_ExecuteWithArgs(object sender, ExecuteEventHandlerArgs args)
 {
     int selectedIndex = args.GetInt(CommandId.SemanticHtmlGallery.ToString());
     IHtmlFormattingStyle style = commandSemanticHtml.Items[selectedIndex] as IHtmlFormattingStyle;
     ApplyHtmlFormattingStyle(style);
 }