/// <summary>
        /// Creates the <see cref="CamView"/> main toolbar items that are only available while
        /// the <see cref="GameViewCamViewState"/> is active.
        /// </summary>
        private void AddToolbarItems()
        {
            this.textBoxRenderWidth                    = new ToolStripTextBoxAdv("textBoxRenderWidth");
            this.textBoxRenderWidth.BackColor          = Color.FromArgb(196, 196, 196);
            this.textBoxRenderWidth.AutoSize           = false;
            this.textBoxRenderWidth.Width              = 35;
            this.textBoxRenderWidth.MaxLength          = 4;
            this.textBoxRenderWidth.AcceptsOnlyNumbers = true;
            this.textBoxRenderWidth.EditingFinished   += this.textBoxRenderWidth_EditingFinished;
            this.textBoxRenderWidth.ProceedRequested  += this.textBoxRenderWidth_ProceedRequested;

            this.textBoxRenderHeight                    = new ToolStripTextBoxAdv("textBoxRenderHeight");
            this.textBoxRenderHeight.BackColor          = Color.FromArgb(196, 196, 196);
            this.textBoxRenderHeight.AutoSize           = false;
            this.textBoxRenderHeight.Width              = 35;
            this.textBoxRenderHeight.MaxLength          = 4;
            this.textBoxRenderHeight.AcceptsOnlyNumbers = true;
            this.textBoxRenderHeight.EditingFinished   += this.textBoxRenderHeight_EditingFinished;
            this.textBoxRenderHeight.ProceedRequested  += this.textBoxRenderHeight_ProceedRequested;

            this.dropdownResolution = new ToolStripDropDownButton(CamViewResCache.IconMonitor);
            this.dropdownResolution.DropDownOpening += this.dropdownResolution_DropDownOpening;

            this.toolbarItems.Add(new ToolStripLabel("Window Size "));
            this.toolbarItems.Add(this.textBoxRenderWidth);
            this.toolbarItems.Add(new ToolStripLabel("x"));
            this.toolbarItems.Add(this.textBoxRenderHeight);
            this.toolbarItems.Add(this.dropdownResolution);

            this.resolutionMenuView       = new MenuStripMenuView(this.dropdownResolution.DropDownItems);
            this.resolutionMenuView.Model = this.resolutionMenuModel;

            this.View.ToolbarCamera.SuspendLayout();
            for (int i = this.toolbarItems.Count - 1; i >= 0; i--)
            {
                ToolStripItem item = this.toolbarItems[i];
                item.Alignment = ToolStripItemAlignment.Right;
                this.View.ToolbarCamera.Items.Add(item);
            }
            this.View.ToolbarCamera.ResumeLayout();

            this.UpdateTargetRenderSizeUI();
        }
        /// <summary>
        /// Disposes any <see cref="CamView"/> main toolbar items that have been created
        /// during <see cref="AddToolbarItems"/>.
        /// </summary>
        private void RemoveToolbarItems()
        {
            this.View.ToolbarCamera.SuspendLayout();
            foreach (ToolStripItem item in this.toolbarItems)
            {
                this.View.ToolbarCamera.Items.Remove(item);
            }
            this.View.ToolbarCamera.ResumeLayout();

            this.textBoxRenderWidth.EditingFinished   -= this.textBoxRenderWidth_EditingFinished;
            this.textBoxRenderWidth.ProceedRequested  -= this.textBoxRenderWidth_ProceedRequested;
            this.textBoxRenderHeight.EditingFinished  -= this.textBoxRenderHeight_EditingFinished;
            this.textBoxRenderHeight.ProceedRequested -= this.textBoxRenderHeight_ProceedRequested;
            this.dropdownResolution.DropDownOpening   -= this.dropdownResolution_DropDownOpening;

            this.resolutionMenuView.Model = null;
            this.resolutionMenuView       = null;
            this.resolutionMenuModel.ClearItems();

            this.toolbarItems.Clear();
            this.textBoxRenderWidth  = null;
            this.textBoxRenderHeight = null;
        }
