예제 #1
0
        private TransactionsTable SetupForEventTests()
        {
            lg.Instance.OutputToConstoleToo = true;
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(_TestSingleTon.TESTDATABASE);

            db.DropTableIfExists("events");
            db.Dispose();


            TransactionsTable eventTable = new TransactionsTable(MasterOfLayouts.GetDatabaseType(_TestSingleTon.TESTDATABASE));

            return(eventTable);
        }
예제 #2
0
        public void AddAndThenEditLinks()
        {
            // add a couple links, take count
            // then edit one of the early links a few times
            // get the link into a subpanel and make the counts are as expected
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

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

            NoteDataXML basicNote = new NoteDataXML();

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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

            // in this test we don't use the subpanel but just have it here for fun
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption = "PanelA";
            panel.AddNote(panelA);
            panelA.CreateParent(panel);

            panel.SaveLayout();
            System.Collections.Generic.List <string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(0, linkstome.Count);


            NoteDataXML_LinkNote link = new NoteDataXML_LinkNote();

            panel.AddNote(link);
            link.CreateParent(panel);
            link.SetLink("mynewpanel.thisguid1");
            panel.SaveLayout();


            linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(1, linkstome.Count);

            // now edit the existing link
            link.SetLink("mynewpanel.thisguid2");
            panel.SaveLayout();
            Assert.AreEqual(1, linkstome.Count);
            // the counts should remain the same
        }
예제 #3
0
        public void BuildReciprocalLinks()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

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

            NoteDataXML basicNote = new NoteDataXML();

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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

            // #2



            panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            panel.NewLayout("mynewpanel2", true, null);
            basicNote             = new NoteDataXML();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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

            NoteDataXML_LinkNote note = new NoteDataXML_LinkNote();



            panel.AddNote(note);
            note.CreateParent(panel);
            note.SetLink("mynewpanel.thisguid1");
            panel.SaveLayout();



            System.Collections.Generic.List <string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel2");
            Assert.AreEqual(0, linkstome.Count);
            linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(1, linkstome.Count);
        }
        public void TestSortingOnGetValues_ShouldFailBecauseAreSubPanels()
        {
            Layout.LayoutDetails.Instance.YOM_DATABASE = test_database_name;
            SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.ID));

            db.InsertData(dbConstants.table_name, new string[4] {
                dbConstants.NAME, dbConstants.XML, dbConstants.GUID, dbConstants.SUBPANEL
            }, new object[4] {
                "Zum", "boo xml", "GUID_DDA", 1
            });
            db.InsertData(dbConstants.table_name, new string[4] {
                dbConstants.NAME, dbConstants.XML, dbConstants.GUID, dbConstants.SUBPANEL
            }, new object[4] {
                "Alexander", "boo xml", "GUID_B", 1
            });
            db.InsertData(dbConstants.table_name, new string[4] {
                dbConstants.NAME, dbConstants.XML, dbConstants.GUID, dbConstants.SUBPANEL
            }, new object[4] {
                "aboo", "boo xml", "GUID_A", 1
            });
            db.InsertData(dbConstants.table_name, new string[4] {
                dbConstants.NAME, dbConstants.XML, dbConstants.GUID, dbConstants.SUBPANEL
            }, new object[4] {
                "Calv", "boo xml", "GUID_C", 1
            });

            //	Layout.MasterOfLayouts mastery = new Layout.MasterOfLayouts ();
            List <Layout.MasterOfLayouts.NameAndGuid> list = MasterOfLayouts.GetListOfLayouts(Constants.BLANK);

            foreach (Layout.MasterOfLayouts.NameAndGuid guid in list)
            {
                _w.output(guid.Caption);
            }
            Assert.AreEqual(0, list.Count);

            /*Assert.AreEqual ("aboo", list[0].Caption);
             * Assert.AreEqual ("Alexander", list[1].Caption);
             * Assert.AreEqual ("Calv", list[2].Caption);
             * Assert.AreEqual ("Zum", list[3].Caption);
             */


            //	mastery.Dispose ();
            db.Dispose();
        }
예제 #5
0
        public void AddLinkToSubpanel()
        {
            // get the link into a subpanel and make the counts are as expected
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

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

            NoteDataXML basicNote = new NoteDataXML();

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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


            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption = "PanelA";
            panel.AddNote(panelA);
            panelA.CreateParent(panel);

            panel.SaveLayout();
            System.Collections.Generic.List <string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(0, linkstome.Count);


            NoteDataXML_LinkNote link = new NoteDataXML_LinkNote();

            panelA.AddNote(link);
            link.CreateParent(panelA.GetPanelsLayout());
            link.SetLink("mynewpanel.thisguid1");
            panel.SaveLayout();


            linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(1, linkstome.Count);
        }
