public void ColorPickerIsEnabledByDefault() { var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ColorPickerSettings>(); var viewModel = new ColorPickerViewModel(ISettingsUtilsMocks.GetStubSettingsUtils <ColorPickerSettings>().Object, SettingsRepository <GeneralSettings> .GetInstance(ISettingsUtilsMocks.GetStubSettingsUtils <GeneralSettings>().Object), ColorPickerIsEnabledByDefaultIPC); Assert.IsTrue(viewModel.IsEnabled); }
public MainWindow() { InitializeComponent(); FontFamilyViewModel fontFamilyVM = (FontFamilyViewModel)fontFamilyComboBox.DataContext; fontFamilyVM.TextEditor = richTextBox; fontFamilyVM.FontSizeSlider = fontSizeSlider; ColorPickerViewModel colorPickerVM = (ColorPickerViewModel)colorPicker.DataContext; colorPickerVM.TextEditor = richTextBox; FileDialogViewModel fileDialogVM = (FileDialogViewModel)fileDialogMenuItem.DataContext; fileDialogVM.TextEditor = richTextBox; fileDialogVM.MainWindow = this; App.LanguageChanged += LanguageChanged; CultureInfo currentLang = App.Language; //Refresh language menu LangMenu.Items.Clear(); foreach (CultureInfo lang in App.Languages) { MenuItem item = new MenuItem(); item.Header = lang.DisplayName; item.Tag = lang; item.IsChecked = lang.Equals(currentLang); item.Click += LanguageChange_Click; LangMenu.Items.Add(item); } App.Language = currentLang; }
public void OriginalFilesModificationTest(string version, string fileName) { // Arrange var mockIOProvider = BackCompatTestProperties.GetModuleIOProvider(version, ColorPickerSettings.ModuleName, fileName); var settingPathMock = new Mock <ISettingsPath>(); var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object, settingPathMock.Object); ColorPickerSettings originalSettings = mockSettingsUtils.GetSettings <ColorPickerSettings>(ColorPickerSettings.ModuleName); var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version); var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object); GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettings <GeneralSettings>(); var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository <GeneralSettings>(mockGeneralSettingsUtils); // Act // Initialise View Model with test Config files using (var viewModel = new ColorPickerViewModel(mockSettingsUtils, generalSettingsRepository, ColorPickerIsEnabledByDefaultIPC)) { // Assert // Verify that the old settings persisted Assert.AreEqual(originalGeneralSettings.Enabled.ColorPicker, viewModel.IsEnabled); Assert.AreEqual(originalSettings.Properties.ActivationShortcut.ToString(), viewModel.ActivationShortcut.ToString()); Assert.AreEqual(originalSettings.Properties.ChangeCursor, viewModel.ChangeCursor); // Verify that the stub file was used var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>) BackCompatTestProperties.VerifyModuleIOProviderWasRead(mockIOProvider, ColorPickerSettings.ModuleName, expectedCallCount); BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount); } }
public ColorPickerView() { InitializeComponent(); bth = new Models.BthModel(); colorConverter = new Converters.StringToColorConverter(); BindingContext = colorViewModel = new ColorPickerViewModel(); }
public ColorPickerPage() { InitializeComponent(); colorPickerViewModel = new ColorPickerViewModel(); ViewModel = colorPickerViewModel; }
public ColorPicker() { _model = new ColorPickerViewModel(this); InitializeComponent(); this.DataContext = _model; }
public ColorPickerPage() { var settingsUtils = new SettingsUtils(new SystemIOProvider()); ViewModel = new ColorPickerViewModel(settingsUtils, ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; InitializeComponent(); }
public ColorPickerPage() { var settingsUtils = new SettingsUtils(); ViewModel = new ColorPickerViewModel(settingsUtils, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; InitializeComponent(); }
public void ColorPickerIsEnabledByDefault() { var viewModel = new ColorPickerViewModel(); ShellPage.DefaultSndMSGCallback = msg => { OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg); Assert.IsTrue(snd.GeneralSettings.Enabled.ColorPicker); }; Assert.IsTrue(viewModel.IsEnabled); }
public void UpdatingColorWillAlsoUpdateComponents() { var vm = new ColorPickerViewModel(); var color = Color.FromRgb(0, 170, 255); // #00aaff hsb: 200, 100%, 100% vm.Color = color; Assert.Equal(color, vm.Color); Assert.Equal(color.R, vm.Red); Assert.Equal(color.G, vm.Green); Assert.Equal(color.B, vm.Blue); Assert.Equal(200.0, vm.Hue, 2); Assert.Equal(1.0, vm.Saturation, 2); Assert.Equal(1.0, vm.Brightness, 2); }
private void Button_Click(object sender, RoutedEventArgs e) { ColorPickerViewModel viewModel = this.DataContext as ColorPickerViewModel; if (colorCanvas.SelectedColor != null) { //System.Windows.Media.Color mediacolor = (System.Windows.Media.Color)colorCanvas.SelectedColor; //viewModel.SelectedColor = System.Drawing.Color.FromArgb( // mediacolor.A, mediacolor.R, mediacolor.G, mediacolor.B); viewModel.SelectedColor = (Color)colorCanvas.SelectedColor; } else { viewModel.SelectedColor = Colors.Transparent; } }
public ColorPickerView(Color oldColor) { InitializeComponent(); dataContext = new ColorPickerViewModel { OldColor = oldColor }; DataContext = dataContext; buttonOK.Click += (s, e) => { DialogResult = true; }; buttonCancel.Click += (s, e) => { DialogResult = false; }; }
public MainWindow() { InitializeComponent(); FontFamilyViewModel fontFamilyVM = (FontFamilyViewModel)fontFamilyComboBox.DataContext; fontFamilyVM.TextEditor = richTextBox; fontFamilyVM.FontSizeSlider = fontSizeSlider; ColorPickerViewModel colorPickerVM = (ColorPickerViewModel)colorPicker.DataContext; colorPickerVM.TextEditor = richTextBox; FileDialogViewModel fileDialogVM = (FileDialogViewModel)fileDialogMenuItem.DataContext; fileDialogVM.TextEditor = richTextBox; fileDialogVM.MainWindow = this; //App.LanguageChanged += LanguageChanged; //CultureInfo currentLang = App.Language; ////Refresh language menu //LangMenu.Items.Clear(); //foreach (CultureInfo lang in App.Languages) //{ // MenuItem item = new MenuItem(); // item.Header = lang.DisplayName; // item.Tag = lang; // item.IsChecked = lang.Equals(currentLang); // item.Click += LanguageChange_Click; // LangMenu.Items.Add(item); //} //App.Language = currentLang; DataContext = new MainWindowViewModel(this); //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en"); //Console.WriteLine(lab4.Resources.Localization.FileMenuItem); }
public void UpdatingHSBWillAlsoUpdateRGBAndColor() { var vm = new ColorPickerViewModel(); // #6a4164 hsb: 308.78, 38.68%, 41.57% const byte red = 106; const byte green = 65; const byte blue = 100; const double hue = 308.78; const double sat = 0.3868; const double bright = 0.4157; vm.Hue = hue; vm.Saturation = sat; vm.Brightness = bright; Assert.Equal(hue, vm.Hue, 2); Assert.Equal(sat, vm.Saturation, 2); Assert.Equal(bright, vm.Brightness, 2); Assert.Equal(ColorHelper.FromHSV(hue, sat, bright), vm.Color); Assert.Equal(red, vm.Red); Assert.Equal(green, vm.Green); Assert.Equal(blue, vm.Blue); }
public void UpdatingRGBWillAlsoUpdateHSBAndColor() { var vm = new ColorPickerViewModel(); // #00c896 hsb: 165, 100%, 78.43% const byte red = 0; const byte green = 200; const byte blue = 150; const double hue = 165.0; const double sat = 1.0; const double bright = 0.78; vm.Red = red; vm.Green = green; vm.Blue = blue; Assert.Equal(red, vm.Red); Assert.Equal(green, vm.Green); Assert.Equal(blue, vm.Blue); Assert.Equal(Color.FromRgb(red, green, blue), vm.Color); Assert.Equal(hue, vm.Hue, 2); Assert.Equal(sat, vm.Saturation, 2); Assert.Equal(bright, vm.Brightness, 2); }
public void ColorPickerIsEnabledByDefault() { var viewModel = new ColorPickerViewModel(ColorPickerIsEnabledByDefault_IPC); Assert.IsTrue(viewModel.IsEnabled); }
public ColorPickerView(Color color, string actionFireCallback) { InitializeComponent(); DataContext = new ColorPickerViewModel(color, actionFireCallback); }
public OKCommand(ColorPickerViewModel viewModel) { this.viewModel = viewModel; }
/// <summary> /// Constructor ColorPicker /// </summary> public ColorPicker() { InitializeComponent(); this.viewModel = new ColorPickerViewModel(); this.DataContext = this.viewModel; }
public ColorPickerView() { InitializeComponent(); DataContext = new ColorPickerViewModel(Colors.Gray); }
private void PickColor(ColorType colorType) { Func<Color> getColor = null; Action<Color> setColor = null; switch (colorType) { case ColorType.MainBackground: getColor = () => MainWindowBackgroundColor; setColor = (color) => MainWindowBackgroundColor = color; break; case ColorType.MainBorder: getColor = () => MainWindowBorderColor; setColor = (color) => MainWindowBorderColor = color; break; case ColorType.MainForeground: getColor = () => MainWindowForegroundColor; setColor = (color) => MainWindowForegroundColor = color; break; case ColorType.OtherBackground: getColor = () => OtherWindowsBackgroundColor; setColor = (color) => OtherWindowsBackgroundColor = color; break; case ColorType.OtherBorder: getColor = () => OtherWindowsBorderColor; setColor = (color) => OtherWindowsBorderColor = color; break; case ColorType.OtherForeground: getColor = () => OtherWindowsForegroundColor; setColor = (color) => OtherWindowsForegroundColor = color; break; case ColorType.OtherButton: getColor = () => OtherWindowsButtonColor; setColor = c => OtherWindowsButtonColor = c; break; case ColorType.OtherForegroundButton: getColor = () => OtherWindowsForegroundButtonColor; setColor = c => OtherWindowsForegroundButtonColor = c; break; case ColorType.OtherBackgroundCircleButton: getColor = () => OtherWindowsBackgroundCircleColor; setColor = c => OtherWindowsBackgroundCircleColor = c; break; default: throw new ArgumentOutOfRangeException("colorType"); } ColorPickerViewModel viewModel = new ColorPickerViewModel(getColor()); bool result = _dialogService.ShowResultDialog(viewModel); if (!result) return; setColor(viewModel.SelectedColor); }
public ColorPickerPage() { ViewModel = new ColorPickerViewModel(ShellPage.SendDefaultIPCMessage); DataContext = ViewModel; InitializeComponent(); }
public ColorPickerView() { InitializeComponent(); BindingContext = viewModel = new ColorPickerViewModel(); }
public ColorPickerView(Color color) { InitializeComponent(); DataContext = new ColorPickerViewModel(color); }
public ColorPickerPage() { ViewModel = new ColorPickerViewModel(); DataContext = ViewModel; InitializeComponent(); }
public ColorPickerSource(ColorPickerHueGridViewController viewController) { this.viewController = viewController; viewModel = viewController.ViewModel; }