Пример #1
0
 public T GetNativeWidget <T> ()
 {
     if (nativeWidget == null)
     {
         var w = CreateNativeWidget();
         if (!(w is T))
         {
             w = ConvertToType(typeof(T), w);
         }
         if (w is Gtk.Widget)
         {
             var c = new CommandRouterContainer((Gtk.Widget)w, this, true);
             c.Show();
             nativeWidget = c;
             c.Destroyed += delegate {
                 GC.SuppressFinalize(this);
                 Dispose(true);
             };
         }
         else
         {
             nativeWidget = w;
         }
     }
     if (nativeWidget is T)
     {
         return((T)nativeWidget);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Пример #2
0
        public EditorView(ViewContent content)
        {
            try {
                this.content = content;

                var editorWidget = content.Control.GetNativeWidget <Gtk.Widget> ();
                editorWidget.ShowAll();
                MonoDevelop.Components.Control previewNative;
                if (Platform.Instance.IsMac)
                {
                    var editor    = new GtkEmbed2(editorWidget);
                    var editorEto = editor.ToEto();
                    preview = new PreviewEditorView(editorEto, null, null, () => content?.WorkbenchWindow?.Document?.Editor?.Text);
                    var nspreview       = XamMac2Helpers.ToNative(preview, true);
                    var nsviewContainer = new NSViewContainer2(nspreview);
                    previewNative = nsviewContainer;
                }
                else
                {
                    preview       = new PreviewEditorView(editorWidget.ToEto(), null, null, () => content?.WorkbenchWindow?.Document?.Editor?.Text);
                    previewNative = Gtk2Helpers.ToNative(preview, true);
                }

                var commandRouterContainer = new CommandRouterContainer(previewNative, content, true);
                commandRouterContainer.ShowAll();
                control = commandRouterContainer;

                content.DirtyChanged += content_DirtyChanged;
                IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged;
                ContentName = content.ContentName;
            } catch (Exception ex) {
                Debug.WriteLine($"{ex}");
            }
        }
Пример #3
0
        public CombinedDesignView(IViewContent content)
        {
            this.content = content;
            if (content is IEditableTextBuffer)
            {
                ((IEditableTextBuffer)content).CaretPositionSet += delegate {
                    ShowPage(0);
                };
            }
            content.ContentChanged += new EventHandler(OnTextContentChanged);
            content.DirtyChanged   += new EventHandler(OnTextDirtyChanged);

            notebook = new Gtk.Notebook();

            // Main notebook

            notebook.TabPos     = Gtk.PositionType.Bottom;
            notebook.ShowTabs   = false;
            notebook.ShowBorder = false;
            notebook.Show();
            box = new VBox();

            // Bottom toolbar

            toolbar              = new Toolbar();
            toolbar.IconSize     = IconSize.SmallToolbar;
            toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
            toolbar.ShowArrow    = false;

            CommandRouterContainer crc = new CommandRouterContainer(content.Control, content, true);

            crc.Show();
            AddButton(GettextCatalog.GetString("Source Code"), crc).Active = true;

            toolbar.ShowAll();

            box.PackStart(notebook, true, true, 0);
            box.PackStart(toolbar, false, false, 0);

            box.Show();

            IdeApp.Workbench.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged);
            content.Control.Realized += delegate {
                if (content != null && content.WorkbenchWindow != null)
                {
                    content.WorkbenchWindow.ActiveViewContent = notebook.CurrentPageWidget == content.Control ? content : this;
                }
            };
            notebook.SwitchPage += delegate {
                if (content != null && content.WorkbenchWindow != null)
                {
                    content.WorkbenchWindow.ActiveViewContent = notebook.CurrentPageWidget == content.Control ? content : this;
                }
            };
        }
Пример #4
0
 public T GetNativeWidget <T> ()
 {
     if (nativeWidget == null)
     {
         var toCache = this;
         var w       = CreateNativeWidget <T> ();
         if (!(w is T))
         {
             var temp = w as Control;
             while (temp != null)
             {
                 w    = temp.GetNativeWidget <T> ();
                 temp = w as Control;
             }
             w = ConvertToType(typeof(T), w);
         }
         if (w is Gtk.Widget)
         {
             var gtkWidget = (Gtk.Widget)w;
             var c         = new CommandRouterContainer(gtkWidget, this, true);
             c.FocusChain = new [] { gtkWidget };
             c.Show();
             nativeWidget = c;
             c.Destroyed += OnGtkDestroyed;
             toCache      = c;
         }
         else
         {
             nativeWidget = w;
         }
         WeakReference <Control> cached;
         Control target;
         if (cache.TryGetValue(nativeWidget, out cached) && cached.TryGetTarget(out target))
         {
             if (target != toCache)
             {
                 throw new Exception();
             }
         }
         else
         {
             cache.Add(nativeWidget, new WeakReference <Control> (toCache));
         }
     }
     if (nativeWidget is T)
     {
         return((T)nativeWidget);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Пример #5
0
        protected virtual md.Components.Control GetControl()
        {
            if (control != null)
            {
                return(control);
            }
            var commandRouterContainer = new CommandRouterContainer(GetNativeControl(), content, true);

            commandRouterContainer.ShowAll();
            control = commandRouterContainer;
            return(control);
        }
Пример #6
0
 public T GetNativeWidget <T> ()
 {
     if (nativeWidget == null)
     {
         var toCache = this;
         var w       = CreateNativeWidget <T> ();
         if (!(w is T))
         {
             var temp = w as Control;
             while (temp != null)
             {
                 w    = temp.GetNativeWidget <T> ();
                 temp = w as Control;
             }
             w = ConvertToType(typeof(T), w);
         }
         if (w is Gtk.Widget)
         {
             var gtkWidget = (Gtk.Widget)w;
             var c         = new CommandRouterContainer(gtkWidget, this, true);
             c.FocusChain = new [] { gtkWidget };
             c.Show();
             nativeWidget = c;
             c.Destroyed += OnGtkDestroyed;
             toCache      = c;
         }
         else
         {
             nativeWidget = w;
         }
         if (cache.TryGetValue(nativeWidget, out Control target))
         {
             if (target != toCache)
             {
                 throw new InvalidOperationException($"Widget {nativeWidget.GetType ()} has been mapped to multiple controls");
             }
         }
         else
         {
             cache.Add(nativeWidget, toCache);
         }
     }
     if (nativeWidget is T resultWidget)
     {
         return(resultWidget);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Пример #7
0
        public EditorView(IViewContent content)
        {
            this.content            = content;
            preview                 = new PreviewEditorView(content.Control.ToEto(), () => content?.WorkbenchWindow?.Document?.Editor?.Text);
            content.ContentChanged += content_ContentChanged;
            content.DirtyChanged   += content_DirtyChanged;
            var commandRouterContainer = new CommandRouterContainer(preview.ToNative(true), content, true);

            commandRouterContainer.Show();
            control = commandRouterContainer;
            IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged;

            base.ContentName = content.ContentName;
        }
Пример #8
0
        public CombinedDesignView(ViewContent content)
        {
            this.content = content;

            /* This code causes that chagnes in a version control view always select the source code view.
             *                      if (content is IEditableTextBuffer) {
             *                      ((IEditableTextBuffer)content).CaretPositionSet += delegate {
             *                              ShowPage (0);
             *                      };
             *              }*/
            content.DirtyChanged += new EventHandler(OnTextDirtyChanged);

            CommandRouterContainer crc = new CommandRouterContainer(content.Control, content, true);

            crc.Show();
            control = crc;

            IdeApp.Workbench.ActiveDocumentChanged += OnActiveDocumentChanged;
        }
Пример #9
0
        public CombinedDesignView(IViewContent content)
        {
            this.content = content;
            if (content is IEditableTextBuffer)
            {
                ((IEditableTextBuffer)content).CaretPositionSet += delegate {
                    ShowPage(0);
                };
            }
            content.ContentChanged += new EventHandler(OnTextContentChanged);
            content.DirtyChanged   += new EventHandler(OnTextDirtyChanged);

            CommandRouterContainer crc = new CommandRouterContainer(content.Control, content, true);

            crc.Show();
            control = crc;

            IdeApp.Workbench.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged);
        }