public FileSelectionWindow(string baseDirectory, SelectionWindowConfiguration configuration) : base(configuration) { this.baseDirectory = baseDirectory; autocomplete = new DirectoryAutocomplete(baseDirectory); var completions = autocomplete.GetCompletionList(""); ResetLabels(completions); }
/// <summary> /// Initialises the window with the provided options. /// </summary> protected SelectionWindow(SelectionWindowConfiguration configuration) { TimerHelper.Current.TakeSnapshot("mainwnd-creating"); styleConfig = ConfigManager.Config.Interface.Style; scrollBoundary = ConfigManager.Config.Interface.Style.ScrollBoundary; // Position and size the window according to user configuration. Matrix fromDevice; using (var source = new HwndSource(new HwndSourceParameters())) { if (source.CompositionTarget == null) { // I doubt this path is ever triggered, but we'll handle it just in case. Log.Send("Could not determine the composition target. Window may not be positioned and sized correctly.", LogLevel.Warning); // We'll just use the identity matrix here. // This works fine as long as the screen's DPI scaling is set to 100%. fromDevice = Matrix.Identity; } else { fromDevice = source.CompositionTarget.TransformFromDevice; } } var position = fromDevice.Transform(configuration.Position); Left = position.X; Top = position.Y; var dimensions = fromDevice.Transform(configuration.Dimensions); Width = dimensions.X; MaxHeight = dimensions.Y; InitializeComponent(); InitialiseLabels(configuration.Orientation); SearchBox.BorderBrush = styleConfig.Search.BorderColour; SearchBox.CaretBrush = styleConfig.CaretColour; SearchBox.Background = styleConfig.Search.BackgroundColour; SearchBox.Foreground = styleConfig.Search.TextColour; SearchBox.Margin = styleConfig.Search.Margin; SearchBox.BorderThickness = styleConfig.Search.BorderWidth; SearchBox.FontSize = styleConfig.FontSize; SearchBox.FontFamily = new FontFamily(styleConfig.FontFamily); Background = styleConfig.BackgroundColour; BorderBrush = styleConfig.BorderColour; BorderThickness = styleConfig.BorderWidth; TimerHelper.Current.TakeSnapshot("mainwnd-created"); }
/// <summary> /// Opens the password menu and displays it to the user, allowing them to choose an existing password file. /// </summary> /// <param name="options">A list of options the user can choose from.</param> /// <returns>One of the values contained in <paramref name="options"/>, or null if no option was chosen.</returns> public string ShowPasswordMenu(IEnumerable <string> options) { SelectionWindowConfiguration windowConfig; try { windowConfig = SelectionWindowConfiguration.ParseMainWindowConfiguration(ConfigManager.Config); } catch (ConfigurationParseException e) { notificationService.Raise(e.Message, Severity.Error); return(null); } var menu = new PasswordSelectionWindow(options, windowConfig); menu.ShowDialog(); if (menu.Success) { return(menu.GetSelection()); } return(null); }
/// <summary> /// Opens a window where the user can choose the location for a new password file. /// </summary> /// <returns>The path to the file that the user has chosen</returns> public string ShowFileSelectionWindow() { SelectionWindowConfiguration windowConfig; try { windowConfig = SelectionWindowConfiguration.ParseMainWindowConfiguration(ConfigManager.Config); } catch (ConfigurationParseException e) { notificationService.Raise(e.Message, Severity.Error); return(null); } // Ask the user where the password file should be placed. var pathWindow = new FileSelectionWindow(ConfigManager.Config.PasswordStore.Location, windowConfig); pathWindow.ShowDialog(); if (!pathWindow.Success) { return(null); } return(pathWindow.GetSelection() + Program.EncryptedFileExtension); }
public PasswordSelectionWindow(IEnumerable <string> options, SelectionWindowConfiguration configuration) : base(configuration) { this.options = options.ToList(); ResetLabels(this.options); }