Пример #1
0
 public IRenderTarget CreateRenderTarget(IPlatformHandle handle, int width, int height)
 {
     if (handle.Type == PlatformType.D2D)
         return new Direct2D.RenderTarget(s_d2D1Factory, handle.Handle,width, height);
     else
         throw new NotSupportedException(String.Format("Cannot create {0} target with D2D Engine",handle.Type));
 }
Пример #2
0
 public Win32NativeControlAttachment(DumbWindow holder, IPlatformHandle child)
 {
     _holder = holder;
     _child  = child;
     UnmanagedMethods.SetParent(child.Handle, _holder.Handle);
     UnmanagedMethods.ShowWindow(child.Handle, UnmanagedMethods.ShowWindowCommand.Show);
 }
Пример #3
0
    public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func <IPlatformHandle> createDefault)
    {
        var parentContext = (parent as AndroidViewControlHandle)?.View.Context
                            ?? global::Android.App.Application.Context;

        if (isSecond)
        {
            var webView = new global::Android.Webkit.WebView(parentContext);
            webView.LoadUrl("https://www.android.com/");

            return(new AndroidViewControlHandle(webView));
        }
        else
        {
            var button = new global::Android.Widget.Button(parentContext)
            {
                Text = "Hello world"
            };
            var clickCount = 0;
            button.Click += (sender, args) =>
            {
                clickCount++;
                button.Text = $"Click count {clickCount}";
            };

            return(new AndroidViewControlHandle(button));
        }
    }
 public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatformHandle handle)
 {
     return(new AndroidNativeControlAttachment(handle)
     {
         AttachedTo = this
     });
 }
Пример #5
0
 void AssertCompatible(IPlatformHandle handle)
 {
     if (!IsCompatibleWith(handle))
     {
         throw new ArgumentException($"Don't know what to do with {handle.HandleDescriptor}");
     }
 }
Пример #6
0
        public INativeControlHostDestroyableControlHandle CreateDefaultChild(IPlatformHandle parent)
        {
            var ch = new DumbWindow(_platform.Info);

            XSync(_platform.Display, false);
            return(ch);
        }
Пример #7
0
        IPlatformHandle CreateWin32(IPlatformHandle parent)
        {
            win32Window = parent.Handle;

            WindowCreated?.Invoke(this, win32Window);

            return(new PlatformHandle(win32Window, "HWND"));
        }
Пример #8
0
 public IRenderTarget CreateRenderer(IPlatformHandle handle, double width, double height)
 {
     if (handle.HandleDescriptor != "GtkWindow")
         throw new NotSupportedException(string.Format(
             "Don't know how to create a Cairo renderer from a '{0}' handle",
             handle.HandleDescriptor));
     return new RenderTarget((Gtk.Window)handle, width, height);
 }
Пример #9
0
 public WindowImpl(Gtk.WindowType type)
     : base(type)
 {
     this.Events = Gdk.EventMask.PointerMotionMask |
                   Gdk.EventMask.ButtonPressMask |
                   Gdk.EventMask.ButtonReleaseMask;
     this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
 }
Пример #10
0
 public void SetCursor(IPlatformHandle cursor)
 {
     if (GtkWidget.IsClosed)
     {
         return;
     }
     Native.GdkWindowSetCursor(Native.GtkWidgetGetWindow(GtkWidget), cursor?.Handle ?? IntPtr.Zero);
 }
        public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatformHandle handle)
        {
            var attachmenetReference = Invoke <IJSInProcessObjectReference>(CreateAttachmentSymbol);
            var a = new Attachment(attachmenetReference, handle);

            a.AttachedTo = this;
            return(a);
        }
Пример #12
0
 /// <summary>
 /// Renders the specified visual with the specified transform and clip.
 /// </summary>
 /// <param name="visual">The visual to render.</param>
 /// <param name="handle">An optional platform-specific handle.</param>
 /// <param name="transform">The transform.</param>
 /// <param name="clip">An optional clip rectangle.</param>
 public virtual void Render(IVisual visual, IPlatformHandle handle, Matrix transform, Rect?clip = null)
 {
     using (var context = CreateDrawingContext(handle))
         using (clip.HasValue ? context.PushClip(clip.Value) : null)
         {
             Render(visual, context, Matrix.Identity, transform);
         }
 }
