Beispiel #1
0
        public ExpanderWidget()
        {
            label = new NSTextView()
            {
                AutoresizingMask = NSViewResizingMask.MaxYMargin | NSViewResizingMask.WidthSizable,
                Alignment        = NSTextAlignment.Left,
                Editable         = false,
                Selectable       = false,
                DrawsBackground  = false,
                Frame            = new RectangleF(17, 3, 60, 13)
            };
            disclosure = new NSButton()
            {
                BezelStyle       = NSBezelStyle.Disclosure,
                AutoresizingMask = NSViewResizingMask.MaxYMargin,
                ImagePosition    = NSCellImagePosition.ImageOnly,
                Frame            = new RectangleF(5, 4, 13, 13),
                State            = NSCellStateValue.On
            };
            disclosure.SetButtonType(NSButtonType.OnOff);

            disclosure.AddObserver(this, new NSString("cell.state"), NSKeyValueObservingOptions.New, IntPtr.Zero);
            AutoresizesSubviews = true;
            backgroundGradient  = new NSGradient(NSColor.FromCalibratedRgba(0.93f, 0.93f, 0.97f, 1.0f),
                                                 NSColor.FromCalibratedRgba(0.74f, 0.76f, 0.83f, 1.0f));
            strokeColor = NSColor.FromCalibratedRgba(0.60f, 0.60f, 0.60f, 1.0f);

            AddSubview(label);
            AddSubview(disclosure);
        }
        private void Win()
        {
            state = State.Win;
            ShowMines(-1);
            var background = new SKShapeNode();
            var p          = new CGPath();

            p.MoveToPoint(0, 0);
            p.AddLineToPoint(40 * 19, 0);
            p.AddLineToPoint(40 * 19, 40 * 13);
            p.AddLineToPoint(0, 40 * 13);
            p.AddLineToPoint(0, 0);
            background.Path      = p;
            background.FillColor = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.7f);
            AddChild(background);

            var label = new SKLabelNode("Arial");

            label.Text                    = "Win";
            label.FontColor               = NSColor.FromCalibratedRgb(0.0f, 0.502f, 0.0f);
            label.FontSize                = 40;
            label.Position                = new CGPoint(40 * 19 / 2, 40 * 13 / 2);
            label.VerticalAlignmentMode   = SKLabelVerticalAlignmentMode.Center;
            label.HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center;
            AddChild(label);
        }
Beispiel #3
0
        public SparkleAbout() : base()
        {
            SetFrame(new RectangleF(0, 0, 360, 288), true);
            Center();

            StyleMask   = (NSWindowStyle.Closable | NSWindowStyle.Titled);
            Title       = "About SparkleShare";
            MaxSize     = new SizeF(360, 288);
            MinSize     = new SizeF(360, 288);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            CreateAbout();
            MakeKeyAndOrderFront(this);

            SparkleShare.Controller.NewVersionAvailable += delegate(string new_version) {
                InvokeOnMainThread(delegate {
                    UpdatesTextField.StringValue = "A newer version (" + new_version + ") is available!";
                    UpdatesTextField.TextColor   =
                        NSColor.FromCalibratedRgba(0.96f, 0.47f, 0.0f, 1.0f);  // Tango Orange #2
                });
            };

            SparkleShare.Controller.VersionUpToDate += delegate {
                InvokeOnMainThread(delegate {
                    UpdatesTextField.StringValue = "You are running the latest version.";
                    UpdatesTextField.TextColor   =
                        NSColor.FromCalibratedRgba(0.31f, 0.60f, 0.02f, 1.0f);  // Tango Chameleon #3
                });
            };

            SparkleShare.Controller.CheckForNewVersion();
        }
Beispiel #4
0
        public ExpanderWidget()
        {
            disclosure = new NSButton {
                BezelStyle       = NSBezelStyle.Disclosure,
                AutoresizingMask = NSViewResizingMask.MaxYMargin,
                ImagePosition    = NSCellImagePosition.ImageOnly,
                Frame            = new RectangleF(5, 4, 13, 13),
                State            = NSCellStateValue.Off
            };
            disclosure.SetButtonType(NSButtonType.OnOff);
            disclosure.Activated += delegate {
                if (DisclosureToggled != null)
                {
                    DisclosureToggled(this, EventArgs.Empty);
                }
            };

            label = new NSButton {
                Bordered         = false,
                AutoresizingMask = NSViewResizingMask.MaxYMargin | NSViewResizingMask.WidthSizable,
                Alignment        = NSTextAlignment.Left,
                Frame            = new RectangleF(17, 3, 60, 13),
                Target           = disclosure,
                Action           = new Selector("performClick:")
            };
            label.SetButtonType(NSButtonType.MomentaryChange);

            AutoresizesSubviews = true;
            backgroundGradient  = new NSGradient(NSColor.FromCalibratedRgba(0.93f, 0.93f, 0.97f, 1.0f),
                                                 NSColor.FromCalibratedRgba(0.74f, 0.76f, 0.83f, 1.0f));
            strokeColor = NSColor.FromCalibratedRgba(0.60f, 0.60f, 0.60f, 1.0f);

            AddSubview(label);
            AddSubview(disclosure);
        }