예제 #6
0
        void HandleResetSysteClick(object sender, EventArgs e)
        {
            if (NewMessage.Show(Loc.Instance.GetString("Caution!"), Loc.Instance.GetString("Reset the system layout to restore default settings. Doing so will lose any customization to the sytem layout AND require a restart of the application. Proceed?"),
                                MessageBoxButtons.YesNo, null) == DialogResult.Yes)
            {
                // do reset
                // 1. Delete existing system note
                MasterOfLayouts.DeleteLayout("system");
                MasterOfLayouts.DeleteLayout("system_sidedock");
                MasterOfLayouts.DeleteLayout("tables");

                // JUST DELETE AND REBOOT, it will build on next reload
                // 2. Restore note
                // because we reboot it does not matter that I do not pass a valid contextmenu into here
                //DefaultLayouts.CreateASystemLayout(null,null);
                // 3. Restart
                Application.Exit();
            }
        }
        //[Ignore]
        public void DeleteTest()
        {
            _setupforlayoutests();
            Assert.False(MasterOfLayouts.ExistsByGUID("DeleteMe"));

            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("DeleteMe", true, null);
            //LayoutDatabase layout = layoutPanel.GetLayoutDatabase();
            //layout.SaveTo ();
            layoutPanel.SaveLayout();


            Assert.True(MasterOfLayouts.ExistsByGUID("DeleteMe"));
            MasterOfLayouts.DeleteLayout("DeleteMe");
            Assert.False(MasterOfLayouts.ExistsByGUID("DeleteMe"));
            layoutPanel.Dispose();
        }
예제 #8
0
        public void TestExistsByGUID()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

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

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

            panel.AddNote(basicNote);
            basicNote.CreateParent(panel);
            panel.SaveLayout();
            Assert.False(MasterOfLayouts.ExistsByGUID("mynewpanel2"));
            Assert.True(MasterOfLayouts.ExistsByGUID("mynewpanel"));
        }
        public void LayoutShouldNotExist()
        {
            _setupforlayoutests();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("testguid", true, null);
            NoteDataXML note = new NoteDataXML();

            for (int i = 0; i < count; i++)
            {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }
            //	layout.SaveTo(); no save, so note should not exist

            Assert.False(MasterOfLayouts.ExistsByGUID("testguid"));
        }
예제 #10
0
        public void DeleteTests()
        {
            // nest several panels
            //_SetupForLayoutPanelTests ();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

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

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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

            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption     = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote(panelA);
            panelA.CreateParent(panel);


            FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text();

            panelA.AddNote(textNote);
            textNote.CreateParent(panelA.GetPanelsLayout());
            textNote.Caption = "My text";
            textNote.GetRichTextBox().Text = "Hello there.";
            panel.SaveLayout();
            Assert.AreEqual(2, MasterOfLayouts.Count(true));
            Assert.True(MasterOfLayouts.ExistsByGUID("mynewpanel"));
            MasterOfLayouts.DeleteLayout("mynewpanel");
            Assert.False(MasterOfLayouts.ExistsByGUID("mynewpanel"));
            Assert.AreEqual(0, MasterOfLayouts.Count(true));
        }
        public void LayoutExists()
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            _w.output("1");
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            _w.output("2");
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("testguid", true, null);

            NoteDataXML note = new NoteDataXML();

            for (int i = 0; i < count; i++)
            {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }
            layoutPanel.SaveLayout();
            layoutPanel.Dispose();
            Assert.True(MasterOfLayouts.ExistsByGUID("testguid"));
        }
예제 #12
0
        public override System.Collections.Generic.List <Layout.MasterOfLayouts.NameAndGuid> BuildQuery()
        {
            List <MasterOfLayouts.NameAndGuid> lastFoundItems = new List <MasterOfLayouts.NameAndGuid>();

            string namesearch = "";             // we ignore namesearch. Just using the FILTER. // extraDetails; // will bring into space sep strings and create a query of ORS "";

            string filter = extraDetails;



            List <string> CommonWords = MefAddIns.mef_Addin_Lookup_Word.GetCommonWords();



            bool FullTextSearch = false;

            try {
                lastFoundItems = MasterOfLayouts.GetListOfLayouts(filter, "", FullTextSearch, null, namesearch);
            } catch (System.Exception) {
                //	NewMessage.Show (ex.ToString ());
            }

            return(lastFoundItems);
        }
