예제 #1
0
파일: MenuHelper.cs 프로젝트: p3k1/FPPaint
        public static void OpenActions(MainWindow mainWindow)
        {
            if (PaintingManager.File.IsModified)
            {
                DialogResult result = MessageBox.Show("File was changed. Do you want to save it?", "Question",
                                                      MessageBoxButtons.YesNoCancel,
                                                      MessageBoxIcon.Question);
                if (result == DialogResult.Cancel)
                    return;
                if (result == DialogResult.Yes)
                    PaintingManager.File.SaveFile(PaintingManager.Page.Picture);
            }

            using (var OpenFile = new OpenFileDialog())
            {
                OpenFile.Multiselect = false;
                OpenFile.Filter = "Bitmaps (*.BMP)|*.bmp";
                if (OpenFile.ShowDialog() == DialogResult.OK && !String.IsNullOrEmpty(OpenFile.FileName))
                {
                    PaintingManager.CreateNewPicture(OpenFile.FileName);
                    mainWindow.PictureProp.Height = PaintingManager.Page.Picture.Height;
                    mainWindow.PictureProp.Width = PaintingManager.Page.Picture.Width;
                    mainWindow.PictureProp.Image = PaintingManager.Page.Picture;
                    PaintingManager.File.Path = OpenFile.FileName;
                    mainWindow.PictureProp.Refresh();
                }
            }
            mainWindow.Text = "FP Paint - " + PaintingManager.File.Name;
        }
예제 #2
0
파일: MenuHelper.cs 프로젝트: p3k1/FPPaint
        public static void NewFileActions(MainWindow mainWindow)
        {
            if (PaintingManager.File.IsModified)
            {
                DialogResult result = MessageBox.Show("File was changed. Do you want to save it?", "Question",
                                                      MessageBoxButtons.YesNoCancel,
                                                      MessageBoxIcon.Question);
                if (result == DialogResult.Cancel)
                    return;
                if (result == DialogResult.Yes)
                    PaintingManager.File.SaveFile(PaintingManager.Page.Picture);
            }

            var newItem = new NewItemForm();
            if (newItem.ShowDialog() == DialogResult.OK)
            {
                mainWindow.PictureProp.Width = newItem.width;
                mainWindow.PictureProp.Height = newItem.height;
                PaintingManager.Page = new Page(newItem.width, newItem.height);
                PaintingManager.File = new File("");
                mainWindow.PictureProp.Image = PaintingManager.Page.Picture;
                using (Graphics g = Graphics.FromImage(PaintingManager.Page.Picture))
                    g.Clear(Color.White);
                mainWindow.PictureProp.Refresh();
            }
            mainWindow.Text = "FP Paint - " + PaintingManager.File.Name;
        }
예제 #3
0
파일: MenuHelper.cs 프로젝트: p3k1/FPPaint
        public static void ExitActions(MainWindow mainWindow)
        {
            if (PaintingManager.File.IsModified)
            {
                DialogResult result = MessageBox.Show("File was changed. Do you want to save it?", "Question", MessageBoxButtons.YesNoCancel,
                                MessageBoxIcon.Question);
                if (result == DialogResult.Cancel)
                    return;
                if (result == DialogResult.Yes)
                    if (!PaintingManager.File.SaveFile(PaintingManager.Page.Picture))
                        return;

            }
            mainWindow.Close();
            Application.Exit();
        }
예제 #4
0
        /// <summary>
        /// Creates color palette.
        /// </summary>
        /// <param name="MainWindow">Window to create palette on.</param>
        public static void CreatePalette(MainWindow MainWindow)
        {
            for (int i = 0; i < ColorList.GetLength(0); i++)
            {
                var ToAdd = new Button();
                ToAdd.BackColor = ColorList[i];
                ToAdd.Size = new Size(35, 35);
                ToAdd.Location = new Point(20 + (i % 2) * 40, 300 + 30 * (i - (i % 2)));
                ToAdd.MouseUp += (sender, args) =>
                {
                    if (args.Button == MouseButtons.Left)
                    {
                        MainWindow.PrimaryColorProp.BackColor = MainWindow.PaintingManager.CurrentTool.PrimaryColor = ((Button)sender).BackColor;
                        return;
                    }
                    if (args.Button == MouseButtons.Right)
                    {
                        MainWindow.SecondaryColorProp.BackColor = MainWindow.PaintingManager.CurrentTool.SecondaryColor = ((Button)sender).BackColor;
                    }
                };
                MainWindow.ToolsAndColorsProp.Controls.Add(ToAdd);

            }
        }
예제 #5
0
파일: MenuHelper.cs 프로젝트: p3k1/FPPaint
 public static void Rotate(MainWindow mainWindow, RotateFlipType type)
 {
     PaintingManager.Page.PrepareToPaint();
     PaintingManager.Page.Rotate(type);
     //int tmpWidth = mainWindow.PictureProp.Width;
     mainWindow.PictureProp.Width = PaintingManager.Page.Picture.Width;
     mainWindow.PictureProp.Height = PaintingManager.Page.Picture.Height;
     mainWindow.PictureProp.Refresh();
 }
예제 #6
0
파일: MenuHelper.cs 프로젝트: p3k1/FPPaint
 public static void Redo(MainWindow mainWindow)
 {
     PaintingManager.Page.Redo();
     mainWindow.PictureProp.Width = PaintingManager.Page.Picture.Width;
     mainWindow.PictureProp.Height = PaintingManager.Page.Picture.Height;
     mainWindow.PictureProp.Image = PaintingManager.Page.Picture;
 }