예제 #1
0
        public NewWindow()
        {
            InitializeComponent();
            ResourceService.CultureChanged += OnCultureChanged;

            foreach (var subview in ModuleHost.Instance.SubViews)
            {
                AddOrShowView(subview, false);
                var menuitem = new MenuItem
                {
                    Header = subview.GetTitle(ResourceService.CurrentCulture)
                };
                menuitem.Click += (_, __) => AddOrShowView(subview, true);
                ResourceService.CultureChanged += (_, e) => menuitem.Header = subview.GetTitle(e.NewValue);
                subviews.Items.Add(menuitem);
            }

            foreach (var subwindow in ModuleHost.Instance.SubWindows)
            {
                var menuitem = new MenuItem
                {
                    Header = subwindow.GetTitle(ResourceService.CurrentCulture)
                };
                var closure = new SubWindowClosure(menuitem, subwindow);
                menuitem.Click += closure.Click;
                ResourceService.CultureChanged += closure.OnCultureChanged;
                switch (subwindow.Category)
                {
                    case SubWindowCategory.Overview:
                        subwindowOverview.Items.Add(menuitem);
                        break;
                    case SubWindowCategory.Statistics:
                        subwindowStatistics.Items.Add(menuitem);
                        break;
                    case SubWindowCategory.Information:
                        subwindowInformation.Items.Add(menuitem);
                        break;
                }
            }

            ResourceService.CultureChanged += (_, __) => viewList[nameof(GameHost)].Title = StringTable.Browser;

            DockCommands = new Config.CommandSet
            {
                Save = new DelegateCommand(() => TrySaveLayout()),
                Load = new DelegateCommand(() => TryLoadLayout()),
                SaveAs = new DelegateCommand(() =>
                {
                    using (var filedialog = new CommonSaveFileDialog())
                    {
                        filedialog.InitialDirectory = Environment.CurrentDirectory;
                        filedialog.DefaultFileName = "config.xml";
                        filedialog.Filters.Add(new CommonFileDialogFilter("Xml Files", "*.xml"));
                        filedialog.Filters.Add(new CommonFileDialogFilter("All Files", "*"));
                        if (filedialog.ShowDialog() == CommonFileDialogResult.Ok)
                            TrySaveLayout(filedialog.FileName);
                    }
                }),
                LoadFrom = new DelegateCommand(() =>
                {
                    using (var filedialog = new CommonOpenFileDialog())
                    {
                        filedialog.InitialDirectory = Environment.CurrentDirectory;
                        filedialog.Filters.Add(new CommonFileDialogFilter("Xml Files", "*.xml"));
                        filedialog.Filters.Add(new CommonFileDialogFilter("All Files", "*"));
                        if (filedialog.ShowDialog() == CommonFileDialogResult.Ok)
                            TryLoadLayout(filedialog.FileName);
                    }
                })
            };
        }
예제 #2
0
        public NewWindow()
        {
            InitializeComponent();
            ResourceService.CultureChanged += OnCultureChanged;

            foreach (var subview in ModuleHost.Instance.SubViews)
            {
                AddOrShowView(subview, false);
                var menuitem = new MenuItem
                {
                    Header = subview.GetTitle(ResourceService.CurrentCulture)
                };
                menuitem.Click += (_, __) => AddOrShowView(subview, true);
                ResourceService.CultureChanged += (_, e) => menuitem.Header = subview.GetTitle(e.NewValue);
                subviews.Items.Add(menuitem);
            }

            foreach (var subwindow in ModuleHost.Instance.SubWindows)
            {
                var menuitem = new MenuItem
                {
                    Header = subwindow.GetTitle(ResourceService.CurrentCulture)
                };
                var closure = new SubWindowClosure(menuitem, subwindow);
                menuitem.Click += closure.Click;
                ResourceService.CultureChanged += closure.OnCultureChanged;
                switch (subwindow.Category)
                {
                case SubWindowCategory.Overview:
                    subwindowOverview.Items.Add(menuitem);
                    break;

                case SubWindowCategory.Statistics:
                    subwindowStatistics.Items.Add(menuitem);
                    break;

                case SubWindowCategory.Information:
                    subwindowInformation.Items.Add(menuitem);
                    break;
                }
            }

            ResourceService.CultureChanged += (_, __) => viewList[nameof(GameHost)].Title = StringTable.Browser;

            DockCommands = new Config.CommandSet
            {
                Save   = new DelegateCommand(() => TrySaveLayout()),
                Load   = new DelegateCommand(() => TryLoadLayout()),
                SaveAs = new DelegateCommand(() =>
                {
                    using (var filedialog = new CommonSaveFileDialog())
                    {
                        filedialog.InitialDirectory = Environment.CurrentDirectory;
                        filedialog.DefaultFileName  = "config.xml";
                        filedialog.Filters.Add(new CommonFileDialogFilter("Xml Files", "*.xml"));
                        filedialog.Filters.Add(new CommonFileDialogFilter("All Files", "*"));
                        if (filedialog.ShowDialog() == CommonFileDialogResult.Ok)
                        {
                            TrySaveLayout(filedialog.FileName);
                        }
                    }
                }),
                LoadFrom = new DelegateCommand(() =>
                {
                    using (var filedialog = new CommonOpenFileDialog())
                    {
                        filedialog.InitialDirectory = Environment.CurrentDirectory;
                        filedialog.Filters.Add(new CommonFileDialogFilter("Xml Files", "*.xml"));
                        filedialog.Filters.Add(new CommonFileDialogFilter("All Files", "*"));
                        if (filedialog.ShowDialog() == CommonFileDialogResult.Ok)
                        {
                            TryLoadLayout(filedialog.FileName);
                        }
                    }
                })
            };
        }