Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
		internal void SetPreferences (PadUserPrefs pi)
		{
			preferences = pi;
			ApplyPreferences ();
		}