void RmlWysiwyg_ElementReturnedToDocument(RmlWysiwygComponent sender, IntVector2 position, string innerRmlHint, string previewElementTagType)
 {
     foreach (var editor in rmlEditors.Values)
     {
         if (editor.Component != sender)
         {
             editor.Component.setPreviewElement(position, innerRmlHint, previewElementTagType);
         }
     }
 }
예제 #2
0
        public override bool delete(Element element, RmlElementEditor editor, RmlWysiwygComponent component)
        {
            String src = element.GetAttributeString("src");

            if (String.IsNullOrEmpty(src))
            {
                component.deleteElement(element);
                return(true);
            }
            return(false);
        }
예제 #3
0
        public override bool delete(Element element, RmlElementEditor editor, RmlWysiwygComponent component)
        {
            String text = element.InnerRml;

            if (String.IsNullOrEmpty(text))
            {
                component.deleteElement(element);
                return(true);
            }
            return(false);
        }
        public override bool applyChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component, out TwoWayCommand additionalUndoOperations)
        {
            additionalUndoOperations = null;
            switch (element.GetAttributeString("type"))
            {
            case "range":
                return(applyRangeChanges(element, editor, component));

            default:
                return(false);
            }
        }
 void RmlWysiwyg_ElementDroppedOffDocument(RmlWysiwygComponent sender, IntVector2 position, string innerRmlHint, string previewElementTagType)
 {
     foreach (var editor in rmlEditors.Values)
     {
         if (editor.Component != sender)
         {
             if (editor.Component.contains(position))
             {
                 editor.Component.insertRml(innerRmlHint);
                 setCurrentRmlEditor(editor.View.Name);
             }
             else
             {
                 editor.Component.cancelAndHideEditor();
                 editor.Component.clearPreviewElement(false);
             }
         }
     }
 }
예제 #6
0
        public override bool applyChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component, out TwoWayCommand additionalUndoOperations)
        {
            additionalUndoOperations = null;
            switch (element.GetAttributeString("type"))
            {
            case "range":
                attributeEditor.applyToElement(element);
                break;

            default:
                String text = textEditor.Text;
                element.InnerRml = textEditor.Text;
                attributeEditor.applyToElement(element);
                break;
            }


            return(true);
        }
예제 #7
0
 public override bool applyChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component, out TwoWayCommand additionalUndoOperations)
 {
     additionalUndoOperations = null;
     return(attributeEditor.applyToElement(element));
 }
 public override bool applyChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component, out TwoWayCommand additionalUndoOperations)
 {
     additionalUndoOperations = null;
     build(element);
     return(true);
 }
예제 #9
0
 void component_Disposed()
 {
     component.Disposed -= component_Disposed;
     component           = null;
 }
예제 #10
0
 private bool applyRangeChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component)
 {
     return(true);
 }