Beispiel #5
0
        private void DrawFlag()
        {
            var s1 = new SKShapeNode();
            var p1 = new CGPath();

            p1.MoveToPoint(size / 3.0f, size / 2.0f);
            p1.AddLineToPoint(size / 3.0f * 2, size / 3.0f);
            p1.AddLineToPoint(size / 3.0f * 2, size / 3.0f * 2);
            s1.Path        = p1.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size));
            s1.StrokeColor = NSColor.Red;
            s1.FillColor   = NSColor.Red;
            AddChild(s1);

            var s2 = new SKShapeNode();
            var p2 = new CGPath();

            p2.MoveToPoint(size / 3.0f * 2, size - size / 3.0f);
            p2.AddLineToPoint(size / 3.0f * 2, size / 4.0f);
            p2.AddLineToPoint(size / 2.0f, size / 4.0f);
            p2.AddLineToPoint(size - size / 5.0f, size / 4.0f);
            s2.Path        = p2.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size));
            s2.StrokeColor = NSColor.Black;
            s2.FillColor   = NSColor.FromCalibratedRgba(0.0f, 0.0f, 0.0f, 0.0f);
            s2.LineWidth   = size / 20;
            AddChild(s2);
        }
Beispiel #6
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.FromCalibratedRgba(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.FromCalibratedRgba(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.FromCalibratedRgba(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));
            }
        }
        void IView.Update(ViewItem[] items)
        {
            lastItems = items;
            var allCtrls = new []
            {
                new { v = view1, l = link1, p = progress1, b = suppressBtn1 },
                new { v = view2, l = link2, p = progress2, b = suppressBtn2 },
                new { v = view3, l = link3, p = progress3, b = suppressBtn3 },
                new { v = view4, l = link4, p = progress4, b = suppressBtn4 },
            };

            foreach (var i in allCtrls.ZipWithIndex())
            {
                var data  = i.Key < items.Length ? items[i.Key] : null;
                var ctrls = i.Value;
                ctrls.v.Hidden = data == null;
                if (data != null)
                {
                    ctrls.v.BackgroundColor = NSColor.FromCalibratedRgba(0.941f, 0.678f, 0.305f, 1f);
                    ctrls.l.SetAttributedContents(data.Contents);
                    ctrls.p.Hidden      = data.Progress == null;
                    ctrls.p.DoubleValue = data.Progress.GetValueOrDefault(0d) * 100d;
                    ctrls.b.Hidden      = !data.IsSuppressable;
                    ctrls.l.LinkClicked = (s, e) =>
                    {
                        if (!string.IsNullOrEmpty(e.Link.Tag as string))
                        {
                            viewEvents.OnItemActionClicked(data, (string)e.Link.Tag);
                        }
                    };
                    ctrls.b.Tag = i.Key;
                }
            }
        }
 public override void AwakeFromNib()
 {
     manager = new LibraryDatabaseManager();
     //source = new LibraryListViewDataSource (manager.Books);
     //Console.WriteLine (manager.Books.Count);
     tableView.DataSource      = source;
     tableView.BackgroundColor = NSColor.FromCalibratedRgba(0.0f, 0.0f, 0.0f, 0.0f);
 }
Beispiel #9
0
 public static NSColor ToNSColor(this Color color)
 {
     return(NSColor.FromCalibratedRgba(
                (float)color.R / 255.0f,
                (float)color.G / 255.0f,
                (float)color.B / 255.0f,
                (float)color.A / 255.0f
                ));
 }
Beispiel #10
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            SCNTransaction.Begin();
            SCNTransaction.AnimationDuration = 0;

            switch (index)
            {
            case 0:
                // Set the slide's title and subtile and add some text
                TextManager.SetTitle("Node Attributes");
                TextManager.SetSubtitle("Lights");

                TextManager.AddBulletAtLevel("SCNLight", 0);
                TextManager.AddBulletAtLevel("Four light types", 0);
                TextManager.AddBulletAtLevel("Omni", 1);
                TextManager.AddBulletAtLevel("Directional", 1);
                TextManager.AddBulletAtLevel("Spot", 1);
                TextManager.AddBulletAtLevel("Ambient", 1);
                break;

            case 1:
                // Add some code
                var codeExampleNode = TextManager.AddCode("#aNode.#Light# = SCNLight.Create (); \naNode.Light.LightType = SCNLightType.Omni;#");
                codeExampleNode.Position = new SCNVector3(14, 11, 1);

                // Add a light to the scene
                LightNode                 = SCNNode.Create();
                LightNode.Light           = SCNLight.Create();
                LightNode.Light.LightType = SCNLightType.Omni;
                LightNode.Light.Color     = NSColor.Black;             // initially off
                LightNode.Light.SetAttribute(new NSNumber(30), SCNLightAttribute.AttenuationStartKey);
                LightNode.Light.SetAttribute(new NSNumber(40), SCNLightAttribute.AttenuationEndKey);
                LightNode.Position = new SCNVector3(5, 3.5f, 0);
                ContentNode.AddChildNode(LightNode);

                // Load two images to help visualize the light (on and off)
                LightOffImageNode        = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/light-off", "tiff"), 7, false);
                LightOnImageNode         = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/light-on", "tiff"), 7, false);
                LightOnImageNode.Opacity = 0;

                LightNode.AddChildNode(LightOnImageNode);
                LightNode.AddChildNode(LightOffImageNode);
                break;

            case 2:
                // Switch the light on
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                LightNode.Light.Color            = NSColor.FromCalibratedRgba(1, 1, 0.8f, 1);
                LightOnImageNode.Opacity         = 1.0f;
                LightOffImageNode.Opacity        = 0.0f;
                SCNTransaction.Commit();
                break;
            }
            SCNTransaction.Commit();
        }
