Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -r687f68519e8e01e867ffbd3dbba58d52f7e9e2e9 -r00bf02e3c099d01fbdb84735d8fc64de0fb98aaa --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 687f68519e8e01e867ffbd3dbba58d52f7e9e2e9) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -163,11 +163,11 @@ True - + Form - - GeneralOptionsControl.cs + + OptionsDialog.cs Component @@ -322,8 +322,8 @@ MessageWindow.cs Designer - - GeneralOptionsControl.cs + + OptionsDialog.cs Designer Index: Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs =================================================================== diff -u -r687f68519e8e01e867ffbd3dbba58d52f7e9e2e9 -r00bf02e3c099d01fbdb84735d8fc64de0fb98aaa --- Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 687f68519e8e01e867ffbd3dbba58d52f7e9e2e9) +++ Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -19,7 +19,7 @@ using Core.Common.Controls; using Core.Common.Controls.Swf; using Core.Common.Gui.Forms.MessageWindow; -using Core.Common.Gui.Forms.OptionsDialog; +using Core.Common.Gui.Forms.Options; using Core.Common.Utils; using Core.Common.Utils.Collections; using Core.Common.Utils.Interop; @@ -1008,7 +1008,7 @@ private void OnFileOptionsClicked(object sender, RoutedEventArgs e) { - var optionsDialog = new GeneralOptionsControl + var optionsDialog = new OptionsDialog { UserSettings = Gui.UserSettings, ColorTheme = (ColorTheme) Gui.UserSettings["colorTheme"], @@ -1018,9 +1018,9 @@ optionsDialog.ShowDialog(); } - private void ApplyColorTheme(GeneralOptionsControl control) + private void ApplyColorTheme(OptionsDialog dialog) { - SetColorTheme(control.ColorTheme); + SetColorTheme(dialog.ColorTheme); } private void SetColorTheme(ColorTheme colorTheme) Index: Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.Designer.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.Designer.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.Designer.cs (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -0,0 +1,115 @@ +namespace Core.Common.Gui.Forms.Options +{ + partial class OptionsDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionsDialog)); + this.groupBoxUserSettings = new System.Windows.Forms.GroupBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOk = new System.Windows.Forms.Button(); + this.comboBoxTheme = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.checkBoxStartPage = new System.Windows.Forms.CheckBox(); + this.groupBoxUserSettings.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxUserSettings + // + resources.ApplyResources(this.groupBoxUserSettings, "groupBoxUserSettings"); + this.groupBoxUserSettings.Controls.Add(this.buttonCancel); + this.groupBoxUserSettings.Controls.Add(this.buttonOk); + this.groupBoxUserSettings.Controls.Add(this.comboBoxTheme); + this.groupBoxUserSettings.Controls.Add(this.label1); + this.groupBoxUserSettings.Controls.Add(this.checkBoxStartPage); + this.groupBoxUserSettings.Name = "groupBoxUserSettings"; + this.groupBoxUserSettings.TabStop = false; + // + // buttonCancel + // + resources.ApplyResources(this.buttonCancel, "buttonCancel"); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOk + // + resources.ApplyResources(this.buttonOk, "buttonOk"); + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); + // + // comboBoxTheme + // + this.comboBoxTheme.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTheme.FormattingEnabled = true; + resources.ApplyResources(this.comboBoxTheme, "comboBoxTheme"); + this.comboBoxTheme.Name = "comboBoxTheme"; + this.comboBoxTheme.SelectedIndexChanged += new System.EventHandler(this.comboBoxTheme_SelectedIndexChanged); + // + // label1 + // + resources.ApplyResources(this.label1, "label1"); + this.label1.Name = "label1"; + // + // checkBoxStartPage + // + resources.ApplyResources(this.checkBoxStartPage, "checkBoxStartPage"); + this.checkBoxStartPage.Checked = true; + this.checkBoxStartPage.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxStartPage.Name = "checkBoxStartPage"; + this.checkBoxStartPage.UseVisualStyleBackColor = true; + // + // OptionsDialog + // + this.AcceptButton = this.buttonOk; + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.buttonCancel; + this.Controls.Add(this.groupBoxUserSettings); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "OptionsDialog"; + this.ShowInTaskbar = false; + this.groupBoxUserSettings.ResumeLayout(false); + this.groupBoxUserSettings.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxUserSettings; + private System.Windows.Forms.CheckBox checkBoxStartPage; + private System.Windows.Forms.ComboBox comboBoxTheme; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOk; + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.cs (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -0,0 +1,145 @@ +using System; +using System.Collections.ObjectModel; +using System.Configuration; +using System.Security.Permissions; +using System.Windows.Forms; +using Core.Common.Utils.Reflection; + +namespace Core.Common.Gui.Forms.Options +{ + public partial class OptionsDialog : Form + { + private ApplicationSettingsBase userSettings; + + public OptionsDialog() + { + InitializeComponent(); + SetColorThemeOptions(); + } + + public ApplicationSettingsBase UserSettings + { + get + { + return userSettings; + } + set + { + UpdateUserSettings(value); + } + } + + public ColorTheme ColorTheme + { + get + { + return (ColorTheme) comboBoxTheme.SelectedValue; + } + set + { + comboBoxTheme.SelectedValue = value; + } + } + + // TODO: Call this method + public Action OnAcceptChanges { get; set; } + + private void AcceptChanges() + { + SetValuesToSettings(); + if (OnAcceptChanges != null) + { + OnAcceptChanges(this); + } + } + + private void DeclineChanges() + { + SetSettingsValuesToControls(); + } + + private void SetColorThemeOptions() + { + var colorThemeItems = new Collection(); + foreach (var theme in (ColorTheme[]) Enum.GetValues(typeof(ColorTheme))) + { + colorThemeItems.Add(new ColorThemeItem + { + Theme = theme, + DisplayName = theme.Localized() + }); + } + comboBoxTheme.DataSource = colorThemeItems; + comboBoxTheme.ValueMember = TypeUtils.GetMemberName(cti => cti.Theme); + comboBoxTheme.DisplayMember = TypeUtils.GetMemberName(cti => cti.DisplayName); + } + + /// + /// Safe call because of linkdemand + /// + /// + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] + private void UpdateUserSettings(ApplicationSettingsBase settings) + { + userSettings = settings; + SetSettingsValuesToControls(); + } + + /// + /// Dialog created. + /// + private void SetSettingsValuesToControls() + { + checkBoxStartPage.Checked = (bool) userSettings["showStartPage"]; + } + + /// + /// Ok clicked. + /// + private void SetValuesToSettings() + { + if ((bool) userSettings["showStartPage"] != checkBoxStartPage.Checked) + { + userSettings["showStartPage"] = checkBoxStartPage.Checked; + } + } + + private void comboBoxTheme_SelectedIndexChanged(object sender, EventArgs e) {} + + /// + /// Used for localizing the items in the theme selection combo box. + /// + private class ColorThemeItem + { + /// + /// Gets or sets the for this item. + /// + public ColorTheme Theme { get; set; } + + /// + /// Gets or sets the name to display for the . + /// + public string DisplayName { get; set; } + } + + protected override void OnFormClosed(FormClosedEventArgs e) + { + if (DialogResult != DialogResult.OK) + { + DeclineChanges(); + } + + base.OnFormClosed(e); + } + + private void buttonOk_Click(object sender, EventArgs e) + { + AcceptChanges(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DeclineChanges(); + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.resx =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.resx (revision 0) +++ Core/Common/src/Core.Common.Gui/Forms/Options/OptionsDialog.resx (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + GrowAndShrink + + + Bottom, Right + + + NoControl + + + + 386, 156 + + + 75, 23 + + + + 10 + + + Annuleren + + + buttonCancel + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxUserSettings + + + 0 + + + Bottom, Right + + + NoControl + + + 305, 155 + + + 75, 23 + + + 9 + + + OK + + + buttonOk + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxUserSettings + + + 1 + + + 83, 45 + + + 86, 21 + + + 8 + + + comboBoxTheme + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxUserSettings + + + 2 + + + True + + + 7, 48 + + + 75, 13 + + + 7 + + + Kleurenthema: + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxUserSettings + + + 3 + + + True + + + 8, 21 + + + 106, 17 + + + 3 + + + Toon startpagina + + + checkBoxStartPage + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxUserSettings + + + 4 + + + Fill + + + 0, 0 + + + 473, 191 + + + 0 + + + Algemeen + + + groupBoxUserSettings + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + GrowAndShrink + + + 473, 191 + + + + AAABAAEAEBAAAAAAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAA + AAD///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af// + /wH///8B////Af///wG3opP/Y0k1/2NJNf9jSTX/Y0k1/2NJNf9jSTX/Y0k1/2NJNf9jSTX/Y0k1//// + /wH///8B////Af///wH///8Bt6KT//////+3opP/t6KT/7eik/+3opP/t6KT/7eik/+3opP/t6KT/2NJ + Nf////8B////Af///wH///8B////Abeik/////////////z6+f/38e7/8efh/+zd1f/m08n/4cq9/7ei + k/9jSTX/////Af///wH///8B////Af///wG3opP//////9zc3P+ZmZn/6+rp//Xt6f/f1M3/2svE/9rH + vf/Br6P/Y0k1/////wH///8B////Af///wH///8Bt6KT//////9nZ2f//////5eXl//48/D/o5iQ/52R + h/+XioD/ybit/2ZNOf////8B////Af///wH///8B////Abqllv//////zs7O/2lpaf/e3t7/+/j3//bv + 6//w5d//69vT/72qnf9mTDj/////Af///wH///8B////Af///wG+qZr///////////////////////79 + /P/59fL/9Ovm/+7h2v+3opP/ZEo2/////wH///8B////Af///wH///8Bw66e//////+0r6r/Qzw7/8C6 + t///////4t3a/9zU0P/b0cv/vaqc/2NJNf////8B////Af///wH///8B////Aciyo///////JiQi/83N + zf9gVlP//////6idlf+jmZH/qqCX/8W1qf9jSTX/////Af///wH///8B////Af///wHMtqf//////6yk + nv8oJST/tbCs/////////////f38/82/tP/Ht6v/ZEo2/////wH///8B////Af///wH///8B0bur//// + /////////////////////////////7eik/9kSjb/ZEo2/2RKNv////8B////Af///wH///8B////AdW/ + r/////////////////////////////////+5pJX/1MW6/2RKNv/Js6SN////Af///wH///8B////Af// + /wHYwrL/////////////////////////////////wKuc/2RKNv/Js6SL////Af///wH///8B////Af// + /wH///8B2MKy/9jCsv/YwrL/2MKy/9jCsv/Uvq7/z7mp/8mzpP/Js6SL////Af///wH///8B////Af// + /wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af///wH///8B////Af// + /wH///8BAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA + //8AAP//AAD//w== + + + + Opties + + + OptionsDialog + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Fisheye: Tag 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Forms/OptionsDialog/GeneralOptionsControl.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Forms/OptionsDialog/GeneralOptionsControl.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Forms/OptionsDialog/GeneralOptionsControl.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -rc27aa10e3d9924c856ba3ed81ca12c96a56fe635 -r00bf02e3c099d01fbdb84735d8fc64de0fb98aaa --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision c27aa10e3d9924c856ba3ed81ca12c96a56fe635) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -60,8 +60,8 @@ - - + + Index: Core/Common/test/Core.Common.Gui.Test/Forms/Options/ColorThemeTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Forms/Options/ColorThemeTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Forms/Options/ColorThemeTest.cs (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -0,0 +1,61 @@ +using System; +using System.Collections.ObjectModel; +using Core.Common.Gui.Properties; +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Forms.Options +{ + [TestFixture] + public class ColorThemeTest + { + [Test] + public void ColorTheme_Values_HasSix() + { + // Call & Assert + Assert.AreEqual(6, Enum.GetValues(typeof(ColorTheme)).Length); + } + + [Test] + public void ColorTheme_GetNames_HasSix() + { + // Setup + var nameList = new[] + { + "Dark", + "Light", + "Metro", + "Aero", + "VS2010", + "Generic" + }; + + // Call & Assert + CollectionAssert.AreEqual(nameList, Enum.GetNames(typeof(ColorTheme))); + } + + [Test] + public void Localized_ForEveryItem_ExpectedTranslatedString() + { + // Setup + var nameList = new[] + { + Resources.Dark, + Resources.Light, + Resources.Metro, + Resources.Aero, + Resources.VS2010, + Resources.Generic + }; + var translations = new Collection(); + + // Call + foreach(ColorTheme item in Enum.GetValues(typeof(ColorTheme))) + { + translations.Add(item.Localized()); + } + + // Assert + CollectionAssert.AreEqual(nameList, translations); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Forms/Options/OptionsDialogTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Forms/Options/OptionsDialogTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Forms/Options/OptionsDialogTest.cs (revision 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa) @@ -0,0 +1,35 @@ +using System.Windows.Forms; +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Forms.Options +{ + [TestFixture] + public class OptionsDialogTest + { + [Test] + public void GivenGeneralOptionsControlCreated_WhenRetrievingOptionsItems_ThenOptionsShouldBeTranslated() + { + using (var control = new Gui.Forms.Options.OptionsDialog()) + { + var subControl = (ComboBox)control.Controls.Find("comboBoxTheme", true)[0]; + + Assert.AreEqual(6, subControl.Items.Count); + + var localizedThemes = new[] + { + "Donker", + "Licht", + "Metro", + "Aero", + "VS2010", + "Generiek" + }; + + for (var i = 0; i < subControl.Items.Count; i++) + { + Assert.AreEqual(localizedThemes[i], subControl.GetItemText(subControl.Items[i])); + } + } + } + } +} \ No newline at end of file Fisheye: Tag 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Forms/OptionsDialog/ColorThemeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 00bf02e3c099d01fbdb84735d8fc64de0fb98aaa refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Forms/OptionsDialog/GeneralOptionsControlTest.cs'. Fisheye: No comparison available. Pass `N' to diff?