Beispiel #1
0
        void hideButton_MouseButtonClick(Widget source, EventArgs e)
        {
            LayerState undoState = LayerState.CreateAndCapture();

            anatomy.smoothBlend(0.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
            layerController.pushUndoState(undoState);
        }
Beispiel #2
0
        internal void showOnly(Anatomy anatomy)
        {
            LayerState currentLayers = LayerState.CreateAndCapture();

            TransparencyController.smoothSetAllAlphas(0.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
            anatomy.smoothBlend(1.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
            layerController.pushUndoState(currentLayers);
        }
        public void applyBookmark(Bookmark bookmark)
        {
            SceneViewWindow window             = standaloneController.SceneViewController.ActiveWindow;
            LayerState      undoLayers         = LayerState.CreateAndCapture();
            CameraPosition  undoCameraPosition = window.createCameraPosition();

            window.setPosition(bookmark.CameraPosition, MedicalConfig.CameraTransitionTime);
            bookmark.Layers.timedApply(MedicalConfig.CameraTransitionTime);
            standaloneController.LayerController.pushUndoState(undoLayers);
            window.pushUndoState(undoCameraPosition);
        }
 void slider_MouseButtonPressed(Widget source, EventArgs e)
 {
     undoState = LayerState.CreateAndCapture();
 }
Beispiel #5
0
        public void initialize(StandaloneController standaloneController)
        {
            RocketInterface.Instance.FileInterface.addExtension(new RocketAssemblyResourceLoader(this.GetType().Assembly));

            if (VirtualFileSystem.Instance.exists("Watermark/AnomalousMedical.png"))
            {
                standaloneController.ImageRenderer.LoadLogo = () =>
                {
                    using (Stream stream = VirtualFileSystem.Instance.openStream("Watermark/AnomalousMedical.png", Engine.Resources.FileMode.Open))
                    {
                        return(new FreeImageBitmap(stream));
                    }
                };
            }

            this.guiManager           = standaloneController.GUIManager;
            this.standaloneController = standaloneController;
            standaloneController.MovementSequenceController.GroupAdded += MovementSequenceController_GroupAdded;

            bool hasPremium = licenseManager.allowFeature(1);

            standaloneController.AnatomyController.ShowPremiumAnatomy = hasPremium;
            guiManager.SaveUIConfiguration += guiManager_SaveUIConfiguration;
            guiManager.LoadUIConfiguration += guiManager_LoadUIConfiguration;
            guiManager.MainGUIShown        += guiManager_MainGUIShown;
            guiManager.MainGUIHidden       += guiManager_MainGUIHidden;

            //Controllers
            imageLicenseServer  = new ImageLicenseServer(licenseManager);
            bookmarksController = new BookmarksController(standaloneController, ScaleHelper.Scaled(100), ScaleHelper.Scaled(100), hasPremium);

            //Create Dialogs
            aboutDialog = new AboutDialog(licenseManager);

            chooseSceneDialog              = new ChooseSceneDialog(guiManager);
            chooseSceneDialog.ChooseScene += new EventHandler(chooseSceneDialog_ChooseScene);

            standaloneController.AnatomyController.ShowPremiumAnatomyChanged += AnatomyController_ShowPremiumAnatomyChanged;
            anatomyFinder = new AnatomyFinder(standaloneController.AnatomyController, standaloneController.SceneViewController, standaloneController.LayerController, standaloneController.AnatomyTaskManager);
            guiManager.addManagedDialog(anatomyFinder);

            options = new OptionsDialog(guiManager);
            options.VideoOptionsChanged += new EventHandler(options_VideoOptionsChanged);
            options.RequestRestart      += new EventHandler(options_RequestRestart);

            bookmarks = new BookmarksGUI(bookmarksController, standaloneController.GUIManager, standaloneController.SceneViewController);

            viewsGui = new ViewsGui(standaloneController.SceneViewController, standaloneController.AnatomyController);
            guiManager.addManagedDialog(viewsGui);

            //Taskbar
            taskbar = new AppButtonTaskbar();
            taskbar.OpenTaskMenu += taskbar_OpenTaskMenu;
            taskbar.setAppIcon("AppButton/Hamburger", "AppButton/Hamburger");
            taskbarLink = new SingleChildChainLink(GUILocationNames.Taskbar, taskbar);
            guiManager.addLinkToChain(taskbarLink);
            guiManager.pushRootContainer(GUILocationNames.Taskbar);

            //Task Menu
            taskMenu = new TaskMenu(standaloneController.DocumentController, standaloneController.TaskController, standaloneController.GUIManager, new LayoutElementName(GUILocationNames.FullscreenPopup));
            taskMenu.GroupComparison = TaskMenuCategories.Sorter;

            guiTaskManager = new GUITaskManager(taskbar, taskMenu, standaloneController.TaskController);

            //Tasks Menu
            TaskController taskController = standaloneController.TaskController;

            standaloneController.AnatomyTaskManager.HighlightTasks += AnatomyTaskManager_HighlightTasks;

            //Tasks
            cameraMovementModeTask = new CameraMovementModeTask(standaloneController.SceneViewController);
            taskController.addTask(cameraMovementModeTask);
            Slideshow.AdditionalTasks.addTask(cameraMovementModeTask);

            selectionOperatorTask = new SelectionOperatorTask(standaloneController.AnatomyController);
            taskController.addTask(selectionOperatorTask);
            Slideshow.AdditionalTasks.addTask(selectionOperatorTask);

            var viewsTask = new PinableMDIDialogOpenTask(viewsGui, "Medical.Views", "Views", "AnomalousMedical/ViewIcon", TaskMenuCategories.Explore);

            taskController.addTask(viewsTask);

            //Patient Section
            taskController.addTask(new ShowPopupTask(chooseSceneDialog, "Medical.NewPatient", "New", "AnomalousMedical/ChangeScene", TaskMenuCategories.Explore, 0));

            taskController.addTask(new DialogOpenTask(aboutDialog, "Medical.About", "About", "AnomalousMedical/About", TaskMenuCategories.System, int.MaxValue - 2));
            taskController.addTask(new VolumeControlTask());

            CallbackTask unhideAllAnatomy = new CallbackTask("Medical.UnhideAllAnatomy", "Unhide All", "AnatomyFinder.ShowAll", TaskMenuCategories.Explore, int.MaxValue - 2, false, (item) =>
            {
                LayerState undo = LayerState.CreateAndCapture();
                standaloneController.LayerController.unhideAll();
                standaloneController.LayerController.pushUndoState(undo);
            });

            taskController.addTask(unhideAllAnatomy);

            //Navigation Section
            PinableMDIDialogOpenTask anatomyFinderTask = new PinableMDIDialogOpenTask(anatomyFinder, "Medical.AnatomyFinder", "Anatomy Finder", "AnomalousMedical/SearchIcon", TaskMenuCategories.Explore);

            taskController.addTask(anatomyFinderTask);
            Slideshow.AdditionalTasks.addTask(anatomyFinderTask);

            ShowPopupTask bookmarkTask = null;

            standaloneController.AnatomyController.setCommandPermission(AnatomyCommandPermissions.Unrestricted, PlatformConfig.UnrestrictedEnvironment);
            standaloneController.AnatomyController.setCommandPermission(AnatomyCommandPermissions.PremiumActive, hasPremium);

            if (PlatformConfig.UnrestrictedEnvironment || hasPremium)
            {
                //Explore
                selectionModeTask = new SelectionModeTask(standaloneController.AnatomyController);
                taskController.addTask(selectionModeTask);
                Slideshow.AdditionalTasks.addTask(selectionModeTask);

                bookmarkTask = new ShowPopupTask(bookmarks, "Medical.Bookmarks", "Bookmarks", "AnomalousMedical/FavoritesIcon", TaskMenuCategories.Explore);
                taskController.addTask(bookmarkTask);
                Slideshow.AdditionalTasks.addTask(bookmarkTask);
            }

            if (PlatformConfig.UnrestrictedEnvironment)
            {
                //System
                CallbackTask helpTaskItem = new CallbackTask("Medical.Help", "Help", "AnomalousMedical/Help", TaskMenuCategories.System, int.MaxValue - 4, false);
                helpTaskItem.OnClicked += new CallbackTask.ClickedCallback(helpTaskItem_OnClicked);
                taskController.addTask(helpTaskItem);

                taskController.addTask(new ShowPopupTask(options, "Medical.Options", "Options", "AnomalousMedical/Options", TaskMenuCategories.System, int.MaxValue - 3));

                CallbackTask exitTaskItem = new CallbackTask("Medical.Exit", "Exit", "AnomalousMedical/Exit", TaskMenuCategories.System, int.MaxValue, false);
                exitTaskItem.OnClicked += new CallbackTask.ClickedCallback(exitTaskItem_OnClicked);
                taskController.addTask(exitTaskItem);

                if (MedicalConfig.ShowDeveloperTools)
                {
                    CallbackTask createOverrideTaskItem = new CallbackTask("Medical.CreateOverride", "CreateOverride", CommonResources.NoIcon, TaskMenuCategories.Developer, int.MaxValue, false);
                    createOverrideTaskItem.OnClicked += CreateOverrideTaskItem_OnClicked;
                    taskController.addTask(createOverrideTaskItem);
                }
            }

            if (PlatformConfig.AllowFullscreenToggle)
            {
                CallbackTask toggleFullscreen = new CallbackTask("Medical.ToggleFullscreen", "Toggle Fullscreen", "AnomalousMedical/ToggleFullscreen", TaskMenuCategories.System, int.MaxValue - 2, false, (item) =>
                {
                    MainWindow.Instance.toggleFullscreen();
                });
                taskController.addTask(toggleFullscreen);

                //Fullscreen Toggle Shortcut
                var toggleFullscreenMessageEvent = new ButtonEvent(EventLayers.Gui, frameUp: (evtMgr) =>
                {
                    MainWindow.Instance.toggleFullscreen();
                });
                toggleFullscreenMessageEvent.addButton(KeyboardButtonCode.KC_RETURN);
                toggleFullscreenMessageEvent.addButton(KeyboardButtonCode.KC_LMENU);
                standaloneController.MedicalController.EventManager.addEvent(toggleFullscreenMessageEvent);
            }

            //Premium / Non Premium
            if (!hasPremium)
            {
                if (PlatformConfig.UnrestrictedEnvironment)
                {
                    buyScreens = new BuyScreenController(standaloneController);
                    taskMenuAd = new PremiumFeaturesTaskMenuAd(taskMenu);
                    selectionModeTask.SelectionModeChooser.ShowBuyMessage += SelectionModeChooser_ShowBuyMessage;
                    anatomyFinder.ShowBuyMessage += anatomyFinder_ShowBuyMessage;
                    bookmarks.ShowBuyMessage     += bookmarks_ShowBuyMessage;
                }

                if (MedicalConfig.FirstRun)
                {
                    guiTaskManager.addPinnedTask(anatomyFinderTask);
                    guiTaskManager.addPinnedTask(viewsTask);
                    guiTaskManager.addPinnedTask(cameraMovementModeTask);
                    if (bookmarkTask != null)
                    {
                        guiTaskManager.addPinnedTask(bookmarkTask);
                    }
                    guiTaskManager.addPinnedTask(unhideAllAnatomy);
                }
            }

            standaloneController.AtlasPluginManager.RequestDependencyDownload += AtlasPluginManager_RequestDependencyDownload;

            //Teeth mover
            teethMover = new SimObjectMover("Teeth", standaloneController.MedicalController.PluginManager.RendererPlugin, standaloneController.MedicalController.EventManager, standaloneController.SceneViewController);
            TeethToolController teethToolController = new TeethToolController(teethMover);

            standaloneController.ImageRenderer.ImageRenderStarted   += teethToolController.ScreenshotRenderStarted;
            standaloneController.ImageRenderer.ImageRenderCompleted += teethToolController.ScreenshotRenderCompleted;

            standaloneController.ViewHostFactory.addFactory(new WizardComponentFactory(teethToolController));
        }
        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 AnatomyFinder(AnatomyController anatomyController, SceneViewController sceneViewController, LayerController layerController, AnatomyTaskManager anatomyTaskManager)
            : base("Medical.GUI.Anatomy.AnatomyFinder.layout")
        {
            this.anatomyController                       = anatomyController;
            anatomyController.AnatomyChanged            += anatomyController_AnatomyChanged;
            anatomyController.ShowPremiumAnatomyChanged += anatomyController_ShowPremiumAnatomyChanged;
            anatomyController.ClearDisplayedAnatomy     += anatomyController_ClearDisplayedAnatomy;
            if (PlatformConfig.UnrestrictedEnvironment)
            {
                anatomyController.DisplayAnatomy += anatomyController_DisplayAnatomy;
            }
            else
            {
                anatomyController.DisplayAnatomy += anatomyController_DisplayAnatomy_Restricted;
            }
            anatomyController.SelectedAnatomy.SelectedAnatomyChanged += anatomyController_SelectedAnatomyChanged;
            anatomyController.SearchStarted        += anatomyController_SearchStarted;
            anatomyController.SearchEnded          += anatomyController_SearchEnded;
            anatomyController.SuggestSearchCaption += anatomyController_SuggestSearchCaption;

            this.sceneViewController = sceneViewController;

            this.layerController               = layerController;
            this.layerController               = layerController;
            layerController.OnRedo            += updateUndoRedo;
            layerController.OnUndo            += updateUndoRedo;
            layerController.OnUndoRedoChanged += updateUndoRedo;
            layerController.OnActiveTransparencyStateChanged += updateUndoRedo;

            anatomyWindowManager = new AnatomyContextWindowManager(sceneViewController, anatomyController, layerController, this, anatomyTaskManager);
            anatomyFilter        = new AnatomyFilter(anatomyController);
            anatomyFilter.refreshCategories();
            anatomyFilter.FilterChanged          += anatomyFilter_FilterChanged;
            anatomyFilter.TopLevelAnatomyChanged += anatomyFilter_TopLevelAnatomyChanged;

            Button filter = window.findWidget("Filter") as Button;

            filter.MouseButtonClick += filter_MouseButtonClick;

            ScrollView anatomyScroll = (ScrollView)window.findWidget("AnatomyList");

            anatomyList = new HashSetMultiSelectButtonGrid(anatomyScroll, new ButtonGridListLayout(), naturalSort);
            anatomyList.ItemActivated += anatomyList_ItemActivated;
            anatomyList.ItemAdded     += anatomyList_ItemAdded;
            anatomyList.ItemRemoved   += anatomyList_ItemRemoved;
            anatomyList.ItemChosen    += anatomyList_ItemChosen;

            buttonGridThumbs = new ButtonGridLiveThumbnailController <Anatomy>("AnatomyFinder_", new IntSize2(ThumbRenderSize, ThumbRenderSize), sceneViewController, anatomyList, anatomyScroll);

            searchBox = (EditBox)window.findWidget("SearchBox");
            searchBox.EventEditTextChange += new MyGUIEvent(searchBox_EventEditTextChange);
            clearButton = (Button)searchBox.findWidgetChildSkin("Clear");
            clearButton.MouseButtonClick += new MyGUIEvent(clearButton_MouseButtonClick);
            clearButton.NeedToolTip       = true;
            clearButton.EventToolTip     += button_UserObject_EventToolTip;
            clearButton.UserObject        = "Clear Search";

            Button unhideAll = window.findWidget("UnhideAll") as Button;

            unhideAll.MouseButtonClick += (s, e) =>
            {
                LayerState undo = LayerState.CreateAndCapture();
                this.layerController.unhideAll();
                this.layerController.pushUndoState(undo);
            };

            undoButton = window.findWidget("Undo") as Button;
            undoButton.MouseButtonClick += (s, e) => layerController.undo();

            redoButton = window.findWidget("Redo") as Button;
            redoButton.MouseButtonClick += (s, e) => layerController.redo();

            PickAnatomy.FirstFrameDownEvent     += PickAnatomy_FirstFrameDownEvent;
            PickAnatomy.OnHeldDown              += PickAnatomy_OnHeldDown;
            PickAnatomy.FirstFrameUpEvent       += pickAnatomy_FirstFrameUpEvent;
            OpenAnatomyFinder.FirstFrameUpEvent += openAnatomyFinder_FirstFrameUpEvent;

            if (!PlatformConfig.UnrestrictedEnvironment && !anatomyController.ShowPremiumAnatomy)
            {
                filter.Visible  = false;
                searchBox.Width = filter.Right - searchBox.Left;
            }

            this.Resized += new EventHandler(AnatomyFinder_Resized);
            fixListItemWidth();

            updateSearch();
        }