Пример #13
0
 protected virtual IPlatformHandle CreateNativeControlCore(IPlatformHandle parent)
 {
     if (_currentHost == null)
     {
         throw new InvalidOperationException();
     }
     return(_currentHost.CreateDefaultChild(parent));
 }
Пример #14
0
 /// <summary>
 /// Renders the specified visual with the specified transform and clip.
 /// </summary>
 /// <param name="visual">The visual to render.</param>
 /// <param name="handle">An optional platform-specific handle.</param>
 /// <param name="transform">The transform.</param>
 /// <param name="clip">An optional clip rectangle.</param>
 public virtual void Render(IVisual visual, IPlatformHandle handle, Matrix transform, Rect? clip = null)
 {
     using (var context = CreateDrawingContext(handle))
     using (clip.HasValue ? context.PushClip(clip.Value) : null)
     {
         Render(visual, context, Matrix.Identity, transform);
     }
 }
        public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatformHandle handle)
        {
            var a = new Attachment(_host.CreateAttachment());

            a.InitWithChild(handle);
            a.AttachedTo = this;
            return(a);
        }
Пример #16
0
 private void Init()
 {
     Events = EventMask.PointerMotionMask |
              EventMask.ButtonPressMask |
              EventMask.ButtonReleaseMask;
     _windowHandle      = new PlatformHandle(Handle, "GtkWindow");
     _imContext         = new Gtk.IMMulticontext();
     _imContext.Commit += ImContext_Commit;
 }
Пример #17
0
 public Attachment(IntPtr display, DumbWindow holder, IntPtr orphanedWindow, IPlatformHandle child)
 {
     _display        = display;
     _orphanedWindow = orphanedWindow;
     _holder         = holder;
     _child          = child;
     XReparentWindow(_display, child.Handle, holder.Handle, 0, 0);
     XMapWindow(_display, child.Handle);
 }
Пример #18
0
        /// <summary>
        /// Renders the specified visual.
        /// </summary>
        /// <param name="visual">The visual to render.</param>
        /// <param name="handle">An optional platform-specific handle.</param>
        public virtual void Render(IVisual visual, IPlatformHandle handle)
        {
            using (var context = this.CreateDrawingContext(handle))
            {
                this.Render(visual, context, Matrix.Identity, Matrix.Identity);
            }

            ++this.RenderCount;
        }
Пример #19
0
        internal bool RegisterDragDrop(IPlatformHandle hwnd, IDropTarget target)
        {
            if (hwnd?.HandleDescriptor != "HWND" || target == null)
            {
                return(false);
            }

            return(UnmanagedMethods.RegisterDragDrop(hwnd.Handle, target) == UnmanagedMethods.HRESULT.S_OK);
        }
Пример #20
0
        internal bool UnregisterDragDrop(IPlatformHandle hwnd)
        {
            if (hwnd?.HandleDescriptor != "HWND")
            {
                return(false);
            }

            return(UnmanagedMethods.RevokeDragDrop(hwnd.Handle) == UnmanagedMethods.HRESULT.S_OK);
        }
Пример #21
0
 private void Init()
 {
     Events = EventMask.PointerMotionMask |
       EventMask.ButtonPressMask |
       EventMask.ButtonReleaseMask;
     _windowHandle = new PlatformHandle(Handle, "GtkWindow");
     _imContext = new Gtk.IMMulticontext();
     _imContext.Commit += ImContext_Commit;
 }
Пример #22
0
 public WindowImpl()
     : base(Gtk.WindowType.Toplevel)
 {
     this.DefaultSize = new Gdk.Size(640, 480);
     this.Events      = Gdk.EventMask.PointerMotionMask |
                        Gdk.EventMask.ButtonPressMask |
                        Gdk.EventMask.ButtonReleaseMask;
     this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
 }