예제 #13
0
        public virtual List <MasterOfLayouts.NameAndGuid> BuildQuery()
        {
            List <MasterOfLayouts.NameAndGuid> lastFoundItems = new List <MasterOfLayouts.NameAndGuid>();

            string namesearch = extraDetails;             // will bring into space sep strings and create a query of ORS "";

            string filter = "All";



            List <string> CommonWords = MefAddIns.mef_Addin_Lookup_Word.GetCommonWords();



            string[] CommonWordsFoundinCardName = namesearch.Split(new char[1] {
                ' '
            }, StringSplitOptions.RemoveEmptyEntries);

            if (CommonWordsFoundinCardName != null)
            {
                // iterate through each CommonWord and remove fromlist
                foreach (string word in CommonWordsFoundinCardName)
                {
                    bool q = CommonWords.Any(w => word.Contains(w));
                    if (q)
                    {
                        // skip, we have a common word match
                    }
                    else
                    {
                        if (namesearch == extraDetails)
                        {
                            // we have not added anything yet
                            namesearch = String.Format("and name like '%{0}%'", word);
                        }
                        else
                        {
                            namesearch = String.Format("{0} or name like '%{1}%'", namesearch, word);

                            // tmp
                            //richText.Text = richText.Text + namesearch;
                        }
                        // we override the cardname because we have found at LEAST one match.

                        // build NAMESEARCH
                        // build a OR query using remaining TITLE WORDS
                    }
                }
            }



            bool FullTextSearch = false;

            try {
                lastFoundItems = MasterOfLayouts.GetListOfLayouts(filter, "", FullTextSearch, null, namesearch);
            } catch (System.Exception) {
                //	NewMessage.Show (ex.ToString ());
            }

            return(lastFoundItems);
        }
예제 #14
0
        public void _SetupForLayoutPanelTests(bool BreakAppearanceOnPurpose, string OverrideDatabaseName)
        {
            LayoutDetails.Instance.UpdateAfterLoadList.Clear();
            SetupForAnyTest();
            LayoutDetails.Instance.YOM_DATABASE = TESTDATABASE;
            if ("" != OverrideDatabaseName)
            {
                LayoutDetails.Instance.YOM_DATABASE = OverrideDatabaseName;
            }
            LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory;
            _w.output(LayoutDetails.Instance.YOM_DATABASE);
            if (false == BreakAppearanceOnPurpose)
            {
                LayoutDetails.Instance.GetAppearanceFromStorage = GetAppearanceFromStorage;
            }
            else
            {
                LayoutDetails.Instance.GetAppearanceFromStorage = null;
            }


            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "testingtext");

            FakeLayoutDatabase   layout = new FakeLayoutDatabase("testguid");
            FAKE_SqlLiteDatabase db     = new FAKE_SqlLiteDatabase(layout.GetDatabaseName());

            LayoutDetails.Instance.TransactionsList = new Transactions.TransactionsTable(MasterOfLayouts.GetDatabaseType(LayoutDetails.Instance.YOM_DATABASE));
            foreach (string s in ListOfTablesToDrop)
            {
                db.DropTableIfExists(s);
                //	db.DropTableIfExists("system");
                _w.output("dropping table " + s);
            }
        }
