Esempio n. 1
0
 public static Size? GetSize(Size? size)
 {
     var form = new SelectSizeForm();
     if (size != null)
     {
         form.controlWidth.Value = size.Value.Width;
         form.controlHeight.Value = size.Value.Height;
     }
     else
     {
         form.controlWidth.Value = 40;
         form.controlHeight.Value = 30;
     }
     var res = form.ShowDialog();
     if (res != DialogResult.OK)
         return null;
     return new Size((int) form.controlWidth.Value, (int) form.controlHeight.Value);
 }
Esempio n. 2
0
        public static Size?GetSize(Size?size)
        {
            var form = new SelectSizeForm();

            if (size != null)
            {
                form.controlWidth.Value  = size.Value.Width;
                form.controlHeight.Value = size.Value.Height;
            }
            else
            {
                form.controlWidth.Value  = 40;
                form.controlHeight.Value = 30;
            }
            var res = form.ShowDialog();

            if (res != DialogResult.OK)
            {
                return(null);
            }
            return(new Size((int)form.controlWidth.Value, (int)form.controlHeight.Value));
        }
Esempio n. 3
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (!editorMode)
            {
                SaveCurrent();
            }
            //TODO need cortage
            var newCross = CrossChoiceForm.SelectCross(Settings.Default.LastDir);

            if (newCross == null)
            {
                return;
            }

            switch (newCross.Length)
            {
            case 1:
            {
                var size = SelectSizeForm.GetSize(null);
                if (size == null)
                {
                    return;
                }
                var newDir = newCross[0];
                cross = new Cross(size.Value.Width, size.Value.Height);
                Settings.Default.LastDir  = newDir;
                Settings.Default.LastFile = "";
                Settings.Default.Save();
                editorMode = true;
                break;
            }

            case 2:
            {
                var newDir  = newCross[0];
                var newFile = newCross[1];
                try
                {
                    cross = CrossIO.Import(newDir, newFile);
                }
                catch (Exception)
                {
                    MessageBox.Show(Localization.GetLocalName("ERROR_IO"));
                }
                Settings.Default.LastDir  = newDir;
                Settings.Default.LastFile = newFile;
                Settings.Default.Save();
                editorMode = false;
                break;
            }

            case 3:
            {
                var newDir  = newCross[0];
                var newFile = newCross[1];
                try
                {
                    cross = CrossIO.ImportEditor(newFile);
                }
                catch (Exception)
                {
                    MessageBox.Show(Localization.GetLocalName("ERROR_IO"));
                }
                Settings.Default.LastDir  = newDir;
                Settings.Default.LastFile = newFile;
                Settings.Default.Save();
                editorMode = true;
                break;
            }
            }
            UpdateSize();
            UpdateBtnState();
            cross.CheckLines();
            panelCross.Invalidate();
        }