Beispiel #11
0
 public static NSColor ToNSUI(this Color color, bool calibrated)
 {
     if (color.ControlObject is NSColor nscolor)
     {
         return(nscolor);
     }
     if (color.ControlObject is CGColor cgcolor && MacVersion.IsAtLeast(10, 8))
     {
         return(NSColor.FromCGColor(cgcolor));
     }
     return(calibrated
                         ? NSColor.FromCalibratedRgba(color.R, color.G, color.B, color.A)
                         : NSColor.FromDeviceRgba(color.R, color.G, color.B, color.A));
 }
Beispiel #12
0
        private void DrawCross()
        {
            var s3 = new SKShapeNode();
            var p3 = new CGPath();

            p3.MoveToPoint(size / 5.0f, size / 5.0f);
            p3.AddLineToPoint(size - size / 5.0f, size - size / 5.0f);
            p3.MoveToPoint(size / 5.0f, size - size / 5.0f);
            p3.AddLineToPoint(size - size / 5.0f, size / 5.0f);
            s3.Path        = p3.CopyByTransformingPath(CGAffineTransform.MakeTranslation(x * size, y * size));
            s3.StrokeColor = NSColor.Black;
            s3.FillColor   = NSColor.FromCalibratedRgba(0.0f, 0.0f, 0.0f, 0.0f);
            s3.LineWidth   = size / 20;
            AddChild(s3);
        }
Beispiel #13
0
        private void CreateAbout()
        {
            using (var a = new NSAutoreleasePool()) {
                string about_image_path = UIHelpers.GetImagePathname("about");

                this.about_image = new NSImage(about_image_path)
                {
                    Size = new SizeF(640, 260)
                };

                this.about_image_view = new NSImageView()
                {
                    Image = this.about_image,
                    Frame = new RectangleF(0, 0, 640, 260)
                };

                this.version_text_field = new NSTextField()
                {
                    StringValue     = string.Format(Properties_Resources.Version, Controller.RunningVersion, Controller.CreateTime.GetValueOrDefault().ToString("d")),
                    Frame           = new RectangleF(295, 140, 318, 22),
                    BackgroundColor = NSColor.White,
                    Bordered        = false,
                    Editable        = false,
                    DrawsBackground = false,
                    TextColor       = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f),
                    Font            = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
                };

                this.credits_text_field = new NSTextField()
                {
                    StringValue = @"Copyright © 2013-" + DateTime.Now.Year + " GRAU DATA AG, Hylke Bons and others." +
                                  "\n" +
                                  "\n" +
                                  "DataSpace Sync is Open Source software. You are free to use, modify, and redistribute it " +
                                  "under the GNU General Public License version 3 or later.",
                    Frame           = new RectangleF(295, Frame.Height - 260, 318, 98),
                    TextColor       = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f),
                    DrawsBackground = false,
                    Bordered        = false,
                    Editable        = false,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                };

                ContentView.AddSubview(this.about_image_view);
                ContentView.AddSubview(this.version_text_field);
                ContentView.AddSubview(this.credits_text_field);
            }
        }