Пример #23
0
 public WindowImpl()
     : base(Gtk.WindowType.Toplevel)
 {
     this.DefaultSize = new Gdk.Size(640, 480);
     this.Events = Gdk.EventMask.PointerMotionMask |
                   Gdk.EventMask.ButtonPressMask |
                   Gdk.EventMask.ButtonReleaseMask;
     this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
 }
Пример #24
0
        /// <summary>
        /// Renders the specified visual.
        /// </summary>
        /// <param name="visual">The visual to render.</param>
        /// <param name="handle">Unused.</param>
        public void Render(IVisual visual, IPlatformHandle handle)
        {
            using (DrawingContext context = new DrawingContext(this.renderTarget, this.DirectWriteFactory))
            {
                this.Render(visual, context, Matrix.Identity, Matrix.Identity);
            }

            ++this.RenderCount;
        }
Пример #25
0
 public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatformHandle handle)
 {
     AssertCompatible(handle);
     return(new Win32NativeControlAttachment(new DumbWindow(Window.Handle.Handle),
                                             handle)
     {
         AttachedTo = this
     });
 }
Пример #26
0
        public void SetCursor(IPlatformHandle cursor)
        {
            var hCursor = cursor?.Handle ?? DefaultCursor;

            UnmanagedMethods.SetClassLong(_hwnd, UnmanagedMethods.ClassLongIndex.GCLP_HCURSOR, hCursor);

            //if (_owner.IsPointerOver)
            //    UnmanagedMethods.SetCursor(hCursor);
        }
Пример #27
0
        /// <summary>
        /// Renders the specified visual.
        /// </summary>
        /// <param name="visual">The visual to render.</param>
        /// <param name="handle">A handle to the drawable.</param>
        public void Render(IVisual visual, IPlatformHandle handle)
        {
            using (DrawingContext context = CreateContext(handle))
            {
                this.Render(visual, context);
            }

            ++this.RenderCount;
        }
Пример #28
0
 public IRenderTarget CreateRenderer(IPlatformHandle handle, double width, double height)
 {
     if (handle.HandleDescriptor != "GtkWindow")
     {
         throw new NotSupportedException(string.Format(
                                             "Don't know how to create a Cairo renderer from a '{0}' handle",
                                             handle.HandleDescriptor));
     }
     return(new RenderTarget((Gtk.Window)handle, width, height));
 }
Пример #29
0
        /// <inheritdoc />
        protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent)
        {
            _platformHandle = base.CreateNativeControlCore(parent);

            if (_mediaPlayer == null)
                return _platformHandle;

            Attach();

            return _platformHandle;
        }
Пример #30
0
        public IRenderTarget CreateRenderer(IPlatformHandle handle, double width, double height)
        {
            var window = handle as Gtk.Window;
            if (window == null)
                throw new NotSupportedException(string.Format(
                    "Don't know how to create a Cairo renderer from a '{0}' handle which isn't Gtk.Window",
                    handle.HandleDescriptor));

            window.DoubleBuffered = true;
            return new RenderTarget(window, width, height);
        }
Пример #31
0
        void DestroyNativeControl()
        {
            if (_nativeControlHandle != null)
            {
                _attachment?.Dispose();
                _attachment = null;

                DestroyNativeControlCore(_nativeControlHandle);
                _nativeControlHandle = null;
            }
        }
Пример #32
0
 public void Dispose()
 {
     if (_child != null)
     {
         UnmanagedMethods.SetParent(_child.Handle, OffscreenParentWindow.Handle);
     }
     _holder?.Dispose();
     _holder     = null;
     _child      = null;
     _attachedTo = null;
 }
Пример #33
0
        internal bool RegisterDragDrop(IPlatformHandle hwnd, IDropTarget target)
        {
            if (hwnd?.HandleDescriptor != "HWND" || target == null)
            {
                return(false);
            }

            var trgPtr = MicroCom.MicroComRuntime.GetNativeIntPtr(target);

            return(UnmanagedMethods.RegisterDragDrop(hwnd.Handle, trgPtr) == UnmanagedMethods.HRESULT.S_OK);
        }
