Esempio n. 1
0
 /// <summary>
 /// Displays the current color
 /// </summary>
 private void DisplayCurrentColor()
 {
     Color.Color = NSColor.FromRgba(SelectedColor.Color.Red / 255f,
                                    SelectedColor.Color.Green / 255f,
                                    SelectedColor.Color.Blue / 255f,
                                    SelectedColor.Color.Alpha / 255f);
 }
Esempio n. 2
0
        public ProgressView()
        {
            int barWidth = 0;

#if DEBUG_PROGRESSBAR
            barWidth = 100;
#endif
            WantsLayer         = true;
            Layer.CornerRadius = MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 3 : 4;

            progressLayer = new CALayer();
            Layer.AddSublayer(progressLayer);
            Layer.BorderWidth = 0;

            var xamBlue = NSColor.FromRgba(52f / 255, 152f / 255, 219f / 255, 1f);
            progressLayer.BackgroundColor = xamBlue.CGColor;
            progressLayer.BorderWidth     = 0;
            progressLayer.FillMode        = CAFillMode.Forwards;
            progressLayer.Frame           = new CGRect(0, barY, barWidth, barHeight);
            progressLayer.AnchorPoint     = new CGPoint(0, 0);

            AccessibilityIdentifier = "MainToolbar.StatusDisplay.Progress";
            AccessibilityHelp       = "The progress of the current action";
            AccessibilityHidden     = true;
        }