Beispiel #3
0
        public void InitMenus()
        {
            this.mainMenuView = new MenuStripMenuView(this.mainMenuStrip.Items);
            this.mainMenuView.ItemInserted += this.mainMenuView_ItemInserted;
            this.mainMenuView.ItemRemoved  += this.mainMenuView_ItemRemoved;
            this.mainMenuView.Model         = this.mainMenuModel;

            MenuModelItem helpItem;

            this.mainMenuModel.AddItems(new[]
            {
                new MenuModelItem {
                    Name = GeneralRes.MenuName_File, SortValue = MenuModelItem.SortValue_Top, Items = new[]
                    {
                        new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_NewProject,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Icon          = Properties.GeneralResCache.ImageAppCreate,
                            Tag           = HelpInfo.FromText(GeneralRes.MenuItemName_NewProject, GeneralRes.MenuItemInfo_NewProject),
                            ActionHandler = this.newProjectItem_Click
                        },
                        new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_PublishGame,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Tag           = HelpInfo.FromText(GeneralRes.MenuItemName_PublishGame, GeneralRes.MenuItemInfo_PublishGame),
                            ActionHandler = this.actionPublishGame_Click
                        },
                        new MenuModelItem
                        {
                            Name      = "TopSeparator",
                            SortValue = MenuModelItem.SortValue_Top,
                            TypeHint  = MenuItemTypeHint.Separator
                        },
                        new MenuModelItem
                        {
                            Name          = this.actionSaveAll.Text,
                            Icon          = this.actionSaveAll.Image,
                            ShortcutKeys  = Keys.Control | Keys.S,
                            Tag           = HelpInfo.FromText(this.actionSaveAll.Text, GeneralRes.MenuItemInfo_SaveAll),
                            ActionHandler = this.actionSaveAll_Click
                        },
                        new MenuModelItem
                        {
                            Name     = "CodeSeparator",
                            TypeHint = MenuItemTypeHint.Separator
                        },
                        new MenuModelItem
                        {
                            Name          = this.actionOpenCode.Text,
                            Icon          = this.actionOpenCode.Image,
                            Tag           = HelpInfo.FromText(this.actionOpenCode.Text, GeneralRes.MenuItemInfo_OpenProjectSource),
                            ActionHandler = this.actionOpenCode_Click
                        },
                        new MenuModelItem
                        {
                            Name      = "BottomSeparator",
                            SortValue = MenuModelItem.SortValue_Bottom,
                            TypeHint  = MenuItemTypeHint.Separator
                        },
                        new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_Quit,
                            SortValue     = MenuModelItem.SortValue_Bottom,
                            ShortcutKeys  = Keys.Alt | Keys.F4,
                            ActionHandler = this.quitItem_Click
                        }
                    }
                },
                new MenuModelItem {
                    Name = GeneralRes.MenuName_Edit, SortValue = MenuModelItem.SortValue_Top, Items = new[]
                    {
                        this.menuEditUndo = new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_Undo,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Icon          = GeneralResCache.arrow_undo,
                            ShortcutKeys  = Keys.Z | Keys.Control,
                            ActionHandler = this.menuEditUndo_Click
                        },
                        this.menuEditRedo = new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_Redo,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Icon          = GeneralResCache.arrow_redo,
                            ShortcutKeys  = Keys.Y | Keys.Control,
                            ActionHandler = this.menuEditRedo_Click
                        }
                    }
                },
                new MenuModelItem {
                    Name = GeneralRes.MenuName_Run, SortValue = MenuModelItem.SortValue_OverBottom, Items = new[]
                    {
                        this.menuRunApp = new MenuModelItem
                        {
                            Name          = this.actionRunApp.Text,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Icon          = this.actionRunApp.Image,
                            ShortcutKeys  = Keys.Alt | Keys.F5,
                            Tag           = HelpInfo.FromText(this.actionRunApp.Text, GeneralRes.MenuItemInfo_RunGame),
                            ActionHandler = this.actionRunApp_Click
                        },
                        this.menuDebugApp = new MenuModelItem
                        {
                            Name          = this.actionDebugApp.Text,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Icon          = this.actionDebugApp.Image,
                            ShortcutKeys  = Keys.Alt | Keys.F6,
                            Tag           = HelpInfo.FromText(this.actionDebugApp.Text, GeneralRes.MenuItemInfo_DebugGame),
                            ActionHandler = this.actionDebugApp_Click
                        },
                        this.menuProfileApp = new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_ProfileGame,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Icon          = Properties.Resources.application_stopwatch,
                            Tag           = HelpInfo.FromText(GeneralRes.MenuItemName_ProfileGame, GeneralRes.MenuItemInfo_ProfileGame),
                            ActionHandler = this.actionProfileApp_Click
                        },
                        new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_ConfigureLauncher,
                            SortValue     = MenuModelItem.SortValue_Top,
                            Tag           = HelpInfo.FromText(GeneralRes.MenuItemName_ConfigureLauncher, GeneralRes.MenuItemInfo_ConfigureLauncher),
                            ActionHandler = this.actionConfigureLauncher_Click
                        },
                        new MenuModelItem
                        {
                            Name      = "TopSeparator",
                            SortValue = MenuModelItem.SortValue_Top,
                            TypeHint  = MenuItemTypeHint.Separator
                        },
                        this.menuRunSandboxPlay = new MenuModelItem
                        {
                            Name          = this.actionRunSandbox.Text,
                            Icon          = this.actionRunSandbox.Image,
                            ShortcutKeys  = Keys.F5,
                            Tag           = HelpInfo.FromText(this.actionRunSandbox.Text, GeneralRes.MenuItemInfo_SandboxPlay),
                            ActionHandler = this.actionRunSandbox_Click
                        },
                        this.menuRunSandboxStep = new MenuModelItem
                        {
                            Name          = this.actionStepSandbox.Text,
                            Icon          = this.actionStepSandbox.Image,
                            ShortcutKeys  = Keys.F6,
                            Tag           = HelpInfo.FromText(this.actionStepSandbox.Text, GeneralRes.MenuItemInfo_SandboxStep),
                            ActionHandler = this.actionStepSandbox_Click
                        },
                        this.menuRunSandboxPause = new MenuModelItem
                        {
                            Name          = this.actionPauseSandbox.Text,
                            Icon          = this.actionPauseSandbox.Image,
                            ShortcutKeys  = Keys.F7,
                            Tag           = HelpInfo.FromText(this.actionPauseSandbox.Text, GeneralRes.MenuItemInfo_SandboxPause),
                            ActionHandler = this.actionPauseSandbox_Click
                        },
                        this.menuRunSandboxStop = new MenuModelItem
                        {
                            Name          = this.actionStopSandbox.Text,
                            Icon          = this.actionStopSandbox.Image,
                            ShortcutKeys  = Keys.F8,
                            Tag           = HelpInfo.FromText(this.actionStopSandbox.Text, GeneralRes.MenuItemInfo_SandboxStop),
                            ActionHandler = this.actionStopSandbox_Click
                        },
                        new MenuModelItem
                        {
                            Name      = "BottomSeparator",
                            SortValue = MenuModelItem.SortValue_Bottom,
                            TypeHint  = MenuItemTypeHint.Separator
                        },
                        this.menuRunSandboxSlower = new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_SandboxSlower,
                            ShortcutKeys  = Keys.F9,
                            Tag           = HelpInfo.FromText(GeneralRes.MenuItemName_SandboxSlower, GeneralRes.MenuItemInfo_SandboxSlower),
                            ActionHandler = this.menuRunSandboxSlower_Click
                        },
                        this.menuRunSandboxFaster = new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_SandboxFaster,
                            ShortcutKeys  = Keys.F10,
                            Tag           = HelpInfo.FromText(GeneralRes.MenuItemName_SandboxFaster, GeneralRes.MenuItemInfo_SandboxFaster),
                            ActionHandler = this.menuRunSandboxFaster_Click
                        }
                    }
                },
                helpItem = new MenuModelItem {
                    Name = GeneralRes.MenuName_Help, SortValue = MenuModelItem.SortValue_Bottom, Items = new[]
                    {
                        new MenuModelItem
                        {
                            Name          = GeneralRes.MenuItemName_About,
                            SortValue     = MenuModelItem.SortValue_Top,
                            ActionHandler = this.aboutItem_Click
                        }
                    }
                }
            });

            // Set some view-specific properties
            ToolStripItem helpViewItem = this.mainMenuView.GetViewItem(helpItem);

            helpViewItem.Alignment = ToolStripItemAlignment.Right;

            // Attach help data to toolstrip actions
            this.actionOpenCode.Tag     = HelpInfo.FromText(this.actionOpenCode.Text, GeneralRes.MenuItemInfo_OpenProjectSource);
            this.actionSaveAll.Tag      = HelpInfo.FromText(this.actionSaveAll.Text, GeneralRes.MenuItemInfo_SaveAll);
            this.actionRunApp.Tag       = HelpInfo.FromText(this.actionRunApp.Text, GeneralRes.MenuItemInfo_RunGame);
            this.actionDebugApp.Tag     = HelpInfo.FromText(this.actionDebugApp.Text, GeneralRes.MenuItemInfo_DebugGame);
            this.actionRunSandbox.Tag   = HelpInfo.FromText(this.actionRunSandbox.Text, GeneralRes.MenuItemInfo_SandboxPlay);
            this.actionStepSandbox.Tag  = HelpInfo.FromText(this.actionStepSandbox.Text, GeneralRes.MenuItemInfo_SandboxStep);
            this.actionPauseSandbox.Tag = HelpInfo.FromText(this.actionPauseSandbox.Text, GeneralRes.MenuItemInfo_SandboxPause);
            this.actionStopSandbox.Tag  = HelpInfo.FromText(this.actionStopSandbox.Text, GeneralRes.MenuItemInfo_SandboxStop);
            this.formatUpdateAll.Tag    = HelpInfo.FromText(this.formatUpdateAll.Text, GeneralRes.MenuItemInfo_FormatUpdateAll);
        }
