Esempio n. 1
0
        public MainControl()
        {
            mSelf = this;
            InitializeComponent();


            mScrollBarControlLogic = new ScrollBarControlLogic(PreviewSplitContainer.Panel1);

            ApplicationEvents.Self.WireframePanning       += delegate { mScrollBarControlLogic.UpdateScrollBars(); };
            ApplicationEvents.Self.WireframeTextureChange += ScrollBarHandleTextureChange;
            ApplicationEvents.Self.AfterZoomChange        += delegate
            {
                mScrollBarControlLogic.ZoomPercentage = (float)ApplicationState.Self.WireframeZoomValue;
                mScrollBarControlLogic.UpdateScrollBars();
            };

            this.imageRegionSelectionControl1   = new FlatRedBall.SpecializedXnaControls.ImageRegionSelectionControl();
            imageRegionSelectionControl1.Click += new EventHandler(HandleImageRegionSelectionControlClick);
            this.PreviewSplitContainer.Panel1.Controls.Add(this.imageRegionSelectionControl1);

            //
            // imageRegionSelectionControl1
            //
            // Winforms has issues with controls that contain custom controls
            // and if this control was in custom code, it caused all kinds of
            // issues.  So we'll just instantiate it here as a workaround.
            this.imageRegionSelectionControl1.CurrentTexture         = null;
            this.imageRegionSelectionControl1.DesiredFramesPerSecond = 30F;
            this.imageRegionSelectionControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            //this.imageRegionSelectionControl1.Width = 100;
            //this.imageRegionSelectionControl1.Height = 100;
            this.imageRegionSelectionControl1.Location = new System.Drawing.Point(0, 23);
            this.imageRegionSelectionControl1.Name     = "imageRegionSelectionControl1";
            this.imageRegionSelectionControl1.Size     = new System.Drawing.Size(296, 264);
            this.imageRegionSelectionControl1.TabIndex = 0;
            this.imageRegionSelectionControl1.Text     = "imageRegionSelectionControl1";
            this.imageRegionSelectionControl1.BringToFront();

            this.zoomControl1.PropertyChanged += HandleEditorControlsPropertyChanged;

            SelectedState.Self.Initialize(this.AnimationTreeView);
            if (this.DesignMode == false)
            {
                HandleRegionXnaInitialize();
                this.imageRegionSelectionControl1.XnaUpdate += new Action(HandleXnaUpdate);
            }
            PropertyGridManager.Self.Initialize(SelectedItemPropertyGrid, this.tileMapInfoWindow1);
            PropertyGridManager.Self.AnimationChainChange += RaiseAnimationChainChanges;
            PropertyGridManager.Self.AnimationFrameChange += HandleAnimationFrameChanges;


            TreeViewManager.Self.Initialize(AnimationTreeView);
            TreeViewManager.Self.AnimationChainsChange += RaiseAnimationChainChanges;

            StatusBarManager.Self.Initialize(statusStrip1, CursorStatusLabel);

            WireframeManager.Self.AnimationFrameChange += HandleAnimationFrameChanges;

            PopulateUnitTypeComboBox();

            PreviewManager.Self.Initialize(PreviewGraphicsControl, previewControls1);
        }
Esempio n. 2
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. 3
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();
        }