Esempio n. 3
0
        /// <summary>
        /// Converts a web formatted hex string in the form #RRGGBB or #RRGGBBAA into a
        /// color.
        /// </summary>
        /// <returns>The <c>NSColor</c> represented by the hex string.</returns>
        /// <param name="hexValue">The web formatted hex string in the form #RRGGBB or #RRGGBBAA.</param>
        public NSColor NSColorFromHexString(string hexValue)
        {
            var   colorString = hexValue.Replace("#", "");
            float red, green, blue, alpha;

            // Convert color based on length
            switch (colorString.Length)
            {
            case 3:                     // #RGB
                red   = Convert.ToInt32(string.Format("{0}{0}", colorString.Substring(0, 1)), 16) / 255f;
                green = Convert.ToInt32(string.Format("{0}{0}", colorString.Substring(1, 1)), 16) / 255f;
                blue  = Convert.ToInt32(string.Format("{0}{0}", colorString.Substring(2, 1)), 16) / 255f;
                return(NSColor.FromRgba(red, green, blue, 1.0f));

            case 6:                     // #RRGGBB
                red   = Convert.ToInt32(colorString.Substring(0, 2), 16) / 255f;
                green = Convert.ToInt32(colorString.Substring(2, 2), 16) / 255f;
                blue  = Convert.ToInt32(colorString.Substring(4, 2), 16) / 255f;
                return(NSColor.FromRgba(red, green, blue, 1.0f));

            case 8:                     // #AARRGGBB
                alpha = Convert.ToInt32(colorString.Substring(0, 2), 16) / 255f;
                red   = Convert.ToInt32(colorString.Substring(2, 2), 16) / 255f;
                green = Convert.ToInt32(colorString.Substring(4, 2), 16) / 255f;
                blue  = Convert.ToInt32(colorString.Substring(6, 2), 16) / 255f;
                return(NSColor.FromRgba(red, green, blue, alpha));

            default:
                throw new ArgumentOutOfRangeException(string.Format("Invalid color value '{0}'. It should be a hex value of the form #RBG, #RRGGBB or #AARRGGBB", hexValue));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Applies the style info button.
        /// </summary>
        public static void ApplyStyleInfoButton(CustomButton button, string title = null, NSImage image = null)
        {
            if (button == null)
            {
                return;
            }

            SetBaseStyle(button, title, image);

            if (title != null)
            {
                button.TitleText = title;
            }

            button.TitleForegroundColor = Colors.BtnAccountExpireFont;
            button.TitleFont            = UIUtils.GetSystemFontOfSize(12f, NSFontWeight.Regular);

            button.CornerRadius = 12;

            button.BackgroundColor = Colors.BtnAccountExpireBackground;
            button.BorderColor     = Colors.BtnAccountExpireBorder;

            button.BorderShadow = new NSShadow
            {
                ShadowOffset = new CGSize(0, 1),
                ShadowColor  = NSColor.FromRgba(0, 0, 0, 0.25f)
            };

            button.IconLocation          = CustomButton.IconLocationEnum.Left_BeforeCenteredText;
            button.HighlitedColorOverlay = NSColor.FromRgba(0, 0, 0, 0.05f);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Bildspur ArtNet Viewer";

            startButton.Activated    += StartButton_Activated;
            artnet.DmxPacketReceived += Artnet_DmxPacketReceived;
            universeNumber.Changed   += (sender, e) => currentUniverse = universeNumber.IntValue;

            SetupDMXView();

            var worker = new BackgroundWorker();

            worker.DoWork += (sender, e) =>
            {
                while (true)
                {
                    InvokeOnMainThread(() =>
                    {
                        for (int i = 0; i < dataViews.Length; i++)
                        {
                            dataViews[i].StringValue     = values[i].ToString();
                            dataViews[i].BackgroundColor = NSColor.FromRgba(color.RedComponent,
                                                                            color.GreenComponent,
                                                                            color.BlueComponent,
                                                                            values[i] / 255.0f);
                        }
                    });
                    Console.WriteLine("work work");
                    Thread.Sleep(25);
                }
            };
            worker.RunWorkerAsync();
        }
Esempio n. 6
0
 internal Color(int a, int r, int g, int b, string name = null)
 {
     this.nsColor = NSColor.FromRgba(r, g, b, a);
     this.name    = name;
     this.value   = 0;
     this.flags   = 0;
 }
Esempio n. 7
0
        public static void LoadStyles()
        {
            if (IdeApp.Preferences.UserInterfaceTheme == Theme.Light)
            {
                HeaderBackgroundColor        = NSColor.FromRgb(0.98f, 0.98f, 0.98f);
                HeaderBorderBackgroundColor  = NSColor.FromRgb(0.96f, 0.96f, 0.96f);
                LabelSelectedForegroundColor = NSColor.Highlight;
                ToolbarBackgroundColor       = NSColor.White;
                CellBackgroundSelectedColor  = NSColor.FromRgb(0.36f, 0.54f, 0.90f);

                PropertyPad = new PropertyPadStyle {
                    Checkerboard0             = NSColor.FromRgb(255, 255, 255),
                    Checkerboard1             = NSColor.FromRgb(217, 217, 217),
                    PanelTabBackground        = NSColor.FromRgb(248, 247, 248),
                    TabBorderColor            = NSColor.FromRgba(0, 0, 0, 25),
                    ValueBlockBackgroundColor = NSColor.FromRgba(0, 0, 0, 20)
                };
            }
            else
            {
                CellBackgroundSelectedColor  = NSColor.FromRgb(0.38f, 0.55f, 0.91f);
                HeaderBackgroundColor        = NSColor.FromRgb(0.29f, 0.29f, 0.29f);
                HeaderBorderBackgroundColor  = NSColor.FromRgb(0.29f, 0.29f, 0.29f);
                LabelSelectedForegroundColor = NSColor.SelectedText;
                ToolbarBackgroundColor       = NSColor.FromRgb(0.25f, 0.25f, 0.25f);

                PropertyPad = new PropertyPadStyle {
                    Checkerboard0             = NSColor.FromRgb(38, 38, 38),
                    Checkerboard1             = NSColor.FromRgb(0, 0, 0),
                    PanelTabBackground        = NSColor.FromRgb(85, 85, 85),
                    TabBorderColor            = NSColor.FromRgba(255, 255, 255, 0),
                    ValueBlockBackgroundColor = NSColor.FromRgba(255, 255, 255, 25)
                };
            }
        }
Esempio n. 8
0
        AgentService()
        {
            var xPos = NSScreen.MainScreen.Frame.Width / 2;
            var yPos = NSScreen.MainScreen.Frame.Height / 2;

            agentView = new AgentView();

            SetAgent(PropertySettings.AgentSelected ?? "clippy", false);

            window = new NSWindow(new CGRect(xPos, yPos, 100, 100), NSWindowStyle.Borderless, NSBackingStore.Buffered, false)
            {
                Title           = "ClippySharp",
                IsOpaque        = false,
                BackgroundColor = NSColor.FromRgba(red: 1, green: 1, blue: 1f, alpha: 0)
            };
            window.Level = NSWindowLevel.ModalPanel;
            window.MovableByWindowBackground = true;
            window.ContentView = agentView;

            window.IsVisible = true;

            Ide.MessageService.PlaceDialog(window, Ide.MessageService.RootWindow);

            IdeApp.Workbench.RootWindow.Hidden += RootWindow_Hidden;

            IdeApp.Workbench.RootWindow.Shown += RootWindow_Shown;

            IdeApp.ProjectOperations.StartClean += ProjectOperations_StartClean;
            IdeApp.ProjectOperations.EndBuild   += ProjectOperations_EndBuild;
            IdeApp.ProjectOperations.EndClean   += ProjectOperations_Finished;
            IdeApp.ProjectOperations.StartBuild += ProjectOperations_StartBuild;
        }
Esempio n. 9
0
 public static NSColor ToNSColor(this Color color)
 {
     if (color.R == 0 && color.G == 0 && color.R == 0 && color.A == 0)
     {
         return(NSColor.Clear);
     }
     return(NSColor.FromRgba(color.R, color.G, color.B, color.A));
 }
Esempio n. 10
0
 internal Color(int value, string name = null)
 {
     value.ToArgb(out int a, out int r, out int g, out int b);
     this.nsColor = NSColor.FromRgba(r, g, b, a);
     this.name    = name;
     this.value   = 0;
     this.flags   = 0;
 }
 public Material(Vector4 color, double roughness, double metalness)
 {
     SCNMaterial = SCNMaterial.Create();
     SCNMaterial.LightingModelName      = SCNLightingModel.PhysicallyBased;
     SCNMaterial.Diffuse.ContentColor   = NSColor.FromRgba(color.X, color.Y, color.Z, color.W);
     SCNMaterial.Roughness.ContentColor = NSColor.FromWhite((float)roughness, 1);
     SCNMaterial.Metalness.ContentColor = NSColor.FromWhite((float)metalness, 1);
 }
        /// <summary>
        /// Shows current color values.
        /// </summary>
        private void ShowCurrentColor()
        {
            // Get the active color
            var color = (SelectedGradient == null) ? KimonoColor.Black : SelectedGradient.SelectedColor;

            // Update color selector
            PointColor.Color = NSColor.FromRgba(color.Red / 255f,
                                                color.Green / 255f,
                                                color.Blue / 255f,
                                                color.Alpha / 255f);

            OpacitySlider.IntValue   = color.Alpha;
            OpacityValue.StringValue = $"{(int)((OpacitySlider.IntValue / 255f) * 100f)}%";

            // Populate the list of colors
            LinkedColorDropdown.RemoveAllItems();
            LinkedColorDropdown.AddItem("None");
            var n = 0;

            foreach (KimonoColor namedColor in Portfolio.Colors)
            {
                // Add color
                LinkedColorDropdown.AddItem(namedColor.Name);
                ++n;

                // Currently selected color?
                if (SelectedGradient.SelectedHandle?.LinkedColor == namedColor)
                {
                    // Yes, highlight it
                    LinkedColorDropdown.SelectItem(n);
                }
            }

            // Is a gradient selected?
            if (SelectedGradient.SelectedHandle == null || SelectedGradient.SelectedHandle.HandleType == KimonoHandleType.GradientPosition)
            {
                LinkedColorDropdown.Enabled  = false;
                AddColorButton.Hidden        = true;
                PointColor.Enabled           = false;
                OpacitySlider.Enabled        = false;
                OpacityValue.Enabled         = false;
                DeletePointButton.Enabled    = false;
                DuplicatePointButton.Enabled = false;
            }
            else
            {
                LinkedColorDropdown.Enabled  = true;
                DuplicatePointButton.Enabled = true;
                AddColorButton.Hidden        = (SelectedGradient.SelectedHandle.LinkedColor != null);
                PointColor.Enabled           = (SelectedGradient.SelectedHandle.LinkedColor == null);
                OpacitySlider.Enabled        = PointColor.Enabled;
                OpacityValue.Enabled         = PointColor.Enabled;
                DeletePointButton.Enabled    = (SelectedGradient.SelectedHandle.Constraint != KimonoHandleConstraint.Locked);
            }
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            AgentEnvirontment.Current.Initialize(new AgentDelegate(), new SoundPlayer());

            var xPos = NSScreen.MainScreen.Frame.Width / 2;
            var yPos = NSScreen.MainScreen.Frame.Height / 2;

            var mainWindow = new NSWindow(new CGRect(xPos, yPos, 200, 150), NSWindowStyle.Borderless, NSBackingStore.Buffered, false)
            {
                Title = "ClippySharp",

                IsOpaque        = false,
                BackgroundColor = NSColor.FromRgba(red: 1, green: 1, blue: 1f, alpha: 0.5f)
            };

            mainWindow.MovableByWindowBackground = true;

            var stackView = new NSStackView()
            {
                Orientation  = NSUserInterfaceLayoutOrientation.Vertical,
                Distribution = NSStackViewDistribution.Fill
            };

            mainWindow.ContentView = stackView;

            agentPopupButton = new NSPopUpButton();
            stackView.AddArrangedSubview(agentPopupButton);

            foreach (var item in AgentEnvirontment.Current.GetAgents())
            {
                agentPopupButton.AddItem(item);
            }

            animationPopupButton = new NSPopUpButton();
            stackView.AddArrangedSubview(animationPopupButton);

            agentView = new AgentView();
            stackView.AddArrangedSubview(agentView);

            agentPopupButton.Activated += AgentPopupButton_Activated;

            animationPopupButton.Activated += AnimationPopupButton_Activated;

            AgentPopupButton_Activated(null, null);

            mainWindow.MakeKeyAndOrderFront(null);
            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
Esempio n. 14
0
        public override void MouseUp(NSEvent @event)
        {
            this.SetBackgroundColor(NSColor.FromRgba(0f, 0f, 0f, 0.75f));

            var x = this.Position.X + ((this.Parent?.Position.X) ?? 0f);
            var y = this.Position.Y + ((this.Parent?.Position.Y) ?? 0f);
            var p = @event.LocationInWindow;

            if (Math.Abs(p.X - x) < this.Width / 2 * this.XScale && Math.Abs(p.Y - y) < this.Height / 2 * this.YScale)
            {
                this.actionClicked.Invoke(this);
            }
        }
Esempio n. 15
0
        public static NSColor FromHex(string hex)
        {
            var colorValue = int.Parse(hex.Replace("#", ""), NumberStyles.HexNumber);

            var red   = (byte)(colorValue >> 16);
            var green = (byte)(colorValue >> 8);
            var blue  = (byte)colorValue;

            return(NSColor.FromRgba(
                       red,
                       green,
                       blue,
                       (byte)255
                       ));
        }
Esempio n. 16
0
        /// <summary>
        /// Shows the color of the current.
        /// </summary>
        private void ShowCurrentColor()
        {
            // Update color selector
            FrameColor.Color = NSColor.FromRgba(SelectedStyle.Frame.Color.Red / 255f,
                                                SelectedStyle.Frame.Color.Green / 255f,
                                                SelectedStyle.Frame.Color.Blue / 255f,
                                                SelectedStyle.Frame.Color.Alpha / 255f);

            OpacitySlider.IntValue   = SelectedStyle.Frame.Color.Alpha;
            OpacityValue.StringValue = $"{(int)((OpacitySlider.IntValue / 255f) * 100f)}%";

            AddColorButton.Hidden = (SelectedStyle.FrameColor != null);
            FrameColor.Enabled    = (SelectedStyle.HasFrame && SelectedStyle.FrameColor == null);
            OpacitySlider.Enabled = (SelectedStyle.HasFrame && SelectedStyle.FrameColor == null);
            OpacityValue.Enabled  = (SelectedStyle.HasFrame && SelectedStyle.FrameColor == null);
        }
Esempio n. 17
0
        /// <summary>
        /// We are using separate layer for higliting elements on a main view
        /// This method is highliting GUI element depends on current introduction step
        /// </summary>
        public void DrawLayer(NSView view, CGRect dirtyRect)
        {
            var     bg        = Colors.WindowBackground;
            NSColor fillColor = NSColor.FromRgba(bg.RedComponent, bg.GreenComponent, bg.BlueComponent, 0.4f);

            NSColor strokeColor = NSColor.FromRgb(50, 158, 230);
            nfloat  strokeWidth = 2;

            if (__InotroductionStage != IntroductionStageEnum.Finished)
            {
                NSBezierPath fillRect = NSBezierPath.FromRect(dirtyRect);
                fillColor.SetFill();
                fillRect.Fill();
            }

            if (__InotroductionStage == IntroductionStageEnum.Firewall)
            {
                CGRect fwRect = __MainViewController.GetFirewallControlViewRect();

                NSBezierPath firewallPath = NSBezierPath.FromRoundedRect(fwRect, fwRect.Height / 2, fwRect.Height / 2);
                firewallPath.LineWidth = strokeWidth;
                strokeColor.SetStroke();
                firewallPath.Stroke();
            }

            if (__InotroductionStage == IntroductionStageEnum.ConnectBtn)
            {
                // CONNECT BUTTON
                CGRect       circleRect    = __MainViewController.GetConnectButtonViewRect();
                NSBezierPath connectBthPth = NSBezierPath.FromRoundedRect(circleRect, circleRect.Width / 2, circleRect.Height / 2);
                connectBthPth.LineWidth = strokeWidth;
                strokeColor.SetStroke();
                connectBthPth.Stroke();
            }

            if (__InotroductionStage == IntroductionStageEnum.Servers)
            {
                // SERVERS SELECTION
                CGRect serversRect = __MainViewController.GetServerSelectionViewRect();
                serversRect = new CGRect(serversRect.X + 3, serversRect.Y + 3, serversRect.Width - 6, serversRect.Height - 6);
                NSBezierPath serversViewPath = NSBezierPath.FromRoundedRect(serversRect, 4, 4);
                serversViewPath.LineWidth = strokeWidth;
                strokeColor.SetStroke();
                serversViewPath.Stroke();
            }
        }
Esempio n. 18
0
        public ProgressView()
        {
            WantsLayer         = true;
            Layer.CornerRadius = MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 3 : 4;

            progressLayer = new CALayer();
            Layer.AddSublayer(progressLayer);
            Layer.BorderWidth = 0;

            var xamBlue = NSColor.FromRgba(52f / 255, 152f / 255, 219f / 255, 1f);

            progressLayer.BackgroundColor = xamBlue.CGColor;
            progressLayer.BorderWidth     = 0;
            progressLayer.FillMode        = CAFillMode.Forwards;
            progressLayer.Frame           = new CGRect(0, 0, 0, barHeight);
            progressLayer.AnchorPoint     = new CGPoint(0, 0);
        }
        private static void DrawBackgroundInRect(CGRect rect)
        {
            var    backgroundColor = NSColor.FromRgba(50, 50, 50, 240).CGColor;
            var    borderColor     = NSColor.FromRgba(100, 100, 100, 240).CGColor;
            nfloat radius          = 6;

            var context = NSGraphicsContext.CurrentContext.CGContext;

            context.SaveState();
            context.SetFillColor(backgroundColor);
            context.SetStrokeColor(borderColor);
            var path = NSBezierPath.FromRoundedRect(rect, radius, radius);

            path.LineWidth = 2;
            path.Stroke();
            path.Fill();
            context.RestoreState();
        }
Esempio n. 20
0
        /// <summary>
        /// Applies the style secondary button.
        /// </summary>
        public static void ApplyStyleSecondaryButton(CustomButton button, string title = null, NSImage image = null)
        {
            if (button == null)
            {
                return;
            }

            SetBaseStyle(button, title, image);

            button.Gradient             = new NSGradient(Colors.SecondaryBtnGradient1Color, Colors.SecondaryBtnGradient2Color);
            button.TitleForegroundColor = Colors.SecondaryBtnTextColor;
            button.BorderColor          = Colors.SecondaryBtnBorderColor;
            button.BorderShadow         = new NSShadow
            {
                ShadowOffset = new CGSize(0f, 1f),
                ShadowColor  = NSColor.FromRgba(0, 0, 0, 0.12f)
            };
            button.HighlitedColorOverlay = NSColor.FromRgba(0, 0, 0, 0.05f);
        }
Esempio n. 21
0
 /// <summary>
 /// Updates the inspector.
 /// </summary>
 public void UpdateInspector()
 {
     // Update fields with the current shape information
     SketchName.StringValue       = SelectedSketch.Name;
     SketchWidth.StringValue      = SelectedSketch.Width.ToString();
     SketchHeight.StringValue     = SelectedSketch.Height.ToString();
     CanvasColorCheckbox.IntValue = SelectedSketch.DrawCanvas ? 1 : 0;
     CanvasColor.Color            = NSColor.FromRgba(SelectedSketch.CanvasColor.Red / 255f,
                                                     SelectedSketch.CanvasColor.Green / 255f,
                                                     SelectedSketch.CanvasColor.Blue / 255f,
                                                     SelectedSketch.CanvasColor.Alpha / 255f);
     OpacitySlider.IntValue             = SelectedSketch.CanvasColor.Alpha;
     OpacityValue.StringValue           = $"{(int)((OpacitySlider.IntValue / 255f) * 100f)}%";
     ToCanvasCheckbox.IntValue          = SelectedSketch.GenerateCodeToOuputToCanvas ? 1 : 0;
     ToDataCheckbox.IntValue            = SelectedSketch.GenerateCodeToOuputSkiaData ? 1 : 0;
     ToBitmapCheckbox.IntValue          = SelectedSketch.GenerateCodeToOuputBitmapImage ? 1 : 0;
     UseSkiaSharpViewsCheckbox.IntValue = SelectedSketch.GenerateCodeToOuputToSkiaSharpViews ? 1 : 0;
     DeleteButton.Enabled = (DesignSurface.Portfolio.Sketches.Count > 1);
 }
Esempio n. 22
0
        /// <summary>
        /// Applies the style main button.
        /// </summary>
        public static void ApplyStyleMainButton(CustomButton button, string title, NSImage image = null)
        {
            if (button == null)
            {
                return;
            }

            SetBaseStyle(button, title, image);

            if (title != null)
            {
                button.TitleText = title;
            }

            button.BorderShadow = new NSShadow
            {
                ShadowOffset = new CGSize(0f, 1f),
                ShadowColor  = NSColor.FromRgba(0, 0, 0, 0.18f)
            };
        }
Esempio n. 23
0
        /// <summary>
        /// Shows the color of the current shadow.
        /// </summary>
        private void ShowCurrentShadowColor()
        {
            // Update color selector
            ShadowColor.Color = NSColor.FromRgba(SelectedStyle.FrameShadow.ShadowColor.Red / 255f,
                                                 SelectedStyle.FrameShadow.ShadowColor.Green / 255f,
                                                 SelectedStyle.FrameShadow.ShadowColor.Blue / 255f,
                                                 SelectedStyle.FrameShadow.ShadowColor.Alpha / 255f);

            ShadowOpacitySlider.IntValue   = SelectedStyle.FrameShadow.ShadowColor.Alpha;
            ShadowOpacityValue.StringValue = $"{(int)((ShadowOpacitySlider.IntValue / 255f) * 100f)}%";

            ShadowCheckbox.IntValue              = (SelectedStyle.HasFrameShadow) ? 1 : 0;
            LinkedShadowColor.Enabled            = SelectedStyle.HasFrameShadow;
            ShadowColor.Enabled                  = (SelectedStyle.HasFrameShadow && SelectedStyle.FrameShadow.LinkedColor == null);
            ShadowOpacitySlider.Enabled          = ShadowColor.Enabled;
            ShadowOpacityValue.Enabled           = ShadowColor.Enabled;
            HorizontalShadowOffsetSlider.Enabled = SelectedStyle.HasFrameShadow;
            VerticalShadowOffsetSlider.Enabled   = SelectedStyle.HasFrameShadow;
            HorizontalShadowBlurSlider.Enabled   = SelectedStyle.HasFrameShadow;
            VerticalShadowBlurSlider.Enabled     = SelectedStyle.HasFrameShadow;
        }
Esempio n. 24
0
        /// <summary>
        /// Applies the style secondary button.
        /// </summary>
        public static void ApplyStyleSecondaryButtonV2(CustomButton button, string title = null, NSImage image = null)
        {
            if (button == null)
            {
                return;
            }

            SetBaseStyle(button, title, image);

            button.CornerRadius         = 3.5f;
            button.BackgroundColor      = NSColor.FromRgb(255, 255, 255);
            button.TitleForegroundColor = NSColor.FromRgb(39, 39, 39);
            button.BorderColor          = NSColor.FromRgb(231, 231, 231);

            button.BorderShadow = new NSShadow
            {
                ShadowOffset = new CGSize(0f, 1f),
                ShadowColor  = NSColor.FromRgba(0, 0, 0, 0.12f)
            };
            button.HighlitedColorOverlay = NSColor.FromRgba(0, 0, 0, 0.05f);
        }
Esempio n. 25
0
        public CustomSearchField()
        {
            TranslatesAutoresizingMaskIntoConstraints = false;

            Cell       = cell = new SearchFieldCell(this);
            WantsLayer = true;

            var internalLayer = new CoreAnimation.CALayer();

            internalLayer.BorderWidth  = 1;
            internalLayer.BorderColor  = NSColor.FromRgba(red: 0.75f, green: 0.75f, blue: 0.75f, 0.45f).CGColor;
            internalLayer.Frame        = new CGRect(1, 0, DefaultWidth + 2, DefaultHeight);
            internalLayer.CornerRadius = 2;
            Layer.AddSublayer(internalLayer);

            Font = NSFont.SystemFontOfSize(SearchFontSize, NSFontWeight.Thin);

            //default size needs to be changed before change cell
            WidthAnchor.ConstraintEqualToConstant(DefaultWidth).Active   = true;
            HeightAnchor.ConstraintEqualToConstant(DefaultHeight).Active = true;
        }
Esempio n. 26
0
        public override bool TryConvertFromRepresentation(
            IRepresentedType representedType,
            object [] representations,
            out object represented)
        {
            represented = null;

            Color color;

            if (TryFindMatchingRepresentation <NSColor, Color> (
                    representedType,
                    representations,
                    out color))
            {
                represented = NSColor.FromRgba(
                    (nfloat)color.Red,
                    (nfloat)color.Green,
                    (nfloat)color.Blue,
                    (nfloat)color.Alpha);
                return(true);
            }

            GeoPolyline polyline;

            if (TryFindMatchingRepresentation <MKPolyline, GeoPolyline> (
                    representedType,
                    representations,
                    out polyline))
            {
                represented = polyline.ToMKPolyline();
                return(true);
            }

            return(base.TryConvertFromRepresentation(
                       representedType,
                       representations,
                       out represented));
        }
Esempio n. 27
0
        void SetupDMXView()
        {
            float textWidth  = 35;
            float textHeight = 20;

            float width  = (float)dataView.Frame.Width;
            float height = (float)dataView.Frame.Height;

            int itemsPerRow = (int)(width / textWidth);
            int heightIndex = 0;

            for (int i = 0; i < dataViews.Length; i++)
            {
                if (i % itemsPerRow == 0)
                {
                    heightIndex++;
                }

                var view = new NSTextField();
                view.Alignment = NSTextAlignment.Center;
                view.SetFrameSize(new CGSize(textWidth, textHeight));
                view.StringValue     = "0";
                view.Editable        = false;
                view.Selectable      = false;
                view.BackgroundColor = NSColor.FromRgba(color.RedComponent, color.GreenComponent, color.BlueComponent, 0);
                view.Bordered        = false;

                float x = textWidth * (i % itemsPerRow);
                float y = height - (textHeight * heightIndex);

                view.SetFrameOrigin(new CGPoint(x, y));

                dataViews[i] = view;
                dataView.AddSubview(view);
            }
        }
Esempio n. 28
0
 public static CGColor ToCgColor(this Color color) => NSColor.FromRgba(
     ColorComponent(color.R),
     ColorComponent(color.G),
     ColorComponent(color.B),
     ColorComponent(color.A)).CGColor;
Esempio n. 29
0
 public static NSColor ToNsColor(this Color color) => NSColor.FromRgba(
     ColorComponent(color.R),
     ColorComponent(color.G),
     ColorComponent(color.B),
     ColorComponent(color.A));
Esempio n. 30
0
 public static NSColor ToNSColor(this SKColor color)
 {
     return(NSColor.FromRgba(color.Red, color.Green, color.Blue, color.Alpha));
 }