private void blur(AnomalousMvcContext context)
 {
     this.slideEditorController.VectorModeChanged -= slideEditorController_VectorModeChanged;
     commitText();
     if (editorController.ResourceProvider != null) //If this is null the project is closed, no reason to try to save the text
     {
         foreach (RmlSlidePanel panel in slide.Panels.Where(p => p is RmlSlidePanel))
         {
             String editorName = panel.createViewName("RmlView");
             var    editor     = rmlEditors[editorName];
             if (editor.Component != null && editor.Component.ChangesMade)
             {
                 String rml = editor.getCurrentComponentText();
                 editor.CachedResource.CachedString = rml;
                 editorController.ResourceProvider.ResourceCache.add(editor.CachedResource);
             }
         }
     }
     slideLayoutPicker.destroyLayoutPicker();
     GlobalContextEventHandler.disableEventContext(eventContext);
     htmlDragDrop.DestroyIconPreview();
     panelResizeWidget.destroyResizeWidget();
     if (Blur != null)
     {
         Blur.Invoke(this);
     }
 }
Exemple #2
0
 /// <summary>
 /// Set the classes from the platform that the plugins may be interested
 /// in. The timer can be subscribed to for updates and the EventManager
 /// will be updated with events every frame. This should be called as
 /// soon as possible and before any plugins are used besides the
 /// PlatformPlugin.
 /// </summary>
 /// <param name="mainTimer">The main update timer.</param>
 /// <param name="eventManager">The main event manager.</param>
 public void setPlatformInfo(UpdateTimer mainTimer, EventManager eventManager)
 {
     GlobalContextEventHandler.setEventManager(eventManager);
     foreach (PluginInterface plugin in loadedPlugins)
     {
         plugin.setPlatformInfo(mainTimer, eventManager);
     }
     mainTimer.addUpdateListener(new ThreadManagerUpdate());
 }
        public RcssEditorContext(String file, String rmlPreviewFile, RcssTypeController rcssTypeController)
        {
            this.rcssTypeController = rcssTypeController;
            this.currentFile        = file;

            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", () => this.rcssTypeController.loadText(currentFile), wordWrap: false, textHighlighter: CssTextHighlighter.Instance);

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

            RmlView rmlView = new RmlView("RmlView");

            rmlView.ElementName       = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            rmlView.RmlFile           = rmlPreviewFile;
            rmlView.ComponentCreated += (view, component) =>
            {
                rmlComponent = component;
            };
            mvcContext.Views.add(rmlView);

            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("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));
            mvcContext.Views.add(taskbar);

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

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", 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);
        }
        public TimelineEditorContext(Timeline timeline, String path, TimelineTypeController timelineTypeController, PropEditController propEditController, PropFactory propFactory, EditorController editorController, GuiFrameworkUICallback uiCallback, TimelineController timelineController)
        {
            this.currentTimeline        = timeline;
            this.currentFile            = path;
            this.timelineTypeController = timelineTypeController;
            this.propEditController     = propEditController;

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

            mvcContext.Models.add(new EditMenuManager());
            mvcContext.Models.add(new EditInterfaceHandler());

            mvcContext.Views.add(new TimelineEditorView("TimelineEditor", currentTimeline, timelineController, editorController, propEditController));

            ExpandingGenericEditorView genericEditor = new ExpandingGenericEditorView("TimelinePropertiesEditor", currentTimeline.getEditInterface(), editorController, uiCallback);

            genericEditor.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            mvcContext.Views.add(genericEditor);

            PropTimelineView propTimelineView = new PropTimelineView("PropTimeline", propEditController, propFactory);

            propTimelineView.Buttons.add(new CloseButtonDefinition("Close", "PropTimeline/Close"));
            mvcContext.Views.add(propTimelineView);

            OpenPropManagerView propManagerView = new OpenPropManagerView("PropManager", propEditController);

            propManagerView.Buttons.add(new CloseButtonDefinition("Close", "PropManager/Close"));
            mvcContext.Views.add(propManagerView);

            MovementSequenceEditorView movementSequenceEditor = new MovementSequenceEditorView("MovementSequenceEditor", listenForSequenceChanges: true);

            movementSequenceEditor.Buttons.add(new CloseButtonDefinition("Close", "MovementSequenceEditor/Close"));
            movementSequenceEditor.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Top);
            mvcContext.Views.add(movementSequenceEditor);

            EditorTaskbarView taskbar = new EditorTaskbarView("TimelineInfoBar", currentFile, "TimelineEditor/Close");

            taskbar.addTask(new CallbackTask("SaveAll", "Save All", "Editor/SaveAllIcon", "", 0, true, item =>
            {
                saveAll();
            }));
            taskbar.addTask(new RunMvcContextActionTask("Save", "Save Timeline", "CommonToolstrip/Save", "", "TimelineEditor/Save", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Cut", "Cut", "Editor/CutIcon", "", "TimelineEditor/Cut", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Copy", "Copy", "Editor/CopyIcon", "", "TimelineEditor/Copy", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Paste", "Paste", "Editor/PasteIcon", "", "TimelineEditor/Paste", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("SelectAll", "Select All", "Editor/SelectAllIcon", "", "TimelineEditor/SelectAll", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Translation", "Translation", "Editor/TranslateIcon", "", "TimelineEditor/Translation", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Rotation", "Rotation", "Editor/RotateIcon", "", "TimelineEditor/Rotation", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("PropTimeline", "Prop Timeline Editor", "Editor/PropTimelineEditorIcon", "", "PropTimeline/ShowIfNotOpen", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("PropManager", "Open Prop Manager", "Editor/PropManagerIcon", "", "PropManager/ShowIfNotOpen", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("MovementSequenceEditor", "Movement Sequence Editor", "Editor/MovementSequenceEditorIcon", "", "MovementSequenceEditor/ShowIfNotOpen", mvcContext));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("TimelineEditor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("TimelineEditor"),
                                                                               new ShowViewCommand("TimelinePropertiesEditor"),
                                                                               new ShowViewCommand("TimelineInfoBar")
                                                                               ),
                                                         new RunCommandsAction("Close",
                                                                               new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                timelineTypeController.saveTimeline(currentTimeline, currentFile);
            }),
                                                         new CutAction(),
                                                         new CopyAction(),
                                                         new PasteAction(),
                                                         new SelectAllAction(),
                                                         new CallbackAction("Translation", context =>
            {
                propEditController.setMoveMode();
            }),
                                                         new CallbackAction("Rotation", context =>
            {
                propEditController.setRotateMode();
            })
                                                         ));

            mvcContext.Controllers.add(new MvcController("PropTimeline",
                                                         new RunCommandsAction("ShowIfNotOpen",
                                                                               new ShowViewIfNotOpenCommand("PropTimeline")
                                                                               ),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand())));

            mvcContext.Controllers.add(new MvcController("PropManager",
                                                         new RunCommandsAction("ShowIfNotOpen",
                                                                               new ShowViewIfNotOpenCommand("PropManager")),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand())));

            mvcContext.Controllers.add(new MvcController("MovementSequenceEditor",
                                                         new RunCommandsAction("ShowIfNotOpen",
                                                                               new ShowViewIfNotOpenCommand("MovementSequenceEditor")
                                                                               ),
                                                         new RunCommandsAction("Close",
                                                                               new CloseViewCommand())));

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

            eventContext = new EventContext();

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                saveAll();
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_S }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                if (timeline.TimelineController.Playing)
                {
                    timeline.TimelineController.stopPlayback();
                }
                else
                {
                    timeline.TimelineController.startPlayback(timeline, propEditController.MarkerPosition, false);
                }
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_SPACE }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("TimelineEditor/Cut");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_X }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("TimelineEditor/Copy");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_C }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("TimelineEditor/Paste");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_V }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("TimelineEditor/SelectAll");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_A }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("TimelineEditor/Translation");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_T }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("TimelineEditor/Rotation");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_R }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: EventManager =>
            {
                mvcContext.runAction("PropTimeline/ShowIfNotOpen");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_P }));
        }
        public SlideEditorContext(Slide slide, String slideName, SlideshowEditController editorController, StandaloneController standaloneController, LectureUICallback uiCallback, UndoRedoBuffer undoBuffer, MedicalSlideItemTemplate itemTemplate, bool autoSetupScene, Action <String, String> wysiwygUndoCallback)
        {
            this.slide      = slide;
            this.uiCallback = uiCallback;
            if (uiCallback.hasCustomQuery(PlayTimelineAction.CustomActions.EditTimeline))
            {
                uiCallback.removeCustomQuery(PlayTimelineAction.CustomActions.EditTimeline);
            }
            uiCallback.addOneWayCustomQuery(PlayTimelineAction.CustomActions.EditTimeline, new Action <PlayTimelineAction>(action_EditTimeline));
            this.slideEditorController          = editorController;
            this.undoBuffer                     = undoBuffer;
            this.imageRenderer                  = standaloneController.ImageRenderer;
            this.itemTemplate                   = itemTemplate;
            this.wysiwygUndoCallback            = wysiwygUndoCallback;
            this.editorController               = editorController;
            this.layerController                = standaloneController.LayerController;
            this.sceneViewController            = standaloneController.SceneViewController;
            panelResizeWidget                   = new PanelResizeWidget();
            panelResizeWidget.RecordResizeUndo += panelResizeWidget_RecordResizeUndo;

            displayManager = new SlideDisplayManager(editorController.VectorMode);

            RunCommandsAction previewTriggerAction = new RunCommandsAction("PreviewTrigger");

            imageStrategy       = new SlideImageStrategy(slide, undoBuffer, this.slideEditorController.ResourceProvider, slide.UniqueName);
            linkTriggerStrategy = new SlideTriggerStrategy(slide, createTriggerActionBrowser(), undoBuffer, "a", "TriggerLink", "Lecture.Icon.TriggerIcon", standaloneController.NotificationManager, previewTriggerAction);
            linkTriggerStrategy.PreviewTrigger += triggerStrategy_PreviewTrigger;
            buttonTriggerStragegy = new SlideTriggerStrategy(slide, createTriggerActionBrowser(), undoBuffer, "button", "Trigger", "Lecture.Icon.TriggerIcon", standaloneController.NotificationManager, previewTriggerAction);
            buttonTriggerStragegy.PreviewTrigger += triggerStrategy_PreviewTrigger;
            inputStrategy = new SlideInputStrategy(slide, undoBuffer, standaloneController.NotificationManager, previewTriggerAction, "input", CommonResources.NoIcon);
            inputStrategy.PreviewTrigger += triggerStrategy_PreviewTrigger;

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

            showEditorWindowsCommand  = new RunCommandsAction("ShowEditors");
            closeEditorWindowsCommand = new RunCommandsAction("CloseEditors");

            RunCommandsAction showCommand = new RunCommandsAction("Show",
                                                                  new ShowViewCommand("InfoBar"),
                                                                  new RunActionCommand("Editor/SetupScene"),
                                                                  new RunActionCommand("Editor/ShowEditors")
                                                                  );

            refreshPanelEditors(false);

            htmlDragDrop = new DragAndDropTaskManager <WysiwygDragDropItem>(
                new WysiwygDragDropItem("Heading", "Editor/HeaderIcon", "<h1>Add Heading Here</h1>"),
                new WysiwygDragDropItem("Paragraph", "Editor/ParagraphsIcon", "<p>Add paragraph text here.</p>"),
                new WysiwygCallbackDragDropItem("Image", "Editor/ImageIcon", String.Format("<img src=\"{0}\" class=\"Center\" style=\"width:80%;\"></img>", RmlWysiwygComponent.DefaultImage),
                                                () => //Markup Callback
            {
                String actionName           = Guid.NewGuid().ToString();
                ShowPopupImageAction action = new ShowPopupImageAction(actionName)
                {
                    ImageName = RmlWysiwygComponent.DefaultImage
                };
                slide.addAction(action);
                return(String.Format("<img src=\"{0}\" class=\"Center\" style=\"width:80%;\" onclick=\"{1}\"></img>", RmlWysiwygComponent.DefaultImage, actionName));
            }),
                new WysiwygDragDropItem("Data Dispaly", CommonResources.NoIcon, "<data type=\"volume\" target=\"\">Data Display</data>"),
                new WysiwygCallbackDragDropItem("Trigger", "Lecture.Icon.TriggerIcon", "<button class=\"Trigger\" onclick=\"\">Add trigger text here.</a>",
                                                () => //Markup Callback
            {
                String actionName       = Guid.NewGuid().ToString();
                SetupSceneAction action = new SetupSceneAction(actionName);
                action.captureSceneState(uiCallback);
                slide.addAction(action);
                return(String.Format("<button class=\"Trigger\" onclick=\"{0}\">Add trigger text here.</a>", actionName));
            }),
                new WysiwygCallbackDragDropItem("Slider", CommonResources.NoIcon, "<input type=\"range\" min=\"0\" max=\"100\" value=\"0\" change=\"\"/>",
                                                () => //Markup Callback
            {
                String actionName       = Guid.NewGuid().ToString();
                BlendSceneAction action = new BlendSceneAction(actionName);
                action.captureSceneToStartAndEnd(uiCallback);
                slide.addAction(action);
                return(String.Format("<input type=\"range\" min=\"0\" max=\"100\" value=\"0\" onchange=\"{0}\"/>", actionName));
            })
                );
            htmlDragDrop.Dragging += (item, position) =>
            {
                foreach (var editor in rmlEditors.Values)
                {
                    editor.Component.setPreviewElement(position, item.PreviewMarkup, item.PreviewTagType);
                }
            };
            htmlDragDrop.DragEnded += (item, position) =>
            {
                bool allowAdd = true;
                foreach (var editor in rmlEditors.Values)
                {
                    if (allowAdd && editor.Component.contains(position))
                    {
                        editor.Component.insertRml(item.createDocumentMarkup());
                        setCurrentRmlEditor(editor.View.Name);
                        allowAdd = false;
                    }
                    else
                    {
                        editor.Component.cancelAndHideEditor();
                        editor.Component.clearPreviewElement(false);
                    }
                }
            };
            htmlDragDrop.ItemActivated += (item) =>
            {
                rmlEditors[currentRmlEditor].Component.insertRml(item.createDocumentMarkup());
            };

            taskbar = new SlideTaskbarView("InfoBar", slideName);
            taskbar.addTask(new CallbackTask("Save", "Save", "CommonToolstrip/Save", "", 0, true, item =>
            {
                saveAll();
            }));
            taskbar.addTask(new CallbackTask("Undo", "Undo", "Lecture.Icon.Undo", "Edit", 0, true, item =>
            {
                undoBuffer.undo();
            }));
            taskbar.addTask(new CallbackTask("Redo", "Redo", "Lecture.Icon.Redo", "Edit", 0, true, item =>
            {
                undoBuffer.execute();
            }));
            foreach (Task htmlDragDropTask in htmlDragDrop.Tasks)
            {
                taskbar.addTask(htmlDragDropTask);
            }
            taskbar.addTask(new CallbackTask("AddSlide", "Add Slide", "Lecture.Icon.AddSlide", "Edit", 0, true, item =>
            {
                slideEditorController.createSlide();
            }));
            taskbar.addTask(new CallbackTask("DuplicateSlide", "Duplicate Slide", "Lecture.Icon.DuplicateSlide", "Edit", 0, true, item =>
            {
                slideEditorController.duplicateSlide(slide);
            }));
            taskbar.addTask(new CallbackTask("RemoveSlide", "Remove Slide", "Lecture.Icon.RemoveSlide", "Edit", 0, true, item =>
            {
                editorController.removeSelectedSlides();
            }));
            taskbar.addTask(new CallbackTask("Capture", "Capture", "Lecture.Icon.Capture", "Edit", 0, true, item =>
            {
                editorController.capture();
            }));
            taskbar.addTask(new CallbackTask("EditTimeline", "Edit Timeline", "Lecture.Icon.EditTimeline", "Edit", 0, true, item =>
            {
                editorController.editTimeline(slide, "Timeline.tl", "Timeline");
            }));
            taskbar.addTask(new CallbackTask("Present", "Present", "Lecture.Icon.Present", "Edit", 0, true, item =>
            {
                editorController.runSlideshow(slide);
            }));
            taskbar.addTask(new CallbackTask("PresentFromBeginning", "Present From Beginning", "Lecture.Icon.PresentBeginning", "Edit", 0, true, item =>
            {
                editorController.runSlideshow(0);
            }));

            slideLayoutPicker = new SlideLayoutPickerTask();
            makeTempPresets();
            slideLayoutPicker.ChangeSlideLayout += slideLayoutPicker_ChangeSlideLayout;
            taskbar.addTask(slideLayoutPicker);

            styleManager = new SlideshowStyleManager(editorController, uiCallback);
            styleManager.addStyleFile(Path.Combine(slide.UniqueName, Slide.StyleSheetName), "This Slide");
            styleManager.addStyleFile("SlideMasterStyles.rcss", "All Slides");
            taskbar.addTask(new CallbackTask("EditSlideshowTheme", "Edit Slideshow Theme", "Lecture.Icon.EditStyle", "Edit", 0, true, item =>
            {
                IntVector2 taskPosition = item.CurrentTaskPositioner.findGoodWindowPosition(SlideshowStyleManager.Width, SlideshowStyleManager.Height);
                styleManager.showEditor(taskPosition.x, taskPosition.y);
            }));

            taskbar.addTask(new CallbackTask("ResetSlide", "Reset Slide", "Lecture.Icon.RevertIcon", "Edit", 0, true, item =>
            {
                resetSlide();
            }));

            mvcContext.Views.add(taskbar);

            setupScene = new RunCommandsAction("SetupScene");
            if (autoSetupScene)
            {
                setupScene.addCommand(new CallbackCommand(context =>
                {
                    undoState  = LayerState.CreateAndCapture();
                    undoCamera = sceneViewController.ActiveWindow != null ? sceneViewController.ActiveWindow.createCameraPosition() : null;
                }));
                slide.populateCommand(setupScene);
                setupScene.addCommand(new CallbackCommand(context =>
                {
                    if (undoState != null)
                    {
                        layerController.pushUndoState(undoState);
                        undoState = null;
                    }
                    if (undoCamera != null)
                    {
                        if (sceneViewController.ActiveWindow != null)
                        {
                            sceneViewController.ActiveWindow.pushUndoState(undoCamera);
                        }
                        undoCamera = null;
                    }
                }));
            }

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         setupScene,
                                                         showCommand,
                                                         showEditorWindowsCommand,
                                                         closeEditorWindowsCommand,
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand())
                                                         ));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", new RunActionCommand("Editor/Show")),
                                                         new CallbackAction("Focus", context =>
            {
                htmlDragDrop.CreateIconPreview();
                GlobalContextEventHandler.setEventContext(eventContext);
                if (Focus != null)
                {
                    Focus.Invoke(this);
                }
                slideLayoutPicker.createLayoutPicker();
                panelResizeWidget.createResizeWidget();
                if (currentRmlEditor != null)     //Make sure we have an active editor
                {
                    String current   = currentRmlEditor;
                    currentRmlEditor = null;
                    setCurrentRmlEditor(current);
                }
                this.slideEditorController.VectorModeChanged += slideEditorController_VectorModeChanged;
            }),
                                                         new CallbackAction("Blur", blur),
                                                         new RunCommandsAction("Suspended", new SaveViewLayoutCommand()),
                                                         new RunCommandsAction("Resumed", new RestoreViewLayoutCommand()),
                                                         previewTriggerAction));

            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);

            ButtonEvent runEvent = new ButtonEvent(EventLayers.Gui);

            runEvent.addButton(KeyboardButtonCode.KC_F5);
            runEvent.FirstFrameUpEvent += eventManager =>
            {
                ThreadManager.invoke(() =>
                {
                    editorController.runSlideshow(0);
                });
            };
            eventContext.addEvent(runEvent);

            ButtonEvent captureEvent = new ButtonEvent(EventLayers.Gui);

            captureEvent.addButton(KeyboardButtonCode.KC_LCONTROL);
            captureEvent.addButton(KeyboardButtonCode.KC_SPACE);
            captureEvent.FirstFrameUpEvent += eventManager =>
            {
                editorController.capture();
            };
            eventContext.addEvent(captureEvent);
        }
        public DependencyEditorContext(DDAtlasDependency plugin, String file, DependencyTypeController dependencyTypeController, EditorController editorController, GuiFrameworkUICallback uiCallback)
        {
            this.dependencyTypeController = dependencyTypeController;
            this.currentFile = file;
            this.plugin      = plugin;

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

            mvcContext.Models.add(new EditMenuManager());

            GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcContext", plugin.EditInterface, editorController, uiCallback, true);

            genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            mvcContext.Views.add(genericPropertiesView);

            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 Dependency Definition File", "CommonToolstrip/Save", "File", "Editor/Save", mvcContext));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("MvcContext"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            })));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", 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);
        }
        public SlideshowRuntime(Slideshow slideshow, ResourceProvider resourceProvider, GUIManager guiManager, int startIndex, TaskController additionalTasks)
        {
            this.guiManager = guiManager;

            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream resourceStream = assembly.GetManifestResourceStream(SlideshowProps.BaseContextProperties.File))
            {
                mvcContext = SharedXmlSaver.Load <AnomalousMvcContext>(resourceStream);
            }
            navModel       = (NavigationModel)mvcContext.Models[SlideshowProps.BaseContextProperties.NavigationModel];
            displayManager = new SlideDisplayManager(slideshow.VectorMode);
            foreach (Slide slide in slideshow.Slides)
            {
                String slideName = slide.UniqueName;
                slide.setupContext(mvcContext, slideName, resourceProvider, displayManager);

                NavigationLink link = new NavigationLink(slideName, null, slideName + "/Show");
                navModel.addNavigationLink(link);
            }

            RunCommandsAction runCommands = (RunCommandsAction)mvcContext.Controllers["Common"].Actions["Start"];

            runCommands.addCommand(new NavigateToIndexCommand()
            {
                Index = startIndex
            });

            taskbar        = new ClosingTaskbar();
            taskbarLink    = new SingleChildChainLink(SlideTaskbarName, taskbar);
            taskbar.Close += close;
            previousTask   = new CallbackTask("Slideshow.Back", "Back", PreviousTaskName, "None", arg =>
            {
                back();
            });
            nextTask = new CallbackTask("Slideshow.Forward", "Forward", NextTaskName, "None", arg =>
            {
                next();
            });
            taskbar.addItem(new TaskTaskbarItem(previousTask));
            taskbar.addItem(new TaskTaskbarItem(nextTask));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.Reload", "Reload", ReloadTaskName, "None", arg =>
            {
                reload();
            })));
            //taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ToggleMode", "Toggle Display Mode", "SlideshowIcons/NormalVectorToggle", "None", arg =>
            //{
            //    displayManager.VectorMode = !displayManager.VectorMode;
            //    guiManager.layout();
            //})));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ZoomIn", "Zoom In", "SlideshowIcons/ZoomIn", "None", arg =>
            {
                zoomIn();
            })));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ResetZoom", "Reset Zoom", "SlideshowIcons/ResetZoom", "None", arg =>
            {
                if (displayManager.AdditionalZoomMultiple != 1.0f)
                {
                    displayManager.AdditionalZoomMultiple = 1.0f;
                    guiManager.layout();
                }
            })));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ZoomOut", "Zoom Out", "SlideshowIcons/ZoomOut", "None", arg =>
            {
                zoomOut();
            })));

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

            nextEvent.addButton(KeyboardButtonCode.KC_RIGHT);
            nextEvent.FirstFrameUpEvent += eventManager =>
            {
                next();
            };
            eventContext.addEvent(nextEvent);

            ButtonEvent backEvent = new ButtonEvent(EventLayers.Gui);

            backEvent.addButton(KeyboardButtonCode.KC_LEFT);
            backEvent.FirstFrameUpEvent += eventManager =>
            {
                back();
            };
            eventContext.addEvent(backEvent);

            ButtonEvent zoomInEvent = new ButtonEvent(EventLayers.Gui);

            zoomInEvent.addButton(KeyboardButtonCode.KC_EQUALS);
            zoomInEvent.FirstFrameUpEvent += eventManager =>
            {
                zoomIn();
            };
            eventContext.addEvent(zoomInEvent);

            ButtonEvent zoomOutEvent = new ButtonEvent(EventLayers.Gui);

            zoomOutEvent.addButton(KeyboardButtonCode.KC_MINUS);
            zoomOutEvent.FirstFrameUpEvent += eventManager =>
            {
                zoomOut();
            };
            eventContext.addEvent(zoomOutEvent);

            ButtonEvent closeEvent = new ButtonEvent(EventLayers.Gui);

            closeEvent.addButton(KeyboardButtonCode.KC_ESCAPE);
            closeEvent.FirstFrameUpEvent += eventManager =>
            {
                ThreadManager.invoke(close); //Delay so we do not modify the input collection
            };
            eventContext.addEvent(closeEvent);

            foreach (Task task in additionalTasks.Tasks)
            {
                taskbar.addItem(new TaskTaskbarItem(task));
            }

            mvcContext.Blurred += (ctx) =>
            {
                guiManager.deactivateLink(SlideTaskbarName);
                guiManager.removeLinkFromChain(taskbarLink);
                GlobalContextEventHandler.disableEventContext(eventContext);
            };
            mvcContext.Focused += (ctx) =>
            {
                guiManager.addLinkToChain(taskbarLink);
                guiManager.pushRootContainer(SlideTaskbarName);
                setNavigationIcons();
                GlobalContextEventHandler.setEventContext(eventContext);
            };
            mvcContext.RemovedFromStack += (ctx) =>
            {
                taskbar.Dispose();
            };
        }
        public OffsetSequenceEditorContext(OffsetModifierSequence movementSequence, String file, OffsetSequenceTypeController typeController, GuiFrameworkUICallback uiCallback, SimObjectMover simObjectMover)
        {
            this.typeController            = typeController;
            this.currentFile               = file;
            this.movementSequence          = movementSequence;
            this.simObjectMover            = simObjectMover;
            simObjectMover.ShowMoveTools   = true;
            simObjectMover.ShowRotateTools = false;

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

            mvcContext.Models.add(new EditMenuManager());

            OffsetSequenceEditorView offsetSequenceView = new OffsetSequenceEditorView("SequenceEditor", uiCallback, simObjectMover, movementSequence);

            offsetSequenceView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Bottom);
            mvcContext.Views.add(offsetSequenceView);

            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 Movement Sequence File", "CommonToolstrip/Save", "File", "Editor/Save", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Cut", "Cut", "Editor/CutIcon", "", "Editor/Cut", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Copy", "Copy", "Editor/CopyIcon", "", "Editor/Copy", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Paste", "Paste", "Editor/PasteIcon", "", "Editor/Paste", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("SelectAll", "Select All", "Editor/SelectAllIcon", "", "Editor/SelectAll", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Translation", "Translation", "Editor/TranslateIcon", "", "Editor/Translation", mvcContext));
            taskbar.addTask(new RunMvcContextActionTask("Rotation", "Rotation", "Editor/RotateIcon", "", "Editor/Rotation", mvcContext));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("SequenceEditor"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close", new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            }),
                                                         new CutAction(),
                                                         new CopyAction(),
                                                         new PasteAction(),
                                                         new SelectAllAction(),
                                                         new CallbackAction("Translation", context =>
            {
                this.simObjectMover.ShowMoveTools   = true;
                this.simObjectMover.ShowRotateTools = false;
            }),
                                                         new CallbackAction("Rotation", context =>
            {
                this.simObjectMover.ShowMoveTools   = false;
                this.simObjectMover.ShowRotateTools = true;
            })));

            mvcContext.Controllers.add(new MvcController("Common",
                                                         new RunCommandsAction("Start", 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);

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Cut");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_X }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Copy");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_C }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Paste");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_V }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/SelectAll");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_A }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Translation");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_T }));

            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                mvcContext.runAction("Editor/Rotation");
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_R }));
        }
