public void TryMixedTypeSave()
        {
            // 1. write data to notes
            _setupforlayoutests();
            int count = 25;
            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);

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

            for (int i = 0; i < count; i++)
            {
                note = (NoteDataInterface)Activator.CreateInstance(typeof(NoteDataXML));                //new NoteDataXML ();

                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }

            // store a SECOND TYPE into the mix
            note         = (NoteDataInterface)Activator.CreateInstance(typeof(NoteDataXML_RichText));
            note.Caption = "textnote";
            string guid = note.GuidForNote;

            _w.output("new guid" + guid);
            layoutPanel.AddNote(note);
            note.CreateParent(layoutPanel);
            layoutPanel.SaveLayout();
        }
        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));
        }
        void Function_Visible(string secondary, bool visible)
        {
            if (secondary != Constants.BLANK)
            {
                string[] windows = GetNotesToOperateOn(secondary);
                if (windows != null)
                {
                    int             counter  = 0;
                    LayoutPanelBase MyLayout = Layout;
                    GetMasterLayoutToUse(ref MyLayout);

                    foreach (string notename in windows)
                    {
                        if (notename != Constants.BLANK)
                        {
                            counter++;
                            NoteDataInterface note = MyLayout.FindNoteByName(notename);
                            if (note != null)
                            {
                                note = MyLayout.GoToNote(note);
                                if (note != null)
                                {
                                    note.Visible = visible;
                                    note.UpdateLocation();
                                }
                            }
                        }
                    }
                }
            }
        }
        int WriteANote(NoteDataInterface note, bool bGetWords, ref string sWordInformation, StreamWriter writer)
        {
            int words = 0;

            if (note != null && (note is NoteDataXML_RichText))
            {
                RichTextBox tempBox = new RichTextBox();
                tempBox.Rtf = note.Data1;
                SaveTextLineByLine(writer, tempBox.Lines, note.Caption);

                if (true == bGetWords)
                {
                    int Words =
                        LayoutDetails.Instance.WordSystemInUse.CountWords(tempBox.Text);
                    words = Words;                    //TotalWords = TotalWords + Words;



                    sWordInformation = sWordInformation + String.Format("{0}: {1}{2}", note.Caption, Words.ToString(), Environment.NewLine);
                }

                tempBox.Dispose();
            }
            return(words);
        }
        void Function_EvenWindows(string secondary, bool alpha)
        {
            if (secondary != Constants.BLANK)
            {
                string[] windows = GetNotesToOperateOn(secondary);
                if (windows != null)
                {
                    int             counter  = 0;
                    LayoutPanelBase MyLayout = Layout;
                    GetMasterLayoutToUse(ref MyLayout);

                    // initial implementation just assuming 2 notes and will split 50/50
                    int Width  = MyLayout.Width;
                    int Height = MyLayout.Height - MyLayout.HeightOfToolbars();
                    foreach (string notename in windows)
                    {
                        if (notename != Constants.BLANK)
                        {
                            counter++;
                            NoteDataInterface note = MyLayout.FindNoteByName(notename);
                            if (note != null)
                            {
                                note = MyLayout.GoToNote(note);
                                if (note != null)
                                {
                                    int NewWidth = Width / windows.Length;
                                    note.Width  = NewWidth;
                                    note.Height = Height;

                                    //note.ParentNotePanel.Top =0;
                                    int NewTop  = 0;
                                    int newLeft = 0;
                                    if (1 == counter)
                                    {
                                        newLeft = 0;
                                    }
                                    else
                                    {
                                        newLeft = ((counter - 1) * NewWidth);
                                        //											NewMessage.Show ("Setting " + note.Caption + " " + newLeft.ToString ());
                                        //											note.ParentNotePanel.Left = newLeft;
                                    }
                                    if (note is NoteDataXML_SystemOnly)
                                    {
                                        //NewMessage.Show ("System Note");
                                        note.Maximize(true);
                                        note.Maximize(false);
                                    }
                                    note.Location = new Point(newLeft, NewTop);
                                    note.UpdateLocation();
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Gos to note.
        /// Called from TablePanel
        /// </summary>
        /// <param name='NoteName'>
        /// Note name.
        /// </param>
        public void GoToNote(string NoteName)
        {
            NoteDataInterface note = Layout.FindNoteByName(NoteName);

            if (note != null)
            {
                Layout.GoToNote(note);
            }
        }
Esempio n. 7
0
        public virtual void CopyNote(NoteDataInterface Note)
        {
            // Any child will need to set the fields they want copied
            // LayoutPanel PasteNote also needs a If-Then added for this TYPE

            this.Caption    = Note.Caption;
            this.Data1      = Note.Data1;
            this.Appearance = Note.Appearance;
        }
        public void TestSavingRTFTextWorks()
        {
            Type TypeToTest = typeof(NoteDataXML_RichText);

            // 1. write data to notes
            _setupforlayoutests();
            int count = 15;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

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

            for (int i = 0; i < count; i++)
            {
                note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);                //new NoteDataXML ();

                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }


            note         = (NoteDataInterface)Activator.CreateInstance(TypeToTest);
            note.Caption = "snake";
            string guid       = note.GuidForNote;
            string teststring = "\nthe test is this ";


            note.Data1 = (@"{\rtf1\ansi\ansicpg1252\deff0\deflang4105{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}" +
                          @"\viewkind4\uc1\pard\f0\fs17\par the test is this }");


            //	note.Data1=String.Format (@"{\rtf1\ansi\ansicpg1252\deff0\deflang4105{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17\par {0} \par}", teststring);

            //"This is the story of the bird.";
            note.CreateParent(layoutPanel);
            _w.output("new guid" + guid);

            layoutPanel.AddNote(note);
            //layout.SaveTo ();
            layoutPanel.SaveLayout();
            //layout = new FakeLayoutDatabase ("testguid");
            layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.LoadLayout("testguid", false, null);
            //layout.LoadFrom(layoutPanel);

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

            NoteDataInterface result = layoutPanel.GetLayoutDatabase().GetNoteByGUID(guid);
            string            astest = ((NoteDataXML_RichText)result).GetAsText();

            _w.output(result.Data1);
            _w.output(astest);
            Assert.AreEqual(teststring, astest);
        }
Esempio n. 9
0
        public NotePanel(NoteDataInterface child)
        {
            this.BackColor = Color.Beige;
            Child          = child;
            // removing DoubleBuffered had no impact on load time performance
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw, true);

            this.Padding = new Padding(4, 0, 4, 5);
        }
Esempio n. 10
0
        public NotePanel(NoteDataInterface child)
        {
            this.BackColor = Color.Beige;
            Child = child;
            // removing DoubleBuffered had no impact on load time performance
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw, true);

            this.Padding = new Padding(4,0,4,5);
        }
Esempio n. 11
0
 public override void CopyNote(NoteDataInterface Note)
 {
     base.CopyNote(Note);
     if (Note is NoteDataXML_Table)
     {
         this.dataSource   = ((NoteDataXML_Table)Note).dataSource.Copy();
         this.TableCaption = ((NoteDataXML_Table)Note).TableCaption;
         this.NextTable    = ((NoteDataXML_Table)Note).NextTable;
     }
 }
        public void CreateAllCoreNoteTypesViaActivator()
        {
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                _w.output("creating " + t.ToString());
                NoteDataInterface note = null;

                note = (NoteDataInterface)Activator.CreateInstance(t, -1, -1);
                Assert.NotNull(note);
            }
        }
        public void CreateAllCoreNoteTypesWithAValidGUID()
        {
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                NoteDataInterface note = null;

                note = (NoteDataInterface)Activator.CreateInstance(t, -1, -1);
                Assert.NotNull(note);
                _w.output(String.Format("creating {0} with GUID {1}", t.ToString(), note.GuidForNote));
                Assert.AreNotEqual(CoreUtilities.Constants.BLANK, note.GuidForNote);
            }
        }
        /*// I made the decision to suppress Errors (hence not required CreateParent, for the purpose of MOVING notes
         * // This violated an earlier decision I had made and I had to disable the TryToSaveWithoutCreating a Parent Exception
         * [Test]
         * [ExpectedException]
         * public void TryToSaveWithoutCreatingAParent()
         * {
         *      Type TypeToTest = typeof(NoteDataXML_RichText);
         *      // 1. write data to notes
         *      _setupforlayoutests ();
         *      int count = 25;
         *      FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
         *      LayoutPanel layoutPanel = new LayoutPanel ();
         *
         *      NoteDataInterface note = null;
         *      for (int i = 0; i < count; i++) {
         *              note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);//new NoteDataXML ();
         *      //	note.CreateParent(layoutPanel);
         *              note.Caption = "boo" + i.ToString ();
         *              layout.Add (note);
         *      }
         *
         *
         *      note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);
         *      note.Caption = "snake";
         *      string guid = note.GuidForNote;
         *      //note.CreateParent(layoutPanel);
         *      _w.output("new guid" + guid);
         *      layout.Add (note);
         *      layout.SaveTo ();
         *      _w.output ("save worked");
         * }*/

        /// <summary>
        /// Creates the lots of notes to test different types and return proper caption.
        ///
        /// Testing NOTE: You must CreateParent when building items. Else the save cannot work.
        ///
        /// </summary>
        /// <returns>
        /// The lots of notes to test different types and return proper caption.
        /// </returns>
        /// <param name='TestCaption'>
        /// Test caption.
        /// </param>
        /// <param name='TypeToTest'>
        /// Type to test.
        /// </param>
        private string CreateLotsOfNotesToTestDifferentTypesAndReturnProperCaption(string TestCaption, Type TypeToTest)
        {
            // 1. write data to notes
            //System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


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

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

            NoteDataInterface note = null;

            for (int i = 0; i < count; i++)
            {
                note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);                //new NoteDataXML ();

                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }


            note         = (NoteDataInterface)Activator.CreateInstance(TypeToTest);
            note.Caption = TestCaption;
            string guid = note.GuidForNote;

            note.CreateParent(layoutPanel);
            _w.output("new guid" + guid);
            layoutPanel.AddNote(note);
            layoutPanel.SaveLayout();
            _w.output("save worked");

            // 2. Now we pretend that later one, elsewhere in code, we need to get access to this (i.e., a Random Table)
            layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            //layout = new FakeLayoutDatabase ("testguid");
            layoutPanel.LoadLayout("testguid", false, null);

            //layoutPanel.LoadLayout( (null);
            //	_w.output (layout.Backup ());
            //_w.output(layoutPanel.GetNotes().Count.ToString());
            foreach (NoteDataXML _note in layoutPanel.GetAllNotes())
            {
                if (_note.GuidForNote == guid)
                {
                    _w.output(_note.Caption);
                    return(note.Caption);
                }
            }
            return("<error>");
        }
Esempio n. 15
0
 /// <summary>
 /// Adds the note. (during a move operation. Called from LayoutPanel)
 /// </summary>
 /// <param name='note'>
 /// Note.
 /// </param>
 public void AddNote(NoteDataInterface note)
 {
     if (null == panelLayout)
     {
         throw new Exception("No layout defined for this Subpanel. Did you remember to add it to a Layout?");
     }
     else
     {
         panelLayout.AddNote(note);
     }
     // jan 20 2013 - added this because i was doing an Update in LayoutPanel but that was causing
     // issues with destroying/disposing the original object
     //note.CreateParent(panelLayout);
 }
Esempio n. 16
0
        public void Quicker_UpdateAfterLoadTest()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


            System.Windows.Forms.Form 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 < 5; i++)
                {
                    NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance(t);
                    panel.AddNote(note);
                    note.CreateParent(panel);

                    note.UpdateAfterLoad();
                }
            }

            panel.SaveLayout();
            form.Dispose();
        }
