public PixelEdit() { InitializeComponent(); // Set up double buffer typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, Canvas, new object[] { true }); // Set Colour Picker BackColor PrimaryColourPanel.BackColor = _PrimaryColour; SecondaryColourPanel.BackColor = _SecondaryColour; // Setup Update function _Updater.Interval = 1; _Updater.Tick += Update; _Updater.Start(); FileInfo file = new FileInfo("Options.txt"); if (!file.Exists) { //Create Options file FileStream F = new FileStream("Options.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); F.Close(); } else { StreamReader SR = new StreamReader(file.FullName, System.Text.Encoding.ASCII); int lineNum = 0; string line; string[] words; string[] TextVars = { "", "", "", "", "" }; while (!SR.EndOfStream) { line = SR.ReadLine(); words = line.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries); TextVars[lineNum] = words[1]; lineNum++; } _LastFileName = TextVars[0]; _CurrentTool = (_Tool)Enum.Parse(typeof(_Tool), TextVars[1]); _ToolSize = Convert.ToInt32(TextVars[2]); SizeNumUpDown.Value = _ToolSize; _PrimaryColour = ColorTranslator.FromHtml(TextVars[3]); _SecondaryColour = ColorTranslator.FromHtml(TextVars[4]); SR.Close(); } UpdateSize(); }
// Ellipse Tool private void EllipseToolButton_Click(object sender, EventArgs e) { _CurrentTool = _Tool._Circle; }
// Line Tool private void LineToolButton_Click(object sender, EventArgs e) { _CurrentTool = _Tool._Line; }
// Bucket Tool private void BucketToolButton_Click(object sender, EventArgs e) { _CurrentTool = _Tool._Bucket; }
// Brush Tool private void BrushToolButton_Click(object sender, EventArgs e) { _CurrentTool = _Tool._Brush; }
// Pencil Tool private void PencilToolButton_Click(object sender, EventArgs e) { _CurrentTool = _Tool._Pencil; }
// Square Tool private void SquareToolButton_Click(object sender, EventArgs e) { _CurrentTool = _Tool._Square; }