Beispiel #14
0
        public static NSColor ConvertToNSColor(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return(NSColor.Clear);
            }

            if (data != "none")
            {
                if (data == "black")
                {
                    return(NSColor.Black);
                }
                if (data == "white")
                {
                    return(NSColor.White);
                }
            }

            try
            {
                data = data.TrimStart('#');

                if (data.Length == 6)
                {
                    return(NSColor.FromCalibratedRgb(
                               int.Parse(data.Substring(0, 2), NumberStyles.HexNumber),
                               int.Parse(data.Substring(2, 2), NumberStyles.HexNumber),
                               int.Parse(data.Substring(4, 2), NumberStyles.HexNumber)));
                }
                else // assuming length of 8
                {
                    return(NSColor.FromCalibratedRgba(
                               int.Parse(data.Substring(2, 2), NumberStyles.HexNumber),
                               int.Parse(data.Substring(4, 2), NumberStyles.HexNumber),
                               int.Parse(data.Substring(6, 2), NumberStyles.HexNumber),
                               int.Parse(data.Substring(0, 2), NumberStyles.HexNumber)));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(NSColor.Clear);
        }
 void SetNoContentMessageVisibility(bool value)
 {
     if (string.IsNullOrEmpty(noContentLink.StringValue))
     {
         noContentLink.StringValue = " Nothing visible.\n Search <<left. Search right>> ";
         noContentLink.Links       = new [] {
             new NSLinkLabel.Link(26, 6, "l"),
             new NSLinkLabel.Link(41, 7, "r")
         };
         noContentLink.TextColor       = NSColor.Black;
         noContentLink.BackgroundColor = NSColor.FromCalibratedRgba(0.941f, 0.678f, 0.305f, 1f);
         noContentLink.LinkClicked     = (sender, e) => {
             model.OnNoContentLinkClicked(searchLeft: e.Link.Tag as string == "l");
             e.SuppressDefault = true;
         };
     }
     noContentLink.Hidden = !value;
 }
Beispiel #16
0
            public SparkleLink(string text, string address) : base()
            {
                StringValue = text;
                this.url    = new NSUrl(address);

                Font = NSFont.SystemFontOfSize(11);

                TextColor       = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.5f);
                BackgroundColor = NSColor.White;

                AllowsEditingTextAttributes = true;
                Bordered        = false;
                DrawsBackground = false;
                Editable        = false;
                Selectable      = false;

                SizeToFit();
            }
Beispiel #17
0
        public static NSColor ColorWithHexColorValue(string hexColorValue, nfloat alpha)
        {
            string value = hexColorValue.Replace("#", "0x");

            if (value.Length == 8)
            {
                string red   = value.Substring(2, 2);
                string green = value.Substring(4, 2);
                string blue  = value.Substring(6, 2);

                return(NSColor.FromCalibratedRgba(Convert.ToInt16(red, 16) / 255.0f,
                                                  Convert.ToInt16(green, 16) / 255.0f,
                                                  Convert.ToInt16(blue, 16) / 255.0f,
                                                  alpha));
            }

            return(NSColor.Clear);
        }
Beispiel #18
0
        private CALayer MakeCompositionLayer()
        {
            QCCompositionRepository repo = QCCompositionRepository.SharedCompositionRepository;

            QCComposition      composition = repo.GetComposition("/moving shapes");
            QCCompositionLayer compLayer   = QCCompositionLayer.Create(composition);
            //CGColor cgColor = new CGColor(0.25f, 0.675f, 0.1f, 1.0f);
            NSColor nsColor = NSColor.FromCalibratedRgba(0.25f, 0.675f, 0.1f, 1.0f);

            string path = String.Format("patch.{0}.value", QCComposition.InputPrimaryColorKey);

            compLayer.SetValueForKeyPath(nsColor, (NSString)path);

            path = String.Format("patch.{0}.value", QCComposition.InputPaceKey);
            compLayer.SetValueForKeyPath(NSNumber.FromFloat(5.0f), (NSString)path);

            return(compLayer);
        }
        private NSAttributedString GetAttributedString(string text)
        {
            var paragraph = new NSMutableParagraphStyle();

            paragraph.Alignment     = NSTextAlignment.Center;
            paragraph.LineBreakMode = NSLineBreakMode.ByWordWrapping;


            var attrString = new NSAttributedString
                             (
                text,
                font: NSFont.FromFontName("Arial", 72.0f),
                foregroundColor: NSColor.White,
                backgroundColor: NSColor.FromCalibratedRgba(0, 0, 0, 0.0f),
                paragraphStyle: paragraph
                             );

            return(attrString);
        }
Beispiel #20
0
        public SparkleAbout() : base()
        {
            SetFrame(new RectangleF(0, 0, 640, 281), true);
            Center();

            Delegate    = new SparkleAboutDelegate();
            StyleMask   = (NSWindowStyle.Closable | NSWindowStyle.Titled);
            Title       = "About SparkleShare";
            MaxSize     = new SizeF(640, 281);
            MinSize     = new SizeF(640, 281);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            CreateAbout();
            OrderFrontRegardless();
            MakeKeyAndOrderFront(this);

            Program.UI.UpdateDockIconVisibility();

            Controller.NewVersionEvent += delegate(string new_version) {
                InvokeOnMainThread(delegate {
                    UpdatesTextField.StringValue = "A newer version (" + new_version + ") is available!";
                    UpdatesTextField.TextColor   =
                        NSColor.FromCalibratedRgba(0.96f, 0.47f, 0.0f, 1.0f);  // Tango Orange #2
                });
            };

            Controller.VersionUpToDateEvent += delegate {
                InvokeOnMainThread(delegate {
                    UpdatesTextField.StringValue = "You are running the latest version.";
                    UpdatesTextField.TextColor   =
                        NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);  // Tango Sky Blue #1
                });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                InvokeOnMainThread(delegate {
                    UpdatesTextField.StringValue = "Checking for updates...";
                    UpdatesTextField.TextColor   =
                        NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);  // Tango Sky Blue #1
                });
            };
        }
