Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            // Add the control scroll message filter to re-route all mousewheel events
            // to the control the user is currently hovering over with their cursor.
            Application.AddMessageFilter(new ControlScrollFilter());

            // Add the dock content drag message filter to handle moving dock content around.
            Application.AddMessageFilter(DockPanel.DockContentDragFilter);

            // Add the dock panel message filter to filter through for dock panel splitter
            // input before letting events pass through to the rest of the application.
            Application.AddMessageFilter(DockPanel.DockResizeFilter);

            // Hook in all the UI events manually for clarity.
            HookEvents();

            // Build the tool windows and add them to the dock panel
            _dockProject    = new DockProject();
            _dockProperties = new DockProperties();
            _dockConsole    = new DockConsole();
            _dockLayers     = new DockLayers();
            _dockHistory    = new DockHistory();

            // Add the tool windows to a list
            _toolWindows.Add(_dockProject);
            _toolWindows.Add(_dockProperties);
            _toolWindows.Add(_dockConsole);
            _toolWindows.Add(_dockLayers);
            _toolWindows.Add(_dockHistory);

            // Deserialize if a previous state is stored
            if (File.Exists("dockpanel.xml"))
            {
                DeserializeDockPanel("dockpanel.xml");
            }
            else
            {
                // Add the tool window list contents to the dock panel
                foreach (var toolWindow in _toolWindows)
                {
                    DockPanel.AddContent(toolWindow);
                }

                // Add the history panel to the layer panel group
                DockPanel.AddContent(_dockHistory, _dockLayers.DockGroup);
            }

            // Check window menu items which are contained in the dock panel
            BuildWindowMenu();

            // Add dummy documents to the main document area of the dock panel
            DockPanel.AddContent(new DockDocument("Document 1", Icons.document_16xLG));
            DockPanel.AddContent(new DockDocument("Document 2", Icons.document_16xLG));
            DockPanel.AddContent(new DockDocument("Document 3", Icons.document_16xLG));
        }
Esempio n. 2
0
        public MainForm()
        {
            InitializeComponent();

            // Add the control scroll message filter to re-route all mousewheel events
            // to the control the user is currently hovering over with their cursor.
            Application.AddMessageFilter(new ControlScrollFilter());

            // Add the dock content drag message filter to handle moving dock content around.
            Application.AddMessageFilter(DockPanel.DockContentDragFilter);

            // Add the dock panel message filter to filter through for dock panel splitter
            // input before letting events pass through to the rest of the application.
            Application.AddMessageFilter(DockPanel.DockResizeFilter);

            // Hook in all the UI events manually for clarity.
            HookEvents();

            // Build the tool windows and add them to the dock panel
            _dockAssets    = new DockResources();
            _dockScene     = new DockScene();
            _dockHierarchy = new DockHierarchy();
            _dockInspector = new DockInspector();
            _dockConsole   = new DockConsole();

            // Timer tick every second
            var timer = new System.Windows.Forms.Timer
            {
                Interval = 1000
            };

            timer.Tick += new EventHandler(Timer_Tick);
            timer.Start();

            // Add the tool windows to a list
            _toolWindows.Add(_dockAssets);
            _toolWindows.Add(_dockScene);
            _toolWindows.Add(_dockHierarchy);
            _toolWindows.Add(_dockInspector);
            _toolWindows.Add(_dockConsole);

            // Deserialize if a previous state is stored
            if (File.Exists("EditorPanels.xml"))
            {
                DeserializeDockPanel("EditorPanels.xml");
            }
            else
            {
                // Add the tool window list contents to the dock panel
                foreach (var toolWindow in _toolWindows)
                {
                    DockPanel.AddContent(toolWindow);
                }
            }

            // Check window menu items which are contained in the dock panel
            BuildWindowMenu();

            Activated += delegate
            {
                if (_dockScene.DisplayOpen)
                {
                    Display.Get().Floating = true;
                }
            };
            Deactivate += delegate
            {
                if (_dockScene.DisplayOpen)
                {
                    Display.Get().Floating = false;
                }
            };
            LocationChanged += delegate
            {
                if (_dockScene.DisplayOpen)
                {
                    _dockScene.RefreshDisplay();
                }
            };
            DockPanel.ContentAdded += delegate(object o, DockContentEventArgs args)
            {
                if (args.Content == _dockScene)
                {
                    Display.Get().Iconified = false;
                    _dockScene.DisplayOpen = true;
                    _dockScene.RefreshDisplay();
                }
            };
            DockPanel.ContentRemoved += delegate(object o, DockContentEventArgs args)
            {
                if (args.Content == _dockScene)
                {
                    Display.Get().Iconified = true;
                    _dockScene.DisplayOpen = false;
                }
            };
        }