Example #1
0
        /// <summary>
        /// Добавление нового редактора
        /// </summary>
        /// <param name="editor">Редактор</param>
        public static void AddEditor(BaseForm editor)
        {
            if (Editors != null)
            {
                if (Editors.Contains(editor))
                {
                    return;
                }
            }

            TabPage p = new TabPage(editor.Name);

            p.Tag = (object)editor;

            editor.FormBorderStyle = FormBorderStyle.None;
            editor.Dock            = DockStyle.Fill;
            editor.TopLevel        = false;
            editor.TextChanged    += delegate(object sender, EventArgs e) {
                p.Text = ((BaseForm)sender).Text;
            };
            p.Controls.Add(editor);
            editor.Show();
            W.projectTabs.AddTab(p, true);

            List <BaseForm> edlist = Editors != null?Editors.ToList() : new List <BaseForm>();

            edlist.Add(editor);
            Editors = edlist.ToArray();
        }
        private bool CloseProject()
        {
            if (Editors.Any(p => p.IsDirty))
            {
                var result = TaskDialogEx.Show(this, "Do you want to save your changes?", Text, TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No | TaskDialogCommonButtons.Cancel, TaskDialogIcon.Warning);

                switch (result)
                {
                case DialogResult.Yes:
                    if (Editors.Any(p => !p.Save()))
                    {
                        return(false);
                    }
                    break;

                case DialogResult.Cancel:
                    return(false);
                }
            }

            foreach (var editor in Editors.ToList())
            {
                editor.Close(true);
            }

            Project = null;

            return(true);
        }
Example #3
0
        public void AddFiles(int index, params string[] paths)
        {
            var editors = Editors.ToList();

            // Adds distinct paths at specified index
            for (int i = 0; i < paths.Length; i++)
            {
                editors.Insert(i + index, new EditorInfo(HighlightingLanguage.None, paths[i]));
            }

            Editors = editors.ToArray();
        }
Example #4
0
        /// <summary>
        /// Открытие редактора для файла
        /// </summary>
        /// <param name="e">Файл</param>
        public static Editor OpenEditor(Project.Entry e)
        {
            if (W != null)
            {
                bool found = false;
                if (Editors != null)
                {
                    foreach (BaseForm frm in Editors)
                    {
                        if (frm.FileEditor.File == e)
                        {
                            W.projectTabs.SelectedTab = frm.Tag as TabPage;
                            found = true;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    Editor ed = Editor.Create(e);
                    if (ed != null)
                    {
                        TabPage p = new TabPage(ed.Title);
                        p.Tag       = (object)ed.Form;
                        ed.Form.Tag = (object)p;

                        ed.Form.FormBorderStyle = FormBorderStyle.None;
                        ed.Form.Dock            = DockStyle.Fill;
                        ed.Form.TopLevel        = false;
                        ed.Form.TextChanged    += delegate(object sender, EventArgs ea) {
                            p.Text = ((BaseForm)sender).Text;
                        };
                        p.Controls.Add(ed.Form);
                        ed.Form.Show();
                        W.projectTabs.AddTab(p, true);

                        List <BaseForm> edlist = Editors != null?Editors.ToList() : new List <BaseForm>();

                        edlist.Add(ed.Form);
                        Editors = edlist.ToArray();

                        return(ed);
                    }
                    else
                    {
                        MessageDialog.Show(ControlStrings.EditorNotFoundTitle, ControlStrings.EditorNotFoundText.Replace("%FILE%", e.Name), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            return(null);
        }
Example #5
0
        /// <summary>
        /// Закрытие таба
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void projectTabs_TabClose(object sender, NSProjectControl.TabCloseEventArgs e)
        {
            TabPage p = e.Page;

            SpriteBoy.Events.Forms.EditorCloseEventArgs ev = new Events.Forms.EditorCloseEventArgs()
            {
                Cancel = false
            };
            BaseForm f = (BaseForm)p.Tag;

            e.Cancel = !f.FileEditor.AllowClose();
            if (!e.Cancel)
            {
                if (Editors != null)
                {
                    if (Editors.Length != 0)
                    {
                        List <BaseForm> edlist = Editors.ToList();
                        edlist.Remove(e.Page.Tag as BaseForm);
                        Editors = edlist.ToArray();
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Закрытие редактора
        /// </summary>
        /// <param name="e">Редактор который необходимо закрыть</param>
        public static bool CloseEditor(Editor e, bool force = false)
        {
            if (Editors != null)
            {
                if (!Editors.Contains(e.Form))
                {
                    return(true);
                }
            }
            bool close = true;

            if (!force)
            {
                close = e.AllowClose();
            }

            if (close)
            {
                TabPage tp = null;
                foreach (TabPage t in W.projectTabs.TabPages)
                {
                    if (tp.Tag == (object)e.Form)
                    {
                        tp = t;
                        break;
                    }
                }
                if (tp != null)
                {
                    W.projectTabs.RemoveTab(tp);
                    List <BaseForm> edlist = Editors == null ? new List <BaseForm>() : Editors.ToList();
                    if (edlist.Contains(e.Form))
                    {
                        edlist.Remove(e.Form);
                    }
                    Editors = edlist.ToArray();
                }
            }
            return(close);
        }