asciipumper

- mspaint style program to create irc ascii art
git clone git://git.acid.vegas/asciipumper.git
Log | Files | Refs | Archive | README

OptionsForm.cs (3583B)

      1 using System;
      2 using System.Collections.Generic;
      3 using System.ComponentModel;
      4 using System.Data;
      5 using System.Drawing;
      6 using System.Text;
      7 using System.Windows.Forms;
      8 
      9 namespace AsciiPumper
     10 {
     11 	public partial class OptionsForm : Form
     12 	{
     13 		public OptionsForm()
     14 		{
     15 			InitializeComponent();
     16 			fontdlgEditorFont.Font = new Font(Program.Settings.PaintFontName, Program.Settings.PaintFontSize);
     17 			lblSampleText.Font = new Font(Program.Settings.PaintFontName, Program.Settings.PaintFontSize);
     18 			colorSeperator.BackColor = Program.Settings.SeperatorColor;
     19 			colorHighlight.BackColor = Program.Settings.HighlightColor;
     20 			numCellHeight.Value = Program.Settings.CellHeight;
     21 			numCellWidth.Value = Program.Settings.CellWidth;
     22 			colordlgHighlight.Color = Program.Settings.HighlightColor;
     23 			colordlgSeperator.Color = Program.Settings.SeperatorColor;
     24 
     25 
     26 		}
     27 
     28 		public class SettingsSavedEventArgs : EventArgs
     29 		{
     30 			public static readonly new SettingsSavedEventArgs Empty = new SettingsSavedEventArgs();
     31 		}
     32 
     33 		public event EventHandler<SettingsSavedEventArgs> SettingsSaved;
     34 
     35 		protected virtual void OnSettingsSaved(SettingsSavedEventArgs e)
     36 		{
     37 			EventHandler<SettingsSavedEventArgs> handler = SettingsSaved;
     38 			if (handler != null)
     39 			{
     40 				handler(this, e);
     41 			}
     42 		}
     43 
     44 		private void OptionsForm_Load(object sender, EventArgs e)
     45 		{
     46 			lbCategories.SelectedValue = "Editor";
     47 
     48 		}
     49 
     50 		private void ApplySettings()
     51 		{
     52 			Cursor cur = Cursor.Current;
     53 			Cursor.Current = Cursors.WaitCursor;
     54 			try
     55 			{
     56 				if (fontdlgEditorFont.Font.Name != Program.Settings.PaintFontName)
     57 				{
     58 					Program.Settings.PaintFontName = fontdlgEditorFont.Font.Name;
     59 				}
     60 				if (fontdlgEditorFont.Font.Size != Program.Settings.PaintFontSize)
     61 				{
     62 					Program.Settings.PaintFontSize = fontdlgEditorFont.Font.Size;
     63 				}
     64 				if (colordlgHighlight.Color != Program.Settings.HighlightColor)
     65 					Program.Settings.HighlightColor = colordlgHighlight.Color;
     66 				if (colordlgSeperator.Color != Program.Settings.SeperatorColor)
     67 					Program.Settings.SeperatorColor = colordlgSeperator.Color;
     68 				if (numCellHeight.Value != Program.Settings.CellHeight)
     69 					Program.Settings.CellHeight = (int)numCellHeight.Value;
     70 				if (numCellWidth.Value != Program.Settings.CellWidth)
     71 					Program.Settings.CellWidth = (int) numCellWidth.Value;
     72 
     73 				Program.Settings.Save();
     74 				this.OnSettingsSaved(SettingsSavedEventArgs.Empty);
     75 			}
     76 			finally
     77 			{
     78 				Cursor.Current = cur;
     79 			}
     80 			
     81 		}
     82 
     83 		private void btnOK_Click(object sender, EventArgs e)
     84 		{
     85 			ApplySettings();
     86 			this.DialogResult = DialogResult.OK;
     87 			this.Close();
     88 
     89 		}
     90 
     91 		private void btnApply_Click(object sender, EventArgs e)
     92 		{
     93 			ApplySettings();
     94 		}
     95 
     96 		private void btnCancel_Click(object sender, EventArgs e)
     97 		{
     98 			this.DialogResult = DialogResult.Cancel;
     99 			this.Close();
    100 
    101 		}
    102 
    103 		private void btnEditorFont_Click(object sender, EventArgs e)
    104 		{
    105 			DialogResult res = fontdlgEditorFont.ShowDialog(this);
    106 			if (res == DialogResult.OK)
    107 			{
    108 				lblSampleText.Font = fontdlgEditorFont.Font;
    109 			}
    110 		}
    111 
    112 		private void button1_Click(object sender, EventArgs e)
    113 		{
    114 			DialogResult res = colordlgSeperator.ShowDialog(this);
    115 			if (res == DialogResult.OK)
    116 				colorSeperator.BackColor = colordlgSeperator.Color;
    117 
    118 		}
    119 
    120 		private void button1_Click_1(object sender, EventArgs e)
    121 		{
    122 
    123 			DialogResult res = colordlgHighlight.ShowDialog(this);
    124 			if (res == DialogResult.OK)
    125 				colorHighlight.BackColor = colordlgHighlight.Color;
    126 
    127 		}
    128 	}
    129 }