Exemple #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();
     }
 }
Exemple #2
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;
                }
            };
        }
Exemple #3
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();
     }
 }
Exemple #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;
         }
         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();
     }
 }
Exemple #5
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;
        }
Exemple #6
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;
        }
Exemple #7
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);
        }