Exemplo n.º 1
0
        public NoteNavigation(NoteDataXML_RichText richText)
        {
            RichText = richText;
            MenuItem refreshMenu = new MenuItem();
            refreshMenu.Text = Loc.Instance.GetString ("Refresh");
            refreshMenu.Click+= HandleRefreshMenuClick;

            goTo = new MenuItem();
            goTo.Text = Loc.Instance.GetString("Go here");
            goTo.Enabled = false;
            goTo.Click+= HandleGoToClick;

            widen = new MenuItem();
            widen.Text = Loc.Instance.GetString("Widen");
            widen.Enabled = true;
            widen.Click+= HandleWidenClick;

            clipboard = new MenuItem();
            clipboard.Text = Loc.Instance.GetString("Clipboard");
            clipboard.Enabled = true;
            clipboard.Click+= HandleClipboardClick;

            Menu.MenuItems.Add (refreshMenu);
            Menu.MenuItems.Add (goTo);
            Menu.MenuItems.Add (widen);
            Menu.MenuItems.Add (clipboard);
            //	this.NodeMouseClick += HandleNodeMouseClick;
            this.ContextMenu = Menu;
            Menu.Popup+= HandlePopup;
            this.ShowNodeToolTips = false;

            this.DrawMode = TreeViewDrawMode.OwnerDrawText;
            this.DrawNode+= HandleDrawNode;
        }
Exemplo n.º 2
0
        public NoteNavigation(NoteDataXML_RichText richText)

        {
            RichText = richText;
            MenuItem refreshMenu = new MenuItem();

            refreshMenu.Text   = Loc.Instance.GetString("Refresh");
            refreshMenu.Click += HandleRefreshMenuClick;

            goTo         = new MenuItem();
            goTo.Text    = Loc.Instance.GetString("Go here");
            goTo.Enabled = false;
            goTo.Click  += HandleGoToClick;

            widen         = new MenuItem();
            widen.Text    = Loc.Instance.GetString("Widen");
            widen.Enabled = true;
            widen.Click  += HandleWidenClick;


            clipboard         = new MenuItem();
            clipboard.Text    = Loc.Instance.GetString("Clipboard");
            clipboard.Enabled = true;
            clipboard.Click  += HandleClipboardClick;

            Menu.MenuItems.Add(refreshMenu);
            Menu.MenuItems.Add(goTo);
            Menu.MenuItems.Add(widen);
            Menu.MenuItems.Add(clipboard);
            //	this.NodeMouseClick += HandleNodeMouseClick;
            this.ContextMenu      = Menu;
            Menu.Popup           += HandlePopup;
            this.ShowNodeToolTips = false;

            this.DrawMode  = TreeViewDrawMode.OwnerDrawText;
            this.DrawNode += HandleDrawNode;
        }
        public void SaveNotequired()
        {
            _setupforlayoutests ();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout ("testguid", true, null);
            NoteDataXML_RichText note = new NoteDataXML_RichText ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                //note.UpdateLocation();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            // cannot actually save becaue LayoutPanel is just fake for this test
            // but we check that the flag was set correclty -- i..e, nothing improtant changes, nothing needs tob e saved
            //	layout.SaveTo();
            //layoutPanel.SaveLayout();

            // April 2013 - This test was flagged as Assert.False but I don't understand
            // We WANT the flag to say we need a save, no?
            Assert.True (layoutPanel.GetSaveRequired);
        }
        public void CountSpecificSubType()
        {
            //-- do unit tests counting store 6 textboxes and know this (countbytype)

            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            int count = 25;
            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);

            // jan152013 - tweak to allow this to work with new system without rewriting all the tstings in LayoutDatabasetest
            LayoutDatabase layout = layoutPanel.GetLayoutDatabase();

            form.Controls.Add (layoutPanel);
            form.Show ();

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layout.Add (note);
                note.CreateParent(layoutPanel);
            }
            _w.output (String.Format ("{0} Notes in Layout before save", layout.GetNotes ().Count.ToString ()));

            for (int i = 0; i < 6; i++) {
                note = new NoteDataXML_RichText ();

                note.Caption = "richText";
                layout.Add (note);
                note.CreateParent(layoutPanel);
            }

            layout.SaveTo();

            //	_w.output(String.Format ("{0} Objects Saved", layout.ObjectsSaved().ToString()));
            layout = new FakeLayoutDatabase ("testguid");

            layout.LoadFrom(layoutPanel);

            // now count RichText notes
            int count2 = 0;
            foreach (NoteDataInterface _note in layout.GetNotes ())
            {
                if (_note.GetType() == typeof(NoteDataXML_RichText))
                    {
                    count2++;
                }

                }

            _w.output(String.Format ("{0} Objects Loaded", layout.GetNotes().Count));

            // added linktable
            Assert.AreEqual (7, count2);
        }
        /// <summary>
        /// Builds the list. for the bookmark system
        /// </summary>
        /// <returns>
        /// The list.
        /// </returns>
        /// <param name='RichText'>
        /// Rich text.
        /// </param>
        public List<TreeItem> BuildList(NoteDataXML_RichText RichText)
        {
            System.Text.RegularExpressions.Regex Mainheading = new System.Text.RegularExpressions.Regex ("^=[^=]+=$",
                                                                                                         RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.Multiline);
            System.Text.RegularExpressions.Regex Mainheading2 = new System.Text.RegularExpressions.Regex ("^==[^=]+==$",
                                                                                                          RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.Multiline);
            System.Text.RegularExpressions.Regex Mainheading3 = new System.Text.RegularExpressions.Regex ("^===[^=]+===$",
                                                                                                          RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.Multiline);

            System.Text.RegularExpressions.Regex Mainheading4 = new System.Text.RegularExpressions.Regex ("^====[^=]+====$",
                                                                                                          RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.Multiline);

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex ("\\[\\[~(.*?)\\]\\]",
                                                                                                   System.Text.RegularExpressions.RegexOptions.IgnoreCase |
                                                                                                   System.Text.RegularExpressions.RegexOptions.Multiline);

            //TODO: Move this into the MarkupLanguage
            List<TreeItem> items = new List<TreeItem> ();

            //For [ ] text
            System.Text.RegularExpressions.MatchCollection matches = regex.Matches (RichText.GetRichTextBox().Text, 0);
            foreach (System.Text.RegularExpressions.Match match in matches) {
                string value = match.Value;
                if (value.IndexOf("~var") > -1)
                {
                    // December 2013
                    // we don't show variable text.
                }
                else
                {
                    items.Add (new TreeItem(match.Value, 0,match.Index));
                }
            }

             matches = Mainheading.Matches (RichText.GetRichTextBox().Text, 0);

            foreach (System.Text.RegularExpressions.Match match in matches) {
                items.Add (new TreeItem(match.Value.Replace ("=",""), 0,match.Index));
            }
            matches = Mainheading2.Matches (RichText.GetRichTextBox().Text, 0);

            foreach (System.Text.RegularExpressions.Match match in matches) {
                items.Add (new TreeItem(match.Value.Replace ("=",""), 1,match.Index));
            }
            matches = Mainheading3.Matches (RichText.GetRichTextBox().Text, 0);
            foreach (System.Text.RegularExpressions.Match match in matches) {
                items.Add (new TreeItem(match.Value.Replace ("=",""), 2,match.Index));
            }

            matches = Mainheading4.Matches (RichText.GetRichTextBox().Text, 0);
            foreach (System.Text.RegularExpressions.Match match in matches) {
                items.Add (new TreeItem(match.Value.Replace ("=",""), 3,match.Index));
            }

            //need to somehow merge and sort by index
            // need to a custom fort
            items.Sort ();

            return items;
        }
