private void RestoreWindowSettings(string workingFolder) { WorkFolderSettings settings = Settings.GetWorkFolderSetting(workingFolder); Rectangle rect = new Rectangle( (int)settings.Left, (int)settings.Top, (int)settings.Width, (int)settings.Height); if (rect.Width < 600) { rect = new Rectangle(rect.Left, rect.Right, 600, rect.Height); } if (rect.Height < 400) { rect = new Rectangle(rect.Left, rect.Right, rect.Width, 400); } // check if the saved bounds are nonzero and visible on any screen if (rect != Rectangle.Empty && IsVisibleOnAnyScreen(rect)) { Top = settings.Top; Left = settings.Left; Width = rect.Width; Height = rect.Height; } WindowState = settings.IsMaximized ? WindowState.Maximized : WindowState.Normal; viewModel.RepositoryViewModel.IsShowCommitDetails = settings.IsShowCommitDetails; }
private void Set(string path, WorkFolderSettings settings) { string settingsPath = GetSettingsFilePath<WorkFolderSettings>(path); if (ParentFolderExists(path)) { WriteAs(settingsPath, settings); } }
private void RestoreViewSettings() { WorkFolderSettings settings = settingsService.Get <WorkFolderSettings>(); Node root = modelHandlingService.Root; root.ItemsCanvas.SetRootScale(settings.Scale); root.ItemsCanvas.SetRootOffset(settings.Offset); }
private IReadOnlyList <string> RestoreShownBranches() { WorkFolderSettings settings = Settings.GetWorkFolderSetting(workingFolder); return(settings.ShownBranches .Where(n => !n.StartsWith("_Branch_") && !n.StartsWith("_Multibranch_")) .ToList()); }
private void Set(WorkFolderSettings settings) { string path = GetWorkFolderSettingsPath(); if (ParentFolderExists(path)) { WriteAs(path, settings); } }
private void LoadCustomBranchColors() { customBranchBrushes.Clear(); WorkFolderSettings folderSettings = settingsService.Get <WorkFolderSettings>(); foreach (var pair in folderSettings.BranchColors) { Brush brush = Theme.brushes.FirstOrDefault(b => Converter.HexFromBrush(b) == pair.Value); if (brush != null) { customBranchBrushes[pair.Key] = brush; } } }
private IDictionary <string, Brush> GetCustomBranchColors() { Dictionary <string, Brush> brushes = new Dictionary <string, Brush>(); WorkFolderSettings settings = Settings.GetWorkFolderSetting(workingFolder); foreach (var pair in settings.BranchColors) { Brush brush = currentTheme.brushes.FirstOrDefault(b => Converter.HexFromBrush(b) == pair.Value); if (brush != null) { brushes[pair.Key] = brush; } } return(brushes); }
private void StoreWindowSettings() { WorkFolderSettings settings = Settings.GetWorkFolderSetting(workingFolder); settings.Top = Top; settings.Left = Left; settings.Height = Height; settings.Width = Width; settings.IsMaximized = WindowState == WindowState.Maximized; settings.IsShowCommitDetails = viewModel.RepositoryViewModel.IsShowCommitDetails; settings.ShownBranches = viewModel.RepositoryViewModel.Branches .Where(b => !b.Name.StartsWith("_Multibranch_") && !b.Name.StartsWith("_Branch_")) .Select(b => b.Branch.Name.ToString()) .Distinct() .ToList(); Settings.SetWorkFolderSetting(workingFolder, settings); }
public Brush ChangeBranchBrush(Branch branch) { Brush currentBrush = GetBranchBrush(branch); int index = currentTheme.GetBrushIndex(currentBrush); // Select next brush int newIndex = ((index + 1) % (currentTheme.brushes.Count - 2)) + 2; Brush brush = currentTheme.brushes[newIndex]; string brushHex = Converter.HexFromBrush(brush); WorkFolderSettings settings = Settings.GetWorkFolderSetting(workingFolder); settings.BranchColors[branch.Name] = brushHex; Settings.SetWorkFolderSetting(workingFolder, settings); customBranchBrushes = new Lazy <IDictionary <string, Brush> >(GetCustomBranchColors); return(brush); }
public void Edit<T>(string path, Action<T> editAction) where T : class { try { if (typeof(T) == typeof(WorkFolderSettings)) { WorkFolderSettings settings = Get<WorkFolderSettings>(path); editAction(settings as T); Set(path, settings); } else { T settings = Get<T>(path); editAction(settings); Set(path, settings); } } catch (Exception e) { Log.Exception(e, "Error editing the settings"); } }