Exemple #1
0
        static void SetTheme(NSWindow window)
        {
            if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light)
            {
                window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua);
            }
            else
            {
                window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark);
            }

            if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light)
            {
                window.StyleMask &= ~NSWindowStyle.TexturedBackground;
                return;
            }

            if (window is NSPanel || window.ContentView.Class.Name != "GdkQuartzView")
            {
                window.BackgroundColor = MonoDevelop.Ide.Gui.Styles.BackgroundColor.ToNSColor();
            }
            else
            {
                object[] platforms = Mono.Addins.AddinManager.GetExtensionObjects("/MonoDevelop/Core/PlatformService");
                if (platforms.Length > 0)
                {
                    var platformService = (MonoDevelop.Ide.Desktop.PlatformService)platforms [0];
                    var image           = Xwt.Drawing.Image.FromResource(platformService.GetType().Assembly, "maintoolbarbg.png");

                    window.IsOpaque        = false;
                    window.BackgroundColor = NSColor.FromPatternImage(image.ToBitmap().ToNSImage());
                }
            }
            window.StyleMask |= NSWindowStyle.TexturedBackground;
        }
        private void ChangeBackground(int number)
        {
            NSImage image = NSImage.ImageNamed($"1_{number}.jpg");
            NSColor color = NSColor.FromPatternImage(image);


            this.View.Window.BackgroundColor = color;
            //NSApplication.SharedApplication.KeyWindow.BackgroundColor = color;
        }
        internal override void SetMainWindowDecorations(Gtk.Window window)
        {
            NSWindow w = GtkQuartz.GetWindow(window);

            w.IsOpaque = false;

            var     resource = "maintoolbarbg.png";
            NSImage img      = LoadImage(resource);

            w.BackgroundColor = NSColor.FromPatternImage(img);
            w.StyleMask      |= NSWindowStyle.TexturedBackground;
        }
Exemple #4
0
        protected override void SetBackground(Brush brush)
        {
            base.SetBackground(brush);

            if (_table == null)
            {
                return;
            }

            var backgroundImage = this.GetBackgroundImage(brush);

            _table.BackgroundColor = backgroundImage != null?NSColor.FromPatternImage(backgroundImage) : NSColor.Clear;
        }
Exemple #5
0
        protected override void SetBackground(Brush brush)
        {
            if (Control == null)
            {
                return;
            }

            var backgroundImage = this.GetBackgroundImage(brush);

            Control.BackgroundColor = backgroundImage != null?NSColor.FromPatternImage(backgroundImage) : NSColor.Clear;

            base.SetBackground(brush);
        }
Exemple #6
0
        void UpdateBackground()
        {
            string bgImage = ((Page)Element).BackgroundImage;

            if (!string.IsNullOrEmpty(bgImage))
            {
                View.Layer.BackgroundColor = NSColor.FromPatternImage(NSImage.ImageNamed(bgImage)).CGColor;
                return;
            }
            Color bgColor = Element.BackgroundColor;

            View.Layer.BackgroundColor = bgColor.IsDefault ? NSColor.White.CGColor : bgColor.ToCGColor();
        }
        /// <summary>
        /// Converts a DSColor to a UIColor object
        /// </summary>
        /// <returns>The color from DS color.</returns>
        /// <param name="aColor">A color.</param>
        public static NSColor ToNSColor(this DSColor aColor)
        {
            // if a pattern image has been set then create a pattern color from it
            if (aColor.PatternImage != null)
            {
                return(NSColor.FromPatternImage(aColor.PatternImage.ToUIImage()));
            }

            var aRed   = (nfloat)aColor.RedValue / 255.0f;
            var aGreen = (nfloat)aColor.GreenValue / 255.0f;
            var aBlue  = (nfloat)aColor.BlueValue / 255.0f;
            var aAlpha = (nfloat)aColor.AlphaValue / 255.0f;

            return(NSColor.FromDeviceRgba(aRed, aGreen, aBlue, aAlpha));
        }
Exemple #8
0
 void UpdateBackground()
 {
     this.ApplyNativeImageAsync(Page.BackgroundImageSourceProperty, bgImage =>
     {
         if (bgImage != null)
         {
             View.Layer.BackgroundColor = NSColor.FromPatternImage(bgImage).CGColor;
         }
         else
         {
             Color bgColor = Element.BackgroundColor;
             View.Layer.BackgroundColor = bgColor.IsDefault ? NSColor.White.CGColor : bgColor.ToCGColor();
         }
     });
 }
        public override void Initialize()
        {
            base.Initialize();

            var image = Xwt.Drawing.Image.FromResource(typeof(MacPlatformService).Assembly, "maintoolbarbg.png");

            Window.Realized += delegate {
                NSWindow w = GtkQuartz.GetWindow(Window);
                w.IsOpaque        = false;
                w.BackgroundColor = NSColor.FromPatternImage(image.ToBitmap().ToNSImage());
                w.StyleMask      |= NSWindowStyle.TexturedBackground;
            };

            toolbar                = new CustomToolbar();
            toolbar.Background     = (Gdk.Pixbuf)Xwt.Toolkit.Load(Xwt.ToolkitType.Gtk).GetNativeImage(image);
            toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight();
            MainBox.PackStart(toolbar, false, false, 0);
            ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0;
        }
