/// <summary> /// Initializes a new instance of the <see cref="WorkspaceViewModel" /> class. /// </summary> /// <param name="workspace">The workspace for the view model.</param> public WorkspaceViewModel(Workspace workspace) { Workspace = workspace; Name = Workspace.Name; PlaylistUrl = workspace.Settings.PlaylistUrl; DownloadingAllSongsText = Resources.MainWindow_CurrentWorkspace_SyncButtonLabel; SearchTextboxWatermark = Resources.MainWindow_CurrentWorkspace_SearchWatermarkDefault; Tracks = new ObservableImmutableList <PlaylistItemViewModel>(); Tracks.CollectionChanged += TracksOnCollectionChanged; DisplayedTracks = new ObservableImmutableList <PlaylistItemViewModel>(); PageSelectorViewModel = new PageSelectorViewModel(this); DownloadManager = new DownloadManager(Settings.Default.ParallelDownloads); WorkspaceSettingsViewModel = new WorkspaceSettingsViewModel(this); DisplayedTracksSource = new List <PlaylistItemViewModel>(); Workspace.Settings.PropertyChanged += SettingsOnPropertyChanged; FilterModes = new Dictionary <FilterMode, string>(); Settings.Default.PropertyChanged += ApplicationSettingsOnPropertyChanged; _watcher = new FileSystemWatcher { Path = Workspace.Path, NotifyFilter = NotifyFilters.FileName, Filter = "*.*" }; _watcher.Created += WatcherOnCreated; _watcher.Deleted += WatcherOnDeleted; _watcher.Renamed += WatcherOnRenamed; _watcher.Error += WatcherOnError; SetupFilter(); }
public NetworkModule() { NetworkInterfaceNames = new ObservableImmutableList <NetworkInterfaceName>(); CurrentNetworkInterfaceName = new NetworkInterfaceName(); SetNetworkInterfaceName(); }
public MonitoredHardware() { GpuNvidias = new ObservableImmutableList <GpuNvidia>(); GpuAtis = new ObservableImmutableList <GpuAti>(); Cpus = new ObservableImmutableList <Cpu>(); Rams = new ObservableImmutableList <Ram>(); }
private void Initialize() { // Load list ProfileList = new ObservableImmutableList <ClientProfileVm>( ClientProfile.GetAllProfiles().Select(x => new ClientProfileVm(x))); if (MainWindowVm.Instance.SelectedWorkingProfile != null) { SelectedProfile = MainWindowVm.Instance.SelectedWorkingProfile; } else if (ProfileList == null || ProfileList.Count == 0) { SelectedProfile = new ClientProfileVm() { Name = "Default Profile", IndexKey = new byte[] { 0xB9, 0x9E, 0xB0, 0x02, 0x6F, 0x69, 0x81, 0x05, 0x63, 0x98, 0x9B, 0x28, 0x79, 0x18, 0x1A, 0x00 }, PackKey = new byte[] { 0x22, 0xB8, 0xB4, 0x04, 0x64, 0xB2, 0x6E, 0x1F, 0xAE, 0xEA, 0x18, 0x00, 0xA6, 0xF6, 0xFB, 0x1C }, PackExtension = ".epk", IndexExtension = ".eix", WorkingDirectory = "WORKING_DIR", UnpackDirectory = "UNPACK_DIR" }; ProfileList.Add(SelectedProfile); } else { SelectedProfile = ProfileList.FirstOrDefault(x => x.IsDefault) ?? ProfileList.First(); } }
/// <summary> /// Instantiates new object of class /// </summary> public ProfilesVm() { Instance = this; ProfileList = new ObservableImmutableList <ClientProfileVm>(); Initialize(); InitializeCommands(); }
/// <summary> /// Main Ctor /// </summary> public TreeItemFolderVm(ITreeViewItem parent) { // Member initialization IsVisible = true; Parent = parent; Children = new ObservableImmutableList <ITreeViewItem>(); IsFolder = true; // Initialize commands InitializeCommands(); }
/// <summary> /// Adds item to the working items list /// </summary> /// <param name="item"></param> public void AddItemToWorkingList(WorkingItemVm item) { // Return if the item already exists if (WorkingItemsList.ToList().Find(x => x.DisplayName == item.DisplayName) != null) { return; } // Add it to and re-order list (TODO: change this, it's ugly and potentially slow) WorkingItemsList.Add(item); WorkingItemsList = new ObservableImmutableList <WorkingItemVm>(WorkingItemsList.OrderBy(x => x.DisplayName)); }
public DOS2ModuleData() : base("Divinity: Original Sin 2", "Divinity Original Sin 2") { ManageButtonsText = "Select a Project"; AvailableProjectsToggleText = "Available Projects"; ModProjects = new ObservableImmutableList <ModProjectData>(); ManagedProjects = new ObservableImmutableList <ModProjectData>(); NewProjects = new ObservableImmutableList <AvailableProjectViewData>(); BindingOperations.EnableCollectionSynchronization(ModProjects, ModProjectsLock); BindingOperations.EnableCollectionSynchronization(ManagedProjects, ManagedProjectsLock); BindingOperations.EnableCollectionSynchronization(NewProjects, NewProjectsLock); }
/// <summary> /// Main Ctor /// </summary> public VirtualTreeViewWindowVm() { // Initialize members VirtualTreeViewItems = new ObservableImmutableList <ITreeViewItem>(); // Internal initializer Initialize(); // Initialize commands InitializeCommands(); // Initialize virtual tree view InitializeVirtualView(); }
/// <summary> /// Class' main ctor /// </summary> public FilesActionVm() { // Initialize members Instance = this; _workingItems = new ObservableImmutableList <WorkingItemVm>(); _selectedWorkingItems = new ObservableImmutableList <WorkingItemVm>(); Queue = new ConcurrentQueue <WorkingItemVm>(); // Initialize Initialize(); // Initlaize commands InitializeCommands(); }
/// <summary> /// Sorts list /// </summary> /// <param name="list"></param> /// <returns></returns> private ObservableImmutableList <ITreeViewItem> SortItemsByFolder(ObservableImmutableList <ITreeViewItem> list) { foreach (var child in list) { var folder = child as TreeItemFolderVm; if (folder != null && folder.Children.Count != 0) { folder.Children = SortItemsByFolder(folder.Children); folder.Children = new ObservableImmutableList <ITreeViewItem>(folder.Children.OrderBy(x => x.DisplayName).OrderByDescending(p => p.IsFolder)); } } return(list); }
/// <summary> /// Called when the profile list is updated from the profile list /// </summary> public void UpdateProfileListFromProfilesWindow(ObservableImmutableList <ClientProfileVm> list) { string oldProfileName = ""; if (SelectedWorkingProfile != null) { oldProfileName = SelectedWorkingProfile.Name; } ProfileList = list; if (!String.IsNullOrWhiteSpace(oldProfileName)) { SelectedWorkingProfile = ProfileList.FirstOrDefault(x => x.Name == oldProfileName); } }
/// <summary> /// Internal initializer /// </summary> private void Initialize() { if (Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save(); } Instance = this; Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); CurrentAppVersion = String.Format("Version: {0} GunnerMBT ©", fvi.FileVersion); CanChangeProfile = true; // Default settings var value = Properties.Settings.Default.MaxSimFiles; ConstantsBase.MaxSimFiles = (value <= 0) ? 3 : value; // Get profile list var profileModelList = ClientProfile.GetAllProfiles(); // Update view ProfileList = new ObservableImmutableList <ClientProfileVm>( profileModelList.Select(x => new ClientProfileVm(x))); // Load default profile var profileName = Properties.Settings.Default.DefaultProfile; if (!String.IsNullOrWhiteSpace(profileName)) { //SelectedWorkingProfile = new ClientProfileVm(ClientProfile.GetProfileByPredicate(p => String.Equals(p.Name, profileName, StringComparison.CurrentCultureIgnoreCase))); SelectedWorkingProfile = ProfileList.FirstOrDefault(x => x.Name == profileName); // To make sure every other class is udpated if (SelectedWorkingProfile != null) { Handle(SelectedWorkingProfile); } } // Set update menu string to default value UpdateMenuString = "Check for updates"; }
/// <summary> /// Processes profile's Working directory /// </summary> public void ProcessWorkingDirectory() { // Return if null or no profile is selected if (MainWindowVm.Instance == null || MainWindowVm.Instance.SelectedWorkingProfile == null) { return; } WorkingItemsList.Clear(); try { // Loop through all files foreach (var item in IOHelper.GetAllFilesFromDir(MainWindowVm.Instance.SelectedWorkingProfile.WorkingDirectory) .Where(t => String.Equals(t.Extension, MainWindowVm.Instance.SelectedWorkingProfile.IndexExtension, StringComparison.CurrentCultureIgnoreCase)) .Select(file => new WorkingItemVm(Path.GetFileNameWithoutExtension(file.Name), file.Name, file.FullName, file.DirectoryName))) { // Add it to the list AddItemToWorkingList(item); } } catch (DirectoryNotFoundException ex) { WindowLog.Error("DIR_NOT_FOUND", null, MainWindowVm.Instance.SelectedWorkingProfile.WorkingDirectory); } try { // Loop through all the directories (since there may be files which are unpacked but not existing in the pack dir) foreach (var item in IOHelper.GetAllFirstDirectories(MainWindowVm.Instance.SelectedWorkingProfile.UnpackDirectory)) { if (WorkingItemsList.FirstOrDefault(x => String.Equals(x.DisplayName, item.Name, StringComparison.CurrentCultureIgnoreCase)) == null) { AddItemToWorkingList(new WorkingItemVm( item.Name, item.Name + MainWindowVm.Instance.SelectedWorkingProfile.IndexExtension, item.FullName + MainWindowVm.Instance.SelectedWorkingProfile.IndexExtension, item.FullName)); } } } catch (DirectoryNotFoundException ex) { WindowLog.Error("DIR_NOT_FOUND", null, MainWindowVm.Instance.SelectedWorkingProfile.UnpackDirectory); } WorkingItemsList = new ObservableImmutableList <WorkingItemVm>(WorkingItemsList.OrderBy(x => x.DisplayName)); }
public void ResetToDefault() { if (Keywords == null) { Keywords = new ObservableImmutableList <KeywordData>(); } if (Keywords.Count > 0) { Keywords.Clear(); } Keywords.Add(new KeywordData()); Keywords.Add(new KeywordData()); Keywords.Add(new KeywordData()); DateCustom = "MMMM dd, yyyy"; BindingOperations.EnableCollectionSynchronization(Keywords, KeywordsLock); }
public void Init(MainWindow ParentWindow, GitGenerationSettings GenerationSettings, List <IProjectData> SelectedProjects) { mainWindow = ParentWindow; generationSettings = GenerationSettings; this.DataContext = generationSettings; if (GenerationSettings.ExportProjects == null) { var list = new ObservableImmutableList <IProjectData>(); GenerationSettings.SetExportProjects(list); } else { GenerationSettings.ExportProjects.Clear(); } SelectedProjects.ForEach((IProjectData project) => GenerationSettings.ExportProjects.Add(project)); }
/// <summary> /// Main Ctor /// </summary> public WorkingItemVm(string displayName, string fileName, string fullPath, string directoryPath) { // Initialize members SetItemState(State.Ready); ActionProgress = 0; ErrorList = new ObservableImmutableList <ErrorItem>(); HashMismatchFiles = new ObservableImmutableList <string>(); IsVisible = true; DisplayName = displayName; Filename = fileName; FullPath = fullPath; DirectoryPath = directoryPath; // Initialize commands InstantiateCommands(); //SelectedFilter = WorkingListVM.Instance.FilterList[0]; }
public WeatherModule() { UnitFormatCollection = new ObservableImmutableList <UnitFormat> { new UnitFormat { Unit = "metric", Symbol = "°C" }, new UnitFormat { Unit = "imperial", Symbol = "°F" } }; if (ControlModule.DesignMode) { return; } GetApiData(); CreatePollingTimer(); }
public VolumeMixerModule() { ActiveAppsCollection = new ObservableImmutableList <ActiveApp>(); /*if (ControlModule.DesignMode) * return;*/ // Get master device name TimerHelper.BeginIntervalTimer(1000, GetMasterDeviceNameCmd); // Get master volume TimerHelper.BeginIntervalTimer(1000, SetMasterAudioVolumeCmd); // Get master peak TimerHelper.BeginIntervalTimer(100, GetMasterAudioPeakCmd); if (GetActiveAudioSessionsCmd.CanExecute(null)) { GetActiveAudioSessionsCmd.Execute(null); } // Get active apps timer var getActiveAppsTimer = new Timer(1000); getActiveAppsTimer.Elapsed += (sender, args) => { // Remove inactive processes foreach (var activeApp in ActiveAppsCollection.ToList().Where(x => !ProcessExtensions.ProcessExists(x.ProcessId))) { Debug.WriteLine($"GetActiveApplications - Removing application: '{activeApp.MainWindowTitle}' Id: '{activeApp.ProcessId}'"); ActiveAppsCollection.Remove(activeApp); } if (GetActiveAudioSessionsCmd.CanExecute(null)) { GetActiveAudioSessionsCmd.Execute(null); } }; getActiveAppsTimer.Start(); }
public ModuleData(string moduleName, string moduleFolderName) { ModuleName = moduleName; ModuleFolderName = moduleFolderName; AddTemplateControlVisible = false; Templates = new ObservableImmutableList <TemplateEditorData>(); KeyList = new ObservableImmutableList <KeywordData>(); BindingOperations.EnableCollectionSynchronization(Templates, TemplatesLock); BindingOperations.EnableCollectionSynchronization(KeyList, KeyListLock); LoadKeywords = new ActionCommand(() => { FileCommands.Load.LoadUserKeywords(this); }); SaveSettingsCommand = new ActionCommand(() => { FileCommands.Save.SaveModuleSettings(this); AppController.Main?.SaveAppSettings(); }); DefaultSettingsCommand = new TaskCommand(RevertSettingsToDefault, null, "Reset Settings?", "Revert settings to default?", "Changes will be lost."); }
/// <summary> /// Updates the Index view window content /// </summary> private void UpdateIndexList() { if (_indexDetails == null) { _indexDetails = new ObservableImmutableList <IndexItem>(); } _indexDetails.Clear(); var tempList = EterFilesDal.ReadIndexFile( Path.Combine(MainWindowVm.Instance.SelectedWorkingProfile.WorkingDirectory, Filename), MainWindowVm.Instance.SelectedWorkingProfile.IndexKey, DisplayName); foreach (var item in tempList) { _indexDetails.Add(item); } NumberOfFiles = IndexDetails.Count; }
public DateTimeModule() { TimeFormatCollection = new ObservableImmutableList <TimeFormat> { new TimeFormat { Id = 1, Code = "T", FriendlyView = DateTime.Now.ToString("T") }, new TimeFormat { Id = 2, Code = "t", FriendlyView = DateTime.Now.ToString("t") } }; DateFormatCollection = new ObservableImmutableList <DateFormat> { new DateFormat { Id = 3, Code = "D", FriendlyView = DateTime.Now.ToString("D") }, new DateFormat { Id = 4, Code = "m", FriendlyView = DateTime.Now.ToString("m") }, new DateFormat { Id = 5, Code = "y", FriendlyView = DateTime.Now.ToString("y") } }; if (ControlModule.DesignMode) { return; } var timerNow = new Timer { Interval = 100 }; timerNow.Elapsed += TimerNow_Elapsed;; timerNow.Start(); }
public DefaultModuleData() : base("Default", "Default") { ManagedProjects = new ObservableImmutableList <DefaultProjectData>(); }
public void LoadGitGenerationSettings(IModuleData Data) { string filePath = DefaultPaths.ModuleGitGenSettingsFile(Data); if (Data != null && Data.ModuleSettings != null && File.Exists(Data.ModuleSettings.GitGenSettingsFile)) { filePath = Data.ModuleSettings.GitGenSettingsFile; } if (File.Exists(filePath)) { try { Data.GitGenerationSettings = JsonConvert.DeserializeObject <GitGenerationSettings>(File.ReadAllText(filePath)); Log.Here().Important("Git generation settings file loaded."); } catch (Exception ex) { Log.Here().Error("Error deserializing {0}: {1}", filePath, ex.ToString()); } } bool settingsNeedSaving = false; if (Data.GitGenerationSettings == null) { Data.GitGenerationSettings = new GitGenerationSettings(); settingsNeedSaving = true; } //Rebuild from previous settings, in case a template name has changed, or new templates were added. List <TemplateGenerationData> previousSettings = null; if (Data.GitGenerationSettings.TemplateSettings != null) { previousSettings = Data.GitGenerationSettings.TemplateSettings.ToList(); } ObservableImmutableList <TemplateGenerationData> templateSettings = new ObservableImmutableList <TemplateGenerationData>(); foreach (var template in Data.Templates.Where(t => t.ID.ToLower() != "license")) { TemplateGenerationData tdata = new TemplateGenerationData() { ID = template.ID, TemplateName = template.Name, Enabled = true, TooltipText = template.ToolTipText }; if (previousSettings != null) { var previousData = previousSettings.FirstOrDefault(s => s.ID == template.ID); if (previousData != null) { tdata.Enabled = previousData.Enabled; settingsNeedSaving = true; } } templateSettings.Add(tdata); } Data.GitGenerationSettings.SetTemplateSettings(templateSettings); if (settingsNeedSaving) { FileCommands.Save.SaveGitGenerationSettings(Data, DefaultPaths.ModuleGitGenSettingsFile(Data)); } }