Exemplo n.º 1
0
        /// <summary>
        /// Gets the color of the health.
        /// </summary>
        /// <returns>The health color.</returns>
        /// <param name="health">Health.</param>
        public static NSColor GetHealthColor(Health health)
        {
            NSColor color;

            switch (health)
            {
            case Health.Full:
                color = NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1);
                break;

            case Health.Limited:
                color = NSColor.Orange;
                break;

            case Health.Down:
                color = NSColor.Red;
                break;

            case Health.Legacy:
                color = NSColor.Black;
                break;

            default:
                color = NSColor.Purple;
                break;
            }

            return(color);
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            //set window background color
            this.Window.BackgroundColor = NSColor.FromSrgb(1, 1, (float)1, (float)1);
        }
Exemplo n.º 3
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            //set window background color
            this.Window.BackgroundColor = NSColor.FromSrgb(1, 1, (float)1, (float)1);
            ConnectPopupButton.AddItem("New Server");
            ConnectPopupButton.AddItems(VMCAAppEnvironment.Instance.LocalData.GetServerArray());
        }
Exemplo n.º 4
0
        public override void DrawRect(RectangleF dirtyRect)
        {
            var context = NSGraphicsContext.CurrentContext.GraphicsPort;

            context.SetFillColor(new CGColor(1, 1, 1));           //White
            context.FillRect(dirtyRect);

            for (int i = 1; i < this.Bounds.Size.Height / 10; i++)
            {
                if (i % 10 == 0)
                {
                    NSColor colorWithSRGBRed = NSColor.FromSrgb(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 0.3f);
                    colorWithSRGBRed.Set();
                }
                else if (i % 10 == 0)
                {
                    NSColor colorWithSRGBRed = NSColor.FromSrgb(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 0.2f);
                    colorWithSRGBRed.Set();
                }
                else
                {
                    NSColor colorWithSRGBRed = NSColor.FromSrgb(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 0.1f);
                    colorWithSRGBRed.Set();
                }
                var pointFrom = new PointF(0, (i * GridSize - 0.5f));
                var pointTo   = new PointF(this.Bounds.Size.Width, (i * GridSize - 0.5f));

                NSBezierPath.StrokeLine(pointFrom, pointTo);
            }


            for (int i = 1; i < this.Bounds.Size.Width / 10; i++)
            {
                if (i % 10 == 0)
                {
                    NSColor colorWithSRGBRed = NSColor.FromSrgb(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 0.3f);
                    colorWithSRGBRed.Set();
                }
                else if (i % 10 == 0)
                {
                    NSColor colorWithSRGBRed = NSColor.FromSrgb(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 0.2f);
                    colorWithSRGBRed.Set();
                }
                else
                {
                    NSColor colorWithSRGBRed = NSColor.FromSrgb(100 / 255.0f, 149 / 255.0f, 237 / 255.0f, 0.1f);
                    colorWithSRGBRed.Set();
                }
                var pointFrom = new PointF((i * GridSize - 0.5f), 0);
                var pointTo   = new PointF((i * GridSize - 0.5f), this.Bounds.Size.Height);

                NSBezierPath.StrokeLine(pointFrom, pointTo);
            }
        }
Exemplo n.º 5
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            //set window background color
            this.Window.BackgroundColor = NSColor.FromSrgb(1, 1, (float)1, (float)1);
            string[] servers = VMDirSnapInEnvironment.Instance.LocalData.GetServerArray();
            ConnectToServer.AddItem("New Server");
            ConnectToServer.AddItems(servers);

            ConnectToServer.Activated += LoginAction;
        }
 public override void AwakeFromNib()
 {
     base.AwakeFromNib();
     NetworkChange.NetworkAvailabilityChanged += (object sender, NetworkAvailabilityEventArgs e) =>
     {
         NetworkStatus.StringValue = e.IsAvailable ? "Connected" : "Disconnected";
         NetworkStatus.TextColor   = e.IsAvailable
                                 ? NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1)
                                 : NSColor.Red;
     };
 }
Exemplo n.º 7
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            //set window background color
            this.Window.BackgroundColor = NSColor.FromSrgb(1, 1, (float)1, (float)1);
            ConnectPopupButton.AddItem("New Server");
            var tokens  = SnapInContext.Instance.AuthTokenManager.GetAllAuthTokens();
            var servers = tokens.Where(x => x.ServerDto != null).OrderByDescending(x => x.ServerDto.UpdatedOn).Select(x => x.ServerDto.ServerName).Take(3).ToArray();

            ConnectPopupButton.AddItems(servers);
        }