Exemple #9
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);
                }));
            }
        }
        public MvcEditorContext(AnomalousMvcContext editingContext, String file, MvcTypeController mvcTypeController, EditorController editorController, EditorUICallback uiCallback)
        {
            this.mvcTypeController = mvcTypeController;
            this.currentFile       = file;
            this.editingContext    = editingContext;

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

            mvcContext.Models.add(new EditMenuManager());

            GenericPropertiesFormView genericPropertiesView = new GenericPropertiesFormView("MvcContext", editingContext.getEditInterface(), editorController, uiCallback, true);

            genericPropertiesView.ElementName = new MDILayoutElementName(GUILocationNames.MDI, DockLocation.Left);
            mvcContext.Views.add(genericPropertiesView);

            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));
            mvcContext.Views.add(taskbar);

            mvcContext.Controllers.add(new MvcController("Editor",
                                                         new RunCommandsAction("Show",
                                                                               new ShowViewCommand("MvcContext"),
                                                                               new ShowViewCommand("InfoBar")),
                                                         new RunCommandsAction("Close",
                                                                               new CloseAllViewsCommand()),
                                                         new CallbackAction("Save", context =>
            {
                save();
            })));

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

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

            eventContext = new EventContext();
            eventContext.addEvent(new ButtonEvent(EventLayers.Gui,
                                                  frameUp: eventManager =>
            {
                saveAll();
            },
                                                  keys: new KeyboardButtonCode[] { KeyboardButtonCode.KC_LCONTROL, KeyboardButtonCode.KC_S }));
        }