Exemple #10
0
        public override void Initialize()
        {
            base.Initialize();

            var resource = "maintoolbarbg.png";

            Window.Realized += delegate {
                NSWindow w = GtkQuartz.GetWindow(Window);
                w.IsOpaque = false;
                NSImage img = MacPlatformService.LoadImage(resource);
                w.BackgroundColor = NSColor.FromPatternImage(img);
                w.StyleMask      |= NSWindowStyle.TexturedBackground;
            };

            toolbar                = new CustomToolbar();
            toolbar.Background     = MonoDevelop.Components.CairoExtensions.LoadImage(typeof(MacPlatformService).Assembly, resource);
            toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight();
            MainBox.PackStart(toolbar, false, false, 0);
            ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0;
        }
Exemple #11
0
        internal override MainToolbar CreateMainToolbar(Gtk.Window window)
        {
            NSWindow w = GtkQuartz.GetWindow(window);

            w.IsOpaque = false;

            var     resource = "maintoolbarbg.png";
            NSImage img      = LoadImage(resource);
            var     c        = NSColor.FromPatternImage(img);

            w.BackgroundColor = c;
            w.StyleMask      |= NSWindowStyle.TexturedBackground;

            var result = new MainToolbar()
            {
                Background     = MonoDevelop.Components.CairoExtensions.LoadImage(typeof(MacPlatformService).Assembly, resource),
                TitleBarHeight = GetTitleBarHeight()
            };

            return(result);
        }
Exemple #12
0
        protected override void SetBackground(Brush brush)
        {
            if (Element == null)
            {
                return;
            }

            if (!Brush.IsNullOrEmpty(brush) || _hasBackgrondBrush)
            {
                if (brush is SolidColorBrush solidColorBrush)
                {
                    (Control as FormsBoxView)?.SetColor(solidColorBrush.Color.ToNSColor());
                }
                else
                {
                    var backgroundImage = this.GetBackgroundImage(brush);
                    (Control as FormsBoxView)?.SetBrush(backgroundImage != null ? NSColor.FromPatternImage(backgroundImage) : NSColor.Clear);
                }

                _hasBackgrondBrush = true;
            }
        }
Exemple #13
0
        void UpdateBackground()
        {
            if (View.Layer == null)
            {
                return;
            }

            this.ApplyNativeImageAsync(Page.BackgroundImageSourceProperty, image =>
            {
                if (image != null)
                {
                    View.Layer.BackgroundColor = NSColor.FromPatternImage(image).CGColor;
                }
                else
                {
                    Color bgColor = Element.BackgroundColor;
                    View.Layer.BackgroundColor = bgColor.IsDefault ? NSColor.White.CGColor : bgColor.ToCGColor();

                    Brush background = Element.Background;
                    View.UpdateBackground(background);
                }
            });
        }
Exemple #14
0
        static void SetTheme(NSWindow window)
        {
            window.Appearance = GetAppearance();

            if (IdeApp.Preferences.UserInterfaceTheme == Theme.Light)
            {
                window.StyleMask      &= ~NSWindowStyle.TexturedBackground;
                window.BackgroundColor = MonoDevelop.Ide.Gui.Styles.BackgroundColor.ToNSColor();
                return;
            }

            if (window is NSPanel || window.ContentView.Class.Name != "GdkQuartzView")
            {
                window.BackgroundColor = MonoDevelop.Ide.Gui.Styles.BackgroundColor.ToNSColor();
                if (MacSystemInformation.OsVersion <= MacSystemInformation.Sierra)
                {
                    window.StyleMask |= NSWindowStyle.TexturedBackground;
                }
            }
            else
            {
                object[] platforms = Mono.Addins.AddinManager.GetExtensionObjects("/MonoDevelop/Core/PlatformService");
                if (platforms.Length > 0)
                {
                    var platformService = (MonoDevelop.Ide.Desktop.PlatformService)platforms [0];
                    var image           = Xwt.Drawing.Image.FromResource(platformService.GetType().Assembly, "maintoolbarbg.png");

                    window.IsOpaque        = false;
                    window.BackgroundColor = NSColor.FromPatternImage(image.ToBitmap().ToNSImage());
                }
                window.StyleMask |= NSWindowStyle.TexturedBackground;
            }
            if (MacSystemInformation.OsVersion >= MacSystemInformation.HighSierra && !window.IsSheet)
            {
                window.TitlebarAppearsTransparent = true;
            }
        }
Exemple #15
0
        void UpdateBackground()
        {
            _renderer.ApplyNativeImageAsync(Page.BackgroundImageSourceProperty, bgImage =>
            {
                if (bgImage != null)
                {
                    Layer.BackgroundColor = NSColor.FromPatternImage(bgImage).CGColor;
                }
                else
                {
                    Brush background = _renderer.Element.Background;

                    if (!Brush.IsNullOrEmpty(background))
                    {
                        _renderer.NativeView.UpdateBackground(_renderer.Element.Background);
                    }
                    else
                    {
                        Color bgColor         = _renderer.Element.BackgroundColor;
                        Layer.BackgroundColor = bgColor.IsDefault ? ColorExtensions.WindowBackgroundColor.CGColor : bgColor.ToCGColor();
                    }
                }
            });
        }
Exemple #16
0
        public object Create(object img)
        {
            NSImage nimg = (NSImage)img;

            return(NSColor.FromPatternImage(nimg));
        }
Exemple #17
0
 protected void AssignBackgroundImage(String backgroundFileName)
 {
     BackgroundColor = NSColor.FromPatternImage(NSImage.FromStream(
                                                    Assembly.GetExecutingAssembly().
                                                    GetManifestResourceStream(backgroundFileName)));
 }