示例#1
0
 /// <summary>
 /// Change the browser content
 /// </summary>
 /// <param name="browser">The browser</param>
 /// <param name="targetFile">The fallback target file</param>
 public ChangeBrowserContentCommand(BrowserUserControl browser, string targetFile)
 {
     if (browser.DataContext is BrowserModelView modelView)
     {
         this.browserModel = modelView;
         this.targetFile   = targetFile;
     }
 }
示例#2
0
 /// <summary>
 /// Change the browser content
 /// </summary>
 /// <param name="browser">The browser</param>
 public ChangeBrowserContentCommand(BrowserUserControl browser) : this(browser, string.Empty)
 {
 }
示例#3
0
        /// <summary>
        /// Create a new instance of this model
        /// </summary>
        /// <param name="window"></param>
        public MainWindowModel(Window window) : base(window, true)
        {
            IconVisible        = false;
            updateSearched     = false;
            CloseWindowCommand = new CloseApplicationCommand();

            SetWindowTitle();

            object dockArea = window.FindName("DP_ContentDock");

            if (dockArea is DockPanel panel)
            {
                ISettingFactory settingFactory = new WpfPropertySettingManagerFactory();
                SettingManager  wpfSettings    = settingFactory.GetSettingsManager();

                contentDock = panel;

                BrowserUserControl localBrowser     = new BrowserUserControl(string.Empty);
                ICommand           openLocalBrowser = new MultiCommand(new List <ICommand>()
                {
                    new OpenControlToPanel(contentDock, localBrowser, false),
                    new ChangeBrowserContentCommand(localBrowser)
                });

                BrowserUserControl remoteBrowser     = new BrowserUserControl(string.Empty, new RemoteDocumentManagerFactory(new TimeSpan(0, 30, 0)));
                ICommand           openRemoteBrowser = new MultiCommand(new List <ICommand>()
                {
                    new OpenControlToPanel(contentDock, remoteBrowser, false),
                    new ChangeBrowserContentCommand(remoteBrowser)
                });

                OpenNewsCommand      = openRemoteBrowser;
                OpenChangelogCommand = openLocalBrowser;
                OpenDisclamerCommand = openLocalBrowser;
                OpenAboutCommand     = openLocalBrowser;
                OpenLicenseCommand   = openLocalBrowser;

                OpenHDPatchCommand = new OpenControlToPanel(contentDock, new ComingSoonControl());
                OpenMapCommand     = new OpenControlToPanel(contentDock, new MapUserControl());
                LaunchGameCommand  = new OpenControlToPanel(contentDock, new PatchVersionSelectionUserControl(window));
                OpenSettingCommand = new OpenControlToPanel(contentDock, new SettingsUserControl(currentWindow));
                ComingSoonCommand  = new OpenControlToPanel(contentDock, new ComingSoonControl());

                ReportIssueCommand = new OpenLinkCommand(wpfSettings.GetValue <string>("ReportIssueLink"));
                OpenEditorCommand  = new StartEditorCommand(settingManager);
                OpenSettlersConfigurationCommand = new StartSettlersConfigCommand(settingManager);
                OpenSavesFolderCommand           = new OpenFolderCommand(Environment.GetFolderPath(
                                                                             Environment.SpecialFolder.MyDocuments)
                                                                         + "/TheSettlers4/Save/"
                                                                         );

                string gameFolder    = settingManager.GetValue <string>("GameFolder");
                string textureChange = gameFolder + "Texturenwechsler.bat";
                OpenTextureChangerCommand = new StartProgramCommand(textureChange);

                OpenNewsCommand.Execute("News.md");
            }

            ChangeGroupVisiblity    = new ToggleSubGroupVisibilityCommand(currentWindow);
            window.ContentRendered += (sender, data) =>
            {
                if (updateSearched)
                {
                    return;
                }
                updateSearched = true;
                CheckForUpdateIfNeeded(window);
            };
        }