Пример #34
0
        /// <inheritdoc />
        protected override void DestroyNativeControlCore(IPlatformHandle control)
        {
            Detach();

            base.DestroyNativeControlCore(control);

            if (_platformHandle != null)
            {
                _platformHandle = null;
            }
        }
Пример #35
0
 void ITopLevelImpl.SetCursor(IPlatformHandle cursor)
 {
     if (cursor == null)
     {
         Cursor = Cursors.Arrow;
     }
     else if (cursor.HandleDescriptor == "HCURSOR")
     {
         Cursor = CursorShim.FromHCursor(cursor.Handle);
     }
 }
Пример #36
0
 public IRenderTarget CreateRenderTarget(IPlatformHandle handle, int width, int height)
 {
     if (handle.Type == PlatformType.D2D)
     {
         return(new Direct2D.RenderTarget(s_d2D1Factory, handle.Handle, width, height));
     }
     else
     {
         throw new NotSupportedException(String.Format("Cannot create {0} target with D2D Engine", handle.Type));
     }
 }
Пример #37
0
            public void Dispose()
            {
                if (_child != null)
                {
                    XReparentWindow(_display, _child.Handle, _orphanedWindow, 0, 0);
                    _child = null;
                }

                _holder?.Destroy();
                _holder     = null;
                _attachedTo = null;
            }
Пример #38
0
 protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent)
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         return(CreateWin32(parent));
     }
     //if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
     //    return CreateLinux(parent);
     //if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
     //    return CreateOSX(parent);
     return(base.CreateNativeControlCore(parent));
 }
Пример #39
0
 public IRenderer CreateRenderer(IPlatformHandle handle, double width, double height)
 {
     if (handle.HandleDescriptor == "HWND")
     {
         return new Renderer(handle.Handle, width, height);
     }
     else
     {
         throw new NotSupportedException(string.Format(
             "Don't know how to create a Direct2D1 renderer from a '{0}' handle",
             handle.HandleDescriptor));
     }
 }
Пример #40
0
 private Pango.Context GetPangoContext(IPlatformHandle handle)
 {
     switch (handle.HandleDescriptor)
     {
         case "GtkWindow":
             var window = GLib.Object.GetObject(handle.Handle) as Gtk.Window;
             return window.PangoContext;
         default:
             throw new NotSupportedException(string.Format(
                 "Don't know how to get a Pango Context from a '{0}'.",
                 handle.HandleDescriptor));
     }
 }
Пример #41
0
        /// <summary>
        /// Creates a cairo surface that targets a platform-specific resource.
        /// </summary>
        /// <param name="handle">The platform-specific handle.</param>
        /// <returns>A surface wrapped in an <see cref="IDrawingContext"/>.</returns>
        protected override IDrawingContext CreateDrawingContext(IPlatformHandle handle)
        {
            switch (handle.HandleDescriptor)
            {
                case "RTB":
                    return new DrawingContext(_surface);
                case "GdkWindow":
                    if (_window == null)
                        _window = new Gdk.Window(handle.Handle);

                    return new DrawingContext(_window);
                default:
                    throw new NotSupportedException(string.Format(
                        "Don't know how to create a Cairo renderer from a '{0}' handle",
                        handle.HandleDescriptor));
            }
        }
Пример #42
0
 /// <summary>
 /// Creates a cairo surface that targets a platform-specific resource.
 /// </summary>
 /// <param name="handle">The platform-specific handle.</param>
 /// <returns>A surface wrapped in an <see cref="IDrawingContext"/>.</returns>
 protected override IDrawingContext CreateDrawingContext(IPlatformHandle handle)
 {
     switch (handle.HandleDescriptor)
     {
         case "HWND":
             return new DrawingContext(new Win32Surface(GetDC(handle.Handle)));
         case "RTB":
             return new DrawingContext(this.surface);
         case "HDC":
             return new DrawingContext(new Win32Surface(handle.Handle));
         case "GdkWindow":
             return new DrawingContext(new Gdk.Window(handle.Handle));
         default:
             throw new NotSupportedException(string.Format(
                 "Don't know how to create a Cairo renderer from a '{0}' handle",
                 handle.HandleDescriptor));
     }
 }