Esempio n. 17
0
        /// <summary>
        /// Sets the data. Called from CreateParent
        /// </summary>
        /// <param name='note'>
        /// Note.
        /// </param>
        private void SetData(NoteDataInterface note)
        {
            string link = note.GetLinkData();

            if (General.IsGraphicFile(link))
            {
                // A linknote will not benefit from the smart file finding that a NotePicture might do in tracking down a missing file
                if (File.Exists(link) == true)
                {
                    //trying to figure out why refresh does not work (Aug 2013) -- getting rid of it fixed things
                    //if (null == Pic)
                    {
                        Pic = new PictureBox();
                        ParentNotePanel.Controls.Add(Pic);
                        Pic.SizeMode = PictureBoxSizeMode.StretchImage;

                        //}
                        Pic.Dock        = DockStyle.Fill;
                        Pic.Visible     = true;
                        richBox.Visible = false;

                        Pic.Image = Image.FromFile(link);
                        // we store this for use when a storyboard wants to link to a linked iamge
                        Pic.Image.Tag = link;
                        //	NewMessage.Show (link);
                    }
                }
                else
                {
                    this.richBox.Text = Loc.Instance.GetStringFmt("The file {0} does not exist. If the original note displays correctly it might be that the file is not actually in the location set. Doublecheck.", link);
                }
            }
            else
            {
                if (Pic != null)
                {
                    Pic.Visible   = false;
                    Pic.Image.Tag = null;
                    Pic.Image.Dispose();
                    richBox.Visible = true;
                }
                this.richBox.Rtf = link;
            }
        }
        //This is just proves a deeper system. Will need to be done properly, probably via an AddIn
        //right now the context is GetLayoutBy("section", "writing")
        //returns a random NOTE  matching context INCLUDING notes on subpanels
        public static string GetRandomNoteBy(string typeofsearch, string param)
        {
            typeofsearch = dbConstants.NOTEBOOK;

            BaseDatabase    MyDatabase = CreateDatabase();
            List <object[]> results    = MyDatabase.GetValues(dbConstants.table_name, new string[2] {
                dbConstants.NAME, dbConstants.GUID
            }, typeofsearch, param);
            // Do a query on the database
            // then process, grabbing first ONE Layout out of the mix
            //

            string temp = "";
            string guid = Constants.BLANK;

            if (results != null && results.Count > 0)
            {
                int pickme = LayoutDetails.Instance.RandomNumbers.Next(1, results.Count + 1);
                temp = results [pickme - 1] [0].ToString();
                guid = results [pickme - 1] [1].ToString();
            }



            if (Constants.BLANK != guid)
            {
                // we load it
                LayoutInterface layoutdata = LayoutDetails.DATA_Layout(guid);
                //	LayoutPanelBase panel = new Layout.LayoutPanel();
                layoutdata.LoadFrom(null);
                System.Collections.ObjectModel.ReadOnlyCollection <NoteDataInterface> listofnotes = layoutdata.GetNotes();
                if (listofnotes != null && listofnotes.Count > 0)
                {
                    int pickme = LayoutDetails.Instance.RandomNumbers.Next(1, listofnotes.Count + 1);
                    NoteDataInterface randomNote = (NoteDataInterface)listofnotes[pickme - 1];
                    temp = String.Format("Layout: {0} Note Caption: {1}", temp, randomNote.Caption);
                }
            }
            MyDatabase.Dispose();
            // additional hack is just to return the CAPTION, not the GUID, else I won't know if it worked!
            return(temp);
        }
        /// <summary>
        /// Handles the list box double click.
        ///
        /// Will go to the note (if in OnLayout mode) or open a new note
        ///
        /// </summary>
        /// <param name='sender'>
        /// Sender.
        /// </param>
        /// <param name='e'>
        /// E.
        /// </param>
        void HandleListBoxDoubleClick(object sender, EventArgs e)
        {
            if (this.list.SelectedItem != null)
            {
                if (Modes.NOTES == _mode)
                {
                    NoteDataInterface note = (NoteDataInterface)this.list.SelectedItem;

                    if (note != null)
                    {
                        Layout.GoToNote(note);
                    }
                    else
                    {
                        lg.Instance.Line("LayoutPanel->HandleTabButtonClick", ProblemType.WARNING, String.Format("Note with guid = {0} not found", note.GuidForNote));
                    }
                }
                else
                if (Modes.LAYOUTS == _mode)
                {
                    MasterOfLayouts.NameAndGuid record = (MasterOfLayouts.NameAndGuid) this.list.SelectedItem;
                    LayoutDetails.Instance.LoadLayout(record.Guid);
                }
                else
                if (Modes.LAYOUTSONCURRENTLAYOUT == _mode)
                {
                    if (LayoutDetails.Instance.CurrentLayout != null)
                    {
                        NoteDataInterface note = (NoteDataInterface)this.list.SelectedItem;
                        if (note != null)
                        {
                            LayoutDetails.Instance.CurrentLayout.GoToNote(note);
                        }
                        else
                        {
                            lg.Instance.Line("LayoutPanel->HandleTabButtonClick", ProblemType.WARNING, String.Format("Note with guid = {0} not found", note.GuidForNote));
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Moves the note from one Layout to another.
        /// 
        /// THe layout that is OWNING this currently is the one that called the MOVE
        /// </summary>
        /// <param name='GUIDOfNoteToMove'>
        /// GUID of note to move.
        /// </param>
        /// <param name='GUIDOfLayoutToMoveItTo'>
        /// GUID of layout to move it to.
        /// </param>
        /// <returns>The Layout where the Note was Added to</returns>
        public void RemoveNote(NoteDataInterface NoteToMove)
        {
            //NoteDataInterface NoteToMove = dataForThisLayout.Find (NoteDataInterface => NoteDataInterface.GuidForNote == GUIDOfNoteToMove);
            if (NoteToMove != null) {
                // THis was NOT causing problems with TestMovingNotes
                NoteToMove.Destroy();
                if (dataForThisLayout.Remove (NoteToMove) == false)
                {
                    lg.Instance.Line("LayoutDatabase.MoveNote", ProblemType.WARNING,"Was unable to REmove this note");
                }

            }

            /*
            // Take 1 -- seemed too complicated
            string GUIDOfLayoutThatOwnsIt = this.LayoutGUID;

            SaveTo ();
            LayoutDatabase newLayout = null;

            // grab note out of the list
            NoteDataInterface NoteToMove = dataForThisLayout.Find (NoteDataInterface=>NoteDataInterface.GuidForNote == GUIDOfNoteToMove);
            if (NoteToMove != null) {
                Console.WriteLine ("moving " + NoteToMove.Caption);
                newLayout = new LayoutDatabase(GUIDOfLayoutToMoveItTo);
                newLayout.LoadFrom (null);
                newLayout.Add (NoteToMove);
                try
                {
                    Console.WriteLine ("before save");
                newLayout.SaveTo();
                    Console.WriteLine ("after save");
                }
                catch (Exception ex)
                {
                    Console.WriteLine (ex.ToString());
                }

                // how to load new object
                if (dataForThisLayout.Remove (NoteToMove) == false)
                {
                    lg.Instance.Line("LayoutDatabase.MoveNote", ProblemType.WARNING,"Was unable to REmove this note");
                }
                // We do the rest of these steps in the LayoutPanel that called this routine
                // need to reload the Layout We Added To First before saving this layotu
                //SaveTo();
            }
            Console.WriteLine(String.Format ("MOVE DONE {0} {1} {2}", GUIDOfNoteToMove, GUIDOfLayoutThatOwnsIt, GUIDOfLayoutToMoveItTo));
            return newLayout;*/
        }
Esempio n. 21
0
 public void AddToStart(NoteDataInterface note)
 {
     // need to make sure linktable goes to start of list
     // only link table should do this
     if (note.GuidForNote != CoreUtilities.Links.LinkTable.STICKY_TABLE) {
         throw new Exception ("Only LinkTables call this method");
     }
     if (null != note) {
         lg.Instance.Line("AddToStart", ProblemType.MESSAGE, String.Format ("Adding  to {0}  the linktable. Count before was {1}", LayoutGUID, dataForThisLayout.Count));
         dataForThisLayout.Insert (0, (NoteDataXML) note);
         lg.Instance.Line("AddToStart", ProblemType.MESSAGE, String.Format ("Adding  to {0}  the linktable. Count AFTER was {1}", LayoutGUID, dataForThisLayout.Count));
     }
 }
Esempio n. 22
0
 public NoteDataInterface[] GetNotesSorted()
 {
     NoteDataInterface[] notes_array = new NoteDataInterface[dataForThisLayout.Count];
     dataForThisLayout.CopyTo (notes_array);
     Array.Sort (notes_array);
     return notes_array;
 }
Esempio n. 23
0
 public NoteDataXML_RichText(NoteDataInterface Note) : base(Note)
 {
 }
Esempio n. 24
0
 /// <summary>
 /// Adds the children. If a panel notetype
 /// </summary>
 /// <returns>
 /// The children.
 /// </returns>
 /// <param name='data'>
 /// Data.
 /// </param>
 /// <param name='result'>
 /// Result.
 /// </param>
 private void AddChildrenToGetList(NoteDataInterface data,  System.Collections.ArrayList result)
 {
     lg.Instance.Line("AddChildrenToList", ProblemType.TEMPORARY, "checking...");
     if ( data.IsPanel == true)
     {
         lg.Instance.Line("AddChildrenToList", ProblemType.TEMPORARY, "is a Panel...");
         foreach (NoteDataInterface data2 in data.GetChildNotes())
         {
             lg.Instance.Line("AddChildrenToList", ProblemType.TEMPORARY,
                              String.Format ("scanning children...{0} from {1}",data2.GuidForNote, data.Caption ));
             result.Add (data2);
             // jan 2 2013
             // THis is not needed here becaues GetChildNotes() covers the situation for us!
             //AddChildrenToGetList(data2,  result);
         }
     }
 }
 public abstract void DeleteNote(NoteDataInterface NoteToDelete);
 public abstract NoteDataInterface FindSubpanelNote(NoteDataInterface note);
 public NoteDataXML_NoteList(NoteDataInterface Note)
     : base(Note)
 {
 }
 public NoteDataXML_Timeline(NoteDataInterface Note)
     : base(Note)
 {
 }
Esempio n. 29
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 NoteDataXML_Submissions(NoteDataInterface Note)
     : base(Note)
 {
 }
Esempio n. 31
0
 public override void CopyNote(NoteDataInterface Note)
 {
     base.CopyNote(Note);
 }
 public override void CopyNote(NoteDataInterface Note)
 {
     base.CopyNote (Note);
 }
        public override void CopyNote(NoteDataInterface Note)
        {
            base.CopyNote (Note);
            if (Note is NoteDataXML_SendIndex) {
                this.CopyObject ((Note as NoteDataXML_SendIndex).Controller, this.Controller);

            }
        }
Esempio n. 34
0
 /*Not needed?
 private List<NoteDataInterface> DataForThisLayout {
     get { return dataForThisLayout;}
     set { dataForThisLayout = value;}
 }
 */
 /// <summary>
 /// Add the specified note to the DataForThisLayout list
 /// </summary>
 /// <param name='note'>
 /// Note.
 /// </param>
 public void Add(NoteDataInterface note)
 {
     dataForThisLayout.Add((NoteDataXML)note);
 }
        public override void CopyNote(NoteDataInterface Note)
        {
            base.CopyNote (Note);

            // I moved the data1 copying into NoteDataXML for more flexibility
        }
 //	public abstract  void AddNote();
 public abstract void AddNote(NoteDataInterface note);
 public NoteDataXML_RichText(NoteDataInterface Note)
     : base(Note)
 {
 }
 public abstract NoteDataInterface GoToNote(NoteDataInterface note);
Esempio n. 39
0
 private static bool FindGUID(NoteDataInterface note, string guid)
 {
     if (note.GuidForNote == "") {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 40
0
        public override void CopyNote(NoteDataInterface Note)
        {
            base.CopyNote(Note);

            // I moved the data1 copying into NoteDataXML for more flexibility
        }
 public NoteDataXML_GroupEm(NoteDataInterface Note)
     : base(Note)
 {
 }
 public NoteDataXML_Timeline(NoteDataInterface Note) : base(Note)
 {
 }
 public override void CopyNote(NoteDataInterface Note)
 {
     base.CopyNote (Note);
     if (Note is NoteDataXML_Character)
     {
         this.Gender = (Note as NoteDataXML_Character).Gender;
         this.Priority = (Note as NoteDataXML_Character).Priority;
         this.Alias = (Note as NoteDataXML_Character).Alias;
         this.ColorName =  (Note as NoteDataXML_Character).ColorName;
     }
 }
 public NoteDataXML_SendIndex(NoteDataInterface Note)
     : base(Note)
 {
 }
 public NoteDataXML_Character(NoteDataInterface Note)
     : base(Note)
 {
 }
Esempio n. 46
0
 public NoteDataXML_LinkNote(NoteDataInterface Note) : base(Note)
 {
 }
Esempio n. 47
0
 public override void CopyNote(NoteDataInterface Note)
 {
     base.CopyNote (Note);
     this.Token = ((NoteDataXML_Facts)Note).Token;
     this.FactParseNote = ((NoteDataXML_Facts)Note).FactParseNote;
 }
Esempio n. 48
0
        protected override void DoBuildChildren(LayoutPanelBase Layout)
        {
            base.DoBuildChildren(Layout);
            ReadOnlyButton.CheckOnClick = false;
            string linkfile = GetLink();


            ToolStripButton SetupLinkButton = new ToolStripButton();

            SetupLinkButton.Text   = Loc.Instance.GetString("Paste Link");
            SetupLinkButton.Click += HandleSetupLinkClick;

            ToolStripButton RefreshLinkButton = new ToolStripButton();

            RefreshLinkButton.Text   = Loc.Instance.GetString("Refresh Link");
            RefreshLinkButton.Click += HandleRefreshLinkClick;


            properties.DropDownItems.Add(SetupLinkButton);
            properties.DropDownItems.Add(RefreshLinkButton);



            if (linkfile != Constants.BLANK)
            {
                if (this.richBox.Text == Constants.BLANK)
                {
                    string[] links = linkfile.Split(new char[1] {
                        '.'
                    });
                    if (links.Length == 2)
                    {
                        // we have a valid link
                        LayoutGuid = links[0];
                        ChildGuid  = links[1];
                        if (LayoutGuid != Constants.BLANK && ChildGuid != Constants.BLANK)
                        {
                            // now retrieve parent
                            NoteDataInterface note = MasterOfLayouts.GetNoteFromInsideLayout(LayoutGuid, ChildGuid);

                            // TODO: if null then iterate through all CHILDREN PANELS???
                            if (null == note)
                            {
                                System.Collections.Generic.List <string> children = MasterOfLayouts.GetListOfChildren(LayoutGuid);
                                foreach (string child in children)
                                {
                                    note = MasterOfLayouts.GetNoteFromInsideLayout(child, ChildGuid);
                                    if (note != null)
                                    {
                                        break;
                                    }
                                }
                            }


                            if (note != null)
                            {
                                if (true == note.IsLinkable)
                                {
                                    SetData(note);
                                }
                            }
                            else
                            {
                                string name = MasterOfLayouts.GetNameFromGuid(LayoutGuid);
                                if (Constants.BLANK != name)
                                {
                                    this.richBox.Text = name;
                                }
                                else
                                {
                                    this.richBox.Text = Loc.Instance.GetStringFmt("There is a link but the target does not appear to be imported yet. Guid is {0}", linkfile);
                                }
                            }



                            // now grab child text
                        }
                    }

                    else
                    {
                        this.richBox.Text = Loc.Instance.GetStringFmt("There is a link but the target does not appear to be imported yet. Guid is {0}", linkfile);
                    }
                }
            }
            else
            {
                this.richBox.Text = Loc.Instance.GetString("Start a link by selecting the note you want to link to and select the Link option. Then return here to set the link up");
            }

            Button GoToLayout = new Button();

            GoToLayout.Dock    = DockStyle.Top;
            GoToLayout.Text    = Loc.Instance.GetString("Go To Link");
            GoToLayout.Enabled = false;
            GoToLayout.Click  += HandleGoToLayoutClick;
            if (LayoutGuid != Constants.BLANK)
            {
                GoToLayout.Enabled = true;
            }

            ParentNotePanel.Controls.Add(GoToLayout);
            GoToLayout.BringToFront();
            richBox.BringToFront();
        }
        /// <summary>
        /// Parses the note into table -- will added each line
        /// </summary>
        /// <param name='note'>
        /// Note.
        /// </param>
        void ParseNoteIntoTable(NoteDataInterface note)
        {
            RichTextBox tmp = new RichTextBox();
            tmp.Rtf = note.Data1;
            string Source = tmp.Text;
            tmp.Dispose();

            // assuming is not null, already tested for this
            string[] ImportedItems = Source.Split (new string[2]{"\r\n","\n"}, StringSplitOptions.RemoveEmptyEntries);
            if (ImportedItems != null && ImportedItems.Length > 0) {
                //int count = 0;
                foreach (string item in ImportedItems) {
                    if (item != Constants.BLANK)
                    {
                    if (IsTextAlreadyInTable(item) == false)
                    {
                        int count = RowCount();
                        this.AddRow (new object[3]{count.ToString (),item, "0"});
                        //count++;
                    }
                    }
                    // if text IS IN table, we don't do anything during a parse.
                }
            }
        }
Esempio n. 50
0
        public void AdvancedSearchingForNotesTests()
        {
            _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 DiversionPanel = new FAKE_NoteDataXML_Panel();

            DiversionPanel.Caption = "WeAdd this to make the FindFail later by having an empty layout that sends buggy searches down the wrong corridor";
            panel.AddNote(DiversionPanel);
            DiversionPanel.CreateParent(panel);


            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

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

            basicNote             = new NoteDataXML();
            basicNote.GuidForNote = "thisguid2";
            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();

            NoteDataInterface finder = null;

            finder = panel.FindNoteByGuid("thisguid1");
            Assert.NotNull(finder.ParentNotePanel);
            _w.output("C: " + finder.Caption);
            Assert.AreEqual(finder.Caption, "note1");
            Assert.NotNull(finder.ParentNotePanel);
            finder = null;

            // this note is on a subpanel
            finder = panel.FindNoteByGuid("thisguid2");

            Assert.NotNull(finder);
            Assert.AreEqual(finder.Caption, "note2");

            finder = panel.GoToNote(finder);
            // added this February 2013 because this code stopped finding notes within subpanels for some reason
            Assert.NotNull(finder.ParentNotePanel);
            // find notes inside of notes with the GUI code and such

            // now test the fast search function
            NoteDataInterface foundNote2 = panel.GetNoteOnSameLayout(finder.GuidForNote, false);

            Assert.NotNull(foundNote2);

            Assert.AreEqual(finder.GuidForNote, foundNote2.GuidForNote);
            Assert.NotNull(foundNote2.ParentNotePanel);
        }
 public NoteDataXML_Checklist(NoteDataInterface Note)
     : base(Note)
 {
     this.Notelink = ((NoteDataXML_Checklist)Note).Notelink;
 }
Esempio n. 52
0
        int WriteANote(NoteDataInterface note, bool bGetWords, ref string sWordInformation, StreamWriter writer)
        {
            int words = 0;
            if (note != null && (note is NoteDataXML_RichText))
            {
                RichTextBox tempBox = new RichTextBox();
                tempBox.Rtf = note.Data1;
                SaveTextLineByLine(writer, tempBox.Lines, note.Caption);

                if (true == bGetWords)
                {
                    int Words =
                        LayoutDetails.Instance.WordSystemInUse.CountWords(tempBox.Text);
                    words = Words;//TotalWords = TotalWords + Words;

                    sWordInformation = sWordInformation + String.Format("{0}: {1}{2}", note.Caption, Words.ToString(), Environment.NewLine);
                }

                tempBox.Dispose();
            }
            return words;
        }
 public override void CopyNote(NoteDataInterface Note)
 {
     base.CopyNote (Note);
     this.PrimaryDetails = ((NoteDataXML_Button)Note).PrimaryDetails;
     this.SecondaryDetails = ((NoteDataXML_Button)Note).SecondaryDetails;
 }