- VAL.src.zip
- VAL
- Database
- packages
- EntityFramework.4.2.0.0
- lib
- net40
- EntityFramework.dll
- log4net.1.2.10
- lib
- 1.0
- log4net.dll
- 1.1
- log4net.dll
- 2.0
- log4net.dll
- log4net.1.2.11
- lib
- net10-full
- log4net.dll
- net11-full
- log4net.dll
- net20-cf
- log4net.dll
- net20-full
- log4net.dll
- net35-client
- log4net.dll
- net35-full
- log4net.dll
- net40-client
- log4net.dll
- net40-full
- log4net.dll
- Moq.4.0.10827
- lib
- NET35
- Moq.dll
- NET40
- Moq.dll
- Silverlight4
- Castle.Core.dll
- Moq.Silverlight.dll
- License.txt
- Moq.chm
- repositories.config
- structuremap.2.6.3
- lib
- StructureMap.dll
- READ-ME-First!.txt
- VAL.BusinessService
- VAL.ClientService
- VAL.Common
- VAL.Contracts
- VAL.Controls
- VAL.Data
- VAL.GUI
- VAL.Model
- VAL.Service
- VAL.sln
- VAL.Tests
- VAL.User.Documentation
- VAL.zip
- VisualApplicationLauncher
- Database
- Local.testsettings
- NRepo
- ProjectReferences
- EFCachingProvider.dll
- EFCachingProvider.Web.dll
- EFProviderWrapperToolkit.dll
- EFTracingProvider.dll
- log4net.dll
- StructureMap.dll
- READ-ME-First!.txt
- TraceAndTestImpact.testsettings
- VAL.BusinessService
- VAL.Common
- VAL.Contracts
- VAL.Controls
- VAL.Data
- VAL.GUI
- VAL.Model
- VAL.Service
- VAL.sln
- VAL.Tests
- VAL.User.Documentation
- VAL.vsmdi
|
namespace VAL
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VAL.ColorPicker;
using VAL.Controls;
/// <summary>
/// Simple interface for setting some options for the appearance of the main
/// application screen
/// </summary>
public partial class UserSettings : ApplicationFormBase
{
private enum ColorPickMode
{
BackColor = 0,
ForeColor = 1
}
private UserOptions options = UserOptions.Current;
private ColourPickerWindow colorPicker = new ColourPickerWindow();
private ColorPickMode colorMode = ColorPickMode.BackColor;
/// <summary>
/// Ctor
/// </summary>
public UserSettings()
{
InitializeComponent();
colorPicker.ColorSelected += new ColorSelectedEventHandler(colorPicker_ColorSelected);
LoadUserOptions();
}
void colorPicker_ColorSelected(object sender, ColorSelectedEventArgs e)
{
if (e.ColorSelected == Color.Transparent)
{
Messaging.ShowError("Sorry, transparent colour is not supported in VAL!");
return;
}
switch (colorMode)
{
case ColorPickMode.BackColor:
sampleAppearance.BackColor = Color.FromName(e.ColorSelected.ToKnownColor().ToString());
break;
case ColorPickMode.ForeColor:
sampleAppearance.ForeColor = Color.FromName(e.ColorSelected.ToKnownColor().ToString());
break;
}
}
private void backColourButton_Click(object sender, EventArgs e)
{
colorMode = ColorPickMode.BackColor;
ShowColourPicker(backColourButton);
}
private void ShowColourPicker(Button button)
{
if (colorPicker != null)
{
// places the window right to the button
colorPicker.Location = GetWindowPoint(button);
colorPicker.Show();
colorPicker.BringToFront();
}
}
private Point GetWindowPoint(Control control)
{
return PointToScreen(new Point(control.Right, control.Top));
}
private void foreColourButton_Click(object sender, EventArgs e)
{
colorMode = ColorPickMode.ForeColor;
ShowColourPicker(foreColourButton);
}
private void fontButton_Click(object sender, EventArgs e)
{
this.fontDialog.Font = this.sampleAppearance.Font;
if (fontDialog.ShowDialog(this) == DialogResult.OK)
{
this.sampleAppearance.Font = fontDialog.Font;
}
}
private void LoadUserOptions()
{
try
{
sampleAppearance.BackColor = Color.FromName(options.BackColor);
sampleAppearance.ForeColor = Color.FromName(options.ForeColor);
sampleAppearance.Font = new Font(options.FontName, options.FontSize);
accessPassword.Text = options.GetDecryptedPassword();
accessUserName.Text = options.UserName;
signOnEnabledCheckBox.Checked = options.AutoSignOn;
}
catch
{
RevertToDefaultSettings();
}
}
private void RevertToDefaultSettings()
{
this.sampleAppearance.BackColor = System.Drawing.Color.White;
this.sampleAppearance.ForeColor = System.Drawing.Color.Black;
this.sampleAppearance.Font = SystemFonts.MessageBoxFont;
ApplyUserSettings();
}
private void ApplyUserSettings()
{
options.FontName = sampleAppearance.Font.Name;
options.FontSize = sampleAppearance.Font.Size;
options.ForeColor = sampleAppearance.ForeColor.ToKnownColor().ToString();
options.BackColor = sampleAppearance.BackColor.ToKnownColor().ToString();
options.AutoSignOn = this.signOnEnabledCheckBox.Checked;
if (options.AutoSignOn)
{
string userName = this.accessUserName.Text.Length == 0 ? Environment.UserName.ToUpper() : this.accessUserName.Text;
options.UserName = userName;
options.EncryptPassword(this.accessPassword.Text);
}
options.Save();
}
private void applyButton_Click(object sender, EventArgs e)
{
ApplyUserSettings();
this.DialogResult = DialogResult.OK;
}
private void cancelButton_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void UserSettings_FormClosing(object sender, FormClosingEventArgs e)
{
if (colorPicker != null)
colorPicker.Dispose();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.