Beispiel #21
0
        //NSColor gg ()
        //{
        //    NSString* hexString = [NSString stringWithFormat: @"%02X%02X%02X",
        //    (int)(color.redComponent * 0xFF), (int)(color.greenComponent * 0xFF),
        //    (int)(color.blueComponent * 0xFF)];
        //}

        static NSColor FromString(string colorcode)
        {
            colorcode = colorcode.TrimStart('#');

            NSColor col; // from System.Drawing or System.Windows.Media

            if (colorcode.Length == 6)
            {
                col = NSColor.FromCalibratedRgba( // hardcoded opaque
                    int.Parse(colorcode.Substring(0, 2), NumberStyles.HexNumber),
                    int.Parse(colorcode.Substring(2, 2), NumberStyles.HexNumber),
                    int.Parse(colorcode.Substring(4, 2), NumberStyles.HexNumber), 255);
            }
            else // assuming length of 8
            {
                col = NSColor.FromCalibratedRgba(
                    int.Parse(colorcode.Substring(2, 2), NumberStyles.HexNumber),
                    int.Parse(colorcode.Substring(4, 2), NumberStyles.HexNumber),
                    int.Parse(colorcode.Substring(6, 2), NumberStyles.HexNumber),
                    int.Parse(colorcode.Substring(0, 2), NumberStyles.HexNumber));
            }
            return(col);
        }
