/// <summary>
 /// Signal the editor to save its settings.
 /// </summary>
 /// <param name="forced">If true, the settings will be applied even if the editor is not fully loaded.</param>
 protected void SaveSettings(bool forced)
 {
     if (forced || EditorState == ControlState.Loaded)
     {
         using (IImageDecoratorUndoUnit undo = EditorContext.CreateUndoUnit())
         {
             OnSaveSettings();
             undo.Commit();
             _imageTargetEditor.ImageEditFinished();
         }
     }
 }
Пример #2
0
        private void comboBoxLinkTargets_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (suppressComboBoxLinkTargetsSelectionChanged)
            {
                return;
            }
            if (EditorState == ControlState.Loaded)
            {
                using (new WaitCursor())
                {
                    using (IImageDecoratorUndoUnit undo = EditorContext.CreateUndoUnit())
                    {
                        bool           commitChanges = true;
                        LinkTargetType target        = SelectedLinkTarget;
                        if (target == LinkTargetType.URL && !comboBoxLinkTargets.DroppedDown)
                        {
                            ClearTargetSummaryLabel();
                            commitChanges = EditTargetOptions() == DialogResult.OK;
                        }

                        if (commitChanges)
                        {
                            HtmlImageTargetSettings.LinkTarget = target;
                            SaveSettingsAndApplyDecorator();

                            //note: this is optionally committed because the EditTargetOptions() method
                            //makes changes to the settings that persist in the DOM.  This is bad and we should
                            //stop doing that, and save in the OnSaveSettings() method instead. Then we won't
                            //need this stupid optional commit.
                            undo.Commit();
                        }
                        else
                        {
                            //rollback to the previous selected item
                            suppressComboBoxLinkTargetsSelectionChanged = true;
                            try
                            {
                                comboBoxLinkTargets.SelectedItem = new OptionItem("", HtmlImageTargetSettings.LinkTarget);
                            }
                            finally
                            {
                                suppressComboBoxLinkTargetsSelectionChanged = false;
                            }
                        }
                    }
                }
            }

            LoadTargetSummaryLabel();
            buttonTargetOptions.Enabled = !SelectedLinkTarget.Equals(LinkTargetType.NONE);
        }
Пример #3
0
 private void buttonTargetOptions_Click(object sender, EventArgs e)
 {
     using (new WaitCursor())
     {
         using (IImageDecoratorUndoUnit undo = EditorContext.CreateUndoUnit())
         {
             if (EditTargetOptions() == DialogResult.OK)
             {
                 SaveSettingsAndApplyDecorator();
                 LoadTargetSummaryLabel();
                 undo.Commit();
             }
         }
     }
 }