예제 #11
0
        public override bool applyChanges(Element element, RmlElementEditor editor, RmlWysiwygComponent component, out TwoWayCommand additionalUndoOperations)
        {
            element.ClearLocalStyles();
            StringBuilder styleString = new StringBuilder();
            StringBuilder classString = new StringBuilder();
            bool          changesMade = false;

            element.SetAttribute("src", slideImageEditor.ImageName);
            if (slideImageEditor.ShowFullscreen)
            {
                String actionName = element.GetAttributeString("onclick");
                if (actionName == null)
                {
                    actionName = Guid.NewGuid().ToString();
                    element.SetAttribute("onclick", actionName);
                }

                Action <ShowPopupImageAction> undoAction;
                ShowPopupImageAction          oldAction = slide.getAction(actionName) as ShowPopupImageAction;
                if (oldAction == null)
                {
                    undoAction = a =>
                    {
                        slide.removeAction(actionName);
                    };
                }
                else
                {
                    undoAction = a =>
                    {
                        slide.replaceAction(a);
                    };
                }

                var action = new ShowPopupImageAction(actionName)
                {
                    ImageName = slideImageEditor.ImageName,
                };

                additionalUndoOperations = new TwoWayDelegateCommand <ShowPopupImageAction, ShowPopupImageAction>(action, oldAction, new TwoWayDelegateCommand <ShowPopupImageAction, ShowPopupImageAction> .Funcs()
                {
                    ExecuteFunc = (exec) =>
                    {
                        slide.replaceAction(exec);
                    },
                    UndoFunc = undoAction,
                });

                additionalUndoOperations.execute(); //This is not called automatically by the classes consuming this, so we make sure to actually apply the changes
            }
            else
            {
                String actionName = element.GetAttributeString("onclick");
                ShowPopupImageAction oldAction = null;
                if (actionName != null)
                {
                    oldAction = slide.getAction(actionName) as ShowPopupImageAction;
                }

                if (oldAction != null)
                {
                    additionalUndoOperations = new TwoWayDelegateCommand <ShowPopupImageAction, ShowPopupImageAction>(null, oldAction, new TwoWayDelegateCommand <ShowPopupImageAction, ShowPopupImageAction> .Funcs()
                    {
                        ExecuteFunc = (exec) =>
                        {
                            slide.removeAction(actionName);
                        },
                        UndoFunc = (undo) =>
                        {
                            slide.replaceAction(undo);
                        }
                    });
                    additionalUndoOperations.execute(); //Make sure changes are applied
                }
                else
                {
                    additionalUndoOperations = null;
                }

                element.RemoveAttribute("onclick");
            }
            changesMade = appearance.buildClassList(classString) | changesMade;
            changesMade = appearance.buildStyleAttribute(styleString) | changesMade;
            if (changesMade)
            {
                if (classString.Length > 0)
                {
                    element.SetAttribute("class", classString.ToString());
                }
                else
                {
                    element.RemoveAttribute("class");
                }
                if (styleString.Length > 0)
                {
                    element.SetAttribute("style", styleString.ToString());
                }
                else
                {
                    element.RemoveAttribute("style");
                }
            }

            return(changesMade);
        }
