コード例 #1
0
        /// <summary>
        /// Gets the link. Returns it in the format
        /// ParentLayout.ChildNote
        /// </summary>
        /// <returns>
        /// The link.
        /// </returns>
        protected virtual string GetLink()
        {
            string stringResult = Constants.BLANK;

            // The link Table will be null if we are using the FindNote functions, in which case we ignore this though log it in case its an error
            if (Layout.GetLinkTable() != null)
            {
                LinkTableRecord result = Array.Find(Layout.GetLinkTable().GetRecords(),
                                                    LinkTableRecord => LinkTableRecord.sExtra == String.Format(CoreUtilities.Links.LinkTableRecord.PageLinkFormatString,
                                                                                                               Layout.GUID, this.GuidForNote));
                stringResult = Constants.BLANK;

                if (result != null)
                {
                    lg.Instance.Line("NoteDataXML_LinkNote->GetLink", ProblemType.MESSAGE, result.sFileName);
                    stringResult = result.sFileName;
                }
                else
                {
                    lg.Instance.Line("NoteDataXML_LinkNote->GetLink", ProblemType.WARNING, "No  file defined");
                }
            }
            else
            {
                lg.Instance.Line("NoteDataXML_LinkNote->GetLInk", ProblemType.WARNING, "Possible error in GetLink, the LinkTable was null though that is OKAY if called during a FindNote search");
            }
            return(stringResult);           //@"C:\Users\Public\Pictures\PhotoStage\001.jpg";
        }
コード例 #2
0
        // sFile comes in the format of parent.child
        public virtual void SetLink(string file)
        {
            //the sExtra needs to be in Parent.Child form for the REciprocal links to work later

            LinkTableRecord result = Array.Find(Layout.GetLinkTable().GetRecords(), LinkTableRecord => LinkTableRecord.sExtra == String.Format(CoreUtilities.Links.LinkTableRecord.PageLinkFormatString, Layout.GUID, this.GuidForNote));

            //string file = String.Format (CoreUtilities.Links.LinkTableRecord.PageLinkFormatString, LayoutGuid, ChildGuid);


            // August 2013 -- moved this out of the results==null routine BEACAUSE we need this to be updated when
            //editing a link too! Not just on the initial creation
            string newCaption = Constants.BLANK;

            // may 2013 - if we have a * it means we have a caption encoded at end of string and this neesd to be removed.
            if (file.IndexOf("*") > -1)
            {
                string[] details = file.Split(new char[1] {
                    '*'
                });
                if (details != null && details.Length == 2)
                {
                    file         = details[0];
                    newCaption   = details[1];
                    this.Caption = newCaption;
                }
            }

            if (result == null)
            {
                // add new
                result = new LinkTableRecord();


                result.sFileName = file;


                string SourceContainerGUIDToUse = Layout.GUID;



                result.sExtra = String.Format(CoreUtilities.Links.LinkTableRecord.PageLinkFormatString, SourceContainerGUIDToUse, this.GuidForNote);
                result.sText  = this.Caption;

                Layout.GetLinkTable().Add(result);
            }
            else
            {
                // edit existing
                result.sFileName = file;
                Layout.GetLinkTable().Edit(result);
            }
            this.richBox.Text = Constants.BLANK;
            // force a save else table might not be made correctly
            Layout.SaveLayout();
            Update(Layout);
            BringToFrontAndShow();
        }