예제 #1
0
 public static WorkbenchContext GetContext(string id)
 {
     WorkbenchContext ctx = (WorkbenchContext) contexts [id];
     if (ctx == null) {
         ctx = new WorkbenchContext (id);
         contexts [id] = ctx;
     }
     return ctx;
 }
        void SwitchContext(WorkbenchContext ctxt)
        {
            PadContentCollection old = activePadCollection;

            // switch pad collections
            if (padCollections [ctxt] != null)
                activePadCollection = (PadContentCollection) padCollections [ctxt];
            else
                // this is so, for unkwown contexts, we get the full set of pads
                activePadCollection = workbench.PadContentCollection;

            workbenchContext = ctxt;

            // get the list of layouts
            string ctxtPrefix = ctxt.Id + ".";
            string[] list = dockLayout.GetLayouts (false);

            layouts.Clear ();
            foreach (string name in list) {
                if (name.StartsWith (ctxtPrefix)) {
                    layouts.Add (name.Substring (ctxtPrefix.Length));
                }
            }

            // get the default layout for the new context from the property service
            CurrentLayout = Runtime.Properties.GetProperty
                ("MonoDevelop.Gui.SdiWorkbenchLayout." + ctxt.ToString (), "Default");

            // make sure invalid pads for the new context are not visible
            foreach (IPadContent content in old)
            {
                if (!activePadCollection.Contains (content))
                {
                    DockItem item = dock.GetItemByName (content.Id);
                    if (item != null)
                        item.HideItem ();
                }
            }
        }
 public void SetWorkbenchContext(WorkbenchContext ctx)
 {
     WorkbenchSingleton.Workbench.Context = ctx;
 }