internal void FileOpen() { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "Image Files .BMP .JPG .GIF .Png|*.BMP;*.JPG;*.GIF;*.PNG"; if (fileDialog.ShowDialog() == DialogResult.OK) { ImageFile imageFile = new ImageFile(new Size(500, 500), Color.White); if (imageFile.Open(fileDialog.FileName)) { view.ShowImage(imageFile); } else { MessageBox.Show("Error"); } } }
internal void FileSave() { ImageFile imageFile = new ImageFile(new Size(500, 500), Color.White); throw new Exception("Bug! It has to read the image (from model maybe?)"); string imageFileName = imageFile.FileName; if (imageFileName != null) { if (!imageFile.Save(imageFileName)) MessageBox.Show("Error"); else view.ShowImage(imageFile); // is it necessary? } else { FileSaveAs(); } }
private void editUndoMnu_Click(object sender, EventArgs e) { stack.Pop(); imageFile = stack.Peek(); ShowImage(); }
private void PaintForm_Load(object sender, EventArgs e) { // fill (fill style) list for (int i = 0; i < 3; i++) { BrushType bt = (BrushType)i; fillStyleCombo.Items.Add(bt); } for (int i = 0; i < 53; i++) { HatchStyle hs = (HatchStyle)i; fillStyleCombo.Items.Add(hs); } fillStyleCombo.SelectedIndex = 0; // fill shape style list for (int i = 0; i < 4; i++) { DrawMode ss = (DrawMode)i; shapeStyleCombo.Items.Add(ss); } shapeStyleCombo.SelectedIndex = 0; // fill Width list for (int i = 1; i < 11; i++) widthCombo.Items.Add(i); for (int i = 15; i <= 60; i += 5) widthCombo.Items.Add(i); widthCombo.SelectedIndex = 0; // fill Gradiant style list for (int i = 0; i < 4; i++) { LinearGradientMode gm = (LinearGradientMode)i; gradiantStyleCombo.Items.Add(gm); } gradiantStyleCombo.SelectedIndex = 0; for (int i = 0; i < 4; i++) { DashStyle ds = (DashStyle)i; lineStyleCombo.Items.Add(ds.ToString()); } lineStyleCombo.SelectedIndex = 0; // default texture brush image brushImageBox.Image = new Bitmap(20, 20); // default image imageFile = new ImageFile(new Size(500, 500), Color.White); ShowImage(); }
private void fileNewMnu_Click(object sender, EventArgs e) { NewDialog newDlg = new NewDialog(); if (newDlg.ShowDialog() == DialogResult.OK) { imageFile = new ImageFile(newDlg.ImageSize, newDlg.imageBackColor); ShowImage(); } }
public void ShowImage(ImageFile imageFile) { string fileName = imageFile.FileName; if (fileName == null) fileName = "Untitled"; else fileName = new FileInfo(fileName).Name; Text = string.Format("Paint - [{0}]", fileName); imageBox.ClientSize = imageFile.Bitmap.Size; imageBox.Invalidate(); bitmap = imageFile.Bitmap; SetToolBarButtonsState(arrowBtn); }