Beispiel #22
0
        public About() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                SetFrame(new RectangleF(0, 0, 640, 281), true);
                Center();

                Delegate    = new AboutDelegate();
                StyleMask   = (NSWindowStyle.Closable | NSWindowStyle.Titled);
                Title       = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName);
                MaxSize     = new SizeF(640, 281);
                MinSize     = new SizeF(640, 281);
                HasShadow   = true;
                BackingType = NSBackingStore.Buffered;

                this.website_link       = new CmisSyncLink(Properties_Resources.Website, Controller.WebsiteLinkAddress);
                this.website_link.Frame = new RectangleF(new PointF(295, 25), this.website_link.Frame.Size);

                this.credits_link       = new CmisSyncLink(Properties_Resources.Credits, Controller.CreditsLinkAddress);
                this.credits_link.Frame = new RectangleF(
                    new PointF(this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
                    this.credits_link.Frame.Size);

                this.report_problem_link       = new CmisSyncLink(Properties_Resources.ReportProblem, Controller.ReportProblemLinkAddress);
                this.report_problem_link.Frame = new RectangleF(
                    new PointF(this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
                    this.report_problem_link.Frame.Size);

                this.hidden_close_button = new NSButton()
                {
                    Frame = new RectangleF(0, 0, 0, 0),
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent             = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed();
                };


                ContentView.AddSubview(this.hidden_close_button);

                CreateAbout();

                ContentView.AddSubview(this.website_link);
                ContentView.AddSubview(this.credits_link);
                ContentView.AddSubview(this.report_problem_link);
            }

            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        PerformClose(this);
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        OrderFrontRegardless();
                    });
                }
            };

            Controller.NewVersionEvent += delegate(string new_version) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.updates_text_field.StringValue = "A newer version (" + new_version + ") is available!";
                        this.updates_text_field.TextColor   = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);
                    });
                }
            };

            Controller.VersionUpToDateEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.updates_text_field.StringValue = "You are running the latest version.";
                        this.updates_text_field.TextColor   = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);
                    });
                }
            };

            Controller.CheckingForNewVersionEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.updates_text_field.StringValue = "Checking for updates...";
                        this.updates_text_field.TextColor   = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);
                    });
                }
            };
        }
        private void CreateAbout()
        {
            string about_image_path = Path.Combine(NSBundle.MainBundle.ResourcePath, "Pixmaps", "about.png");

            this.about_image = new NSImage(about_image_path)
            {
                Size = new SizeF(640, 260)
            };

            this.about_image_view = new NSImageView()
            {
                Image = this.about_image,
                Frame = new RectangleF(0, 0, 640, 260)
            };

            this.version_text_field = new SparkleLabel("version " + Controller.RunningVersion, NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, 140, 318, 22),
                TextColor       = NSColor.White,
                Font            = NSFontManager.SharedFontManager.FontWithFamily(
                    "Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
            };

            this.updates_text_field = new SparkleLabel("Checking for updates...", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, Frame.Height - 232, 318, 98),
                TextColor       = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.5f),
                Font            = NSFontManager.SharedFontManager.FontWithFamily(
                    "Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
            };

            this.credits_text_field = new SparkleLabel(
                @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others." +
                "\n" +
                "\n" +
                "SparkleShare is Open Source software. You are free to use, modify, and redistribute it " +
                "under the GNU General Public License version 3 or later.", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, Frame.Height - 260, 318, 98),
                TextColor       = NSColor.White,
                Font            = NSFontManager.SharedFontManager.FontWithFamily(
                    "Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
            };

            this.website_link       = new SparkleLink("Website", Controller.WebsiteLinkAddress);
            this.website_link.Frame = new RectangleF(new PointF(295, 25), this.website_link.Frame.Size);

            this.credits_link       = new SparkleLink("Credits", Controller.CreditsLinkAddress);
            this.credits_link.Frame = new RectangleF(
                new PointF(this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
                this.credits_link.Frame.Size);

            this.report_problem_link       = new SparkleLink("Report a problem", Controller.ReportProblemLinkAddress);
            this.report_problem_link.Frame = new RectangleF(
                new PointF(this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
                this.report_problem_link.Frame.Size);

            this.debug_log_link       = new SparkleLink("Debug log", Controller.DebugLogLinkAddress);
            this.debug_log_link.Frame = new RectangleF(
                new PointF(this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25),
                this.debug_log_link.Frame.Size);

            ContentView.AddSubview(this.about_image_view);
            ContentView.AddSubview(this.version_text_field);
            ContentView.AddSubview(this.updates_text_field);
            ContentView.AddSubview(this.credits_text_field);
            ContentView.AddSubview(this.website_link);
            ContentView.AddSubview(this.credits_link);
            ContentView.AddSubview(this.report_problem_link);
            ContentView.AddSubview(this.debug_log_link);
        }
Beispiel #24
0
        private void CreateAbout()
        {
            using (var a = new NSAutoreleasePool())
            {
                string about_image_path = Path.Combine(NSBundle.MainBundle.ResourcePath,
                                                       "Pixmaps", "about.png");

                this.about_image = new NSImage(about_image_path)
                {
                    Size = new SizeF(640, 260)
                };

                this.about_image_view = new NSImageView()
                {
                    Image = this.about_image,
                    Frame = new RectangleF(0, 0, 640, 260)
                };


                this.version_text_field = new NSTextField()
                {
                    StringValue     = "version " + Controller.RunningVersion,
                    Frame           = new RectangleF(295, 140, 318, 22),
                    BackgroundColor = NSColor.White,
                    Bordered        = false,
                    Editable        = false,
                    DrawsBackground = false,
                    TextColor       = NSColor.White,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily
                                          ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11)
                };

                this.updates_text_field = new NSTextField()
                {
                    StringValue     = "Checking for updates...",
                    Frame           = new RectangleF(295, Frame.Height - 232, 318, 98),
                    Bordered        = false,
                    Editable        = false,
                    DrawsBackground = false,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily
                                          ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                    TextColor = NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f)        // Tango Sky Blue #1
                };

                this.credits_text_field = new NSTextField()
                {
                    StringValue = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others." +
                                  "\n" +
                                  "\n" +
                                  "SparkleShare is Open Source software. You are free to use, modify, and redistribute it " +
                                  "under the GNU General Public License version 3 or later.",
                    Frame           = new RectangleF(295, Frame.Height - 260, 318, 98),
                    TextColor       = NSColor.White,
                    DrawsBackground = false,
                    Bordered        = false,
                    Editable        = false,
                    Font            = NSFontManager.SharedFontManager.FontWithFamily(
                        "Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                };

                ContentView.AddSubview(this.about_image_view);
                ContentView.AddSubview(this.version_text_field);
                ContentView.AddSubview(this.updates_text_field);
                ContentView.AddSubview(this.credits_text_field);
            }
        }
Beispiel #25
0
        private void CreateAbout()
        {
            this.about_image      = NSImage.ImageNamed("about");
            this.about_image.Size = new SizeF(720, 260);

            this.about_image_view = new NSImageView()
            {
                Image = this.about_image,
                Frame = new RectangleF(0, 0, 720, 260)
            };

            this.version_text_field = new SparkleLabel("version " + Controller.RunningVersion, NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, 140, 318, 22),
                TextColor       = NSColor.White
            };

            this.updates_text_field = new SparkleLabel("Checking for updates...", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, Frame.Height - 232, 318, 98),
                TextColor       = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.5f)
            };

            this.credits_text_field = new SparkleLabel(
                @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others" +
                "\n\n" +
                "SparkleShare is Open Source. You are free to use, modify, and redistribute it " +
                "under the GNU GPLv3", NSTextAlignment.Left)
            {
                DrawsBackground = false,
                Frame           = new RectangleF(295, Frame.Height - 260, 318, 98),
                TextColor       = NSColor.White
            };

            this.website_link       = new SparkleLink("Website", Controller.WebsiteLinkAddress);
            this.website_link.Frame = new RectangleF(new PointF(295, 25), this.website_link.Frame.Size);

            this.credits_link       = new SparkleLink("Credits", Controller.CreditsLinkAddress);
            this.credits_link.Frame = new RectangleF(
                new PointF(this.website_link.Frame.X + this.website_link.Frame.Width + 10, 25),
                this.credits_link.Frame.Size);

            this.report_problem_link       = new SparkleLink("Report a problem", Controller.ReportProblemLinkAddress);
            this.report_problem_link.Frame = new RectangleF(
                new PointF(this.credits_link.Frame.X + this.credits_link.Frame.Width + 10, 25),
                this.report_problem_link.Frame.Size);

            this.debug_log_link       = new SparkleLink("Debug log", Controller.DebugLogLinkAddress);
            this.debug_log_link.Frame = new RectangleF(
                new PointF(this.report_problem_link.Frame.X + this.report_problem_link.Frame.Width + 10, 25),
                this.debug_log_link.Frame.Size);

            ContentView.AddSubview(this.about_image_view);
            ContentView.AddSubview(this.version_text_field);
            ContentView.AddSubview(this.updates_text_field);
            ContentView.AddSubview(this.credits_text_field);
            ContentView.AddSubview(this.website_link);
            ContentView.AddSubview(this.credits_link);
            ContentView.AddSubview(this.report_problem_link);
            ContentView.AddSubview(this.debug_log_link);
        }
