Пример #1
0
        public virtual void ShowView(IViewContent content, bool bringToFront, DockNotebook notebook = null)
        {
            var mimeimage = PrepareShowView (content);
            var addToControl = notebook ?? DockNotebook.ActiveNotebook ?? tabControl;
            var tab = addToControl.AddTab ();

            SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, addToControl, tab);
            sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); };
            sdiWorkspaceWindow.Closed += CloseWindowEvent;
            sdiWorkspaceWindow.Show ();

            tab.Content = sdiWorkspaceWindow;
            if (mimeimage != null)
                tab.Icon = mimeimage;

            if (content.Project != null)
                content.Project.NameChanged += HandleProjectNameChanged;
            if (bringToFront)
                content.WorkbenchWindow.SelectWindow();

            // The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged)
            OnActiveWindowChanged (null, null);
        }
Пример #2
0
		public virtual void ShowView (ViewContent content, bool bringToFront, IViewDisplayBinding binding = null, DockNotebook notebook = null)
		{
			bool isFile = content.IsFile;
			if (!isFile) {
				try {
					isFile = File.Exists (content.ContentName);
				} catch { /*Ignore*/ }
			}

			string type;
			if (isFile) {
				type = System.IO.Path.GetExtension (content.ContentName);
				var mt = DesktopService.GetMimeTypeForUri (content.ContentName);
				if (!string.IsNullOrEmpty (mt))
					type += " (" + mt + ")";
			} else
				type = "(not a file)";

			var metadata = new Dictionary<string,string> () {
				{ "FileType", type },
				{ "DisplayBinding", content.GetType ().FullName },
			};

			if (isFile)
				metadata ["DisplayBindingAndType"] = type + " | " + content.GetType ().FullName;

			Counters.DocumentOpened.Inc (metadata);

			var mimeimage = PrepareShowView (content);
			var addToControl = notebook ?? DockNotebook.ActiveNotebook ?? tabControl;
			var tab = addToControl.AddTab ();

			SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, addToControl, tab);
			sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); };
			sdiWorkspaceWindow.Closed += CloseWindowEvent;
			sdiWorkspaceWindow.Show ();
			if (binding != null)
				DisplayBindingService.AttachSubWindows (sdiWorkspaceWindow, binding);

			sdiWorkspaceWindow.CreateCommandHandler ();

			tab.Content = sdiWorkspaceWindow;
			if (mimeimage != null)
				tab.Icon = mimeimage;

			if (content.Project != null)
				content.Project.NameChanged += HandleProjectNameChanged;
			if (bringToFront)
				content.WorkbenchWindow.SelectWindow();

			// The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged)
			OnActiveWindowChanged (null, null);
		}
Пример #3
0
		public virtual void ShowView (IViewContent content, bool bringToFront)
		{
			viewContentCollection.Add (content);
			
			if (PropertyService.Get ("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) {
				try {
					Properties memento = GetStoredMemento(content);
					if (memento != null) {
						((IMementoCapable)content).Memento = memento;
					}
				} catch (Exception e) {
					LoggingService.LogError ("Can't get/set memento : " + e.ToString());
				}
			}
			
			Gdk.Pixbuf mimeimage = null;
			
			if (content.StockIconId != null ) {
				mimeimage = ImageService.GetPixbuf (content.StockIconId, IconSize.Menu);
			}
			else if (content.IsUntitled && content.UntitledName == null) {
				mimeimage = DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu);
			} else {
				mimeimage = DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu);
			}			

			var tab = tabControl.InsertTab (-1);

			SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, tabControl, tab);
			sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); };
			sdiWorkspaceWindow.Closed += CloseWindowEvent;
			sdiWorkspaceWindow.Show ();

			tab.Content = sdiWorkspaceWindow;
			if (mimeimage != null)
				tab.Icon = mimeimage;

			if (content.Project != null)
				content.Project.NameChanged += HandleProjectNameChanged;
			
			if (bringToFront)
				content.WorkbenchWindow.SelectWindow();

			// The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged)
			OnActiveWindowChanged (null, null);
		}
Пример #4
0
		public virtual void ShowView (IViewContent content, bool bringToFront)
		{
			viewContentCollection.Add (content);
			
			if (PropertyService.Get ("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) {
				try {
					Properties memento = GetStoredMemento(content);
					if (memento != null) {
						((IMementoCapable)content).Memento = memento;
					}
				} catch (Exception e) {
					LoggingService.LogError ("Can't get/set memento : " + e.ToString());
				}
			}
			
			Gtk.Image mimeimage = null;
			
			if (content.StockIconId != null ) {
				mimeimage = new Gtk.Image ((IconId) content.StockIconId, IconSize.Menu );
			}
			else if (content.IsUntitled && content.UntitledName == null) {
				mimeimage = new Gtk.Image (DesktopService.GetPixbufForType ("gnome-fs-regular", Gtk.IconSize.Menu));
			} else {
				mimeimage = new Gtk.Image (DesktopService.GetPixbufForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu));
			}			

			TabLabel tabLabel = new TabLabel (new Label (), mimeimage != null ? mimeimage : new Gtk.Image (""));
			tabLabel.CloseClicked += new EventHandler (closeClicked);			
			tabLabel.ClearFlag (WidgetFlags.CanFocus);
			tabLabel.Show ();
			
			SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, tabControl, tabLabel);
			sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); };
			sdiWorkspaceWindow.Closed += CloseWindowEvent;
			sdiWorkspaceWindow.Show ();
			
			tabControl.InsertPage (sdiWorkspaceWindow, tabLabel, -1);
			
			if (content.Project != null)
				content.Project.NameChanged += HandleProjectNameChanged;
			
			if (bringToFront)
				content.WorkbenchWindow.SelectWindow();
		}