예제 #12
0
        public RmlEditorContext(String file, RmlTypeController rmlTypeController, AnomalousMvcContext editingMvcContext, EditorController editorController, EditorUICallback uiCallback)
        {
            this.rmlTypeController = rmlTypeController;
            this.currentFile       = file;
            this.uiCallback        = uiCallback;

            undoBuffer = new UndoRedoBuffer(50);

            rmlTypeController.loadText(currentFile);

            mvcContext = new AnomalousMvcContext();
            mvcContext.StartupAction = "Common/Start";
            mvcContext.FocusAction   = "Common/Focus";
            mvcContext.BlurAction    = "Common/Blur";
            mvcContext.SuspendAction = "Common/Suspended";
            mvcContext.ResumeAction  = "Common/Resumed";

            TextEditorView textEditorView = new TextEditorView("RmlEditor", () => rmlComponent.CurrentRml, wordWrap: false, textHighlighter: RmlTextHighlighter.Instance);

            textEditorView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            textEditorView.Buttons.add(new CloseButtonDefinition("Close", "RmlTextEditor/Close"));
            textEditorView.ComponentCreated += (view, component) =>
            {
                textEditorComponent = component;
            };
            mvcContext.Views.add(textEditorView);

            RmlWysiwygView rmlView = new RmlWysiwygView("RmlView", uiCallback, undoBuffer);

            rmlView.ElementName       = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            rmlView.RmlFile           = file;
            rmlView.ComponentCreated += (view, component) =>
            {
                rmlComponent            = component;
                rmlComponent.RmlEdited += rmlEditor =>
                {
                    if (textEditorComponent != null)
                    {
                        textEditorComponent.Text = rmlEditor.CurrentRml;
                    }
                };
            };
            mvcContext.Views.add(rmlView);

            DragAndDropView <WysiwygDragDropItem> htmlDragDrop = new DragAndDropView <WysiwygDragDropItem>("HtmlDragDrop",
                                                                                                           new WysiwygDragDropItem("Heading", "Editor/HeaderIcon", "<h1>Heading</h1>"),
                                                                                                           new WysiwygDragDropItem("Paragraph", "Editor/ParagraphsIcon", "<p>Add paragraph text here.</p>"),
                                                                                                           new WysiwygDragDropItem("Image", "Editor/ImageIcon", String.Format("<img src=\"{0}\" style=\"width:200px;\"></img>", RmlWysiwygComponent.DefaultImage)),
                                                                                                           new WysiwygDragDropItem("Link", "Editor/LinksIcon", "<a onclick=\"None\">Link</a>"),
                                                                                                           new WysiwygDragDropItem("Button", "Editor/AddButtonIcon", "<input type=\"submit\" onclick=\"None\">Button</input>"),
                                                                                                           new WysiwygDragDropItem("Separator", CommonResources.NoIcon, "<x-separator/>"),
                                                                                                           new WysiwygDragDropItem("Two Columns", CommonResources.NoIcon, "<div class=\"TwoColumn\"><div class=\"Column\"><p>Column 1 text goes here.</p></div><div class=\"Column\"><p>Column 2 text goes here.</p></div></div>"),
                                                                                                           new WysiwygDragDropItem("Heading and Paragraph", CommonResources.NoIcon, "<h1>Heading For Paragraph.</h1><p>Paragraph for heading.</p>", "div"),
                                                                                                           new WysiwygDragDropItem("Left Image and Paragraph", CommonResources.NoIcon, String.Format("<div class=\"ImageParagraphLeft\"><img src=\"{0}\" style=\"width:200px;\"/><p>Add paragraph text here.</p></div>", RmlWysiwygComponent.DefaultImage)),
                                                                                                           new WysiwygDragDropItem("Right Image and Paragraph", CommonResources.NoIcon, String.Format("<div class=\"ImageParagraphRight\"><img src=\"{0}\" style=\"width:200px;\"/><p>Add paragraph text here.</p></div>", RmlWysiwygComponent.DefaultImage))
                                                                                                           );

            htmlDragDrop.Dragging += (item, position) =>
            {
                rmlComponent.setPreviewElement(position, item.PreviewMarkup, item.PreviewTagType);
            };
            htmlDragDrop.DragEnded += (item, position) =>
            {
                if (rmlComponent.contains(position))
                {
                    rmlComponent.insertRml(item.createDocumentMarkup());
                }
                else
                {
                    rmlComponent.cancelAndHideEditor();
                    rmlComponent.clearPreviewElement(false);
                }
            };
            htmlDragDrop.ItemActivated += (item) =>
            {
                rmlComponent.insertRml(item.createDocumentMarkup());
            };
            htmlDragDrop.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            mvcContext.Views.add(htmlDragDrop);

            EditorTaskbarView taskbar = new EditorTaskbarView("InfoBar", currentFile, "Editor/Close");

            taskbar.addTask(new CallbackTask("SaveAll", "Save All", "Editor/SaveAllIcon", "", 0, true, item =>
            {
                saveAll();
            }));
            taskbar.addTask(new RunMvcContextActionTask("Save", "Save Rml File", "CommonToolstrip/Save", "File", "Editor/Save", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Undo", "Undo", CommonResources.NoIcon, "Edit", "Editor/Undo", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Redo", "Redo", CommonResources.NoIcon, "Edit", "Editor/Redo", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Cut", "Cut", "Editor/CutIcon", "Edit", "Editor/Cut", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Copy", "Copy", "Editor/CopyIcon", "Edit", "Editor/Copy", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Paste", "Paste", "Editor/PasteIcon", "Edit", "Editor/Paste", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("SelectAll", "Select All", "Editor/SelectAllIcon", "Edit", "Editor/SelectAll", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("RmlEditor", "Edit Rml", RmlTypeController.Icon, "Edit", "RmlTextEditor/Show", mvcContext));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("RmlTextEditor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewIfNotOpenCommand("RmlEditor")),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand(),
                                                                               new CallbackCommand(context =>
            {
                textEditorComponent = null;
            }))
                                                         ));

            mvcContext.Controllers.add(new MvcController("HtmlDragDrop",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewIfNotOpenCommand("HtmlDragDrop")),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand())
                                                         ));

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("RmlView"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            }),
                                                         new CallbackAction("Cut", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.cut();
                }
            }),
                                                         new CallbackAction("Copy", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.copy();
                }
            }),
                                                         new CallbackAction("Paste", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.paste();
                }
            }),
                                                         new CallbackAction("SelectAll", context =>
            {
                if (textEditorComponent != null)
                {
                    textEditorComponent.selectAll();
                }
            }),
                                                         new CallbackAction("Undo", context =>
            {
                undoBuffer.undo();
            }),
                                                         new CallbackAction("Redo", context =>
            {
                undoBuffer.execute();
            })
                                                         ));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", new RunActionCommand("HtmlDragDrop/Show"), new RunActionCommand("Editor/Show")),
                                                         new CallbackAction("Focus", context =>
            {
                GlobalContextEventHandler.setEventContext(eventContext);
                if (Focus != null)
                {
                    Focus.Invoke(this);
                }
            }),
                                                         new CallbackAction("Blur", context =>
            {
                GlobalContextEventHandler.disableEventContext(eventContext);
                if (Blur != null)
                {
                    Blur.Invoke(this);
                }
            }),
                                                         new RunCommandsAction("Suspended", new SaveViewLayoutCommand()),
                                                         new RunCommandsAction("Resumed", new RestoreViewLayoutCommand())));

            eventContext = new EventContext();
            ButtonEvent saveEvent = new ButtonEvent(EventLayers.Gui);

            saveEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            saveEvent.addButton(KeyboardButtonCode.KC_S);
            saveEvent.FirstFrameUpEvent += eventManager =>
            {
                saveAll();
            };
            eventContext.addEvent(saveEvent);

            ButtonEvent undoEvent = new ButtonEvent(EventLayers.Gui);

            undoEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            undoEvent.addButton(KeyboardButtonCode.KC_Z);
            undoEvent.FirstFrameUpEvent += eventManager =>
            {
                undoBuffer.undo();
            };
            eventContext.addEvent(undoEvent);

            ButtonEvent redoEvent = new ButtonEvent(EventLayers.Gui);

            redoEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            redoEvent.addButton(KeyboardButtonCode.KC_Y);
            redoEvent.FirstFrameUpEvent += eventManager =>
            {
                undoBuffer.execute();
            };
            eventContext.addEvent(redoEvent);

            if (editingMvcContext != null)
            {
                String controllerName = PathExtensions.RemoveExtension(file);
                if (editingMvcContext.Controllers.hasItem(controllerName))
                {
                    MvcController viewController = editingMvcContext.Controllers[controllerName];

                    GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcContext", viewController.getEditInterface(), editorController, uiCallback, true);
                    genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
                    genericPropertiesView.Buttons.add(new CloseButtonDefinition("Close", "MvcEditor/Close"));
                    mvcContext.Views.add(genericPropertiesView);

                    taskbar.addTask(new RunMvcContextActionTask("EditActions", "Edit Actions", "MvcContextEditor/ControllerIcon", "Edit", "MvcEditor/Show", mvcContext));

                    mvcContext.Controllers.add(new MvcController("MvcEditor",
                                                                 new RunCommandsAction("Show",
                                                                                       new ShowViewIfNotOpenCommand("MvcContext")),
                                                                 new RunCommandsAction("Close",
                                                                                       new CloseViewCommand())
                                                                 ));
                }

                if (editingMvcContext.Views.hasItem(controllerName))
                {
                    RmlView view = editingMvcContext.Views[controllerName] as RmlView;
                    if (view != null && view.RmlFile == file)
                    {
                        GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcView", view.getEditInterface(), editorController, uiCallback, true);
                        genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
                        genericPropertiesView.Buttons.add(new CloseButtonDefinition("Close", "MvcViewEditor/Close"));
                        mvcContext.Views.add(genericPropertiesView);

                        taskbar.addTask(new RunMvcContextActionTask("EditView", "Edit View", "MvcContextEditor/IndividualViewIcon", "Edit", "MvcViewEditor/Show", mvcContext));

                        mvcContext.Controllers.add(new MvcController("MvcViewEditor",
                                                                     new RunCommandsAction("Show",
                                                                                           new ShowViewIfNotOpenCommand("MvcView")),
                                                                     new RunCommandsAction("Close",
                                                                                           new CloseViewCommand())
                                                                     ));
                    }
                }

                taskbar.addTask(new CallbackTask("PreviewMvc", "Preview", "MvcContextEditor/MVCcomIcon", "", 0, true, (item) =>
                {
                    uiCallback.previewMvcContext(editingMvcContext);
                }));
            }
        }