/// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <returns> TODO need refactoring
        /// null - cancel,
        /// couple values - load dir\file,
        /// single value - open editor with new empty user cross in dir
        /// triple values - edit exists user cross
        ///</returns>
        public static string[] SelectCross(string path)
        {
            var form = new CrossChoiceForm
            {
                currentDir = path?.Split(new[] {'\\', '/'}, StringSplitOptions.RemoveEmptyEntries)[0]
            };
            var res = form.ShowDialog();

            //TODO need refactoring
            switch (res)
            {
                case DialogResult.OK:
                    return new[] {form.currentDir, form.currentFile};
                case DialogResult.Yes:
                    return new[] {form.currentDir};
                case DialogResult.No:
                    return new[] { form.currentDir, form.currentFile, "EdiorMode" };
                default:
                    return null;
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <returns> TODO need refactoring
        /// null - cancel,
        /// couple values - load dir\file,
        /// single value - open editor with new empty user cross in dir
        /// triple values - edit exists user cross
        ///</returns>
        public static string[] SelectCross(string path)
        {
            var form = new CrossChoiceForm
            {
                currentDir = path?.Split(new[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries)[0]
            };
            var res = form.ShowDialog();

            //TODO need refactoring
            switch (res)
            {
            case DialogResult.OK:
                return(new[] { form.currentDir, form.currentFile });

            case DialogResult.Yes:
                return(new[] { form.currentDir });

            case DialogResult.No:
                return(new[] { form.currentDir, form.currentFile, "EdiorMode" });

            default:
                return(null);
            }
        }
Example #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();
        }