示例#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);
        }
示例#2
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);
        }
示例#3
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);
        }