Example #1
0
 private static void closeView(CommentsManager commentsManager)
 {
     if (commentsManager.m_FileName == s_FullFileName)
     {
         s_FullFileName     = null;
         s_RelativeFileName = null;
     }
 }
Example #2
0
 public static void CloseView(CommentsManager commentsManager)
 {
     if (s_Instandce != null)
     {
         closeView(commentsManager);
         s_Instandce.BookmarkAdjustment(s_Instandce.GetBookmarkPrims(commentsManager.m_FileName));
         Save();
     }
 }
Example #3
0
 // #document Reload
 public static void Reload(CommentsManager commentsManager)
 {
     if (GetInstance() != null)
     {
         closeView(commentsManager);
         SetView(commentsManager, null);
         if (s_Instandce != null)
         {
             s_Instandce.RedrawToolWindow();
         }
     }
 }
Example #4
0
        /* private void OnWindowActivated(EnvDTE.Window GotFocus, EnvDTE.Window LostFocus)
         * {
         * } */

        public BookmarkPrims CreateBookmarkPrims(CommentsManager commentsManager = null)
        {
            BookmarkPrims bookmarkPrims = null;

            if (!m_FileBookmarkPrims.ContainsKey(s_RelativeFileName))
            {
                bookmarkPrims = new BookmarkPrims(commentsManager);
                m_FileBookmarkPrims.TryAdd(s_RelativeFileName, bookmarkPrims);
            }
            else
            {
                bookmarkPrims = m_FileBookmarkPrims[s_RelativeFileName];
                bookmarkPrims.SetCommentsManager(commentsManager);
            }
            if (commentsManager != null)
            {
                bookmarkPrims = BookmarkAdjustment(bookmarkPrims);
                commentsManager.SetBookmark(bookmarkPrims);
            }
            return(bookmarkPrims);
        }
Example #5
0
        public static void SetView(CommentsManager commentsManager, SVsServiceProvider serviceProvider)
        {
            if (serviceProvider != null)
            {
                s_dte = (DTE)serviceProvider.GetService(typeof(DTE));
            }

            commentsManager.GetView().TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out ITextDocument document);
            ProjectItem projectItem = s_dte.Solution.FindProjectItem(document.FilePath);

            string backFileName = s_FullFileName;

            if (projectItem != null && projectItem.ContainingProject != null)
            {
                string solutionDirectory = "";
                string projectPath       = projectItem.ContainingProject.FileName;
                if (projectPath != "") // projectPath will be empty if file isn't part of a projec+t.
                {
                    s_projectDirectory = Path.GetDirectoryName(projectPath) + @"\";
                }

                string solutionPath = s_dte.Solution.FileName;
                if (solutionPath != "") // solutionPath will be empty if project isn't part of a saved solution
                {
                    solutionDirectory = Path.GetDirectoryName(solutionPath) + @"\";
                    solutionDirectory = solutionDirectory.ToUpper();
                }

                if (s_solutionDirectory == solutionDirectory)
                {       // Solution は同じ
                    SetFileName(commentsManager.m_FileName);
                }
                else
                {       // 新しい Solution が選択された
                    if (s_Instandce != null && s_bookmarkFileName != "")
                    {
                        Save();
                    }

                    s_solutionDirectory = solutionDirectory;
                    SetFileName(commentsManager.m_FileName);

                    // s_bookmarkDirectory = @"C:\MyProj\temp\mbook\";
                    s_bookmarkDirectory = s_solutionDirectory + @"MyBookmark\";
                    Directory.CreateDirectory(s_bookmarkDirectory);
                    s_bookmarkFileName = s_bookmarkDirectory + @"MyBookmark.mbk";

                    /* s_bookmarkFileName = s_solutionDirectory.Substring(3);
                     * s_bookmarkFileName = s_bookmarkFileName.Replace(':', '_');
                     * s_bookmarkFileName = s_bookmarkFileName.Replace('\\', '-');
                     * s_bookmarkFileName = s_bookmarkDirectory + s_bookmarkFileName + @".mbk"; */

                    Load(commentsManager);

                    string debugLogFileName = s_bookmarkDirectory + @"\debug.txt"; // debug.txtにログを出力する。
                    File.Delete(debugLogFileName);
                    s_LogWriter = new StreamWriter(debugLogFileName, true);
                    MyBookmarkManager.Log("### DebugLog Start");
                }
            }

            SetFileName(commentsManager.m_FileName);
            if (s_FullFileName != backFileName)
            {
                if (s_Instandce != null)
                {
                    BookmarkPrims bookmarkPrims = s_Instandce.CreateBookmarkPrims(commentsManager);            // m_FileBookmarkPrims.TryAdd(s_fileName, bookmarkPrims); する
                }
            }
        }
Example #6
0
        public static bool Load(CommentsManager commentsManager)
        {
            try
            {
                s_Instandce = new MyBookmarkManager();

                using (StreamReader s = new StreamReader(s_bookmarkFileName))
                {
                    s_SaveJsonString = s.ReadToEnd();
                    var json = DynamicJson.Parse(s_SaveJsonString);
                    if (json != null)
                    {
                        foreach (string array1index in json.GetDynamicMemberNames())
                        {
                            var bpfjson = json[int.Parse(array1index)];
                            foreach (string bpf in bpfjson.GetDynamicMemberNames())
                            {
                                if (bpf == "Key")
                                {
                                    SetFileName(bpfjson[bpf]);
                                }
                                else if (bpf == "Value")
                                {
                                    foreach (string array2index in bpfjson[bpf].GetDynamicMemberNames())
                                    {
                                        var bpjson = bpfjson[bpf][int.Parse(array2index)];

                                        BookmarkPrims bookmarkPrims = s_Instandce.CreateBookmarkPrims();
                                        int           lineNo        = 1;
                                        foreach (string bp in bpjson.GetDynamicMemberNames())
                                        {
                                            if (bp == "Key")
                                            {
                                                lineNo = int.Parse(bpjson[bp].ToString());
                                                if (lineNo < 1)
                                                {
                                                    lineNo = 1;
                                                }
                                            }
                                            else if (bp == "Value")
                                            {
                                                // BookmarkPrim prim = bpjson[bp].Deserialize<BookmarkPrim>();
                                                dynamic      bpjsonv = bpjson[bp];
                                                BookmarkPrim prim    = new BookmarkPrim();
                                                prim.m_comment = GetJsonString(bpjsonv, "m_comment");
                                                prim.m_line0   = GetJsonString(bpjsonv, "m_line0");
                                                prim.m_line1   = GetJsonString(bpjsonv, "m_line1");
                                                prim.m_line2   = GetJsonString(bpjsonv, "m_line2");
                                                prim.SetTag();
                                                bookmarkPrims.TryAdd(lineNo, prim);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    s_Instandce.RedrawToolWindow();
                }
            }
            catch
            {
                return(false);
            }
            return(true);

            // return BinaryDeserialize<MyBookmarkManager>(s_bookmarkFileName, out s_Instandce);      // ブックマーク読み込み
        }
Example #7
0
 public BookmarkPrims(CommentsManager commentsManager)
 {
     SetCommentsManager(commentsManager);
 }
Example #8
0
 public void SetCommentsManager(CommentsManager commentsManager)
 {
     m_CommentsManager = commentsManager;
 }
Example #9
0
 public CommentLineTransformSource(CommentsManager adornment)
 {
     _adornment = adornment;
 }