Beispiel #26
0
        private void CreateNote()
        {
            this.cover = new NSBox()
            {
                Frame = new RectangleF(
                    new PointF(-1, 58),
                    new SizeF(Frame.Width + 2, this.ContentView.Frame.Height + 1)),
                FillColor   = NSColor.FromCalibratedRgba(0.77f, 0.77f, 0.75f, 1.0f),
                BorderColor = NSColor.LightGray,
                BoxType     = NSBoxType.NSBoxCustom
            };


            this.user_name_text_field = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.FromCalibratedRgba(0.77f, 0.77f, 0.75f, 1.0f),
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(85, ContentView.Frame.Height - 41),
                    new SizeF(320, 22)),
                StringValue = Program.Controller.CurrentUser.Name,
                Font        = NSFont.FromFontName(SparkleUI.FontName + " Bold", NSFont.SystemFontSize)
            };

            this.user_email_text_field = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.FromCalibratedRgba(0.77f, 0.77f, 0.75f, 1.0f),
                TextColor       = NSColor.DisabledControlText,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(85, ContentView.Frame.Height - 60),
                    new SizeF(320, 20)),
                StringValue = Program.Controller.CurrentUser.Email,
            };


            this.balloon_text_field = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = true,
                Frame           = new RectangleF(
                    new PointF(30, ContentView.Frame.Height - 137),
                    new SizeF(418, 48))
            };

            (this.balloon_text_field.Cell as NSTextFieldCell).PlaceholderString  = "Anything to add?";
            (this.balloon_text_field.Cell as NSTextFieldCell).LineBreakMode      = NSLineBreakMode.ByWordWrapping;
            (this.balloon_text_field.Cell as NSTextFieldCell).UsesSingleLineMode = false;

            this.balloon_text_field.Cell.FocusRingType = NSFocusRingType.None;


            this.cancel_button = new NSButton()
            {
                Title      = "Cancel",
                BezelStyle = NSBezelStyle.Rounded,
                Frame      = new RectangleF(Frame.Width - 15 - 105 * 2, 12, 105, 32),
            };

            this.sync_button = new NSButton()
            {
                Title      = "Sync",
                BezelStyle = NSBezelStyle.Rounded,
                Frame      = new RectangleF(Frame.Width - 15 - 105, 12, 105, 32),
            };

            this.cancel_button.Activated += delegate { Controller.CancelClicked(); };
            this.sync_button.Activated   += delegate { Controller.SyncClicked(this.balloon_text_field.StringValue); };

            DefaultButtonCell = this.sync_button.Cell;


            if (BackingScaleFactor >= 2)
            {
                this.balloon_image = NSImage.ImageNamed("text-balloon@2x");
            }
            else
            {
                this.balloon_image = NSImage.ImageNamed("text-balloon");
            }

            this.balloon_image.Size = new SizeF(438, 72);
            this.balloon_image_view = new NSImageView()
            {
                Image = this.balloon_image,
                Frame = new RectangleF(21, ContentView.Frame.Height - 145, 438, 72)
            };


            if (!string.IsNullOrEmpty(Controller.AvatarFilePath))
            {
                this.user_image = new NSImage(Controller.AvatarFilePath);
            }
            else
            {
                this.user_image = NSImage.ImageNamed("user-icon-default");
            }

            this.user_image.Size = new SizeF(48, 48);
            this.user_image_view = new NSImageView()
            {
                Image = this.user_image,
                Frame = new RectangleF(21, ContentView.Frame.Height - 65, 48, 48)
            };

            this.user_image_view.WantsLayer          = true;
            this.user_image_view.Layer.CornerRadius  = 5.0f;
            this.user_image_view.Layer.MasksToBounds = true;


            ContentView.AddSubview(this.cover);
            ContentView.AddSubview(this.cancel_button);
            ContentView.AddSubview(this.sync_button);
            ContentView.AddSubview(this.user_name_text_field);
            ContentView.AddSubview(this.user_email_text_field);

            ContentView.AddSubview(this.user_image_view);
            ContentView.AddSubview(this.balloon_image_view);
            ContentView.AddSubview(this.balloon_text_field);

            MakeFirstResponder((NSResponder)this.balloon_text_field);
        }
        private void SetupView()
        {
            var screenRes    = screenResolution();
            int PANEL_HEIGHT = 200;

            subtitlesPanel = new NSPanelExt
                             (
                new CoreGraphics.CGRect(40, 50, screenRes.Width - 80, PANEL_HEIGHT),
                NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Miniaturizable | NSWindowStyle.DocModal,
                NSBackingStore.Buffered, true
                             )
            {
                BackgroundColor    = NSColor.FromCalibratedRgba(0, 0, 0, 0.2f),
                ReleasedWhenClosed = true,
                HidesOnDeactivate  = false,
                FloatingPanel      = true,
                StyleMask          = NSWindowStyle.NonactivatingPanel,
                Level              = NSWindowLevel.MainMenu - 1,
                IsMovable          = true,
                CollectionBehavior = NSWindowCollectionBehavior.CanJoinAllSpaces |
                                     NSWindowCollectionBehavior.FullScreenAuxiliary
            };

            subtitlesPanel.OrderFront(null);
            subtitlesPanel.KeyPressed += SubtitlesPanel_KeyPressed;

            subtitleTextButton = new NSButton(new CoreGraphics.CGRect(40, 0, screenRes.Width - 120, PANEL_HEIGHT - 30))
            {
                Title      = "",
                WantsLayer = true
            };

            subtitleTextButton.Layer.BackgroundColor = NSColor.Clear.CGColor;

            subtitleTextField = new NSTextField(new CoreGraphics.CGRect(40, 0, screenRes.Width - 120, PANEL_HEIGHT - 30))
            {
                Alignment = NSTextAlignment.Center
            };
            subtitleTextField.Cell.Alignment = NSTextAlignment.Center;

            forwardButton            = new NSButton(new CoreGraphics.CGRect(0, 0, 40, 30));
            forwardButton.Title      = ">>";
            forwardButton.Activated += (object sender, EventArgs e) => {
                subtitlesProvider.Forward();
                _timer.Start();
            };

            backButton            = new NSButton(new CoreGraphics.CGRect(0, 30, 40, 30));
            backButton.Title      = "<<";
            backButton.Activated += (object sender, EventArgs e) => {
                subtitlesProvider.Back();
                _timer.Start();
            };

            startStopButton            = new NSButton(new CoreGraphics.CGRect(0, 60, 40, 30));
            startStopButton.Title      = "Play";
            startStopButton.Activated += (object sender, EventArgs e) => {
                subtitlesProvider.StartStop(subtitlesProvider.Playing);
                _timer.Start();
            };

            subtitlesPanel.ContentView.AddSubview(subtitleTextButton, NSWindowOrderingMode.Below, null);
            subtitlesPanel.ContentView.AddSubview(subtitleTextField, NSWindowOrderingMode.Below, null);

            subtitlesPanel.ContentView.AddSubview(forwardButton, NSWindowOrderingMode.Below, null);
            subtitlesPanel.ContentView.AddSubview(backButton, NSWindowOrderingMode.Below, null);
            subtitlesPanel.ContentView.AddSubview(startStopButton, NSWindowOrderingMode.Below, null);

            SetupSubtitlesProvider();
            IntializeKeepWindowFocusedTimer();
        }
 static NSColor MakeColor(byte r, byte g, byte b)
 {
     return(NSColor.FromCalibratedRgba(r / 255f, g / 255f, b / 255f, 1));
 }
