Ejemplo n.º 1
0
        static DocumentUserPrefs CreateDocumentPrefs(UserPreferencesEventArgs args, Document document)
        {
            string path = (string)document.OriginalFileName ?? document.FileName;

            var dp = new DocumentUserPrefs();

            dp.FileName = FileService.AbsoluteToRelativePath(args.Item.BaseDirectory, path);
            if (document.GetContent <ITextView> () is ITextView view)
            {
                var pos  = view.Caret.Position.BufferPosition;
                var line = pos.Snapshot.GetLineFromPosition(pos.Position);
                dp.Line   = line.LineNumber + 1;
                dp.Column = pos.Position - line.Start + 1;
            }

            try {
                var tab = ((SdiWorkspaceWindow)document.Window).DockNotebookTab;
                if (tab != null)
                {
                    dp.IsPinned = tab.IsPinned;
                }
            } catch (Exception ex) {
                LoggingService.LogInternalError(ex);
            }

            return(dp);
        }
Ejemplo n.º 2
0
        static void OnLoadUserPrefs(object s, UserPreferencesEventArgs args)
        {
            XmlElement elem = args.Properties.GetValue <XmlElement> ("MonoDevelop.Ide.DebuggingService.Breakpoints");

            if (elem == null)
            {
                elem = args.Properties.GetValue <XmlElement> ("MonoDevelop.Ide.DebuggingService");
            }

            if (elem != null)
            {
                lock (breakpoints)
                    breakpoints.Load(elem);
            }

            PinnedWatchStore wstore = args.Properties.GetValue <PinnedWatchStore> ("MonoDevelop.Ide.DebuggingService.PinnedWatches");

            if (wstore != null)
            {
                pinnedWatches.LoadFrom(wstore);
            }

            lock (breakpoints)
                pinnedWatches.BindAll(breakpoints);
        }
Ejemplo n.º 3
0
        static void OnStoreUserPrefs(object s, UserPreferencesEventArgs args)
        {
            var baseDir = (args.Item as Solution)?.BaseDirectory;

            lock (breakpoints)
                args.Properties.SetValue("MonoDevelop.Ide.DebuggingService.Breakpoints", breakpoints.Save(baseDir));
            args.Properties.SetValue("MonoDevelop.Ide.DebuggingService.PinnedWatches", pinnedWatches);
        }
Ejemplo n.º 4
0
 static void AddNotebookDocuments(UserPreferencesEventArgs args, List <DocumentUserPrefs> files, DockNotebook notebook, int notebookId)
 {
     foreach (var tab in notebook.Tabs)
     {
         var sdiwindow = (SdiWorkspaceWindow)tab.Content;
         var document  = sdiwindow.Document;
         if (!String.IsNullOrEmpty(document.FileName))
         {
             var dp = CreateDocumentPrefs(args, document);
             dp.NotebookId = notebookId;
             files.Add(dp);
         }
     }
 }
