form.Text = "Color";
- form.Size = new Size (221, 332); // 300
-
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.MaximizeBox = false;
defineColoursButton.Location = new Point (5, 244);
defineColoursButton.Size = new Size (210, 22);
defineColoursButton.TabIndex = 6;
- defineColoursButton.Text = Locale.GetText ("Define Colors >>");
+ // FIXME: update resource files
+ defineColoursButton.Text = "Define Custom Colors >>";
+ //defineColoursButton.Text = Locale.GetText ("Define Custom Colors >>");
// okButton
okButton.FlatStyle = FlatStyle.System;
okButton.Location = new Point (5, 271);
addColoursButton.Location = new Point (227, 271);
addColoursButton.Size = new Size (213, 22);
addColoursButton.TabIndex = 7;
- addColoursButton.Text = Locale.GetText ("Add Colors");
+ // FIXME: update resource files
+ addColoursButton.Text = "Add To Custom Colors";
+ //addColoursButton.Text = Locale.GetText ("Add To Custom Colors");
// baseColorControl
baseColorControl.Location = new Point (3, 6);
redTextBox.LostFocus += new EventHandler (OnLostFocusTextBoxes);
greenTextBox.LostFocus += new EventHandler (OnLostFocusTextBoxes);
blueTextBox.LostFocus += new EventHandler (OnLostFocusTextBoxes);
+
+ ResetCustomColors ();
}
#endregion // Public Constructors
if (fullOpen && allowFullOpen) {
defineColoursButton.Enabled = false;
-
colorMatrixControl.ColorToShow = baseColorControl.ColorToShow;
-
- form.Size = new Size (448, 332);
+ form.Size = GetFormSize (true);
} else {
if (allowFullOpen)
defineColoursButton.Enabled = true;
-
- form.Size = new Size (221, 332); // 300
+ form.Size = GetFormSize (false);
}
}
}
}
set {
- if (allowFullOpen) {
- customColors = value;
+ if (value == null)
+ ResetCustomColors ();
+ else {
+ int[] tmp_colors = value;
- baseColorControl.SetCustomColors ();
+ Array.Copy (tmp_colors, customColors, tmp_colors.Length);
}
+
+ baseColorControl.SetCustomColors ();
}
}
public override string ToString ()
{
- return base.ToString () + ", Color: " + Color.ToString ();
+ return base.ToString () + ", Color: " + Color.ToString ();
}
#endregion // Public Instance Methods
#region Protected Instance Methods
protected override bool RunDialog (IntPtr hwndOwner)
{
+ defineColoursButton.Enabled = (AllowFullOpen && !FullOpen);
+ defineColoursButton.Refresh ();
+
+ form.Size = GetFormSize (FullOpen && AllowFullOpen);
// currently needed, otherwise there are a lot of drawing artefacts/transparent controls if the same dialog gets opened again
form.Refresh ();
}
#endregion // Protected Instance Methods
- #region Private Methods
+ #region Private Methods
+
+ Size GetFormSize (bool fullOpen)
+ {
+ if (fullOpen)
+ return new Size (448, 332);
+ else
+ return new Size (221, 332); // 300
+ }
+
void OnClickCancelButton (object sender, EventArgs e)
{
form.DialogResult = DialogResult.Cancel;
{
if (allowFullOpen) {
defineColoursButton.Enabled = false;
-
colorMatrixControl.ColorToShow = baseColorControl.ColorToShow;
-
- form.Size = new Size (448, 332);
+ form.Size = GetFormSize (true);
}
}
UpdateControls (col);
}
+
+ void ResetCustomColors ()
+ {
+ // check if this.customColors already exists
+ if (customColors == null)
+ customColors = new int [16];
+
+ int default_color = Color.FromArgb(0, 255, 255, 255).ToArgb ();
+
+ for (int i = 0; i < customColors.Length; i++)
+ customColors [i] = default_color;
+ }
#endregion
#region Internal structs and classes
private SmallColorControl selectedSmallColorControl;
private int currentlyUsedUserSmallColorControl = 0;
- private int[] customColors = null;
private ColorDialog colorDialog = null;
{
userSmallColorControl [currentlyUsedUserSmallColorControl].InternalColor = col;
- // check if this.customColors already exists
- if (customColors == null) {
- customColors = new int [16];
- int white = Color.White.ToArgb ();
-
- for (int i = 0; i < customColors.Length; i++)
- customColors [i] = white;
- }
-
- customColors [currentlyUsedUserSmallColorControl] = col.ToArgb ();
-
- // update ColorDialog dialog property
- colorDialog.CustomColors = customColors;
+ colorDialog.customColors [currentlyUsedUserSmallColorControl] = col.ToArgb ();
currentlyUsedUserSmallColorControl++;
if (currentlyUsedUserSmallColorControl > 15)
public void SetCustomColors ()
{
- int[] customColors = colorDialog.CustomColors;
-
- if (customColors != null) {
- for (int i = 0; i < customColors.Length; i++) {
- userSmallColorControl [i].InternalColor = Color.FromArgb (customColors [i]);
- }
- } else {
- for (int i = 0; i < userSmallColorControl.Length; i++) {
- userSmallColorControl [i].InternalColor = Color.White;
- }
+ for (int i = 0; i < colorDialog.customColors.Length; i++) {
+ userSmallColorControl [i].InternalColor = Color.FromArgb (colorDialog.customColors [i]);
}
}
}