Beispiel #29
0
        public SparkleAbout() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                SetFrame(new RectangleF(0, 0, 640, 281), true);
                Center();

                Delegate    = new SparkleAboutDelegate();
                StyleMask   = (NSWindowStyle.Closable | NSWindowStyle.Titled);
                Title       = "About SparkleShare";
                MaxSize     = new SizeF(640, 281);
                MinSize     = new SizeF(640, 281);
                HasShadow   = true;
                BackingType = NSBackingStore.Buffered;

                this.hidden_close_button = new NSButton()
                {
                    Frame = new RectangleF(0, 0, 0, 0),
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent             = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed();
                };

                ContentView.AddSubview(this.hidden_close_button);

                CreateAbout();
            }

            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        PerformClose(this);
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        OrderFrontRegardless();
                    });
                }
            };

            Controller.NewVersionEvent += delegate(string new_version) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.updates_text_field.StringValue = "A newer version (" + new_version + ") is available!";
                        this.updates_text_field.TextColor   =
                            NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);
                    });
                }
            };

            Controller.VersionUpToDateEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.updates_text_field.StringValue = "You are running the latest version.";
                        this.updates_text_field.TextColor   =
                            NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);
                    });
                }
            };

            Controller.CheckingForNewVersionEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.updates_text_field.StringValue = "Checking for updates...";
                        this.updates_text_field.TextColor   =
                            NSColor.FromCalibratedRgba(0.45f, 0.62f, 0.81f, 1.0f);  // Tango Sky Blue #1
                    });
                }
            };
        }
Beispiel #30
0
 internal static NSColor GetColorFromRgb(int r, int g, int b)
 {
     return(NSColor.FromCalibratedRgba(
                r / 255.0f, g / 255.0f, b / 255.0f, 1.0f));
 }