Esempio n. 1
0
        private void CreateWireframeControl()
        {
            this.wireframeControl1 = new Gum.Wireframe.WireframeControl();
            //
            // wireframeControl1
            //
            this.wireframeControl1.AllowDrop = true;
            //this.wireframeControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            //| System.Windows.Forms.AnchorStyles.Left)
            //| System.Windows.Forms.AnchorStyles.Right)));
            this.wireframeControl1.Dock                   = DockStyle.Fill;
            this.wireframeControl1.ContextMenuStrip       = this.WireframeContextMenuStrip;
            this.wireframeControl1.Cursor                 = System.Windows.Forms.Cursors.Default;
            this.wireframeControl1.DesiredFramesPerSecond = 30F;
            this.wireframeControl1.Location               = new System.Drawing.Point(0, 52);
            this.wireframeControl1.Name                   = "wireframeControl1";
            this.wireframeControl1.Size                   = new System.Drawing.Size(532, 452);
            this.wireframeControl1.TabIndex               = 0;
            this.wireframeControl1.Text                   = "wireframeControl1";

            this.wireframeControl1.DragDrop  += DragDropManager.Self.HandleFileDragDrop;
            this.wireframeControl1.DragEnter += DragDropManager.Self.HandleFileDragEnter;
            this.wireframeControl1.DragOver  += (sender, e) =>
            {
                //this.DoDragDrop(e.Data, DragDropEffects.Move | DragDropEffects.Copy);
                //DragDropManager.Self.HandleDragOver(sender, e);
            };


            wireframeControl1.ErrorOccurred += (exception) => Crashes.TrackError(exception);

            this.wireframeControl1.QueryContinueDrag += (sender, args) =>
            {
                args.Action = DragAction.Continue;
            };

            this.wireframeControl1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.wireframeControl1_MouseClick);

            this.wireframeControl1.KeyDown += (o, args) =>
            {
                if (args.KeyCode == Keys.Tab)
                {
                    GumCommands.Self.GuiCommands.ToggleToolVisibility();
                }
            };

            gumEditorPanel = new Panel();

            // place the scrollbars first so they are in front of everything
            scrollBarControlLogic = new ScrollBarControlLogic(gumEditorPanel, wireframeControl1);
            scrollBarControlLogic.SetDisplayedArea(800, 600);
            wireframeControl1.CameraChanged += () =>
            {
                if (ProjectManager.Self.GumProjectSave != null)
                {
                    scrollBarControlLogic.SetDisplayedArea(
                        ProjectManager.Self.GumProjectSave.DefaultCanvasWidth,
                        ProjectManager.Self.GumProjectSave.DefaultCanvasHeight);
                }
                else
                {
                    scrollBarControlLogic.SetDisplayedArea(800, 600);
                }

                scrollBarControlLogic.UpdateScrollBars();
                scrollBarControlLogic.UpdateScrollBarsToCameraPosition();
            };


            //... add it here, so it can be done after scroll bars and other controls
            gumEditorPanel.Controls.Add(this.wireframeControl1);
        }
Esempio n. 2
0
        public MainWindow()
        {
#if DEBUG
            // This suppresses annoying, useless output from WPF, as explained here:
http:       //weblogs.asp.net/akjoshi/resolving-un-harmful-binding-errors-in-wpf
            System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
#endif


            InitializeComponent();

            // Create the wireframe control, but don't add it...
            CreateWireframeControl();

            // place the scrollbars first so they are in front of everything
            scrollBarControlLogic = new ScrollBarControlLogic(this.panel1, wireframeControl1);
            scrollBarControlLogic.SetDisplayedArea(800, 600);
            wireframeControl1.CameraChanged += () =>
            {
                if (ProjectManager.Self.GumProjectSave != null)
                {
                    scrollBarControlLogic.SetDisplayedArea(
                        ProjectManager.Self.GumProjectSave.DefaultCanvasWidth,
                        ProjectManager.Self.GumProjectSave.DefaultCanvasHeight);
                }
                else
                {
                    scrollBarControlLogic.SetDisplayedArea(800, 600);
                }

                scrollBarControlLogic.UpdateScrollBars();
                scrollBarControlLogic.UpdateScrollBarsToCameraPosition();
            };


            //... add it here, so it can be done after scroll bars and other controls
            this.panel1.Controls.Add(this.wireframeControl1);

            CreateWireframeEditControl();
            CreateToolbarPanel();


            stateView = new StateView();
            this.AddWinformsControl(stateView, "States", TabLocation.CenterTop);

            ((SelectedState)SelectedState.Self).Initialize(stateView);
            GumCommands.Self.Initialize(this);

            TypeManager.Self.Initialize();
            PluginManager.Self.Initialize(this);

            ElementTreeViewManager.Self.Initialize(this.ObjectTreeView);
            StateTreeViewManager.Self.Initialize(this.stateView.TreeView, this.stateView.StateContextMenuStrip);
            PropertyGridManager.Self.Initialize(
                ((TestWpfControl)this.VariableHost.Child)
                );
            StandardElementsManager.Self.Initialize();
            MenuStripManager.Self.Initialize(
                RemoveElementMenuItem, RemoveStateMenuItem, RemoveVariableMenuItem);
            ToolCommands.GuiCommands.Self.Initialize(wireframeControl1);
            Wireframe.WireframeObjectManager.Self.Initialize(WireframeEditControl, wireframeControl1);

            wireframeControl1.XnaUpdate += () =>
                                           Wireframe.WireframeObjectManager.Self.Activity();


            EditingManager.Self.Initialize(this.WireframeContextMenuStrip);
            OutputManager.Self.Initialize(this.OutputTextBox);
            // ProjectManager.Initialize used to happen here, but I
            // moved it down to the Load event for MainWindow because
            // ProjectManager.Initialize may load a project, and if it
            // does, then we need to make sure that the wireframe controls
            // are set up properly before that happens.
            HandleXnaInitialize();

            InitializeFileWatchTimer();
        }