示例#1
0
 public void OnDialogClosed(IQuickFilingDialog qfDialog)
 {
     try
     {
         if (!string.IsNullOrEmpty(qfDialog.SelectedItem))
         {
             if (_hierarchyType == HierarchyType.Pages)
             {
                 //MessageBox.Show(qfDialog.SelectedItem.ToString());
                 string mmGuid = OnenoteUtils.AddOrGetMeta(qfDialog.SelectedItem,
                                                           new Meta("mindmanagerguid", Guid.NewGuid().ToString()));
                 string ret = OnenoteUtils.GetLink(qfDialog.SelectedItem);
                 ret    += "&mm-guid={" + mmGuid + "}";
                 retlink = ret.ToString();
             }
             else if (_hierarchyType == HierarchyType.Sections)
             {
                 retlink = qfDialog.SelectedItem;
             }
         }
         else
         {
             throw new OneMapException("No Item selected");
         }
     }
     catch (Exception ex)
     {
         throw new OneMapException("could not add meta->OnDialogClosed+++" + ex.ToStringReflection(), ex, ex.GetBaseException());
     }
     finally
     {
         exitThread = false;
     }
 }
示例#2
0
        public static void SyncHyperLink(ref Hyperlink onenoteLink)
        {
            string currentHyperLink = onenoteLink.Address + onenoteLink.Arguments;

            try
            {
                string mmguid = currentHyperLink.Substring(currentHyperLink.IndexOf("mm-guid="));
                //mmguid = mmguid.Replace("mm-guid", "").Replace("=", "").Replace("}", "").Replace("{", "").Replace('"', ' ');
                mmguid = mmguid.Replace('"', ' ');
                mmguid = mmguid.Replace(" ", "{", "}", "=", "mm-guid").Trim();
                var newHyperlink = OnenoteUtils.GetHyperLinkBymmGuid(mmguid);
                if (newHyperlink != string.Empty)
                {
                    //todo: does # inside strings adds a bookmark and what should be done.
                    // otherwise it adds the #tail at the end of bookmarks
                    onenoteLink.Bookmark = "";
                    newHyperlink        += "&mm-guid={" + mmguid + "}";
                    var hl = Utils.GetMindManagerLink(newHyperlink);
                    onenoteLink.Address   = hl.Text;
                    onenoteLink.Arguments = hl.Argument;
                }
            }
            catch (OneMapException ex)
            {
                throw new OneMapException("Error in SyncHyperLink", ex);
            }
            catch (Exception ex)
            {
                throw new OneMapException("Error in SyncHyperLink", ex);
            }
            finally
            {
            }
        }
示例#3
0
        public void TestMethod1()
        {
            var temp =
                @"onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#tttooo&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={166B3538-91ED-4CC5-AFC5-6F9B0EBCCA61}&end&mm-guid={4f3850ca-29b5-4b2b-9aca-947c31384868}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#Oaa&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={DFC69630-51C3-49C9-8E33-02653A8CCF93}&end&mm-guid={c9e1e5bc-e2c1-480a-bce2-ab53973ca93e}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#Obb&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={B1B3514C-5695-4416-B738-915681D71189}&end&mm-guid={69871266-e520-44ff-a0ce-86ffff1524bc}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#Occ23&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={2B8003F0-E949-42CE-8CAC-769557087002}&end&mm-guid={c66720fc-26cf-4293-898c-1dbd38a54ca6}
onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#Odd&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={51C1EAFE-168E-4B03-8629-2A792A1FA99C}&end&mm-guid={b6db3e91-b974-4dce-9648-0b51e1a6f995}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={B6DF9CF1-6F07-4AEB-98C6-D909D60FAE83}&end&mm-guid={79c8db69-4e7d-4fb1-921b-aa0a6be0f479}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={3B6715AF-B557-4FB4-9E17-CB0ED1160F68}&end&mm-guid={9406af74-8ed0-45f7-8846-9ec2802d602b}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#Fdsfdsfds&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={2200CC75-9986-48CE-80FE-8FE4F276AAF1}&end&mm-guid={72571467-a8ac-40dd-8f43-84052857676a}@onenote:///H:\mybase\onenote\notebooks\asp.net\asp.net\testsection1.one#Main%20Topic&section-id={0BEEFA4B-1CE9-4EA5-9483-E48211243F16}&page-id={A2C520A7-346B-43D5-B907-CB2B38F7DF3D}&end&mm-guid={15467fe1-6ef5-4e67-8369-e92958cdce29}";

            string[] items = temp.Split('@');
            foreach (var it in items)
            {
                Assert.IsTrue((OnenoteUtils.ValidateOnenoteLink(it) != "success"));
            }
        }