Exemplo n.º 8
0
        public static NSColor Parse(string color)
        {
            Func <string, int, int, byte> parseHex = (s, i, l) => {
                var t = Convert.ToByte(s.Substring(i, l), 16);
                if (l == 1)
                {
                    return((byte)((t << 4) | t));
                }
                else
                {
                    return(t);
                }
            };

            color = color.Trim();

            if (color.Length > 0 && color [0] == '#')
            {
                byte r = 0, g = 0, b = 0, a = 0xff;

                if (color.Length == 4 || color.Length == 5)
                {
                    r = parseHex(color, 1, 1);
                    g = parseHex(color, 2, 1);
                    b = parseHex(color, 3, 1);
                    if (color.Length == 5)
                    {
                        a = parseHex(color, 4, 1);
                    }
                }
                else if (color.Length == 7 || color.Length == 9)
                {
                    r = parseHex(color, 1, 2);
                    g = parseHex(color, 3, 2);
                    b = parseHex(color, 5, 2);
                    if (color.Length == 9)
                    {
                        a = parseHex(color, 7, 2);
                    }
                }

                return(NSColor.FromSrgb(r / 255f, g / 255f, b / 255f, a / 255f));
            }

            return((
                       from list in NSColorList.AvailableColorLists
                       from name in list.AllKeys()
                       where String.Equals(name, color, StringComparison.InvariantCultureIgnoreCase)
                       select list.ColorWithKey(name)
                       ).FirstOrDefault());
        }
Exemplo n.º 9
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            //set window background color
            this.Window.BackgroundColor = NSColor.FromSrgb(1, 1, (float)1, (float)1);

            this.TitleDescriptionField.StringValue = TitleDescription;
            this.DescriptionField1.StringValue     = Description1;
            this.DescriptionField2.StringValue     = Description2;
            this.DescriptionField3.StringValue     = Description3;


            ConnectToServer.StringValue = VMIdentityConstants.SERVER_CONNECT;

            ConnectToServer.Activated += LoginAction;
        }
        /// <summary>
        /// Awakes from nib.
        /// </summary>
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            IpAddressTextField.StringValue = Network.GetIpAddress(_nodeName);
            _infrastructureDto             = (InfrastructureDto)_rootNode.Hosts.First(x => x.Name == _nodeName);
            HotnametextField.StringValue   = _infrastructureDto.Name;
            SitenameTextField.StringValue  = SiteName;
            var health = _infrastructureDto.Active ? Constants.Active : Constants.InActive;
            var color  = _infrastructureDto.Active
                                ? NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1)
                                : NSColor.Red;

            HealthTextField.StringValue = health.ToUpper();
            HealthTextField.TextColor   = color;
            SetServicesTableView(_infrastructureDto.Services);
        }
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            //set window background color
            this.Window.BackgroundColor = NSColor.FromSrgb(1, 1, (float)1, (float)1);

            this.TitleDescriptionField.StringValue = TitleDescription;
            this.DescriptionField1.StringValue     = Description1;
            this.DescriptionField2.StringValue     = Description2;
            this.DescriptionField3.StringValue     = Description3;

            //string[] servers = VMDirSnapInEnvironment.Instance.LocalData.GetServerArray ();
            ConnectToServer.AddItem("Connect to Server");
            //ConnectToServer.AddItems (Servers);

            ConnectToServer.Activated += LoginAction;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Alter the display of the cell text.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="tableColumn">Table column.</param>
        /// <param name="row">Row.</param>
        public override void WillDisplayCell(NSTableView tableView, NSObject cell,
                                             NSTableColumn tableColumn, nint row)
        {
            UIErrorHelper.CheckedExec(delegate() {
                if (cell is NSBrowserCell)
                {
                    NSBrowserCell browserCell = cell as NSBrowserCell;
                    if (browserCell != null)
                    {
                        browserCell.Leaf = true;
                        if (tableColumn.Identifier == Constants.TableColumnIconId)
                        {
                            browserCell.Image = NSImage.ImageNamed(Constants.InfrastructureNodeImage);
                        }
                    }
                }
                else if (cell is NSTextFieldCell)
                {
                    NSTextFieldCell textCell = cell as NSTextFieldCell;

                    // Apply the text color code to the status column text
                    if (textCell != null && tableColumn.Identifier == Constants.PscTableColumnStatusId)
                    {
                        var collection = _controller.PscDataSource.Entries;
                        if (collection != null)
                        {
                            var item = collection [(int)row];

                            // Color Code -> Heartbeat: REMOTE: LightGray | IN-ACTIVE: Red | Heartbeat ACTIVE: GREEN | No Heartbeat: Black
                            textCell.TextColor =
                                item.IsRemote
                                                                ? NSColor.LightGray
                                                                :
                                (!item.Active
                                                                        ? NSColor.Red
                                                                        : NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1)
                                );
                        }
                    }
                }
            });
        }
Exemplo n.º 13
0
 /// <summary>
 /// Converts a <see cref="SplatColor"/> into the cocoa native <see cref="NSColor"/>.
 /// </summary>
 /// <param name="value">The color to convert.</param>
 /// <returns>The <see cref="NSColor"/> generated.</returns>
 public static NSColor ToNative(this SplatColor value)
 {
     return(NSColor.FromSrgb(value.R / 255.0f, value.G / 255.0f, value.B / 255.0f, value.A / 255.0f));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Gets the color of the status text.
 /// </summary>
 /// <returns>The status text color.</returns>
 /// <param name="item">Item.</param>
 private NSColor GetStatusTextColor(ServiceDto item)
 {
     return(!item.Alive ? NSColor.Red : NSColor.FromSrgb((nfloat)3.0 / 255, (nfloat)161 / 255, (nfloat)27 / 255, 1));
 }
Exemplo n.º 15
0
 public static NSColor ConvertColor(System.Drawing.Color c)
 {
     return(NSColor.FromSrgb(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f));
 }