예제 #15
0
        /// <summary>
        /// Updates the view.
        ///
        /// Will take the raw string data of the connections and create links to the notes.
        ///
        /// *Note: Once BackgroundTask is setup, this will be what is called from PROGRESS ... the core number crunching will take place in the handler sans interface
        /// </summary>
        void UpdateView()
        {
            if (tip == null)
            {
                tip            = new ToolTip();
                tip.ShowAlways = true;

                //BottomInfo.Controls.Add (tip);
            }
            // clear list
            for (int i = BottomInfo.Controls.Count - 1; i >= 0; i--)
            {
                if (BottomInfo.Controls[i].Name != REFRESH_BUTTON)
                {
                    BottomInfo.Controls.Remove(BottomInfo.Controls[i]);
                }
            }

            if (results_to_store != null)
            {
                int count = 0;
                foreach (string s in results_to_store)
                {
                    count++;                     // just for naming labels
                    FactRecord factRecord = FactRecord.CreateFactRecord(s, true);
                    if (factRecord != null)
                    {
                        GroupBox box = null;

                        box = getGroupBoxForLayout(factRecord.layoutguid);
                        if (box == null)
                        {
                            box              = new GroupBox();
                            box.Dock         = DockStyle.Left;
                            box.Text         = MasterOfLayouts.GetNameFromGuid(factRecord.layoutguid);
                            box.Name         = factRecord.layoutguid;
                            box.AutoSize     = true;
                            box.MinimumSize  = new Size(200, 75);
                            box.AutoSizeMode = AutoSizeMode.GrowOnly;
                            tip.SetToolTip(box, box.Text);
                        }

                        LinkLabel newLabel = new LinkLabel();
                        newLabel.Name         = "label" + count;
                        newLabel.Text         = factRecord.chapter;
                        newLabel.AutoSize     = true;                     // if false, it will supply a tooltip and override mine
                        newLabel.AutoEllipsis = false;

                        string toolTip = factRecord.text.Substring(0, Math.Min(100, factRecord.text.Length));                          // also used for the search


                        newLabel.Dock   = DockStyle.Left;
                        newLabel.Click += (object sender, EventArgs e) =>
                        {
                            LayoutDetails.Instance.LoadLayout(factRecord.layoutguid, factRecord.noteguid, toolTip /*"[["+factRecord.theFact*/);
                            //	NewMessage.Show (factRecord.layoutguid + " -- " + factRecord.noteguid);
                        };
                        box.Controls.Add(newLabel);
                        BottomInfo.Controls.Add(box);

                        //tip.SetToolTip(box, "Hello there boxy");

                        //	NewMessage.Show (factRecord.text);
                        tip.SetToolTip(newLabel, toolTip);
                        //tip.SetToolTip(newLabel, "zippy"); worked
                        //NewMessage.Show (factRecord.ToString ());
                    }
                    else
                    {
                        NewMessage.Show("Fact Record was null for : " + s);
                    }
                }

                //ok: this works. Now the hard part
                //	NewMessage.Show ("Matches are = " + results_to_store.Count);
            }
        }
예제 #16
0
        /// <summary>
        /// Starts the fact gathering.
        ///
        /// We return an error code for displaying errors.
        ///
        /// </summary>
        public int StartFactGathering(ref List <string> results, /* string _FactParseNote, */ string textFromNote)
        {
            try {
                /*if (Constants.BLANK == _FactParseNote ) {
                 *      return 1;
                 * } else*/
                // Step 1 - Link to a note on this page with the name(s) of another note : Loop

                if (textFromNote == Constants.BLANK)
                {
                    return(2);
                }
                else
                {
                    //NewMessage.Show ("Found = " + note.Data1); // worked

                    // to do: will need to parse .data1 and grab lines


                    //The Pool;[[Group,Storyboard,Chapters*,*]]

                    //string textFromNote = note.GetAsText ();
                    string[] lines = textFromNote.Split(new char[1] {
                        '\n'
                    }, StringSplitOptions.RemoveEmptyEntries);
                    if (lines != null && lines.Length > 0)
                    {
                        // for each Layout we have to open we added to the results list
                        // results are stored on the note
                        //	List<string> results = new List<string>();
                        foreach (string theLine in lines)
                        {
                            string   noteData1 = theLine;                                  //"The Pool;[[Group,Storyboard,Chapters*,*]]";
                            string[] RawView   = noteData1.Split(new char[1] {
                                ';'
                            }, StringSplitOptions.RemoveEmptyEntries);
                            if (RawView != null && RawView.Length == 2)
                            {
                                // Second part -- fine deatils

                                // Strings will be formatted like this[[Group,Storyboard,Chapters*,*]]
                                // logic - strip out [[ and ]]
                                // break into stringarray , seperate by ','
                                // string[0] = word Group. We ignore and always fill in Group
                                // string[1] = Storyboard  -- this is the important bit -- the name of the Storyboard to look
                                // string[2] = which "folder" to look in on the storyboard



                                // Step 2 - Open that other note
                                string LayoutName = RawView [0];                                        //"LayoutToFind";
                                string Code       = RawView [1];
                                string LayoutGUID = MasterOfLayouts.GetGuidFromName(LayoutName);
                                if (LayoutGUID != Constants.BLANK && Code != Constants.BLANK)
                                {
                                    LayoutPanel temporaryLayoutPanel = new LayoutPanel("", false);
                                    temporaryLayoutPanel.LoadLayout(LayoutGUID, false, null, true);
                                    if (temporaryLayoutPanel == null)
                                    {
                                        return(100);
                                    }

                                    //NewMessage.Show (temporaryLayoutPanel.Count ().ToString());

                                    string[] code = new string[3];
                                    // we fake a string array to meet the Fact-Parse system's expectations of Storyboard/GrouporNoGroup/Details
                                    // even though we do not need the first two lines
                                    code [0] = "[[factlist]]";
                                    code [1] = "[[bygroup]]";

                                    code [2] = Code;
                                    //NewMessage.Show (Code);
                                    Hashtable hResults = Addin_YourothermindMarkup.GetFactsOnRemoteNote(temporaryLayoutPanel, code);

                                    if (hResults != null)
                                    {
                                        foreach (DictionaryEntry gg in hResults)
                                        {
                                            //	NewMessage.Show ("Matching " + gg.Key.ToString() + " with " + token);
                                            if (gg.Key.ToString() == token)
                                            {
                                                string[] factsforentry = gg.Value.ToString().Split(new string[1] {
                                                    FactListMaker.SEP_PHRASES
                                                }, StringSplitOptions.RemoveEmptyEntries);
                                                if (factsforentry != null)
                                                {
                                                    foreach (string s in factsforentry)
                                                    {
                                                        string sresult = /*gg.Value*/ s + FactListMaker.SEP_INSIDEPHRASE + token + FactListMaker.SEP_INSIDEPHRASE + LayoutGUID;
                                                        results.Add(sresult);
                                                    }
                                                }
                                            }


//												// only add if they matc h the search criteria
//												if (gg.Key.ToString () == token)
//												{
//													string sresult = gg.Value + FactListMaker.SEP_INSIDEPHRASE + gg.Key + FactListMaker.SEP_INSIDEPHRASE + LayoutGUID;
//													results.Add (sresult);
//												}
                                        }
                                    }


                                    // now we have to run the actual Fact - Parsing
                                    // Step 3 - On that Other Note run the indicated fact search (from Step 1)


                                    // Step 4 - Return the list of facts/positions in a usable manner to here.



                                    // dispose memory 09/07/2014
                                    hResults = null;
                                    temporaryLayoutPanel.Dispose();
                                }
                                else
                                {
                                    return(3);
                                }
                            }
                            else
                            {
                                return(4);
                            }
                        }                                 // foreach line



                        // Step 6 - Now we parse the results and add them to the form.
                        //  -- nope we have this called in the Progress thing
                    }                            //lines
                    else
                    {
                        return(5);
                    }
                }
            } catch (Exception ex) {
                lg.Instance.Line("StartFactGathering", ProblemType.EXCEPTION, ex.ToString());
            }

            return(0);
        }
