public MainViewModel() { DownloadCommand = new TrackDownloadCommand(this); OpenFolderCommand = new OpenFolderCommand(this); SettingsCommand = new OpenSettingsCommand(this); ChangeSavePathCommand = new ChangeSavePathCommand(this); }
public SettingsPageModel(PasswordBox PasswordBox) { this.PasswordBox = PasswordBox; this.PasswordBox.PasswordChanged += (i1, i2) => SyncSettingsBindings(); Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationElement KeyValueConfigurationElement = configuration.AppSettings.Settings[Configurations.SERVICE_PATH]; if (KeyValueConfigurationElement is object) { Path = KeyValueConfigurationElement.Value; } else { Path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), System.IO.Path.ChangeExtension(Configurations.SERVICE_NAME, ".exe")); } SelectServiceFileCommand = new OpenFileCommand(Path => { this.Path = Path; configuration.AppSettings.Settings.Remove(Configurations.SERVICE_PATH); configuration.AppSettings.Settings.Add(Configurations.SERVICE_PATH, Path); configuration.Save(); }, Configurations.SERVICE_NAME + " Executable|" + System.IO.Path.ChangeExtension(Configurations.SERVICE_NAME, ".exe")); SelectInputPathCommand = new OpenFolderCommand(Path => InputPath = Path); SelectOutputPathCommand = new OpenFolderCommand(Path => OutputPath = Path); SelectProcessedPathCommand = new OpenFolderCommand(Path => ProcessedPath = Path); SelectErrorPathCommand = new OpenFolderCommand(Path => ErrorPath = Path); SelectSurfacePathCommand = new OpenFolderCommand(Path => SurfacePath = Path); SelectAnalysisPathCommand = new OpenFolderCommand(Path => AnalysisPath = Path); StopServiceCommand = new WrappedCommand(new StopServiceCommand(Configurations.SERVICE_NAME)); }
public MainViewModel(IFolderProvider folderProvider) { Ensure.NotNull(folderProvider, "folderProvider"); Folders = new ObservableCollection <Folder>(folderProvider.Get().OrderBy(f => f.Name.ToString())); Open = new OpenFolderCommand(); Copy = new CopyToClipBoardAsTextCommand(); }
public ExportCompletedViewModel(string title, FileInfo file) { Title = title; File = file; OpenFileCommand = ReactiveCommand.Create(this.WhenAnyValue(me => me.File).Select(f => f?.Exists == true)); OpenFolderCommand = ReactiveCommand.Create(this.WhenAnyValue(me => me.File).Select(f => f?.Directory?.Exists == true)); OpenFileCommand.Subscribe(_ => Process.Start(File.FullName)); OpenFolderCommand.Subscribe(_ => Process.Start(File.DirectoryName)); Result = CloseCommand.Select(_ => (bool?)true); }
public MainViewModel() { DownloadCommand = new TrackDownloadCommand(this); OpenFolderCommand = new OpenFolderCommand(this); SettingsCommand = new OpenSettingsCommand(this); ChangeSavePathCommand = new ChangeSavePathCommand(this); SearchCommand = new SearchCommand(this); SetTrackCommand = new SetTrackCommand(this); AddToDownloadListCommand = new AddToDownloadListCommand(this); DownloadDownloadListCommand = new DownloadDownloadListCommand(this); }
public MainWindowViewModel() { Items = new List <TestItem>(); for (int i = 0; i < 10; ++i) { Items.Add(new TestItem($"Item {i}", $"Item {i} Value")); } Nodes = new List <TestNode> { new TestNode { Header = "Root", SubHeader = "Root Item", IsExpanded = true, Children = new[] { new TestNode { Header = "Child 1", SubHeader = "Child 1 Value", }, new TestNode { Header = "Child 2", SubHeader = "Child 2 Value", IsExpanded = false, Children = new[] { new TestNode { Header = "Grandchild", SubHeader = "Grandchild Value", }, new TestNode { Header = "Grandmaster Flash", SubHeader = "White Lines", }, } }, } } }; CollapseNodesCommand = ReactiveCommand.Create(); CollapseNodesCommand.Subscribe(_ => ExpandNodes(false)); ExpandNodesCommand = ReactiveCommand.Create(); ExpandNodesCommand.Subscribe(_ => ExpandNodes(true)); OpenFileCommand = ReactiveCommand.Create(); OpenFileCommand.Subscribe(_ => { var ofd = new OpenFileDialog(); ofd.ShowAsync(); }); OpenFolderCommand = ReactiveCommand.Create(); OpenFolderCommand.Subscribe(_ => { var ofd = new OpenFolderDialog(); ofd.ShowAsync(); }); shell = ShellViewModel.Instance; }
/// <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); }; }
public MainWindowViewModel() { OpenFolderCommand = new OpenFolderCommand(this); NavigateToCommand = new NavigateToCommand(this); CloseFolderCommand = new CloseFolderCommand(this); }
public MainWindowViewModel(List <Task> tasks, UserGroup group) { GridWidth = false; // Set the current user CurrentUser = RunTimeContext.Context.CurrentUser; #region Lists // The list of scheduled tasks (bind to the Schedule list in UI) ScheduledList = new ObservableCollection <Schedule>(ScheduleManager.GetScheduledTask(RunTimeContext.Context.CurrentUser, RunTimeContext.Context.DatabaseContext)); // Result list (bind to the result panel in UI) ResultList = new ObservableCollection <ResultTask>(); // Property list, to use with FileLib, /!\ not implemented now :( Props = new ObservableCollection <Dictionary <string, string> >(); // Task list, with all the task, given by the loading screen as constructor parameter TaskList = tasks == null ? new ObservableCollection <Task>() : new ObservableCollection <Task>(tasks); // The list of queued tasks (bind to the queue panel in UI) QueueList = new ObservableCollection <Task>(); // The list of markets (Bind to the combobox with the list of markets in UI) MarketList = new ObservableCollection <Market>(MarketManager.GetAllMarkets(RunTimeContext.Context.DatabaseContext)); #endregion #region Selected // Set the market to the main market of the user SelectedMarket = CurrentUser.MainMarket; // Set the selected task to the first one of the list SelectedTask = FilteredTasks.FirstOrDefault(); #endregion #region User right // Those three properties are used to be bind with some UI elements like menu // If you bind the IsVisibility property of a control with one of those, only the group of person with the appropriate // rights will be able to see it // eg : Visibility="{Binding IsAdmin}" <-- only Admin level people will see // Do the user have Admin Access ? IsAdmin = (@group == UserGroup.Dev || @group == UserGroup.Admin) ? Visibility.Visible : Visibility.Collapsed; // Manager ? IsManager = @group == UserGroup.Manager ? Visibility.Visible : Visibility.Collapsed; // Or maybe a Developer ? IsDev = @group == UserGroup.Dev ? Visibility.Visible : Visibility.Collapsed; #endregion #region Commands OpenConfigCommand = new OpenConfigCommand(this); OpenScheduleCommand = new OpenScheduleCommand(this); OpenFileCommand = new OpenFileCommand(this); OpenFolderCommand = new OpenFolderCommand(this); OpenLogCommand = new OpenLogCommand(this); RunCommand = new RunTaskCommand(this); QueueCommand = new QueueTaskCommand(this); RemoveCommand = new RemoveTaskCommand(this); CloseCommand = new CloseWindowCommand(); MinimizeCommand = new MinimizeWindowCommand(); MaximizeCommand = new MaximizeWindowCommand(); LogoutCommand = new LogoutCommand(); ClearQueueCommand = new ClearQueueCommand(this); MoveDownQueueCommand = new MoveDownQueueCommand(this); MoveUpQueueCommand = new MoveUpQueueCommand(this); StartQueueCommand = new StartQueueCommand(this); AddScheduleCommand = new AddScheduleCommand(this); RemoveScheduleCommand = new RemoveScheduleCommand(this); ChangeScheduleCommand = new ChangeScheduleCommand(this); ShowAllTaskCommand = new ShowAllTaskCommand(this); ShowMarketTaskCommand = new ShowMarketTaskCommand(this); ShowInfoCommand = new ShowInfoCommand(this); ShowQueueCommand = new ShowQueueCommand(this); FilterResultCommand = new FilterResultCommand(this); ReportDevCommand = new ReportDevCommand(this); #endregion // Number of time in a row a task failed // if 3 the error window will appear automatically FailedInARow = 0; #region Hide other regions GridWidth = true; //CollapseQueue(); //CollapseGrid(); #endregion // A simple bool to see if a task is running at the moment or not TaskRunning = false; // The result filter, chaging it will change automatically the task list ResultFilter = ""; // The log List Log = new ObservableCollection <Log>(); // The list of currently scheduled tasks, use for rerun if failed and keep track of current running status CurrentlyScheduledTasks = new Dictionary <int, ScheduledTaskInfo>(); #region Timer // Create new DispatcherTimer and attach event handler to it var launchScheduleTimer = new DispatcherTimer(); launchScheduleTimer.Tick += LaunchScheduleTimer_Tick; launchScheduleTimer.Interval = new TimeSpan(0, 1, 0); launchScheduleTimer.Start(); #endregion }