示例#4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var document = _app.ActiveDocument;

            try
            {
                IEnumerator enumerator = document.Range(MmRange.mmRangeAllTopics, false).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var topic = enumerator.Current as Topic;
                    if (topic != null && topic.HasHyperlink)
                    {
                        foreach (var hyperlink in topic.Hyperlinks.AsEnumerable())
                        {
                            if (Utils.IsValidLink(hyperlink))
                            {
                                string currentHyperLink = hyperlink.Address + "#" + hyperlink.Bookmark +
                                                          hyperlink.Arguments;
                                string mmguid = currentHyperLink.Substring(currentHyperLink.IndexOf("mm-guid="));
                                mmguid =
                                    mmguid.Replace("mm-guid", "")
                                    .Replace("=", "")
                                    .Replace("}", "")
                                    .Replace("{", "")
                                    .Replace('"', ' ');
                                var newHyperlink = OnenoteUtils.GetHyperLinkBymmGuid(mmguid);
                                // MessageBox.Show("newhyperlink: " + newHyperlink);
                                if (string.IsNullOrEmpty(newHyperlink))
                                {
                                    hyperlink.Bookmark  = "";
                                    hyperlink.Arguments = "";
                                    hyperlink.Delete();
                                }
                            }
                        }
                    }
                }
                Initialize();
            }
            catch (COMException cex)
            {
                throw new OneMapException("btnDelete_Click-> couldn't delete link", cex.InnerException, cex.GetBaseException());
            }
            catch (Exception ex)
            {
                throw new OneMapException("btnDelete_Click-> couldn't delete link");
            }
            finally
            {
                Utils.ReleaseComObject(document);
            }
        }
示例#5
0
            private void ImportPageLink(string selectedItem)
            {
                string retstring = OnenoteUtils.GetMindManagerLink(selectedItem);

                if (!string.IsNullOrEmpty(retstring))
                {
                    var       seltopic  = _mindManager.ActiveDocument.Selection.PrimaryTopic;
                    var       hl        = Utils.GetMindManagerLink(retstring);
                    Hyperlink hyperlink = seltopic.Hyperlinks.AddHyperlink(hl.Text);
                    hyperlink.Arguments = hl.Argument;

                    // _mindManager.ActiveDocument.Save();
                }
            }