예제 #17
0
        public void GetListOfLayoutTests()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.Show();
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form, null);

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

            PanelOtherGuy.NewLayout(panelname2, true, null);
            form.Controls.Add(PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

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

            List <MasterOfLayouts.NameAndGuid> names = MasterOfLayouts.GetListOfLayouts("WritingProjects");

            Assert.AreEqual(0, names.Count);

            // 1 prtoject

            PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout("NextLayout", true, null);
            PanelOtherGuy.SetCaption("booler");
            PanelOtherGuy.SetNotebookSection("Writing", "Projects");
            form.Controls.Add(PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            names = MasterOfLayouts.GetListOfLayouts("WritingProjects");

            Assert.AreEqual(1, names.Count);

            // search LIKE NAME

            PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout("NextLayout22", true, null);
            PanelOtherGuy.SetCaption("boolAt");

            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "textfake");

            FAKE_NoteDataXML_Text richy = new FAKE_NoteDataXML_Text();


            PanelOtherGuy.AddNote(richy);
            richy.CreateParent(PanelOtherGuy);
            richy.GetRichTextBox().Text = "Hello there";

            PanelOtherGuy.SetNotebookSection("Writing", "Projects");
            form.Controls.Add(PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout("NextLayout33", true, null);
            PanelOtherGuy.SetCaption("bolzzz");
            PanelOtherGuy.SetNotebookSection("Writing", "Projects");
            form.Controls.Add(PanelOtherGuy);
            PanelOtherGuy.SaveLayout();


            names = MasterOfLayouts.GetListOfLayouts("WritingProjects");

            Assert.AreEqual(3, names.Count);

            names = MasterOfLayouts.GetListOfLayouts("WritingProjects", "bool", false, null);

            Assert.AreEqual(2, names.Count);


            //
            // text searching
            //


            PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout("NextLayout55", true, null);
            PanelOtherGuy.SetCaption("bolzzz222");
            PanelOtherGuy.SetNotebookSection("Writing", "Projects");
            form.Controls.Add(PanelOtherGuy);
            PanelOtherGuy.SaveLayout();


            richy = new FAKE_NoteDataXML_Text();

            PanelOtherGuy.AddNote(richy);
            richy.CreateParent(PanelOtherGuy);
            richy.GetRichTextBox().Text = "Hello there again!";
            PanelOtherGuy.SaveLayout();
            richy = new FAKE_NoteDataXML_Text();


            PanelOtherGuy.AddNote(richy);
            richy.CreateParent(PanelOtherGuy);
            richy.GetRichTextBox().Text = "Hello the fish are good there";
            PanelOtherGuy.SaveLayout();


            names = MasterOfLayouts.GetListOfLayouts("All", "fish", true, null);
            Assert.AreEqual(1, names.Count);
            // FINAL TEST now count all


            names = MasterOfLayouts.GetListOfLayouts("All");
            Assert.AreEqual(6, names.Count);

            // now test to see if text in a subpanel is found correct
            FAKE_NoteDataXML_Panel subpanel = new FAKE_NoteDataXML_Panel();

            PanelOtherGuy.AddNote(subpanel);
            subpanel.CreateParent(PanelOtherGuy);

            names = MasterOfLayouts.GetListOfLayouts("All", "sharks", true, null);
            Assert.AreEqual(0, names.Count);

            FAKE_NoteDataXML_Text Rich2 = new FAKE_NoteDataXML_Text();

            subpanel.AddNote(Rich2);
            Rich2.GetRichTextBox().Text = "Sharks";

            PanelOtherGuy.SaveLayout();

            names = MasterOfLayouts.GetListOfLayouts("All", "sharks", true, null);
            Assert.AreEqual(1, names.Count);
        }
예제 #18
0
        public void ExportImport()
        {
            lg.Instance.OutputToConstoleToo = true;
            Form   form           = new Form();
            string ThisLayoutGUID = "mynewpanelXA";

            // create a layout
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

            form.Controls.Add(panel);
            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout(ThisLayoutGUID, true, null);

            NoteDataXML basicNote = new NoteDataXML();

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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


            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption     = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote(panelA);
            panelA.CreateParent(panel);


            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();

            panelB.Caption     = "PanelBBBBB2";
            panelB.GuidForNote = "panelBB";


            panelA.AddNote(panelB);
            panelB.CreateParent(panelA.GetPanelsLayout());
            FAKE_NoteDataXML_Text textNoteA = new FAKE_NoteDataXML_Text();

            panelB.AddNote(textNoteA);
            textNoteA.GuidForNote = "My Text Note For the B Panel";
            textNoteA.CreateParent(panelB.GetPanelsLayout());
            textNoteA.Caption = "My text B";



            FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text();

            panelA.AddNote(textNote);
            textNote.GuidForNote = "Text Note For Panel A";
            textNote.CreateParent(panelA.GetPanelsLayout());
            textNote.Caption = "My text A";
            textNote.GetRichTextBox().Text = "Hello there." + Environment.NewLine + "I am still here, are you?" + Environment.NewLine + "Yep!";
            panel.SaveLayout();
            Assert.AreEqual(7, panel.CountNotes(), "Count1");

            // Note count: Default Note + BasicNote+ PanelA + LinkTable + MyText  + PanbelB + My Text B  =7


            //test existence
            Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID));
            // counting our subpanel we have 2
            Assert.AreEqual(3, MasterOfLayouts.Count(true));
            // NOT counting our subpanel we have 1
            Assert.AreEqual(1, MasterOfLayouts.Count(false));

            // export
            string file = Path.Combine(Environment.CurrentDirectory, "exportest.txt");

            if (File.Exists(file))
            {
                File.Delete(file);
            }
            string subfile = file + "__child0.txt";

            if (File.Exists(subfile))
            {
                File.Delete(subfile);
            }
            string subfile2 = file + "__child1.txt";

            if (File.Exists(subfile2))
            {
                File.Delete(subfile2);
            }

            Assert.False(File.Exists(file), file + " does not exist");

            MasterOfLayouts.ExportLayout(ThisLayoutGUID, file);
            // test exportfile existence    // count 2 files exported
            Assert.True(File.Exists(file), "main file exists");
            Assert.True(File.Exists(subfile), "subfile exists");
            Assert.True(File.Exists(subfile2), "subfile2 exists");



            // delete original note
            MasterOfLayouts.DeleteLayout(ThisLayoutGUID);


            // test existence
            Assert.False(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID));
            // counting our subpanel we have ZERO
            Assert.AreEqual(0, MasterOfLayouts.Count(true), "Nothing should be left");
            // Import as New (but won't be duplicate because old is gone)

            int errorcode = MasterOfLayouts.ImportLayout(file);

            Console.WriteLine(errorcode);
            Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID));
            // test existence

            // confirm all notes laoded into layout
            panel = null;
            panel = new FAKE_LayoutPanel(ThisLayoutGUID, false);
            form.Controls.Add(panel);
            panel.LoadLayout(ThisLayoutGUID, false, null);
            //	panel.SaveLayout();

            Assert.AreEqual(7, panel.CountNotes(), "Count2");
            Assert.AreEqual(1, MasterOfLayouts.Count(false));
            Assert.AreEqual(3, MasterOfLayouts.Count(true));



            // Import as Overwrite
            if (File.Exists(file))
            {
                File.Delete(file);
            }
            subfile = file + "__child0.txt";
            if (File.Exists(subfile))
            {
                File.Delete(subfile);
            }
            Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID));
            MasterOfLayouts.ExportLayout(ThisLayoutGUID, file);

            panel     = null;
            errorcode = MasterOfLayouts.ImportLayout(file);
            Assert.AreEqual(0, errorcode);
            // test existences
            panel = new FAKE_LayoutPanel(ThisLayoutGUID, false);
            form.Controls.Add(panel);
            panel.LoadLayout(ThisLayoutGUID, false, null);

            Assert.AreEqual(7, panel.CountNotes());
            Assert.AreEqual(1, MasterOfLayouts.Count(false));
            Assert.AreEqual(3, MasterOfLayouts.Count(true));


            lg.Instance.OutputToConstoleToo = false;
        }
