[Color Picker] Open settings (#13747)
* Add settings * Added try catch and icon update Co-authored-by: Laute <Niels.Laute@philips.com>
This commit is contained in:
parent
85eddfc536
commit
0ca9b1be48
|
@ -4,6 +4,8 @@
|
|||
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using ColorPicker.Settings;
|
||||
using ColorPicker.ViewModelContracts;
|
||||
|
@ -134,6 +136,7 @@ namespace ColorPicker.Helpers
|
|||
_colorEditorWindow = new ColorEditorWindow(this);
|
||||
_colorEditorWindow.Content = _colorEditorViewModel;
|
||||
_colorEditorViewModel.OpenColorPickerRequested += ColorEditorViewModel_OpenColorPickerRequested;
|
||||
_colorEditorViewModel.OpenSettingsRequested += ColorEditorViewModel_OpenSettingsRequested;
|
||||
_colorEditorViewModel.OpenColorPickerRequested += (object sender, EventArgs e) =>
|
||||
{
|
||||
SessionEventHelper.Event.EditorColorPickerOpened = true;
|
||||
|
@ -183,5 +186,20 @@ namespace ColorPicker.Helpers
|
|||
|
||||
_colorEditorWindow.Hide();
|
||||
}
|
||||
|
||||
private void ColorEditorViewModel_OpenSettingsRequested(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
var fullPath = Directory.GetParent(assemblyPath).FullName;
|
||||
Process.Start(new ProcessStartInfo(fullPath + "\\..\\PowerToys.exe") { Arguments = "--open-settings=ColorPicker" });
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,12 @@ namespace ColorPicker.ViewModelContracts
|
|||
{
|
||||
event EventHandler OpenColorPickerRequested;
|
||||
|
||||
event EventHandler OpenSettingsRequested;
|
||||
|
||||
ICommand OpenColorPickerCommand { get; }
|
||||
|
||||
ICommand OpenSettingsCommand { get; }
|
||||
|
||||
ICommand RemoveColorCommand { get; }
|
||||
|
||||
ObservableCollection<ColorFormatModel> ColorRepresentations { get; }
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace ColorPicker.ViewModels
|
|||
public ColorEditorViewModel(IUserSettings userSettings)
|
||||
{
|
||||
OpenColorPickerCommand = new RelayCommand(() => OpenColorPickerRequested?.Invoke(this, EventArgs.Empty));
|
||||
OpenSettingsCommand = new RelayCommand(() => OpenSettingsRequested?.Invoke(this, EventArgs.Empty));
|
||||
RemoveColorCommand = new RelayCommand(DeleteSelectedColor);
|
||||
|
||||
SelectedColorChangedCommand = new RelayCommand((newColor) =>
|
||||
|
@ -47,8 +48,12 @@ namespace ColorPicker.ViewModels
|
|||
|
||||
public event EventHandler OpenColorPickerRequested;
|
||||
|
||||
public event EventHandler OpenSettingsRequested;
|
||||
|
||||
public ICommand OpenColorPickerCommand { get; }
|
||||
|
||||
public ICommand OpenSettingsCommand { get; }
|
||||
|
||||
public ICommand RemoveColorCommand { get; }
|
||||
|
||||
public ICommand SelectedColorChangedCommand { get; }
|
||||
|
|
|
@ -82,17 +82,17 @@
|
|||
VerticalAlignment="Center"
|
||||
Margin="0,1,0,0" />
|
||||
|
||||
<!-- Enable once we have settings linking available -->
|
||||
<!--<Button Width="46"
|
||||
<Button Width="46"
|
||||
Command="{Binding OpenSettingsCommand}"
|
||||
Height="32"
|
||||
Content=""
|
||||
Content=""
|
||||
TabIndex="2"
|
||||
Background="Transparent"
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,46,0"
|
||||
ToolTipService.ToolTip="{x:Static p:Resources.Open_settings}"
|
||||
AutomationProperties.Name="{x:Static p:Resources.Open_settings}" />-->
|
||||
AutomationProperties.Name="{x:Static p:Resources.Open_settings}" />
|
||||
|
||||
<Button Width="64"
|
||||
Height="32"
|
||||
|
|
Loading…
Reference in a new issue