Ejemplo n.º 1
0
        public ScenarioExplorer()
        {
            prefManager = new PreferencesManager();
            prefs       = prefManager.LoadAppPreferences();
            DataCtx     = new ScenarioExplorerViewModel();
            CreateMenu(prefs.RecentFiles, DataCtx);
            this.DataContext = DataCtx;

            this.InitializeComponent();

            if (App.StartupArgs.Length > 0)
            {
                LoadScenario(App.StartupArgs[0]);
            }
        }
Ejemplo n.º 2
0
        private void CreateMenu(string[] recents, ScenarioExplorerViewModel vm)
        {
            /*
             *<MenuItem Header="File">
             * <MenuItem Header="Open" Click="FileOpenClick"></MenuItem>
             * <MenuItem Header="Exit"></MenuItem>
             * </MenuItem>
             * <MenuItem Header="Help">
             * <MenuItem Header="About"></MenuItem>
             * </MenuItem>
             *
             *
             */

            var fileItems = new List <Control> {
                new MenuItem
                {
                    Header  = "Open",
                    Command = ReactiveCommand.CreateFromTask(FileOpenClick)
                },
                new Separator()
            };

            if (recents.Any())
            {
                foreach (var recent in recents)
                {
                    var item = new MenuItem()
                    {
                        Header  = Path.GetFileName(recent),
                        Command = ReactiveCommand.Create(() => LoadScenario(recent))
                    };

                    fileItems.Add(item);
                }

                fileItems.Add(new Separator());
            }

            fileItems.Add(new MenuItem
            {
                Header  = "Exit",
                Command = ReactiveCommand.Create(this.Close)
            });

            var file = new MenuItem
            {
                Header = "File",
                Items  = fileItems
            };

            var view = new MenuItem
            {
                Header = "View",
                Items  = new List <Control>
                {
                    new MenuItem()
                    {
                        Header  = "Interned Strings",
                        Command = ReactiveCommand.Create(ShowInternedStringsView)
                    }
                }
            };

            var edit = new MenuItem
            {
                Header = "Edit",
                Items  = new List <Control>
                {
                    new MenuItem()
                    {
                        Header  = "Toggle Mode",
                        Command = ReactiveCommand.Create(ToggleDisoveryMode)
                    }
                }
            };

            vm.MenuItems = new Control[] { file, view, edit };
        }