예제 #1
0
        public void SetNoteEditorBackColor()
        {
            bool result = true;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                MetaModel.MetaModel.Initialize();
                var persistence = new PersistenceManager();
                var noteEditor = new NoteEditor();

                var form = CreateForm();
                form.Controls.Add(noteEditor);
                form.Shown += (sender, args) =>
                {
                    var ptree1 = persistence.NewTree();
                    var c1 = new MapNode(ptree1.Tree.RootNode, "c1");
                    c1.Selected = true;

                    var sut = new NoteEditorCtrl(noteEditor, persistence);
                    sut.SetNoteEditorBackColor(Color.Azure);

                    result = noteEditor.BackColor.Equals(Color.Azure);

                    form.Close();
                };

                form.ShowDialog();
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result);
        }
예제 #2
0
        void mainForm_Load(object sender, EventArgs e)
        {
            MapTree tree;

            if (MetaModel.MetaModel.Instance.LastOpenedFile == null)
            {
                tree = PersistenceManager.NewTree().Tree;
            }
            else
            {
                try
                {
                    tree = PersistenceManager.OpenTree(MetaModel.MetaModel.Instance.LastOpenedFile).Tree;
                }
                catch (Exception exp)
                {
                    tree = PersistenceManager.NewTree().Tree;
                    MetaModel.MetaModel.Instance.LastOpenedFile = null;
                    System.Diagnostics.Trace.TraceWarning(DateTime.Now.ToString() + ": Couldn't load last opened file. " + exp.Message);
                }
            }

            noteCrtl = new NoteEditorCtrl(mainForm.NoteEditor, PersistenceManager);

            pluginManager.InitializeContextMenu(NodeContextMenu);

            new ContextMenuCtrl(this, NodeContextMenu);

            pluginManager.InitializeSideBarWindow(mainForm.SideBarTabs);

            pluginManager.InitializeMainMenu(mainForm);

            mainForm.NoteEditor.OnDirty += (a) => {
                if (PersistenceManager.CurrentTree != null)
                {
                    PersistenceManager.CurrentTree.IsDirty = true;
                }
            };     // register for NoteEditor changes

            mainForm.FormClosing += mainForm_FormClosing;
        }
예제 #3
0
        void mainForm_Load(object sender, EventArgs e)
        {
            MapTree tree;

            if (MetaModel.MetaModel.Instance.LastOpenedFile == null)
            {
                tree = PersistenceManager.NewTree().Tree;
            }
            else
            {
                try
                {
                    tree = PersistenceManager.OpenTree(MetaModel.MetaModel.Instance.LastOpenedFile).Tree;
                }
                catch(Exception exp)
                {
                    tree = PersistenceManager.NewTree().Tree;
                    MetaModel.MetaModel.Instance.LastOpenedFile = null;
                    System.Diagnostics.Trace.TraceWarning(DateTime.Now.ToString() + ": Couldn't load last opened file. " + exp.Message);
                }
            }

            noteCrtl = new NoteEditorCtrl(mainForm.NoteEditor, PersistenceManager);

            pluginManager.InitializeContextMenu(NodeContextMenu);

            new ContextMenuCtrl(this, NodeContextMenu);

            pluginManager.InitializeSideBarWindow(mainForm.SideBarTabs);

            pluginManager.InitializeMainMenu(mainForm);

            mainForm.NoteEditor.OnDirty += (a) => {
                if(PersistenceManager.CurrentTree != null)
                {
                    PersistenceManager.CurrentTree.IsDirty = true;
                }
                }; // register for NoteEditor changes

            mainForm.FormClosing += mainForm_FormClosing;
        }
예제 #4
0
파일: MainCtrl.cs 프로젝트: xtuzy/MindMate
        void mainForm_Load(object sender, EventArgs e)
        {
            MapTree tree;

            string fileArg = ProgramMainHelper.GetFileToOpenFromAppArguments(mainForm);

            if (fileArg != null)
            {
                try
                {
                    tree = PersistenceManager.OpenTree(fileArg);
                }
                catch (Exception exp)
                {
                    tree = PersistenceManager.NewTree();
                    MetaModel.MetaModel.Instance.LastOpenedFile = null;
                    Log.Write("Couldn't load the file provided in application argument. " + exp.Message);
                }
            }
            else if (MetaModel.MetaModel.Instance.LastOpenedFile == null)
            {
                tree = PersistenceManager.NewTree();
            }
            else
            {
                try
                {
                    tree = PersistenceManager.OpenTree(MetaModel.MetaModel.Instance.LastOpenedFile);
                }
                catch (Exception exp)
                {
                    tree = PersistenceManager.NewTree();
                    MetaModel.MetaModel.Instance.LastOpenedFile = null;
                    Log.Write("Couldn't load last opened file. " + exp.Message);
                }
            }

            noteCrtl = new NoteEditorCtrl(mainForm.NoteEditor, PersistenceManager, Dialogs);

            pluginManager.InitializeContextMenu(NodeContextMenu);

            new ContextMenuCtrl(this, NodeContextMenu);

            pluginManager.InitializeSideBarWindow(mainForm.SideBarTabs);

            pluginManager.InitializeMainMenu(mainForm);

            mainForm.NoteEditor.OnDirty += (a) => {
                if (PersistenceManager.CurrentTree != null)
                {
                    PersistenceManager.CurrentTree.IsDirty = true;
                }
            };     // register for NoteEditor changes

            mainForm.NoteEditor.OnSave += (obj) =>
            {
                if (this.PersistenceManager.CurrentTree.IsNewMap)
                {
                    // bug fix: if the map is new and following call will trigger a file save dialog, we have to do it through a separate thread to avoid 'S' being written in the note editor
                    Action action = () => SaveCurrentMap();
                    this.schedular.AddTask(() => ((Control)mainForm).Invoke(action), DateTime.Now);
                }
                else
                {
                    SaveCurrentMap();
                }
            };

            mainForm.FormClosing += mainForm_FormClosing;
        }
예제 #5
0
        public void ShowHtmlSourceDialog()
        {
            string result = null;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                MetaModel.MetaModel.Initialize();
                var persistence = new PersistenceManager();
                var noteEditor = new NoteEditor();

                var form = CreateForm();
                form.Controls.Add(noteEditor);
                form.Shown += (sender, args) =>
                {
                    var ptree1 = persistence.NewTree();
                    var c1 = new MapNode(ptree1.Tree.RootNode, "c1");
                    c1.NoteText = "This is a note.";
                    c1.Selected = true;

                    var sut = new NoteEditorCtrl(noteEditor, persistence);
                    Debugging.FormDebugHooks.Instance.ProvideShownEventHook((o, e) => {
                        var f = (HtmlSourceDialog)o;
                        foreach(Control c in f.Controls)
                        {
                            if(c.Name == "txtSource")
                            {
                                c.Text = "updated";
                                break;
                            }
                        }
                        f.DialogResult = DialogResult.OK;
                    });

                    sut.ShowHtmlSourceDialog();

                    result = noteEditor.HTML;

                    form.Close();
                    Debugging.FormDebugHooks.Instance.ClearHook();
                };

                form.ShowDialog();
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual("updated", result);
        }