Beispiel #4
0
        public DemoForm()
        {
            this.InitializeComponent();

            // Generate some test / demo objects
            this.objA = new Test();
            this.objA.IPropWithAVeryLongName = 42;
            this.objA.SomeString             = "Blubdiwupp";
            this.objA.SomeFloat          = (float)Math.PI;
            this.objA.SomeByte           = 128;
            this.objA.Substruct          = new Test2(42);
            this.objA.ReflectedTypeTestA = new Test3[] { new Test3() };
            this.objA.ReflectedTypeTestB = new Dictionary <string, object> {
                { "First", new Test3() }
            };
            this.objA.ReflectedTypeTestD = new List <ISomeInterface> {
                new Test3(), new Test3()
            };
            this.objA.stringListField = new List <string>()
            {
                "hallo", "welt"
            };

            this.objB = new Test();
            this.objB.IPropWithAVeryLongName = 17;
            this.objB.SomeString             = "Kratatazong";
            this.objB.SomeFloat       = 3.0f;
            this.objB.SomeByte        = 0;
            this.objB.Substruct       = new Test2(100);
            this.objB.stringListField = new List <string>()
            {
                "hallo", "welt"
            };

            this.propertyGrid1.SelectObject(this.objA);
            foreach (PropertyEditor childEditor in this.propertyGrid1.MainEditor.ChildEditors)
            {
                // Test the manual readonly-override on this property.
                if (childEditor.EditedMember != null && childEditor.EditedMember.Name == "ReadOnlySubstruct")
                {
                    childEditor.ReadOnly = true;
                }
            }

            this.menuModel      = new MenuModel();
            this.menuView       = new MenuStripMenuView(this.menuStrip.Items);
            this.menuView.Model = this.menuModel;
            {
                MenuModelItem file = new MenuModelItem("File", null, new[]
                {
                    MenuModelItem.Separator,
                    new MenuModelItem {
                        Name = "Invisible", Visible = false
                    },
                    MenuModelItem.Separator,

                    new MenuModelItem {
                        Name = "Quit", SortValue = MenuModelItem.SortValue_Bottom, ActionHandler = OnMenuItemClicked
                    },
                    new MenuModelItem {
                        Name = "New", Items = new[]
                        {
                            new MenuModelItem("Stuff", OnMenuItemClicked),
                            new MenuModelItem("Awesome Stuff", OnMenuItemClicked)
                        }
                    },
                    new MenuModelItem("Open", bmpItemSmall, OnMenuItemClicked),
                    new MenuModelItem("Close", OnMenuItemClicked),
                });
                MenuModelItem edit = new MenuModelItem("Edit", null, new[]
                {
                    new MenuModelItem("Undo", OnMenuItemClicked),
                    new MenuModelItem("Redo", OnMenuItemClicked),
                    new MenuModelItem("Checkable", OnMenuItemClicked)
                });
                this.menuModel.AddItem(file);
                this.menuModel.AddItem(edit);

                this.menuModel.GetItem(@"File\Close").Enabled       = false;
                this.menuModel.GetItem(@"Edit\Undo").ShortcutKeys   = Keys.Control | Keys.Z;
                this.menuModel.GetItem(@"Edit\Checkable").Checkable = true;
                this.menuModel.GetItem(@"Edit\Checkable").Checked   = true;

                this.menuModel.RequestItem(@"File\New Option\Blah").ActionHandler = OnMenuItemClicked;
                this.menuModel.RequestItem(@"file\New Option\blah");
                this.menuModel.RequestItem(@"File\New Option\Blub");
                this.menuModel.RequestItem(@"File\New option\blub").ActionHandler = OnMenuItemClicked;
                this.menuModel.RequestItem(@"A Menu\Stuff\Execute").ActionHandler = OnMenuItemClicked;
            }

            this.tiledViewModel = new ListModel <TiledModelItem>();
            this.tiledViewModel.Add(new TiledModelItem {
                Name = "Frederick"
            });
            this.tiledViewModel.Add(new TiledModelItem {
                Name = "Herbert"
            });
            this.tiledViewModel.Add(new TiledModelItem {
                Name = "Mary"
            });
            this.tiledViewModel.Add(new TiledModelItem {
                Name = "John"
            });
            this.tiledViewModel.Add(new TiledModelItem {
                Name = "Sally"
            });
            this.tiledView.Model           = this.tiledViewModel;
            this.tiledView.ItemAppearance += this.tiledView_ItemAppearance;

            this.timelineViewModel   = new TimelineModel();
            this.timelineView1.Model = this.timelineViewModel;
            {
                TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel {
                    TrackName = "Track A"
                };
                graphTrack.Add(new TimelineLinearGraphModel(new TimelineLinearGraphModel.Key[]
                {
                    new TimelineLinearGraphModel.Key(0.0f, 1.0f),
                    new TimelineLinearGraphModel.Key(10.0f, 0.75f),
                    new TimelineLinearGraphModel.Key(15.0f, 0.5f),
                    new TimelineLinearGraphModel.Key(20.0f, 0.0f),
                    new TimelineLinearGraphModel.Key(25.0f, -0.5f),
                    new TimelineLinearGraphModel.Key(30.0f, -0.75f),
                    new TimelineLinearGraphModel.Key(40.0f, -1.0f),
                    new TimelineLinearGraphModel.Key(50.0f, 5.0f)
                }));
                this.timelineViewModel.Add(graphTrack);
            }
            {
                Func <float, float> func = x => (float)Math.Sin(0.005f * x * x);

                TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel {
                    TrackName = "Track B"
                };
                graphTrack.Add(new TimelineFunctionGraphModel(
                                   x => func(x),
                                   delegate(float a, float b)
                {
                    float result       = Math.Min(func(a), func(b));
                    int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f);
                    int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f);
                    for (int i = intervalIndexA; i <= intervalIndexB; i++)
                    {
                        float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d);
                        result  = Math.Min(result, func(x));
                        if (result <= -1.0f)
                        {
                            break;
                        }
                    }
                    return(result);
                },
                                   delegate(float a, float b)
                {
                    float result       = Math.Max(func(a), func(b));
                    int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f);
                    int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f);
                    for (int i = intervalIndexA; i <= intervalIndexB; i++)
                    {
                        float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d);
                        result  = Math.Max(result, func(x));
                        if (result >= 1.0f)
                        {
                            break;
                        }
                    }
                    return(result);
                },
                                   0.0f,
                                   500.0f));
                this.timelineViewModel.Add(graphTrack);
            }
            {
                Func <float, float> func = x => (float)Math.Sin(0.005f * x * x) * (float)(0.5f + 0.5f * Math.Sin(0.1f * x));

                TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel {
                    TrackName = "Track C"
                };
                graphTrack.Add(new TimelineFunctionGraphModel(
                                   x => func(x),
                                   delegate(float a, float b)
                {
                    float result       = Math.Min(func(a), func(b));
                    int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f);
                    int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f);
                    for (int i = intervalIndexA; i <= intervalIndexB; i++)
                    {
                        float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d);
                        result  = Math.Min(result, func(x));
                        if (result <= -1.0f)
                        {
                            break;
                        }
                    }
                    return(result);
                },
                                   delegate(float a, float b)
                {
                    float result       = Math.Max(func(a), func(b));
                    int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f);
                    int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f);
                    for (int i = intervalIndexA; i <= intervalIndexB; i++)
                    {
                        float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d);
                        result  = Math.Max(result, func(x));
                        if (result >= 1.0f)
                        {
                            break;
                        }
                    }
                    return(result);
                },
                                   0.0f,
                                   1500.0f));
                this.timelineViewModel.Add(graphTrack);
            }
            {
                TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel {
                    TrackName = "Track D"
                };
                graphTrack.Add(new TimelineLinearGraphModel(Enumerable.Range(0, 360).Select(i => 0.5f + (float)Math.Sin((float)i * Math.PI / 180.0f)), 1.0f, 0.0f));
                graphTrack.Add(new TimelineLinearGraphModel(Enumerable.Range(0, 360).Select(i => (float)Math.Sin((float)i * Math.PI / 180.0f)), 1.0f, 50.0f));
                this.timelineViewModel.Add(graphTrack);
            }
        }