コード例 #1
0
        public mainForm()
        {
            InitializeComponent();



            bmap     = new Bitmap(picture.Width, picture.Height);
            graphics = Graphics.FromImage(bmap);

            RefreshPlugins();

            RefreshPluginsFactory();

            try
            {
                XDocument xdoc  = XDocument.Load("configuration.xml");
                string    theme = "-1";
                string    lang  = "-1";
                foreach (XElement configElement in xdoc.Element("configurations").Elements("config"))
                {
                    lang  = configElement.Element("language").Value;
                    theme = configElement.Element("theme").Value;
                }

                ts_cmb.SelectedIndex     = Convert.ToInt32(lang, 10);
                cmb_themes.SelectedIndex = currentTheme = Convert.ToInt32(theme, 10);
            }
            catch (Exception ex)
            {
                MessageBox.Show(message, title_mess, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            configIsChanged = false;

            CustomFigure.OpenCustomFigures(cmb_custom_figures, allFabrics);
        }
コード例 #2
0
        private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (configIsChanged)
            {
                DialogResult result = MessageBox.Show(saveMsg, saveMsg_title,
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Information,
                                                      MessageBoxDefaultButton.Button1,
                                                      MessageBoxOptions.DefaultDesktopOnly);

                if (result == DialogResult.Yes)
                {
                    XDocument xdoc = new XDocument(new XElement("configurations",
                                                                new XElement("config",
                                                                             new XAttribute("name", "userConfig"),
                                                                             new XElement("language", ts_cmb.SelectedIndex),
                                                                             new XElement("theme", currentTheme))));
                    xdoc.Save("configuration.xml");
                }
            }

            if (customFigureIsChange)
            {
                if (CustomFigure.savedFigures.Count >= 0)
                {
                    CustomFigure.SavingCustomFigures();
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: VictoriaMasilevich/OOP-7
 public mainForm()
 {
     InitializeComponent();
     bmap     = new Bitmap(picture.Width, picture.Height);
     graphics = Graphics.FromImage(bmap);
     CustomFigure.OpenCustomFigures(cmb_custom_figures, allFabrics);
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: VictoriaMasilevich/OOP-7
 private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (customFigureIsChange)
     {
         if (CustomFigure.savedFigures.Count > 0)
         {
             CustomFigure.SavingCustomFigures();
         }
     }
 }
コード例 #5
0
 private void btn_add_custom_figure_Click(object sender, EventArgs e)
 {
     if (figureList.Count <= 1)
     {
         MessageBox.Show("One or less figures can not be customized", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         customFigureIsChange = true;
         CustomFigure.AddCustomFigure(currentFabrics, figureList, cmb_custom_figures);
     }
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: VictoriaMasilevich/OOP-7
 private void btn_add_custom_figure_Click(object sender, EventArgs e)
 {
     if (figureList.Count <= 1)
     {
         MessageBox.Show("Нарисуйте больше одной фигуры", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         customFigureIsChange = true;
         CustomFigure.AddCustomFigure(currentFabrics, figureList, cmb_custom_figures);
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: VictoriaMasilevich/OOP-7
 private void btn_delete_custom_figure_Click(object sender, EventArgs e)
 {
     if (cmb_custom_figures.SelectedIndex >= 0)
     {
         customFigureIsChange = true;
         CustomFigure.DeleteCustomFigure(cmb_custom_figures.SelectedIndex, cmb_custom_figures);
     }
     else
     {
         MessageBox.Show("Выберите фигуру", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #8
0
 private void btn_delete_custom_figure_Click(object sender, EventArgs e)
 {
     if (cmb_custom_figures.SelectedIndex >= 0)
     {
         customFigureIsChange = true;
         CustomFigure.DeleteCustomFigure(cmb_custom_figures.SelectedIndex, cmb_custom_figures);
         //cmb_custom_figures.Items.RemoveAt(cmb_custom_figures.SelectedIndex);
     }
     else
     {
         MessageBox.Show("Please, pick any custom figure in the combobox", "Woops...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #9
0
ファイル: Form1.cs プロジェクト: VictoriaMasilevich/OOP-7
 private void picture_MouseDown(object sender, MouseEventArgs e)
 {
     if (cmb_custom_figures.SelectedIndex >= 0)
     {
         int index = cmb_custom_figures.SelectedIndex;
         CustomFigure.DrawCustomFigure(index, graphics, e.Location);
         picture.Invalidate();
         picture.Image = bmap;
     }
     else
     {
         if (cb_figures.SelectedIndex >= 0)
         {
             isDrawing = true;
             start     = new Point(e.X, e.Y);
             figure    = maker.FactoryMethod(fatness, color, start, start);
             currentFabrics.Add(maker);
         }
     }
 }
コード例 #10
0
        private void picture_MouseDown(object sender, MouseEventArgs e)
        {
            if (isEdit)
            {
            }
            else
            {
                if (cmb_custom_figures.SelectedIndex >= 0)
                {
                    int index = cmb_custom_figures.SelectedIndex;
                    figuresExs = new List <MainFigure>(CustomFigure.DrawCustomFigure(index, graphics, e.Location));
                    int i = 0;
                    foreach (var figure in figuresExs)
                    {
                        jsonList.Add(new InfoForJSON()
                        {
                            fatness = figure.fatness, color = figure.color, topLeft = figure.topLeft, bottomRight = figure.bottomRight, figureName = CustomFigure.fabrics[index][i].ToString()
                        });
                        i++;
                    }

                    picture.Invalidate();
                    picture.Image = bmap;
                }
                else
                {
                    if (cb_figures.SelectedIndex >= 0)
                    {
                        isDrawing = true;
                        start     = new Point(e.X, e.Y);
                        figure    = maker.FactoryMethod(fatness, color, start, start);
                        currentFabrics.Add(maker);
                    }
                }
            }
        }