Ejemplo n.º 5
0
        void OnLoadingWorkspaceUserPreferences(object s, UserPreferencesEventArgs args)
        {
            WorkbenchUserPrefs prefs = args.Properties.GetValue <WorkbenchUserPrefs> ("MonoDevelop.Ide.Workbench");

            if (prefs == null)
            {
                return;
            }

            string currentFileName = prefs.ActiveDocument != null?Path.GetFullPath(Path.Combine(args.Item.BaseDirectory, prefs.ActiveDocument)) : null;

            foreach (DocumentUserPrefs doc in prefs.Files)
            {
                FilePath fileName = args.Item.BaseDirectory.Combine(doc.FileName).FullPath;
                if (File.Exists(fileName))
                {
                    OpenDocumentOptions ops = OpenDocumentOptions.OnlyInternalViewer;
                    if (fileName == currentFileName)
                    {
                        ops |= OpenDocumentOptions.BringToFront;
                    }
                    IdeApp.Workbench.OpenDocument(fileName, doc.Line, doc.Column, ops, null, null);
                }
            }

            foreach (PadUserPrefs pi in prefs.Pads)
            {
                foreach (Pad pad in IdeApp.Workbench.Pads)
                {
                    if (pi.Id == pad.Id && pad.Content is IMementoCapable)
                    {
                        try {
                            string          xml         = pi.State.OuterXml;
                            IMementoCapable m           = (IMementoCapable)pad.Content;
                            XmlReader       innerReader = new XmlTextReader(new StringReader(xml));
                            innerReader.MoveToContent();
                            ICustomXmlSerializer cs = (ICustomXmlSerializer)m.Memento;
                            if (cs != null)
                            {
                                m.Memento = cs.ReadFrom(innerReader);
                            }
                        } catch (Exception ex) {
                            LoggingService.LogError("Error loading view memento.", ex);
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        static DocumentUserPrefs CreateDocumentPrefs(UserPreferencesEventArgs args, Document document)
        {
            string path = (string)document.OriginalFileName ?? document.FileName;

            var dp = new DocumentUserPrefs();

            dp.FileName = FileService.AbsoluteToRelativePath(args.Item.BaseDirectory, path);
            if (document.GetContent <ITextView> () is ITextView view)
            {
                var pos  = view.Caret.Position.BufferPosition;
                var line = pos.Snapshot.GetLineFromPosition(pos.Position);
                dp.Line   = line.LineNumber + 1;
                dp.Column = pos.Position - line.Start + 1;
            }
            return(dp);
        }
Ejemplo n.º 7
0
        void OnStoringWorkspaceUserPreferences(object s, UserPreferencesEventArgs args)
        {
            WorkbenchUserPrefs prefs = new WorkbenchUserPrefs();

            foreach (Document document in Documents)
            {
                if (!String.IsNullOrEmpty(document.FileName))
                {
                    DocumentUserPrefs dp = new DocumentUserPrefs();
                    dp.FileName = FileService.AbsoluteToRelativePath(args.Item.BaseDirectory, document.FileName);
                    if (document.Editor != null)
                    {
                        dp.Line   = document.Editor.Caret.Line;
                        dp.Column = document.Editor.Caret.Column;
                    }
                    prefs.Files.Add(dp);
                }
            }

            foreach (Pad pad in Pads)
            {
                IMementoCapable mc = pad.GetMementoCapable();
                if (mc != null)
                {
                    ICustomXmlSerializer mem = mc.Memento;
                    if (mem != null)
                    {
                        PadUserPrefs data = new PadUserPrefs();
                        data.Id = pad.Id;
                        StringWriter  w  = new StringWriter();
                        XmlTextWriter tw = new XmlTextWriter(w);
                        mem.WriteTo(tw);
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(w.ToString());
                        data.State = doc.DocumentElement;
                        prefs.Pads.Add(data);
                    }
                }
            }

            if (ActiveDocument != null)
            {
                prefs.ActiveDocument = FileService.AbsoluteToRelativePath(args.Item.BaseDirectory, ActiveDocument.FileName);
            }

            args.Properties.SetValue("MonoDevelop.Ide.Workbench", prefs);
        }
Ejemplo n.º 8
0
        static Task OnLoadUserPrefs(object s, UserPreferencesEventArgs args)
        {
            var elem = args.Properties.GetValue <XmlElement> ("MonoDevelop.Ide.DebuggingService.Breakpoints") ?? args.Properties.GetValue <XmlElement> ("MonoDevelop.Ide.DebuggingService");

            if (elem != null)
            {
                lock (breakpoints)
                    breakpoints.Load(elem);
            }

            PinnedWatchStore wstore = args.Properties.GetValue <PinnedWatchStore> ("MonoDevelop.Ide.DebuggingService.PinnedWatches");

            if (wstore != null)
            {
                pinnedWatches.LoadFrom(wstore);
            }

            lock (breakpoints)
                pinnedWatches.BindAll(breakpoints);

            return(Task.FromResult(true));
        }
Ejemplo n.º 9
0
		static void OnLoadUserPrefs (object s, UserPreferencesEventArgs args)
		{
			XmlElement elem = args.Properties.GetValue<XmlElement> ("MonoDevelop.Ide.DebuggingService.Breakpoints");
			if (elem == null)
				elem = args.Properties.GetValue<XmlElement> ("MonoDevelop.Ide.DebuggingService");
			if (elem != null)
				breakpoints.Load (elem);
			PinnedWatchStore wstore = args.Properties.GetValue<PinnedWatchStore> ("MonoDevelop.Ide.DebuggingService.PinnedWatches");
			if (wstore != null)
				pinnedWatches.LoadFrom (wstore);
			pinnedWatches.BindAll (breakpoints);
		}
Ejemplo n.º 10
0
		static void OnStoreUserPrefs (object s, UserPreferencesEventArgs args)
		{
			args.Properties.SetValue ("MonoDevelop.Ide.DebuggingService.Breakpoints", breakpoints.Save ());
			args.Properties.SetValue ("MonoDevelop.Ide.DebuggingService.PinnedWatches", pinnedWatches);
		}
Ejemplo n.º 11
0
 static void OnStoreUserPrefs(object s, UserPreferencesEventArgs args)
 {
     args.Properties.SetValue("MonoDevelop.Ide.DebuggingService.Breakpoints", breakpoints.Save());
     args.Properties.SetValue("MonoDevelop.Ide.DebuggingService.PinnedWatches", pinnedWatches);
 }
Ejemplo n.º 12
0
        void OnStoringWorkspaceUserPreferences(object s, UserPreferencesEventArgs args)
        {
            WorkbenchUserPrefs prefs = new WorkbenchUserPrefs();
            var nbId = 0;
            var fwId = 1;

            foreach (var window in DockWindow.GetAllWindows())
            {
                int x, y;
                window.GetPosition(out x, out y);
                var fwp = new FloatingWindowUserPrefs {
                    WindowId = fwId,
                    X        = x,
                    Y        = y,
                    Width    = window.Allocation.Width,
                    Height   = window.Allocation.Height
                };

                foreach (var nb in window.Container.GetNotebooks())
                {
                    AddNotebookDocuments(args, fwp.Files, nb, nbId++);
                }

                if (fwp.Files.Count > 0)
                {
                    prefs.FloatingWindows.Add(fwp);
                    fwId++;
                }
            }

            var mainContainer = workbench.TabControl.Container;

            foreach (var nb in mainContainer.GetNotebooks())
            {
                AddNotebookDocuments(args, prefs.Files, nb, nbId++);
            }

            foreach (Pad pad in Pads)
            {
                IMementoCapable mc = pad.GetMementoCapable();
                if (mc != null)
                {
                    ICustomXmlSerializer mem = mc.Memento;
                    if (mem != null)
                    {
                        PadUserPrefs data = new PadUserPrefs();
                        data.Id = pad.Id;
                        StringWriter  w  = new StringWriter();
                        XmlTextWriter tw = new XmlTextWriter(w);
                        mem.WriteTo(tw);
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(w.ToString());
                        data.State = doc.DocumentElement;
                        prefs.Pads.Add(data);
                    }
                }
            }

            if (ActiveDocument != null)
            {
                prefs.ActiveDocument = FileService.AbsoluteToRelativePath(args.Item.BaseDirectory, ActiveDocument.FileName);
            }

            args.Properties.SetValue("MonoDevelop.Ide.Workbench", prefs);
        }
Ejemplo n.º 13
0
        async Task OnLoadingWorkspaceUserPreferences(object s, UserPreferencesEventArgs args)
        {
            WorkbenchUserPrefs prefs = args.Properties.GetValue <WorkbenchUserPrefs> ("MonoDevelop.Ide.Workbench");

            if (prefs == null)
            {
                return;
            }

            try {
                IdeApp.Workbench.LockActiveWindowChangeEvent();
                IdeServices.NavigationHistoryService.LogActiveDocument();

                var      docViews        = new List <Tuple <Document, string> > ();
                FilePath baseDir         = args.Item.BaseDirectory;
                var      floatingWindows = new List <DockWindow> ();

                using (ProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor(GettextCatalog.GetString("Loading workspace documents"), Stock.StatusSolutionOperation, true)) {
                    var docList = prefs.Files.Distinct(new DocumentUserPrefsFilenameComparer()).OrderBy(d => d.NotebookId).ToList();
                    await OpenDocumentsInContainer(pm, baseDir, docViews, docList, workbench.TabControl.Container);

                    foreach (var fw in prefs.FloatingWindows)
                    {
                        var dockWindow = new DockWindow();
                        dockWindow.Move(fw.X, fw.Y);
                        dockWindow.Resize(fw.Width, fw.Height);
                        docList = fw.Files.Distinct(new DocumentUserPrefsFilenameComparer()).OrderBy(d => d.NotebookId).ToList();
                        await OpenDocumentsInContainer(pm, baseDir, docViews, docList, dockWindow.Container);

                        floatingWindows.Add(dockWindow);
                    }

                    // Note: At this point, the progress monitor will be disposed which causes the gtk main-loop to be pumped.
                    // This is EXTREMELY important, because without this main-loop pumping action, the next foreach() loop will
                    // not cause the Solution tree-view to properly expand, nor will the ActiveDocument be set properly.
                }

                string currentFileName = prefs.ActiveDocument != null?baseDir.Combine(prefs.ActiveDocument).FullPath : null;

                Document activeDoc = null;
                foreach (var t in docViews)
                {
                    if (t.Item2 == currentFileName)
                    {
                        activeDoc = t.Item1;
                    }
                }

                if (activeDoc == null && docViews.Count > 0)
                {
                    activeDoc = docViews [0].Item1;
                }

                foreach (PadUserPrefs pi in prefs.Pads)
                {
                    foreach (Pad pad in IdeApp.Workbench.Pads)
                    {
                        if (pi.Id == pad.Id)
                        {
                            pad.InternalContent.SetPreferences(pi);
                            break;
                        }
                    }
                }

                foreach (var w in floatingWindows)
                {
                    w.ShowAll();
                }

                if (activeDoc != null)
                {
                    activeDoc.RunWhenLoaded(activeDoc.Select);
                }
            } finally {
                IdeApp.Workbench.UnlockActiveWindowChangeEvent();
            }
        }
Ejemplo n.º 14
0
        void OnLoadingWorkspaceUserPreferences(object s, UserPreferencesEventArgs args)
        {
            WorkbenchUserPrefs prefs = args.Properties.GetValue <WorkbenchUserPrefs> ("MonoDevelop.Ide.Workbench");

            if (prefs == null)
            {
                return;
            }

            NavigationHistoryService.LogActiveDocument();

            List <IViewContent> docViews    = new List <IViewContent> ();
            FilePath            baseDir     = args.Item.BaseDirectory;
            IViewContent        currentView = null;

            using (IProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor(GettextCatalog.GetString("Loading workspace documents"), Stock.OpenFileIcon, true)) {
                string currentFileName = prefs.ActiveDocument != null?baseDir.Combine(prefs.ActiveDocument).FullPath : null;

                foreach (DocumentUserPrefs doc in prefs.Files.Distinct(new DocumentUserPrefsFilenameComparer()))
                {
                    string fileName = baseDir.Combine(doc.FileName).FullPath;
                    if (File.Exists(fileName))
                    {
                        var view = IdeApp.Workbench.BatchOpenDocument(pm, fileName, doc.Line, doc.Column);
                        if (fileName == currentFileName)
                        {
                            currentView = view;
                        }

                        if (view != null)
                        {
                            docViews.Add(view);
                        }
                    }
                }

                // Note: At this point, the progress monitor will be disposed which causes the gtk main-loop to be pumped.
                // This is EXTREMELY important, because without this main-loop pumping action, the next foreach() loop will
                // not cause the Solution tree-view to properly expand, nor will the ActiveDocument be set properly.
            }

            foreach (var view in docViews)
            {
                Document doc = WrapDocument(view.WorkbenchWindow);
                if (view == currentView)
                {
                    Present();
                    doc.RunWhenLoaded(() => {
                        var window = doc.Window;
                        if (window != null)
                        {
                            window.SelectWindow();
                        }
                    });
                }
            }

            foreach (PadUserPrefs pi in prefs.Pads)
            {
                foreach (Pad pad in IdeApp.Workbench.Pads)
                {
                    if (pi.Id == pad.Id && pad.Content is IMementoCapable)
                    {
                        try {
                            string          xml         = pi.State.OuterXml;
                            IMementoCapable m           = (IMementoCapable)pad.Content;
                            XmlReader       innerReader = new XmlTextReader(new StringReader(xml));
                            innerReader.MoveToContent();
                            ICustomXmlSerializer cs = (ICustomXmlSerializer)m.Memento;
                            if (cs != null)
                            {
                                m.Memento = cs.ReadFrom(innerReader);
                            }
                        } catch (Exception ex) {
                            LoggingService.LogError("Error loading view memento.", ex);
                        }
                        break;
                    }
                }
            }
        }
 private void OnStoreUserPrefs(object s, UserPreferencesEventArgs args)
 {
     args.Properties.SetValue("MonoDevelop.Ide.BookmarkService.Bookmarks", bookmarks.ToXml());
 }
 private void OnLoadUserPrefs(object s, UserPreferencesEventArgs args)
 {
     XmlElement elem = args.Properties.GetValue<XmlElement>("MonoDevelop.Ide.BookmarkService.Bookmarks");
     if (elem == null)
         return;
     bookmarks.Load(elem);
     RaiseBookmarksChange();
     foreach (var doc in IdeApp.Workbench.Documents)
     {
         bookmarks.InitBookmarksForDocument(doc);
     }
 }