예제 #19
0
        public void IterateBigDatabase()
        {
            _TestSingleTon.Instance.SetupForAnyTest();
            LayoutDetails.Instance.YOM_DATABASE = @"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db";
            LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory;

            LayoutDetails.Instance.GetAppearanceFromStorage = _TestSingleTon.Instance.GetAppearanceFromStorage;



            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "testingtext");

            FakeLayoutDatabase   layout = new FakeLayoutDatabase("testguid");
            FAKE_SqlLiteDatabase db     = new FAKE_SqlLiteDatabase(layout.GetDatabaseName());

            LayoutDetails.Instance.SuppressWarnings = true;             /// want image missing popups not to bug us

            LayoutDetails.Instance.AddToList(typeof(NoteDataXML_Picture.NoteDataXML_Pictures), "picture");
            LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_SendIndex), "index");
            LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_Submissions), "index");

            LayoutDetails.Instance.TransactionsList = new Transactions.TransactionsTable(MasterOfLayouts.GetDatabaseType(LayoutDetails.Instance.YOM_DATABASE));


            Form form = new Form();

            // system panel
//			LayoutPanel panel = new LayoutPanel("", false);
//			panel.LoadLayout("system", false, null);


            FAKE_LayoutPanel system = new FAKE_LayoutPanel("", false);

            form.Controls.Add(system);
            system.LoadLayout("system", false, null);

            LayoutDetails.Instance.SystemLayout = system;

            FAKE_LayoutPanel tablelay = new FAKE_LayoutPanel("", false);

            form.Controls.Add(tablelay);
            tablelay.LoadLayout("tables", false, null);

            LayoutDetails.Instance.TableLayout = tablelay;
            //	YOM2013.DefaultLayouts.CreateASystemLayout(form,null);
            //	string ThisLayoutGUID = "mynewpanelXA";
            // create a layout
            //	_TestSingleTon.Instance._SetupForLayoutPanelTests (false, @"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db");
            //	_SetupForLayoutPanelTests ();

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

            form.Controls.Add(panel);
            //NOTE: For now remember that htis ADDS 1 Extra notes
            //	panel.NewLayout (ThisLayoutGUID, true, null);



            // tmp: goto all notes
            System.Collections.Generic.List <MasterOfLayouts.NameAndGuid> ss = MasterOfLayouts.GetListOfLayouts("");
            Assert.AreEqual(3651, ss.Count);
            //Console.WriteLine(ss.Count);
            //	NewMessage.Show (ss.Count.ToString ());
            int count = 0;

            foreach (MasterOfLayouts.NameAndGuid name in ss)
            {
                panel.Dispose();
                panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
                form.Controls.Add(panel);
                count++;
                panel.LoadLayout(name.Guid, false, null);
                //	MDIHOST.DoCloseNote(false);
            }
            Assert.AreEqual(3651, count);
            form.Dispose();
        }
        public void ArchiveAllAndCount()
        {
            lg.Instance.OutputToConstoleToo = true;
            Form   form           = new Form();
            string ThisLayoutGUID = "mynewpanelXA";

            // create a layout
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

            form.Controls.Add(panel);
            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout(ThisLayoutGUID, true, null);

            NoteDataXML basicNote = new NoteDataXML();

            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption     = "note1";

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


            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption     = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote(panelA);
            panelA.CreateParent(panel);


            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();

            panelB.Caption     = "PanelBBBBB2";
            panelB.GuidForNote = "panelBB";
            panelA.AddNote(panelB);
            panelB.CreateParent(panelA.GetPanelsLayout());
            FAKE_NoteDataXML_Text textNoteA = new FAKE_NoteDataXML_Text();

            panelB.AddNote(textNoteA);
            textNoteA.GuidForNote = "My Text Note For the B Panel";
            textNoteA.CreateParent(panelB.GetPanelsLayout());
            textNoteA.Caption = "My text B";



            FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text();

            panelA.AddNote(textNote);
            textNote.GuidForNote = "Text Note For Panel A";
            textNote.CreateParent(panelA.GetPanelsLayout());
            textNote.Caption = "My text A";
            textNote.GetRichTextBox().Text = "Hello there." + Environment.NewLine + "I am still here, are you?" + Environment.NewLine + "Yep!";
            panel.SaveLayout();
            Assert.AreEqual(7, panel.CountNotes(), "Count1");

            // Note count: Default Note + BasicNote+ PanelA + LinkTable + MyText  + PanbelB + My Text B  =7



            //test existence
            Assert.True(MasterOfLayouts.ExistsByGUID(ThisLayoutGUID));
            // counting our subpanel we have 2
            Assert.AreEqual(3, MasterOfLayouts.Count(true));
            // NOT counting our subpanel we have 1
            Assert.AreEqual(1, MasterOfLayouts.Count(false));

            LayoutDetails.Instance.CurrentLayout = panel;
            MefAddIns.Addin_Archive Archiver = new MefAddIns.Addin_Archive();

            // delete existing files
            string path = Archiver.BuildArchiveDepotPath();

            string[] files = Directory.GetFiles(path);
            foreach (string s in files)
            {
                File.Delete(s);
            }
            files = Directory.GetFiles(path);

            Assert.AreEqual(0, files.Length);


            Archiver.ArchiveAll(panel, "automatedtesting");
            files = Directory.GetFiles(path);
            Assert.AreEqual(3, files.Length);
        }
        public void CountPanelsSubType()
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            //FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            Assert.False(MasterOfLayouts.ExistsByGUID("testlayout"));


            _w.output("here");
            //-- do unit tests counting store 6 textboxes and know this (countbytype)
            //_setupforlayoutests ();

            _w.output("here");
            int count = 25;

            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("testlayout", false, null);
            form.Controls.Add(layoutPanel);
            form.Show();



            NoteDataXML note = new NoteDataXML();

            for (int i = 0; i < count; i++)
            {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }
            _w.output(String.Format("{0} Notes in Layout before save", layoutPanel.GetAllNotes().Count.ToString()));

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


                note.Caption = "Panel";
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
                ((NoteDataXML_Panel)note).Add10TestNotes();
            }



            layoutPanel.SaveLayout();
            layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            //_w.output(String.Format ("{0} Objects Saved", layoutPanel.ObjectsSaved().ToString()));
            layoutPanel.LoadLayout("testlayout", false, null);

//			layout = new FakeLayoutDatabase ("testguid");
//
//			layout.LoadFrom(layoutPanel);

            // now count RichText notes
            int count2       = 0;
            int subnotecount = 0;

            foreach (NoteDataInterface _note in layoutPanel.GetAllNotes())
            {
                if (_note.GetType() == typeof(NoteDataXML_Panel))
                {
                    count2++;
                    subnotecount = subnotecount + ((NoteDataXML_Panel)_note).GetChildNotes().Count;
                }
            }


            // total note count should be (once I get GetNotes working on Child Notes = 60 + 6 + 25 = 91

            _w.output(String.Format("{0} Objects Loaded", layoutPanel.GetAllNotes().Count));
            //NOT DONE YET
            Assert.AreEqual(6, count2);
            Assert.AreEqual(60, subnotecount);
            Assert.AreEqual(count2, layoutPanel.GetAvailableFolders().Count);

            // had to change because a linktable makes 91 become 92
            Assert.AreEqual(92, layoutPanel.GetAllNotes().Count);
        }