Пример #43
0
 public IRenderer CreateRenderer(IPlatformHandle handle, double width, double height)
 {
     return new Renderer(handle, width, height);
 }
Пример #44
0
 /// <summary>
 /// Handles a paint request from <see cref="ITopLevelImpl.Paint"/>.
 /// </summary>
 /// <param name="rect">The rectangle to paint.</param>
 /// <param name="handle">An optional platform-specific handle.</param>
 private void HandlePaint(Rect rect, IPlatformHandle handle)
 {
     this.renderer.Render(this, handle);
     this.renderManager.RenderFinished();
 }
Пример #45
0
 internal Cursor(IPlatformHandle platformCursor)
 {
     PlatformCursor = platformCursor;
 }
 public IRenderTarget CreateRenderTarget(IPlatformHandle handle)
 {
     return new WindowRenderTarget(handle);
 }
Пример #47
0
 public void SetCursor(IPlatformHandle cursor)
 {
     //Not supported
 }
Пример #48
0
 public IRenderTarget CreateRenderer(IPlatformHandle handle) 
     => new RenderTarget(MethodTable.Instance.CreateWindowWindowRenderTarget(handle.Handle));
Пример #49
0
 public IRenderTarget CreateRenderer(IPlatformHandle handle) 
     => new RenderTarget(handle);
Пример #50
0
 public IRenderTarget CreateRenderer(IPlatformHandle handle)
 {
     throw new NotImplementedException();
 }
Пример #51
0
 /// <summary>
 /// When overriden by a derived class creates an <see cref="IDrawingContext"/> for a
 /// rendering session.
 /// </summary>
 /// <param name="handle">The handle to use to create the context.</param>
 /// <returns>An <see cref="IDrawingContext"/>.</returns>
 protected abstract IDrawingContext CreateDrawingContext(IPlatformHandle handle);
Пример #52
0
 public void SetCursor(IPlatformHandle cursor)
 {
     GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor;
 }
Пример #53
0
 public void SetCursor(IPlatformHandle cursor) => _tl.SetCursor(cursor);
Пример #54
0
 /// <summary>
 /// Renders the specified visual.
 /// </summary>
 /// <param name="visual">The visual to render.</param>
 /// <param name="handle">An optional platform-specific handle.</param>
 public virtual void Render(IVisual visual, IPlatformHandle handle)
 {
     Render(visual, handle, Matrix.Identity);
     ++RenderCount;
 }
Пример #55
0
 public WindowRenderTarget(IPlatformHandle hwnd)
 {
     _hwnd = hwnd;
     FixSize();
 }
Пример #56
0
 public void SetCursor(IPlatformHandle cursor)
 {
     UnmanagedMethods.SetClassLong(_hwnd, UnmanagedMethods.ClassLongIndex.GCL_HCURSOR,
         cursor?.Handle ?? DefaultCursor);
 }
Пример #57
0
 public IRenderer CreateRenderer(IPlatformHandle handle, double width, double height)
 {
     Locator.CurrentMutable.RegisterConstant(this.GetPangoContext(handle), typeof(Pango.Context));
     return new Renderer(handle, width, height);
 }
Пример #58
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Renderer"/> class.
 /// </summary>
 /// <param name="handle">The window handle.</param>
 /// <param name="width">The width of the window.</param>
 /// <param name="height">The height of the window.</param>
 public Renderer(IPlatformHandle handle, double width, double height)
 {
 }
Пример #59
0
 public void SetCursor(IPlatformHandle cursor)
 {
     //still not implemented
 }
Пример #60
0
 /// <summary>
 /// Creates a drawing context for a rendering session.
 /// </summary>
 /// <param name="handle">The platform handle. Unused.</param>
 /// <returns>An <see cref="IDrawingContext"/>.</returns>
 protected override IDrawingContext CreateDrawingContext(IPlatformHandle handle)
 {
     return new DrawingContext(_renderTarget, DirectWriteFactory);
 }