示例#6
0
            private void ImportSectionLinks(string selectedItem)
            {
                var retstring = selectedItem;
                var pDialog   = new ProgressDialog();

                try
                {
                    var owner = new Win32Window(Process.GetCurrentProcess().MainWindowHandle);
                    pDialog.Show(owner);
                    var selTopic = _mindManager.ActiveDocument.Selection.PrimaryTopic;
                    if (selTopic != null)
                    {
                        var pageIds = OnenoteUtils.GetSectionPageIds(retstring);
                        int count   = pageIds.Count();
                        int block   = 100 / count;
                        pDialog.Progress = 100 % count;
                        string mmLink;
                        foreach (var pageId in pageIds)
                        {
                            mmLink = OnenoteUtils.GetMindManagerLink(pageId);
                            var hl = Utils.GetMindManagerLink(mmLink);

                            pDialog.Progress += block;
                            pDialog.Message   = hl.Title;
                            Topic topic = selTopic.AddSubTopic(hl.Title);
                            if (!string.IsNullOrEmpty(mmLink))
                            {
                                Hyperlink hyperlink = topic.Hyperlinks.AddHyperlink(hl.Text);
                                hyperlink.Arguments = hl.Argument;
                            }

                            Application.DoEvents();
                            //_MindManager.ActiveDocument.Save();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error importing section: " + ex.Message);
                }
                finally
                {
                    pDialog.Close();
                }
            }
示例#7
0
 public void SyncDocumentWithOnenote()
 {
     if (OnenoteUtils.WSearchIsOn())
     {
         try
         {
             Utils.SyncActiveDocumentWithOnenote(ref _MindManager);
         }
         catch (Exception ex)
         {
             throw new OneMapException("SyncDocumentWithOneNote-> couldn't synchronize document with onenote", ex);
         }
         //  _MindManager.ActiveDocument.Save();
     }
     else
     {
         MessageBox.Show("WSearch is not on!!!!");
     }
 }
示例#8
0
 private void SyncTopicLinksWithOnnote()
 {
     if (OnenoteUtils.WSearchIsOn())
     {
         var      seltopic = _MindManager.ActiveDocument.Selection.PrimaryTopic;
         SyncForm syncForm = new SyncForm();
         try
         {
             Utils.SyncTopicWithOnenote(seltopic, ref syncForm);
         }
         catch (Exception ex)
         {
             throw new OneMapException("SyncDocumentWithOneNote-> couldn't synchronize document with onenote", ex);
         }
         finally
         {
             syncForm.Close();
         }
     }
     else
     {
         MessageBox.Show("WSearch is not on!!!!");
     }
 }
示例#9
0
        private void Initialize()
        {
            lstLinks.Items.Clear();
            var document = _app.ActiveDocument;
            var linkList = new List <Tuple <string, bool, string, string> >();

            try
            {
                //todo: don't know what filter is used for
                IEnumerator enumerator = document.Range(MmRange.mmRangeAllTopics, false).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var topic = enumerator.Current as Topic;
                    if (topic != null && topic.HasHyperlink)
                    {
                        foreach (var hyperlink in topic.Hyperlinks.AsEnumerable())
                        {
                            if (Utils.IsValidLink(hyperlink))
                            {
                                string currentHyperLink = hyperlink.Address + "#" + hyperlink.Bookmark + hyperlink.Arguments;
                                string mmguid           = currentHyperLink.Substring(currentHyperLink.IndexOf("mm-guid="));
                                mmguid =
                                    mmguid.Replace("mm-guid", "")
                                    .Replace("=", "")
                                    .Replace("}", "")
                                    .Replace("{", "")
                                    .Replace('"', ' ');
                                var newHyperlink = OnenoteUtils.GetHyperLinkBymmGuid(mmguid);
                                // MessageBox.Show("newhyperlink: " + newHyperlink);

                                //if newHyperlink is not empty then onenote page exists
                                if (!string.IsNullOrEmpty(newHyperlink))
                                {
                                    var foundHyperLink = linkList.Any(x => x.Item4.Contains(newHyperlink));
                                    if (!foundHyperLink)
                                    {
                                        if (currentHyperLink.Contains("&section-id"))
                                        {
                                            linkList.Add(
                                                new Tuple <string, bool, string, string>(
                                                    currentHyperLink.Substring(0,
                                                                               currentHyperLink.IndexOf("&section-id")),
                                                    true, topic.Guid, newHyperlink));
                                        }
                                        else if (currentHyperLink.Contains("section-id"))
                                        {
                                            linkList.Add(
                                                new Tuple <string, bool, string, string>(
                                                    currentHyperLink.Substring(0,
                                                                               currentHyperLink.IndexOf("section-id")),
                                                    false, topic.Guid, newHyperlink));
                                        }
                                    }
                                }
                                else
                                {
                                    linkList.Add(
                                        new Tuple <string, bool, string, string>(
                                            currentHyperLink.Substring(0,
                                                                       currentHyperLink.IndexOf("&section-id")), false,
                                            topic.Guid, newHyperlink));
                                }
                            }
                        }
                    }
                    Utils.ReleaseComObject(topic);
                }
                //LinkList.ForEach(x => lstLinks.Items.Add(x.Address));
                linkList.ForEach(x =>
                {
                    if (!x.Item2)
                    {
                        int index = lstLinks.Items.Add(new MyListBoxItem(Color.Red, x.Item1));
                    }
                    else
                    {
                        lstLinks.Items.Add(new MyListBoxItem(Color.Blue, x.Item1));
                    }
                });
            }
            catch (Exception ex)
            {
                throw new OneMapException("ManageLinksfrm_Load()->Error Managing links", ex);
            }
            finally
            {
                Utils.ReleaseComObject(document);
            }
        }