Exemplo n.º 6
0
 public abstract void SetCurrentTextNote(NoteDataXML_RichText note);
        public void CopyNoteTest()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            System.Windows.Forms .Form form = new System.Windows.Forms.Form();

            FAKE_LayoutPanel panelToUse = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);

            form.Controls.Add (panelToUse);

            // needed else DataGrid does not initialize

            form.Show ();
            //form.Visible = false;
            _w.output("boom");
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form,null);

            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();
            panelToUse.NewLayout (panelname,true, null);
            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            _w.output ("herefirst");

            Timer SaveTimer= new Timer();
            SaveTimer.Interval = 300;
            SaveTimer.Tick+= HandleSaveTimerTick;
            SaveTimer.Start ();

            // ADD 1 of each type
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) {
                for (int i = 0; i < 2; i++) {
                    NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t);
                    panelToUse.AddNote (note);
                    note.CreateParent(panelToUse);

                    note.UpdateAfterLoad();
                    panelToUse.CopyNote(note);
                    panelToUse.PasteNote();
                }
            }
            panelToUse.SaveLayout();
            //int propercount= 4 * LayoutDetails.Instance.ListOfTypesToStoreInXML().Length;
            Assert.AreEqual (46, panelToUse.CountNotes());

            //
            // Now we test pasting one of our notes onto another Layout
            //

            string panelname2 = System.Guid.NewGuid().ToString();
            FAKE_LayoutPanel  PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout (panelname2,true, null);
            PanelOtherGuy.SaveLayout();

            form.Controls.Add(PanelOtherGuy);

            Assert.AreEqual( 2, PanelOtherGuy.CountNotes(), "count1");

            // ADD 1 of each type
            //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                for (int i = 0; i < 10; i++) {

                    NoteDataInterface note = new NoteDataXML_RichText();
                    PanelOtherGuy.AddNote (note);
                    note.CreateParent(PanelOtherGuy);

                    note.UpdateAfterLoad();

                }
            }
            Assert.AreEqual( 12, PanelOtherGuy.CountNotes(), "count2");
            PanelOtherGuy.PasteNote();
            Assert.AreEqual( 13, PanelOtherGuy.CountNotes(), "count2");
            PanelOtherGuy.SaveLayout();

            FAKE_NoteDataXML_Text Noter = new FAKE_NoteDataXML_Text();
            Noter.Caption ="Hello there";

            PanelOtherGuy.AddNote (Noter);

            Noter.GetRichTextBox().Text ="bear";
            PanelOtherGuy.SaveLayout ();

            PanelOtherGuy.CopyNote(Noter);
            NoteDataXML_RichText CopyOfTextNote = (NoteDataXML_RichText)PanelOtherGuy.PasteNote();
            Assert.AreEqual ("Hello there",CopyOfTextNote.Caption);
            Assert.AreEqual ("bear", CopyOfTextNote.GetRichTextBox().Text);

            //
            //
            // Table Copy Test
            //
            //

            NoteDataXML_Table randomTables = new NoteDataXML_Table(100, 100,new ColumnDetails[2]{new ColumnDetails("id",100), new ColumnDetails("tables",100)} );
            randomTables.Caption = LayoutDetails.SYSTEM_RANDOM_TABLES;
            //	randomTables.Columns = new appframe.ColumnDetails[2]{new appframe.ColumnDetails("id",100), new appframe.ColumnDetails("tables",100)};

            PanelOtherGuy.AddNote(randomTables);
            //randomTables.CreateParent(PanelOtherGuy);

            randomTables.AddRow(new object[2]{"1", "example|colors"});
            randomTables.AddRow(new object[2]{"2", "example|colorPROMPTS"});
            PanelOtherGuy.SaveLayout ();

            PanelOtherGuy.CopyNote(randomTables);
            NoteDataXML_Table CopyOfTable = (NoteDataXML_Table)PanelOtherGuy.PasteNote();
            Assert.AreEqual (2, CopyOfTable.RowCount());
        }
        public void MoveNoteOutOfParent_SaveShouldHappenAutomatically()
        {
            _w.output ("START");
                System.Windows.Forms .Form form = new System.Windows.Forms.Form ();
                _TestSingleTon.Instance._SetupForLayoutPanelTests ();

                FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);

            LayoutDetails.Instance.CurrentLayout = panel;
                form.Controls.Add (panel);
                form.Show ();

                //NOTE: For now remember that htis ADDS 1 Extra notes
                panel.NewLayout ("mynewpanel", true, null);
            panel.SetCaption("TheMainPanel");
                NoteDataXML basicNote = new NoteDataXML ();
                basicNote.Caption = "note1";

                panel.AddNote (basicNote);
                //basicNote.CreateParent(panel);

                //panel.MoveNote(
                // create four panels A and B at root level. C inside A. D inside C
                FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
                panelA.Caption = "PanelA";
                panelA.GuidForNote = "panela";
                FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel ();
                panelB.Caption = "PanelB";
                panelB.GuidForNote = "panelb";
                FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel ();
                panelC.Caption = "PanelC";
                panelC.GuidForNote = "panelc";

                _w.output ("panels made");

                panel.AddNote (panelA);  // 1

                panel.AddNote (panelB);  // 2
                //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it

                basicNote = new NoteDataXML ();
                basicNote.Caption = "note2";

                panelA.AddNote (basicNote);  // Panel A has 1 note
                basicNote.CreateParent (panelA.myLayoutPanel ());  // DO need to call it when adding notes like this (to a subpanel, I think)
            basicNote.BringToFrontAndShow();
            NoteDataXML_RichText textNote = new NoteDataXML_RichText();
            textNote.Caption = "howdy";
            //	((FAKE_LayoutPanel)panelA.GetPanelsLayout()).SetCaption("boohowcrashmenow");
            panelA.AddNote (textNote);
            textNote.CreateParent(panelA.myLayoutPanel());

            textNote.BringToFrontAndShow();
            textNote.TestEnter ();
            panelA.GetPanelsLayout().TestForceError();
            // the current layout can never be set to a subplayout
            Assert.AreNotEqual(panelA.GetPanelsLayout(), LayoutDetails.Instance.CurrentLayout, "the current layout can never be set to a subplayout");
                panel.SaveLayout ();
                Assert.AreEqual (2, panelA.CountNotes (), "Panel A holds TWo note");  // So this counts as  + 2

                // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6
                _w.output ("STARTCOUNT");
                Assert.AreEqual (7, panel.CountNotes (), "Total notes SHOULD BE 7 :  (1 + 1 note on it)panel A + (1+1textnote)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

                _w.output ("ENDCOUNT");

                // now we move basicNote out
                // WITOUT calling save  ****
                // it should still ahve saved

            panelA.myLayoutPanel ().MoveNote(basicNote.GuidForNote, "up");
            Assert.AreEqual (1, panelA.CountNotes (), "Panel A holds 1 note -- because we moved one out");
            Assert.AreEqual (7, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");
            panel = null;
            panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            panel.LoadLayout("mynewpanel", false, null);
            //Assert.AreEqual (0, panelA.CountNotes (), "Panel A holds one note");
            Assert.AreEqual (7, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");
        }
Exemplo n.º 9
0
        public void TestRemoteFactParse()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            LayoutDetails.Instance.AddToList(typeof(ADD_Facts.NoteDataXML_Facts), "factsfromtest");

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            //
            // #1 - Creating SOURCE layout
            //

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            panel.SetCaption("SourcePanel");
            Assert.AreEqual("SourcePanel", panel.Caption);

            NoteDataXML_RichText basicNote = new NoteDataXML_RichText();
            basicNote.GuidForNote = "chapter1";
            basicNote.Caption = "chapter1";

            panel.AddNote(basicNote);
            basicNote.CreateParent(panel);
            basicNote.SelectedText = "The dog runs[[dog]] fast.\n\t But we don't love him[[snake]]. We love aliens[[alien]].";
            //Assert.AreEqual(basicNote.GetAsText(), "The dog runs[[dog]] fast.\n But we don't love him. We love aliens[[alien]].");

            NoteDataXML_RichText basicNote2 = new NoteDataXML_RichText();
            basicNote2.GuidForNote = "chapter2";
            basicNote2.Caption = "chapter2";

            panel.AddNote(basicNote2);
            basicNote2.CreateParent(panel);
            basicNote2.SelectedText = "The cat runs[[cat]] fast.\n But we don't love him. \n\n\tWe love dogs[[dog]].";
            Assert.AreEqual(basicNote2.GetAsText(), "The cat runs[[cat]] fast.\n But we don't love him. \n\n\tWe love dogs[[dog]].");
            panel.SaveLayout();

            NoteDataXML_GroupEm storyboard = new NoteDataXML_GroupEm();
            storyboard.GuidForNote="storyboard";
            storyboard.Caption ="Storyboard";
            panel.AddNote (storyboard);
            storyboard.CreateParent(panel);

            panel.SaveLayout();
            Assert.AreEqual(5, panel.Count(), "why 5? Linktable + 3 should be 4? Nope: Rmemeber there is always a default note created too");
            Assert.AreEqual (0, storyboard.GetGroups ().Count);
            Assert.AreEqual(0, storyboard.CountStoryBoardItems());
            storyboard.AddRecordDirectly ("chapter1", basicNote.GuidForNote, "Chapters 1");
            Assert.AreEqual(1, storyboard.CountStoryBoardItems(), "We only added 1 record but group counts as a second?");
            storyboard.AddRecordDirectly ("chapter2", basicNote2.GuidForNote, "Chapters 1");
            Assert.AreEqual(2, storyboard.CountStoryBoardItems(), "We only added 1 record but group counts as a second?");

            Assert.AreEqual (1, storyboard.GetGroups ().Count);

            panel.SaveLayout();

            //
            // #2 - Creating DESTINATION layout -- this is where we invoke the FACT search on Layout #1
            //

            FAKE_LayoutPanel panel2 = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            panel2.NewLayout("mynewpanel2", true, null);

            ADD_Facts.NoteDataXML_Facts fact = new ADD_Facts.NoteDataXML_Facts();
            fact.GuidForNote="factnote";
            fact.Caption="Fact";
            panel2.AddNote (fact);
            fact.CreateParent(panel2);

            panel2.SaveLayout();
            Assert.AreEqual(3, panel2.Count(), "Default note + fact + linktable = 3");

            NoteDataXML_RichText basicNote3 = new NoteDataXML_RichText();
            basicNote3.GuidForNote = "factsource";
            basicNote3.Caption = "Fact Source";

            panel2.AddNote(basicNote3);
            basicNote3.CreateParent(panel2);
            basicNote3.SelectedText = "SourcePanel;[[Group,Storyboard,Chapters*,*]]";

            panel2.SaveLayout();
            Assert.AreEqual(4, panel2.Count(), "Default note + fact + linktable = 3");

            // intentionally testing this from the previous layout just incase somethingw eird has happened
            Assert.AreEqual(basicNote2.GetAsText(), "The cat runs[[cat]] fast.\n But we don't love him. \n\n\tWe love dogs[[dog]].");

            //			06Anobreak;[[Group,Storyboard,Chapters*,*]]
            //			06Bnobreak;[[Group,Storyboard,Chapters*,*]]

            string FactParseNote = "Fact Source";
            NoteDataXML_RichText note = (NoteDataXML_RichText)panel2.FindNoteByName (FactParseNote);
            Assert.NotNull(note);
            string textFromNote = note.GetAsText ();
            Assert.AreEqual("SourcePanel;[[Group,Storyboard,Chapters*,*]]", textFromNote);
            // now attempt the Fact Parse
            List<string> results = new List<string>();
            int error = fact.StartFactGathering(ref results, textFromNote);
            Assert.AreEqual(0, error, "first pass");
            Assert.NotNull (results);

            Assert.AreEqual(0,results.Count, "How many matching facts found");

            fact.SetTag("dog");
            Assert.AreEqual("dog", fact.Token);
            fact.SetSaveRequired(true);
            panel2.SaveLayout();
            Assert.AreEqual("dog", fact.Token);

            //Assert.AreEqual(2,results.Count, "How many matching facts found. THIS SHOULD FAIL -- we have no markup assigned");
            YourOtherMind.iMarkupYourOtherMind markup = new YourOtherMind.iMarkupYourOtherMind();
            LayoutDetails.Instance.AddMarkupToList(markup);
            LayoutDetails.Instance.SetCurrentMarkup(markup);
            Assert.AreEqual("YourOtherMind", LayoutDetails.Instance.GetCurrentMarkup().ToString ());

            results = new List<string>();
            error = fact.StartFactGathering(ref results, textFromNote);
            Assert.AreEqual(0, error, "second pass");

            Assert.AreEqual(2,results.Count, "How many matching facts found. Now that we have setup tag");

            fact.SetTag ("cat");
            results = new List<string>();
            error = fact.StartFactGathering(ref results, textFromNote);
            Assert.AreEqual(1,results.Count, "How many matching facts found. Now that we have setup tag");

            fact.SetTag ("fish");
            results = new List<string>();
            error = fact.StartFactGathering(ref results, textFromNote);
            Assert.AreEqual(0,results.Count, "How many matching facts found. Now that we have setup tag");

            fact.SetTag ("alien");
            results = new List<string>();
            error = fact.StartFactGathering(ref results, textFromNote);
            Assert.AreEqual(1,results.Count, "How many matching facts found. Now that we have setup tag");
        }
Exemplo n.º 10
0
 public System.Collections.Generic.List <TreeItem> BuildList(NoteDataXML_RichText RichText)
 {
     return(null);
 }
Exemplo n.º 11
0
        public FullScreenEditor(NoteDataXML_RichText theNote)
        {
            this.KeyPreview    = true;
            this.StartPosition = FormStartPosition.Manual;
            var screen = Screen.FromPoint(Cursor.Position);

            this.Location    = screen.Bounds.Location;
            this.WindowState = FormWindowState.Maximized;
            //this.DesktopBounds = MyWind

            if (null == theNote)
            {
                throw new Exception("theNote was invalid in FullSCreenEditor");
            }
            originalNote = theNote;

            RichTextBox      = new RichTextExtended();
            RichTextBox.Dock = DockStyle.Fill;
            this.Controls.Add(RichTextBox);
//			Panel tempToHideRTFBorder = new Panel();
//			this.Controls.Add (tempToHideRTFBorder);
//			tempToHideRTFBorder.Controls.Add (RichTextBox);
//			tempToHideRTFBorder.Dock = DockStyle.Fill;
//			tempToHideRTFBorder.BorderStyle = BorderStyle.Fixed3D;

            RichTextBox.Rtf         = theNote.Data1;
            RichTextBox.BorderStyle = BorderStyle.None;
            RichTextBox.BackColor   = theNote.GetRichTextBox().BackColor;


            // pretty up
            this.ControlBox = false;
            this.Text       = string.Empty;
            this.BackColor  = RichTextBox.BackColor;
            // this works but you see richTextBorder
            this.Padding = new System.Windows.Forms.Padding(15);
            //RichTextBox.Margin= new System.Windows.Forms.Padding(10);

            hud = new Panel();
            this.Controls.Add(hud);
            hud.Dock      = DockStyle.Bottom;
            hud.Height    = this.Height / 5;
            hud.BackColor = System.Drawing.Color.White;
            hud.ForeColor = System.Drawing.Color.Black;
            hud.BringToFront();

            Button closeButton = new Button();

            closeButton.Text = Loc.GetStr("Close");

            closeButton.Dock   = DockStyle.Bottom;
            closeButton.Click += (object sender, EventArgs e) => {
                Close();
            };
            closeButton.ForeColor = this.ForeColor;

            Button outlinerButton = new Button();

            hud.Controls.Add(outlinerButton);
            outlinerButton.Text   = Loc.GetStr("Outline");
            outlinerButton.Dock   = DockStyle.Bottom;
            outlinerButton.Click += (object sender, EventArgs e) => {
                bookMarkView.Visible = !bookMarkView.Visible;
                if (bookMarkView.Visible)
                {
                    AddBookmarkView();
                }
            };



            wordLabel      = new Label();
            startingWords  = LayoutDetails.Instance.WordSystemInUse.CountWords(RichTextBox.Text);
            wordLabel.Text = Loc.Instance.GetStringFmt("{0} words", startingWords);
            //wordLabel.BackColor = this.BackColor;
            //wordLabel.ForeColor = RichTextBox.ForeColor;
            hud.Visible = false;
            hud.Controls.Add(closeButton);
            hud.Controls.Add(wordLabel);



            // outliner

            bookMarkView = new NoteNavigation(originalNote);
            this.Controls.Add(bookMarkView);
            bookMarkView.Dock    = DockStyle.Left;
            bookMarkView.Visible = false;

            RichTextBox.BringToFront();
        }
 public System.Collections.Generic.List<TreeItem> BuildList(NoteDataXML_RichText RichText)
 {
     return null;
 }
Exemplo n.º 13
0
        public void TestNavigationNote()
        {
            NoteDataXML_RichText texter = new NoteDataXML_RichText(100, 100);

            System.Windows.Forms .Form form = new System.Windows.Forms.Form ();
            _TestSingleTon.Instance._SetupForLayoutPanelTests ();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            form.Controls.Add (panel);
            form.Show ();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout ("mynewpanel", true, null);

            panel.AddNote(texter);

            texter.GetRichTextBox().Text = "";

            NoteNavigation bookMarkView = new NoteNavigation (texter);

            // Test 1: Tests that no crash happens when we don't have a proper markup assigned
            bookMarkView.UpdateListOfBookmarks();

            LayoutDetails.Instance.SetCurrentMarkup(new iMarkupYourOtherMind());
            // Test 2: Same test. No crash still.
            bookMarkView.UpdateListOfBookmarks();
            string TestText = @"7 minutes
            Bus crash over cliff in Ecuador
            Lost style flash leading to salvation
            ddd[[f]]
            =Dog=

            =Dog 2=
            The |whatis|this|
            ===error===
            The |firstssafdfsf|day of the ghoose|
            The |linkfdfgdfgdfg|dfdgdfgedfgdnded|";
                texter.GetRichTextBox().Text = TestText;
            // test 3: some text
            bookMarkView.UpdateListOfBookmarks();

            // Main Level Node +1
            // Dog +1
            // Dog 2 + 1
            // <Make Up Node to insert between Dog 2 and Error> +1
            // Error + 1
            // Current Position (Automated Node) + 1
            // = 6
            Assert.AreEqual (6, bookMarkView.NumberOfNodes());

            texter.GetRichTextBox().Text = "[[~scene]]";
            bookMarkView.UpdateListOfBookmarks();
            Assert.AreEqual (3, bookMarkView.NumberOfNodes());
            texter.GetRichTextBox().Text = @"Hello.
            =h1=
            =h2=
            =h3=
            =h4=
            =h1=
            ";
            bookMarkView.UpdateListOfBookmarks();
            Assert.AreEqual (7, bookMarkView.NumberOfNodes());
        }
Exemplo n.º 14
0
        public void TestMovingNotes()
        {
            _w.output ("START");
            System.Windows.Forms .Form form = new System.Windows.Forms.Form ();
            _TestSingleTon.Instance._SetupForLayoutPanelTests ();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            form.Controls.Add (panel);
            form.Show ();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout ("mynewpanel", true, null);
            NoteDataXML basicNote = new NoteDataXML ();
            basicNote.Caption = "note1";

            panel.AddNote (basicNote);
            //basicNote.CreateParent(panel);

            //panel.MoveNote(
            // create four panels A and B at root level. C inside A. D inside C
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panelA.GuidForNote = "panela";
            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel ();
            panelB.Caption = "PanelB";
            panelB.GuidForNote = "panelb";
            FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel ();
            panelC.Caption = "PanelC";
            panelC.GuidForNote = "panelc";

            _w.output ("panels made");

            panel.AddNote (panelA);  // 1
            panel.AddNote (panelB);  // 2
            //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it

            basicNote = new NoteDataXML ();
            basicNote.Caption = "note2";

            panelA.AddNote (basicNote);  // Panel A has 1 note
            basicNote.CreateParent (panelA.myLayoutPanel ());  // DO need to call it when adding notes like this (to a subpanel, I think)
            panel.SaveLayout ();
            Assert.AreEqual (1, panelA.CountNotes (), "Panel A holds one note");  // So this counts as  + 2

            // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6
            _w.output ("STARTCOUNT");
            Assert.AreEqual (6, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

            _w.output ("ENDCOUNT");

            //COUNT SHOULD BE: panelA has 1 note
            //COUNT Total should be: Default Note + Note + PanelA + Panel B  + (Note Inside Panel A) = 5

            panelA.AddNote (panelC);  // panelC is now part of Panel 2
            panelC.CreateParent (panelA.myLayoutPanel ());
            panel.SaveLayout (); // NEED TO SAVE before conts will be accurated

            //COUNT SHOULD BE: panelA has 2 notes (Panel C + the Note I add)

            _w.output ("START COUNT SUB");
            Assert.AreEqual (2, panelA.CountNotes (), "two notes in panelA");
            _w.output ("END COUNT SUB");

            Assert.AreEqual (7, panel.CountNotes (), "total of SEVEN notes");

            _w.output ("START COUNT SUB2");
            Assert.AreEqual (0, panelB.CountNotes (), "0 count worked?");
            _w.output ("END COUNT SUB2");
            //COUNT Total should be: Default Note + Note + PanelA + Panel B + (NoteInside Panel A) + (Panel C Inside Panel A) = 6

            FAKE_NoteDataXML_Panel panelD = new FAKE_NoteDataXML_Panel ();
            panelD.Caption = "PanelD";
            panelC.AddNote (panelD); // panelC which is inside PANELA now adds panelD (which is empty?)
            panelD.CreateParent (panelC.myLayoutPanel ());

            panel.SaveLayout ();
            _w.output ("START COUNT SUB3");
            Assert.AreEqual (0, panelD.CountNotes (), "No notes in panelD");
            _w.output ("START COUNT SUB3");
            /*
            NoteDataXML_RichText extra = new NoteDataXML_RichText();
            panelD.AddNote (extra); //this was here only to test that there is an error with counting EMPTY panels
            extra.CreateParent(panelD.myLayoutPanel());
            panel.SaveLayout();*/
            // update on ERROR: Every note in D is being counted DOUBLE

            // weird error: If a panel is empty it will register as +1 (i.e, counted twice)

            // PanelC and PanelA are adding this note
            //			AddChildrenToList, TYPE: TEMPORARY, scanning children...47d43f01-a031-42d1-8539-bb7ae284a9e1 from PanelC

            //			AddChildrenToList, TYPE: TEMPORARY, scanning children...47d43f01-a031-42d1-8539-bb7ae284a9e1 from PanelA

            //OK: Every note is claiming ownership of the TEXT NOTE, which is the problem, I think.
            _w.output ("START COUNT SUB4");
            Assert.AreEqual (1, panelC.CountNotes (), "1 notes in panelC");
            _w.output ("E COUNT SUB4");
            Assert.AreEqual (0, panelD.CountNotes (), "1 note in panelD");
            _w.output ("_------------------------------");
            _w.output ("panel.CountNotes=" +panel.CountNotes ());

            _w.output ("_------------------------------");
            Assert.AreEqual (8, panel.CountNotes (), "We have only added one panel so we should be up to 8");

            Assert.AreEqual (3, panelA.CountNotes ());

            Assert.AreEqual (8, panel.CountNotes (), "number of notes in main panel");
            Assert.AreEqual (0, panelB.CountNotes (), "testt");
            Assert.AreEqual (1, panelC.CountNotes (), "testt");

            // add a note to panel d (we want to make sure this note does not disappear while D is being moved around
            NoteDataXML noteford = new NoteDataXML ();
            noteford.Caption = "note for d";
            panelD.AddNote (noteford);

            // Move panel D from panelC into PANEL A
            panelC.myLayoutPanel ().MoveNote (panelD.GuidForNote, "up");
            panel.SaveLayout ();
            Assert.AreEqual (4, panelA.CountNotes ()); // 4 because I added a note to D which is inside A
            Assert.AreEqual (9, panel.CountNotes ());
            Assert.AreEqual (0, panelC.CountNotes ());
            Assert.AreEqual (0, panelB.CountNotes ());
            Assert.AreEqual (1, panelD.CountNotes ());
            // Move panel D from panelA into ROOT
            panelA.myLayoutPanel ().MoveNote (panelD.GuidForNote, "up");
            panel.SaveLayout ();
            Assert.AreEqual (2, panelA.CountNotes ());
            Assert.AreEqual (9, panel.CountNotes ());
            Assert.AreEqual (0, panelC.CountNotes ()); // ** FINE HERE
            _w.output ("do c twice, what happens?");
            Assert.AreEqual (0, panelC.CountNotes ());
            Assert.AreEqual (0, panelB.CountNotes ());
            Assert.AreEqual (1, panelD.CountNotes ());

            lg.Instance.Loudness = Loud.ACRITICAL;

            _w.output ("START COUNT SUB5");
            NoteDataXML_RichText richy = new NoteDataXML_RichText ();
            richy.GuidForNote = "richy";
            panel.AddNote (richy);
            richy.CreateParent (panel);
            panel.SaveLayout ();
            _w.output ("do c THRICE, what happens?");
            Assert.AreEqual (0, panelC.CountNotes ());
            _w.output ("E COUNT SUB5");
            // now move note into A
            _w.output ("move richy FROM PANEL into PanelA (PanelA also holds PanelC). The exact logic seems to be that IN THE FOLLOWING MOVE, PANELA Gets Disposed of??!?");
            panel.MoveNote (richy.GuidForNote, panelA.GuidForNote);
            panel.SaveLayout ();
            _w.output ("do c 4x, what happens?");
            Assert.AreEqual (0, panelC.CountNotes ());

            _w.output ("done move richy");
            Assert.AreEqual (3, panelA.CountNotes ());
            Assert.AreEqual (10, panel.CountNotes ());
            _w.output ("countc");
            Assert.AreEqual (0, panelC.CountNotes ());  // * Jan 19 2013 - brok ehere
            _w.output ("e countc");
            _w.output ("countb");

            Assert.AreEqual (0, panelB.CountNotes ());
            _w.output ("e countb");

            _w.output ("Panel A Notes " + panelA.CountNotes ().ToString ());
            _w.output ("Total Notes " + panel.CountNotes ());
            // also see if this test or another could replicate the problems I had in previous version with RefhresTabs
            panel.SaveLayout ();

            // now do a test to load it
            panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            //form.Controls.Add (panel);
            //form.Show ();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.LoadLayout ("mynewpanel", false, null);
            _w.output ("getting notes for " + panel.Caption);
            System.Collections.ArrayList TheNotes = panel.GetAllNotes ();

            //	System.Collections.Generic.List<NoteDataInterface> list = new System.Collections.Generic.List<NoteDataInterface> ();
            //list.AddRange ((NoteDataInterface[])TheNotes.ToArray ());
            int count = 0;
            foreach (NoteDataInterface note in TheNotes) {
                if (note.GuidForNote == CoreUtilities.Links.LinkTable.STICKY_TABLE)
                {
                    count++;
                }
            }
            // make sure there is only one linktable
            Assert.AreEqual(1, count);

            //.NoteDataInterface[] found = (NoteDataInterface)list.Find (NoteDataInterface=>NoteDataInterface.GuidForNote == CoreUtilities.Links.LinkTable.STICKY_TABLE );
                //	Assert.True (false);
        }
Exemplo n.º 15
0
        public void SpeedTest()
        {
            // this will be a benchmarking test that will create a complicated Layout
            // Then it will time and record the results of LOADING and SAVING that layout into a
            // table saved in my backup paths
            // will also output a DAAbackup file (text readable) format too
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            System.Windows.Forms .Form form = _TestSingleTon.Instance.FORM;//new System.Windows.Forms.Form();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);

            form.Controls.Add (panel);

            // needed else DataGrid does not initialize

            form.Show ();
            //form.Visible = false;
            _w.output("boom");
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form,null);

            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();
            panel.NewLayout (panelname,true, null);
            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            _w.output ("herefirst");

            // ADD 1 of each type
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) {
                for (int i = 0; i < 10; i++) {
                    NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t);
                    panel.AddNote (note);
                    note.CreateParent(panel);
                }
            }
            _w.output("here");
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panel.AddNote (panelA);
            string stringoftypes = "";
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) {
                NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t);
                panelA.AddNote (note);
                stringoftypes = stringoftypes + " " + t.ToString();
            }
            panel.SaveLayout();
            string base_path = _TestSingleTon.PATH_TO_SpeedTestFiles;//@"C:\Users\BrentK\Documents\Keeper\Files\yomspeedtests2013\";
            _w.output ("here");
            NoteDataXML_RichText richy;
            for (int i = 0; i < 20; i ++) {
                richy = new NoteDataXML_RichText ();
                richy.Caption = "richtext";
                panel.AddNote (richy);
                Assert.True (richy.GetIsRichTextBlank ());
                richy.DoOverwriteWithRTFFile (System.IO.Path.Combine (base_path,"speedtest.rtf"));
                Assert.False (richy.GetIsRichTextBlank ());
            }
            _w.output("First save");
            panel.SaveLayout();
            string table = "layoutpanelsaveload";
            // Now try and write this data out.
            SqlLiteDatabase timetracking = new SqlLiteDatabase(System.IO.Path.Combine (base_path,"speedtests.s3db"));
            timetracking.CreateTableIfDoesNotExist(table, new string [5] {"id", "datetime", "timetook", "types","saveorload"},
            new string[5] {"INTEGER", "TEXT", "FLOAT", "TEXT", "TEXT"}, "id");

            // * Now start the Load Test
            TimeSpan time;
            CoreUtilities.TimerCore.TimerOn = true;
            time = CoreUtilities.TimerCore.Time (() => {
            panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
                form.Controls.Add (panel);
                panel.LoadLayout(panelname, false,null);
            });
            _w.output("TIME " + time);

            timetracking.InsertData(table, new string[4] {"datetime", "timetook", "types","saveorload"},new object[4] {DateTime.Now.ToString (),
                time.TotalSeconds, stringoftypes,"load"});

            time = CoreUtilities.TimerCore.Time (() => {
                // We keep the PANEL from above! Don't recreate it.
                //panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK);
                panel.SaveLayout();
            });

            Console.WriteLine("TIME " + time);

            timetracking.InsertData(table, new string[4] {"datetime", "timetook", "types","saveorload"},new object[4] {DateTime.Now.ToString (),
                time.TotalSeconds, stringoftypes,"save"});

            string backup = timetracking.BackupDatabase();

            System.IO.TextWriter write = new System.IO.StreamWriter(System.IO.Path.Combine (base_path,"timeresults.txt"));
            write.WriteLine (backup);

            write.Close();

            FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid");
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(layout.GetDatabaseName ());
            _w.output("Backup of stored database: " + db.BackupDatabase());

            timetracking.Dispose();
            db.Dispose();
        }
        public void SaveRequired()
        {
            _setupforlayoutests ();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", false, null);
            NoteDataXML_RichText note = new NoteDataXML_RichText ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();

                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
                note.UpdateLocation();
            }
            //layout.SaveTo();
            Assert.True (layoutPanel.GetSaveRequired);
        }
        public void TestDeleteNote()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            // add a note with specific label
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            layoutPanel.NewLayout("testguid", true, null);
            NoteDataXML_RichText note = new NoteDataXML_RichText ();
            string guid2find = "";
            NoteDataInterface mynotetogo = null;
            for (int i = 0; i < 1; i++) {
                note.CreateParent(layoutPanel);
                note.Caption = "boo" + i.ToString ();
                note.UpdateLocation();
                guid2find = note.GuidForNote;
                layoutPanel.AddNote (note);
                mynotetogo = note;
            }
            //	layout.SaveTo();
            layoutPanel.SaveLayout();
            _w.output (guid2find);
            Assert.True (layoutPanel.GetLayoutDatabase().IsNoteExistsInLayout (guid2find));
            _w.output("here");
            // then delete it

            layoutPanel.GetLayoutDatabase().RemoveNote(mynotetogo);
            Assert.False (layoutPanel.GetLayoutDatabase().IsNoteExistsInLayout (guid2find));
        }
        public void AutosaveThrash()
        {
            // just spawna timer and see if I can make it fail

            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            System.Windows.Forms .Form form = new System.Windows.Forms.Form();

            panelAutosave = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);

            form.Controls.Add (panelAutosave);

            // needed else DataGrid does not initialize

            form.Show ();
            //form.Visible = false;
            _w.output("boom");
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form,null);

            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();
            panelAutosave.NewLayout (panelname,true, null);
            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            _w.output ("herefirst");

            Timer SaveTimer= new Timer();
            SaveTimer.Interval = 300;
            SaveTimer.Tick+= HandleSaveTimerTick;
            SaveTimer.Start ();

            // ADD 1 of each type
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) {
                for (int i = 0; i < 2; i++) {
                    NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t);
                    panelAutosave.AddNote (note);
                    note.CreateParent(panelAutosave);

                    note.UpdateAfterLoad();
                }
            }

            panelAutosave.SaveLayout();

            //
            // Second panel
            //

            string panelname2 = System.Guid.NewGuid().ToString();
            FAKE_LayoutPanel  PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout (panelname2,true, null);
            PanelOtherGuy.SaveLayout();

            Assert.AreEqual( 2, PanelOtherGuy.CountNotes(), "count1");

            // ADD 1 of each type
            //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                for (int i = 0; i < 10; i++) {

                        NoteDataInterface note = new NoteDataXML_RichText();
                    PanelOtherGuy.AddNote (note);
                    note.CreateParent(PanelOtherGuy);

                    note.UpdateAfterLoad();

                }
            }
            Assert.AreEqual( 12, PanelOtherGuy.CountNotes(), "count2");
            PanelOtherGuy.SaveLayout();
            PanelOtherGuy = null;
            PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.LoadLayout(panelname2, false, null);
            Assert.AreEqual(12, PanelOtherGuy.CountNotes(), "count2");
            // add another Layout and do something with it while autosave continues running

            SaveTimer.Stop();
            form.Dispose ();
        }