Example #1
0
        /// <summary>
        /// Search for HTML tags, remove them and apply a bold font
        /// to the text range marked by the tags.
        ///
        /// It is presumed that:
        ///     - Every start tag has a matching end tag
        ///     - Tag ranges do not overlap
        /// </summary>
        /// <param name="attrText"> The attributed string to be searched from</param>
        /// <param name="index">The index to start searching</param>
        /// <returns>The new starting index, -1 when no tags are found.</returns>
        private static int NextAttributedPart(ref NSMutableAttributedString attrText, int index)
        {
            // Search for an html tag.
            string text       = attrText.Value;
            int    startIndex = text.IndexOf("<", index);

            if (startIndex >= 0)
            {
                int startIndex1 = startIndex;
                int endIndex1   = text.IndexOf(">", startIndex);
                attrText.DeleteRange(new NSRange(startIndex1, endIndex1 - startIndex + 1));
                text = attrText.Value;

                // Find the closing tag.
                int startIndex2 = text.IndexOf("<", startIndex);
                if (text.Substring(startIndex2 + 1, 1) == "/")
                {
                    int endIndex2 = text.IndexOf(">", startIndex2);
                    attrText.DeleteRange(new NSRange(startIndex2, endIndex2 - startIndex2 + 1));
                    var range = new NSRange(startIndex1, startIndex2 - startIndex1);
                    attrText.BeginEditing();
                    attrText.AddAttribute(CTStringAttributeKey.Font, NSFont.BoldSystemFontOfSize(13), range);
                    startIndex = startIndex2;
                }
            }
            return(startIndex);
        }
        void CreateTitleLabels()
        {
            nfloat labelWidth = _sheetFrame.Width - 2 * _xMargin;

            // Create the window title label.
            _yCurr -= _labelHeight;
            var titleLabelRect = new CGRect(_xMargin, _yCurr, labelWidth, _labelHeight);
            var titleLabel     = ControlsFactory.NewStandardLabel(titleLabelRect);

            titleLabel.Font        = NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);
            titleLabel.StringValue = "Uncombine film";
            View.AddSubview(titleLabel);

            // Create the instruction label.
            _yCurr -= _labelHeight + _yLabelsDistance;
            var instructionLabelRect = new CGRect(_xMargin, _yCurr, labelWidth, _labelHeight);
            var instructionLabel     = ControlsFactory.NewStandardLabel(instructionLabelRect);

            instructionLabel.Font        = NSFont.LabelFontOfSize(NSFont.LabelFontSize);
            instructionLabel.StringValue = "Create multiple films, one per distinct screening title";
            View.AddSubview(instructionLabel);

            // Set sample view used to disable resizing.
            _sampleView = titleLabel;
        }
Example #3
0
        public NativeCanvas(Func <CGColorSpace> getColorspace) : base(CreateNewState, CreateStateCopy)
        {
            _getColorspace = getColorspace;

            if (_systemFontName == null)
            {
#if MONOMAC || __MACOS__
                var systemFont = NSFont.SystemFontOfSize(12f);
                _systemFontName = systemFont.FontName;
                systemFont.Dispose();

                var boldSystemFont = NSFont.BoldSystemFontOfSize(12f);
                _boldSystemFontName = boldSystemFont.FontName;
                boldSystemFont.Dispose();
#else
                var systemFont = UIFont.SystemFontOfSize(12f);
                _systemFontName = systemFont.Name;
                systemFont.Dispose();

                var boldSystemFont = UIFont.BoldSystemFontOfSize(12f);
                _boldSystemFontName = boldSystemFont.Name;
                boldSystemFont.Dispose();
#endif
            }

            _defaultFontName = "Helvetica";
            _fontName        = _defaultFontName;
        }
Example #4
0
        private static NSFont _ToUIFont(string family, float size, FontAttributes attributes)
        {
            bool isBold   = (uint)(attributes & FontAttributes.Bold) > 0U;
            bool isItalic = (uint)(attributes & FontAttributes.Italic) > 0U;

            if (family != null)
            {
                try
                {
                    var uiFont1 = NSFont.FromFontName(family, (nfloat)size);
                    if (uiFont1 != null)
                    {
                        return(uiFont1);
                    }
                }
                catch
                {
                }
            }
            if (isBold & isItalic)
            {
                var uiFont = NSFont.SystemFontOfSize((nfloat)size);
                return(NSFont.BoldSystemFontOfSize((nfloat)size));
            }
            if (isBold)
            {
                return(NSFont.BoldSystemFontOfSize((nfloat)size));
            }

            //if (isItalic)
            //	return NSFont.ItalicSystemFontOfSize ((nfloat)size);

            return(NSFont.SystemFontOfSize((nfloat)size));
        }
Example #5
0
        public void SetGroupItem(bool isGroupItem, NSTableView tableView, float?groupSize = null, float?normalSize = null)
        {
            if (isGroupItem)
            {
                this.Font = NSFont.BoldSystemFontOfSize(groupSize ?? NSFont.SystemFontSize);
            }
            else if (Highlighted)
            {
                Font = NSFont.BoldSystemFontOfSize(normalSize ?? NSFont.SystemFontSize);
            }
            else
            {
                Font = NSFont.SystemFontOfSize(normalSize ?? NSFont.SystemFontSize);
            }

            if (Highlighted)
            {
                TextColor = NSColor.Highlight;
            }
            else if (!tableView.Window.IsKeyWindow)
            {
                TextColor = NSColor.DisabledControlText;
            }
            else if (isGroupItem)
            {
                TextColor = GroupColor;
            }
            else
            {
                TextColor = NSColor.ControlText;
            }
        }
Example #6
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            NSTableCellView view = (NSTableCellView)tableView.MakeView(CellIdentifier, this);

            if (view == null)
            {
                view = new NSTableCellView();

                var click = new
                            NSButton(new CGRect(0, -10, 400, 42));
                click.SetButtonType(NSButtonType.MomentaryPushIn);
                click.BezelStyle = NSBezelStyle.RegularSquare;
                click.AlphaValue = 0;
                click.Title      = "";
                click.Tag        = row;

                click.Activated += (sender, e) =>
                {
                    if (DataSource.addresses[(int)row].extended && (int)row != 0)
                    {
                        DataSource.addresses[(int)row].top = true;
                        wvc.update();
                        var btw = sender as NSButton;
                    }
                    ;
                };



                view.TextField                 = new NSTextField(new CGRect(0, 0, 400, 35));
                view.Identifier                = CellIdentifier;
                view.TextField.Font            = NSFont.BoldSystemFontOfSize(28);
                view.TextField.BackgroundColor = NSColor.Clear;
                view.TextField.Bordered        = false;
                view.TextField.Selectable      = false;
                view.TextField.Editable        = false;
                view.AddSubview(view.TextField);
                view.AddSubview(click);
            }

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "address":
                view.TextField.StringValue = DataSource.addresses[(int)row].Address;
                foreach (NSView subview in view.Subviews)
                {
                    var btw = subview as NSButton;
                    if (btw != null)
                    {
                        btw.Tag = row;
                    }
                }

                break;
            }

            return(view);
        }
Example #7
0
        public override float GetPreferredSize(object value, System.Drawing.SizeF cellSize, NSCell cell)
        {
            var font  = cell.Font ?? NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);
            var str   = new NSString(Convert.ToString(value));
            var attrs = NSDictionary.FromObjectAndKey(font, NSAttributedString.FontAttributeName);

            return(str.StringSize(attrs).Width + 8);             // for border
        }
 public AppDelegate()
 {
     // By updating the GlobalContext you can change fonts/colors/ect for all content
     // inside NSStandardUIHost.
     NSStandardUIHost.SetGlobalContext(new()
     {
         { typeof(Style), new Style(HeaderFont: NSFont.BoldSystemFontOfSize(13)) }
     });
 }
Example #9
0
        public override nfloat GetPreferredWidth(object value, CGSize cellSize, int row, object dataItem)
        {
            var args = new MacCellFormatArgs(ColumnHandler.Widget, dataItem, row, field);

            ColumnHandler.DataViewHandler.Callback.OnCellFormatting(ColumnHandler.DataViewHandler.Widget, args);

            field.Font        = args.Font.ToNS() ?? NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);
            field.ObjectValue = value as NSObject;
            return(field.Cell.CellSizeForBounds(new CGRect(0, 0, nfloat.MaxValue, cellSize.Height)).Width);
        }
 public ScreeningLabel(CGRect frame, Screening screening, bool withDay = false) : base(frame)
 {
     Initialize();
     _screening    = screening;
     Font          = NSFont.BoldSystemFontOfSize(ScreeningControl.FontSize);
     Editable      = false;
     Bordered      = false;
     StringValue   = _screening.ToScreeningLabelString(withDay);
     LineBreakMode = NSLineBreakMode.TruncatingMiddle;
     ColorView.SetScreeningColor(_screening, this);
     NeedsDisplay = true;
 }
Example #11
0
 public static NSFont GetSystemFont(bool bold, float size = 0.0f)
 {
     if (size <= 0)
     {
         size = (float)NSFont.SystemFontSize;
     }
     if (bold)
     {
         return(NSFont.BoldSystemFontOfSize(size));
     }
     return(NSFont.SystemFontOfSize(size));
 }
Example #12
0
        private NativeGraphicsService()
        {
            var vFont = NSFont.SystemFontOfSize(NSFont.SystemFontSize);

            _systemFontName = vFont.FontName;
            vFont.Dispose();

            var vBoldFont = NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);

            _boldSystemFontName = vBoldFont.FontName;
            vBoldFont.Dispose();
        }
 static void UpdateField(NSTextField field, string text, bool fontBold, double fontSize, Points maxWidth, IObserver <Size <Points> > desiredSize)
 {
     field.Cell.Font = fontBold
                         ? NSFont.BoldSystemFontOfSize((float)fontSize)
                         : NSFont.SystemFontOfSize((float)fontSize);
     field.StringValue = text;
     if (field.Cell.LineBreakMode != NSLineBreakMode.Clipping)
     {
         field.PreferredMaxLayoutWidth = (nfloat)maxWidth.Value;
     }
     desiredSize.OnNext(field.FittingSize.ToFusion());
     field.NeedsDisplay = true;
 }
        private void CreateFilmTitleLabel()
        {
            _yCurr -= _labelHeight;
            var rect           = new CGRect(_xMargin, _yCurr, _contentWidth, _labelHeight);
            var filmTitleLabel = ControlsFactory.NewStandardLabel(rect, UseTitleBackground);

            filmTitleLabel.StringValue = _film.Title;
            filmTitleLabel.Font        = NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);
            View.AddSubview(filmTitleLabel);

            // Set sample view used to disable resizing.
            _sampleView = filmTitleLabel;
        }
Example #15
0
        public void PrintLineHead(string line)
        {
            this.InvokeOnMainThread(() =>
            {
                var dic = new NSDictionary(
                    NSStringAttributeKey.ForegroundColor,
                    NSColor.Black,
                    NSStringAttributeKey.Font,
                    NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize)
                    );

                this.PrintLine(line, dic);
            });
        }
Example #16
0
        public BasePopOverControl(IHostResourceProvider hostResources, string title, string imageNamed) : base()
        {
            if (title == null)
            {
                throw new ArgumentNullException(nameof(title));
            }
            if (imageNamed == null)
            {
                throw new ArgumentNullException(nameof(imageNamed));
            }
            if (hostResources == null)
            {
                throw new ArgumentNullException(nameof(hostResources));
            }

            TranslatesAutoresizingMaskIntoConstraints = false;
            WantsLayer = true;

            HostResources = hostResources;

            var iconView = new NSImageView {
                Image        = hostResources.GetNamedImage(imageNamed),
                ImageScaling = NSImageScale.None,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            AddSubview(iconView);

            this.viewTitle = new UnfocusableTextField {
                Font        = NSFont.BoldSystemFontOfSize(11),
                StringValue = title,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            AddSubview(this.viewTitle);

            this.AddConstraints(new[] {
                NSLayoutConstraint.Create(iconView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 5f),
                NSLayoutConstraint.Create(iconView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 5f),
                NSLayoutConstraint.Create(iconView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, DefaultIconButtonSize),
                NSLayoutConstraint.Create(iconView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultIconButtonSize),

                NSLayoutConstraint.Create(this.viewTitle, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 7f),
                NSLayoutConstraint.Create(this.viewTitle, NSLayoutAttribute.Left, NSLayoutRelation.Equal, iconView, NSLayoutAttribute.Right, 1f, 5f),
                NSLayoutConstraint.Create(this.viewTitle, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 120),
                NSLayoutConstraint.Create(this.viewTitle, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight),
            });

            AppearanceChanged();
        }
Example #17
0
        public static NSAttributedString GetAttributedString(string text, nfloat size, NSColor color = null, bool isSelected = false)
        {
            NSFont font = NSFont.SystemFontOfSize(size);

            if (isSelected)
            {
                font = NSFont.BoldSystemFontOfSize(size);
            }

            return(GetAttributedString(text, font, color, paragraphStyle: new NSMutableParagraphStyle
            {
                LineBreakMode = NSLineBreakMode.TruncatingMiddle,
                Alignment = NSTextAlignment.Left
            }));
        }
Example #18
0
        private void CreateFilmFanLabels()
        {
            _yCurr -= _labelHeight;
            var xCurr = _xMargin + _labelWidth + _xBetweenControls;
            var rect  = new CGRect(xCurr, _yCurr, _labelWidth, _labelHeight);

            foreach (var fan in ScreeningInfo.FilmFans)
            {
                var fanLabel = ControlsFactory.NewStandardLabel(rect, true);
                fanLabel.StringValue = fan;
                fanLabel.Font        = NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);
                View.AddSubview(fanLabel);
                xCurr += _controlWidth + _xBetweenControls;
                rect.X = xCurr;
            }
        }
Example #19
0
        public void SetFilename(string filename, bool selected)
        {
            // Very simplified version how to select text
            var size = NSFont.SystemFontSize;

            if (selected)
            {
                Label.Font = NSFont.BoldSystemFontOfSize(size);
            }
            else
            {
                Label.Font = NSFont.SystemFontOfSize(size);
            }

            Label.StringValue = filename;
        }
Example #20
0
        public override float GetPreferredSize(object value, System.Drawing.SizeF cellSize, NSCell cell)
        {
            var val = value as MacImageData;

            if (val == null)
            {
                return(0);
            }

            var font  = cell.Font ?? NSFont.BoldSystemFontOfSize(NSFont.SystemFontSize);
            var str   = val.Text;
            var attrs = NSDictionary.FromObjectAndKey(font, NSAttributedString.FontAttributeName);

            var size = str.StringSize(attrs).Width + 4 + 16 + MacImageListItemCell.ImagePadding * 2;              // for border + image

            return(size);
        }
Example #21
0
        public NSObject GetObjectValue(NSTableView tableView, NSTableColumn tableColumn, int row)
        {
            tableColumn.HeaderCell.AttributedStringValue = new NSAttributedString(
                tableColumn.HeaderCell.StringValue,
                NSFont.BoldSystemFontOfSize(9)
                );


            // What is the identifier for the column?
            string identifier = tableColumn.Identifier;

            // What person?
            Person person = _employees[row];

            // What is the value of the attribute named identifier?
            return(person.ValueForKey(new NSString(identifier)));
        }
Example #22
0
        public static NSFont ToNSFont(this FontAttributes attributes)
        {
            if (attributes == null)
            {
                return(NSFont.SystemFontOfSize(12));
            }

            if (attributes.Family == Device.FontService.SystemFontName)
            {
                var weight = (int)attributes.Weight;
                if (weight > (int)Weight.Regular)
                {
                    return(NSFont.BoldSystemFontOfSize(attributes.Size));
                }

                return(NSFont.SystemFontOfSize(attributes.Size));
            }

            return(NSFont.FromFontName(attributes.Family, attributes.Size));
        }
Example #23
0
        public static NSFont ToNSFont(this Font font)
        {
            if (font == null)
            {
                return(NSFont.SystemFontOfSize(12));
            }

            var attributes = font.Attributes;

            if (attributes.Name == Device.FontService.SystemFontName)
            {
                var weight = (int)attributes.Weight;
                if (weight > (int)Weight.Regular)
                {
                    return(NSFont.BoldSystemFontOfSize(attributes.Size));
                }

                return(NSFont.SystemFontOfSize(attributes.Size));
            }

            return(NSFont.FromFontName(attributes.Name, attributes.Size));
        }
Example #24
0
        public SetupWindow()
        {
            SetFrame(new CGRect(0, 0, 640, 420), display: true);

            StyleMask   = NSWindowStyle.Titled;
            MaxSize     = new CGSize(640, 420);
            MinSize     = new CGSize(640, 420);
            HasShadow   = true;
            IsOpaque    = false;
            BackingType = NSBackingStore.Buffered;
            Level       = NSWindowLevel.Floating;

            Center();

            this.side_splash      = NSImage.ImageNamed("side-splash");
            this.side_splash.Size = new CGSize(150, 482);

            this.side_splash_view = new NSImageView()
            {
                Image = this.side_splash,
                Frame = new CGRect(0, 0, 150, 482)
            };

            this.header_text_field = new SparkleLabel("", NSTextAlignment.Left)
            {
                Frame = new CGRect(190, Frame.Height - 80, Frame.Width, 24),
                Font  = NSFont.BoldSystemFontOfSize(16)
            };

            this.description_text_field = new SparkleLabel("", NSTextAlignment.Left)
            {
                Frame = new CGRect(190, Frame.Height - 130, 640 - 240, 44)
            };

            this.header_text_field.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
        }
        private static NSMutableAttributedString ToNsMutabeAttributedString(TextPart textPart, NSColor foreground, double fontSize, bool bold)
        {
            var attrStr = new NSMutableAttributedString(textPart.Text);
            var range   = new NSRange(0, textPart.Text.Count());

            attrStr.BeginEditing();

            var url = textPart as Url;

            if (url != null)
            {
                attrStr.AddAttribute(NSStringAttributeKey.Link, new NSUrl(url.Uri.AbsoluteUri), range);
                attrStr.AddAttribute(NSStringAttributeKey.UnderlineStyle, new NSNumber(1), range);
                attrStr.AddAttribute(NSStringAttributeKey.Cursor, Cursor.Pointing.ToCocoa(), range);
            }

            attrStr.AddAttribute(
                NSStringAttributeKey.BackgroundColor,
                NSColor.Clear,
                range);

            attrStr.AddAttribute(
                NSStringAttributeKey.ForegroundColor,
                textPart.ForegroundColor.HasValue ? textPart.ForegroundColor.Value.ToNSColor() : foreground,
                range);

            // Fixes #2681 Setting the font size and weight for each part prevents the text formatting to change when
            // a link is clicked.
            attrStr.AddAttribute(
                NSStringAttributeKey.Font,
                bold ? NSFont.BoldSystemFontOfSize((float)fontSize) : NSFont.SystemFontOfSize((float)fontSize),
                range);

            attrStr.EndEditing();
            return(attrStr);
        }
Example #26
0
        public NSFont CreateFont(float size)
        {
            // we have a postcript name, use that to create the font
            if (!string.IsNullOrEmpty(PostScriptName))
            {
                // if we try to get a system font by name we get errors now..
                if (PostScriptName == SystemFontName)
                {
                    return(NSFont.SystemFontOfSize(size));
                }
                if (PostScriptName == BoldSystemFontName)
                {
                    return(NSFont.BoldSystemFontOfSize(size));
                }

                // always return something...
                var font = NSFont.FromFontName(PostScriptName, size) ?? NSFont.UserFontOfSize(size);
                return(font);
            }

            var family = (FontFamilyHandler)Widget.Family.Handler;

            return(FontHandler.CreateFont(family.MacName, size, Traits, Weight));
        }
Example #27
0
        public EventLog()
        {
            Title    = "Recent Changes";
            Delegate = new SparkleEventsDelegate();

            int min_width  = 480;
            int min_height = 640;
            int height     = (int)(NSScreen.MainScreen.Frame.Height * 0.85);

            float x = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
            float y = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (height * 0.5));

            SetFrame(
                new CGRect(
                    new CGPoint(x, y),
                    new CGSize(min_width, height)),
                true);

            StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled | NSWindowStyle.Resizable);

            MinSize        = new CGSize(min_width, min_height);
            HasShadow      = true;
            IsOpaque       = false;
            BackingType    = NSBackingStore.Buffered;
            TitlebarHeight = (float)(Frame.Height - ContentView.Frame.Height);
            Level          = NSWindowLevel.Floating;


            this.web_view = new WebView(new CGRect(0, 0, 481, 579), "", "")
            {
                Frame = new CGRect(new CGPoint(0, 0),
                                   new CGSize(ContentView.Frame.Width, ContentView.Frame.Height - 39))
            };

            this.web_view.Preferences.PlugInsEnabled = false;

            this.cover = new NSBox()
            {
                Frame = new CGRect(
                    new CGPoint(-1, -1),
                    new CGSize(Frame.Width + 2, this.web_view.Frame.Height + 1)),
                FillColor        = NSColor.White,
                BorderType       = NSBorderType.NoBorder,
                BoxType          = NSBoxType.NSBoxCustom,
                AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable
            };

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

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


            this.size_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(0, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)),
                StringValue      = "Size:",
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.size_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(60, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)),
                StringValue      = "…",
                Font             = NSFont.BoldSystemFontOfSize(12),
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.history_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(130, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)),
                StringValue      = "History:",
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.history_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(190, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)
                    ),
                StringValue      = "…",
                Font             = NSFont.BoldSystemFontOfSize(12),
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.popup_button = new NSPopUpButton()
            {
                Frame = new CGRect(
                    new CGPoint(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                    new CGSize(156, 26)),
                PullsDown        = false,
                AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.MinYMargin
            };

            this.background = new NSBox()
            {
                Frame = new CGRect(
                    new CGPoint(-1, -1),
                    new CGSize(Frame.Width + 2, this.web_view.Frame.Height + 2)),
                FillColor        = NSColor.White,
                BorderColor      = NSColor.LightGray,
                BoxType          = NSBoxType.NSBoxCustom,
                AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable
            };

            this.progress_indicator = new NSProgressIndicator()
            {
                Frame = new CGRect(
                    new CGPoint(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                    new CGSize(20, 20)),
                Style            = NSProgressIndicatorStyle.Spinning,
                AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.MaxXMargin |
                                   NSViewResizingMask.MinYMargin | NSViewResizingMask.MaxYMargin
            };

            this.progress_indicator.StartAnimation(this);


            ContentView.AddSubview(this.size_label);
            ContentView.AddSubview(this.size_label_value);
            ContentView.AddSubview(this.history_label);
            ContentView.AddSubview(this.history_label_value);
            ContentView.AddSubview(this.popup_button);
            ContentView.AddSubview(this.progress_indicator);
            ContentView.AddSubview(this.background);
            ContentView.AddSubview(this.hidden_close_button);


            Controller.HideWindowEvent     += HideWindowEventDelegate;
            Controller.ShowWindowEvent     += ShowWindowEventDelegate;
            Controller.ShowSaveDialogEvent += ShowSaveDialogEventDelegate;

            Controller.UpdateChooserEvent           += UpdateChooserEventDelegate;
            Controller.UpdateChooserEnablementEvent += UpdateChooserEnablementEventDelegate;
            Controller.UpdateContentEvent           += UpdateContentEventDelegate;
            Controller.UpdateSizeInfoEvent          += UpdateSizeInfoEventDelegate;

            Controller.ContentLoadingEvent += ContentLoadingEventDelegate;
        }
Example #28
0
 public static UIFont BoldSystemFontOfSize(nfloat size)
 {
     return(new UIFont(NSFont.BoldSystemFontOfSize(size)));
 }
Example #29
0
        public void ShowPage(PageType type, string [] warnings)
        {
            if (type == PageType.Setup)
            {
                Header      = "Welcome to SparkleShare!";
                Description = "First off, what’s your name and email?\n(visible only to team members)";

                FullNameLabel       = new SparkleLabel("Full Name:", NSTextAlignment.Right);
                FullNameLabel.Frame = new CGRect(165, Frame.Height - 234, 160, 17);

                FullNameTextField = new NSTextField()
                {
                    Frame       = new CGRect(330, Frame.Height - 238, 196, 22),
                    StringValue = new NSProcessInfo().GetFullUserName(),
                    Delegate    = new SparkleTextFieldDelegate()
                };

                EmailLabel       = new SparkleLabel("Email:", NSTextAlignment.Right);
                EmailLabel.Frame = new CGRect(165, Frame.Height - 264, 160, 17);

                EmailTextField = new NSTextField()
                {
                    Frame    = new CGRect(330, Frame.Height - 268, 196, 22),
                    Delegate = new SparkleTextFieldDelegate()
                };

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };

                ContinueButton = new NSButton()
                {
                    Title   = "Continue",
                    Enabled = false
                };


                (FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue);
                };

                (EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue);
                };

                ContinueButton.Activated += delegate {
                    string full_name = FullNameTextField.StringValue.Trim();
                    string email     = EmailTextField.StringValue.Trim();

                    Controller.SetupPageCompleted(full_name, email);
                };

                CancelButton.Activated += delegate { Controller.SetupPageCancelled(); };

                Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) {
                    SparkleShare.Controller.Invoke(() => {
                        ContinueButton.Enabled = button_enabled;
                    });
                };


                ContentView.AddSubview(FullNameLabel);
                ContentView.AddSubview(FullNameTextField);
                ContentView.AddSubview(EmailLabel);
                ContentView.AddSubview(EmailTextField);

                Buttons.Add(ContinueButton);
                Buttons.Add(CancelButton);

                Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue);

                if (FullNameTextField.StringValue.Equals(""))
                {
                    MakeFirstResponder((NSResponder)FullNameTextField);
                }
                else
                {
                    MakeFirstResponder((NSResponder)EmailTextField);
                }
            }

            if (type == PageType.Invite)
            {
                Header      = "You’ve received an invite!";
                Description = "Do you want to add this project to SparkleShare?";

                AddressLabel       = new SparkleLabel("Address:", NSTextAlignment.Right);
                AddressLabel.Frame = new CGRect(165, Frame.Height - 238, 160, 17);
                AddressLabel.Font  = NSFont.BoldSystemFontOfSize(12);

                AddressTextField = new SparkleLabel(Controller.PendingInvite.Address, NSTextAlignment.Left)
                {
                    Frame = new CGRect(330, Frame.Height - 240, 260, 17)
                };

                PathLabel       = new SparkleLabel("Remote Path:", NSTextAlignment.Right);
                PathLabel.Frame = new CGRect(165, Frame.Height - 262, 160, 17);
                PathLabel.Font  = NSFont.BoldSystemFontOfSize(12);

                PathTextField = new SparkleLabel(Controller.PendingInvite.RemotePath, NSTextAlignment.Left)
                {
                    Frame = new CGRect(330, Frame.Height - 264, 260, 17)
                };

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };
                AddButton = new NSButton()
                {
                    Title = "Add"
                };


                CancelButton.Activated += delegate { Controller.PageCancelled(); };
                AddButton.Activated    += delegate { Controller.InvitePageCompleted(); };


                ContentView.AddSubview(AddressLabel);
                ContentView.AddSubview(PathLabel);
                ContentView.AddSubview(AddressTextField);
                ContentView.AddSubview(PathTextField);

                Buttons.Add(AddButton);
                Buttons.Add(CancelButton);
            }

            if (type == PageType.Add)
            {
                Header      = "Where’s your project hosted?";
                Description = "";

                AddressLabel = new SparkleLabel("Address:", NSTextAlignment.Left)
                {
                    Frame = new CGRect(190, Frame.Height - 310, 160, 17),
                    Font  = NSFont.BoldSystemFontOfSize(12)
                };

                AddressTextField = new NSTextField()
                {
                    Frame       = new CGRect(190, Frame.Height - 336, 196, 22),
                    Enabled     = (Controller.SelectedPreset.Address == null),
                    Delegate    = new SparkleTextFieldDelegate(),
                    StringValue = "" + Controller.PreviousAddress
                };

                AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathLabel = new SparkleLabel("Remote Path:", NSTextAlignment.Left)
                {
                    Frame = new CGRect(190 + 196 + 16, Frame.Height - 310, 160, 17),
                    Font  = NSFont.BoldSystemFontOfSize(12)
                };

                PathTextField = new NSTextField()
                {
                    Frame       = new CGRect(190 + 196 + 16, Frame.Height - 336, 196, 22),
                    Enabled     = (Controller.SelectedPreset.Path == null),
                    Delegate    = new SparkleTextFieldDelegate(),
                    StringValue = "" + Controller.PreviousPath
                };

                PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;

                PathHelpLabel = new SparkleLabel(Controller.SelectedPreset.PathExample, NSTextAlignment.Left)
                {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new CGRect(190 + 196 + 16, Frame.Height - 358, 204, 19)
                };

                AddressHelpLabel = new SparkleLabel(Controller.SelectedPreset.AddressExample, NSTextAlignment.Left)
                {
                    TextColor = NSColor.DisabledControlText,
                    Frame     = new CGRect(190, Frame.Height - 358, 204, 19)
                };

                if (TableView == null || TableView.RowCount != Controller.Presets.Count)
                {
                    TableView = new NSTableView()
                    {
                        Frame            = new CGRect(0, 0, 0, 0),
                        RowHeight        = 38,
                        IntercellSpacing = new CGSize(8, 12),
                        HeaderView       = null,
                        Delegate         = new SparkleTableViewDelegate()
                    };

                    ScrollView = new NSScrollView()
                    {
                        Frame               = new CGRect(190, Frame.Height - 280, 408, 185),
                        DocumentView        = TableView,
                        HasVerticalScroller = true,
                        BorderType          = NSBorderType.BezelBorder
                    };

                    IconColumn = new NSTableColumn()
                    {
                        Width         = 36,
                        HeaderToolTip = "Icon",
                        DataCell      = new NSImageCell()
                        {
                            ImageAlignment = NSImageAlignment.Right
                        }
                    };

                    DescriptionColumn = new NSTableColumn()
                    {
                        Width         = 350,
                        HeaderToolTip = "Description",
                        Editable      = false
                    };

                    TableView.AddColumn(IconColumn);
                    TableView.AddColumn(DescriptionColumn);

                    // Hi-res display support was added after Snow Leopard
                    if (Environment.OSVersion.Version.Major < 11)
                    {
                        DataSource = new SparkleDataSource(1, Controller.Presets);
                    }
                    else
                    {
                        DataSource = new SparkleDataSource((float)BackingScaleFactor, Controller.Presets);
                    }

                    TableView.DataSource = DataSource;
                    TableView.ReloadData();

                    (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate {
                        Controller.SelectedPresetChanged((int)TableView.SelectedRow);
                        Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, (int)TableView.SelectedRow);
                    };
                }

                TableView.SelectRow(Controller.SelectedPresetIndex, byExtendingSelection: false);
                TableView.ScrollRowToVisible(Controller.SelectedPresetIndex);
                MakeFirstResponder((NSResponder)TableView);

                HistoryCheckButton = new NSButton()
                {
                    Frame = new CGRect(190, Frame.Height - 400, 300, 18),
                    Title = "Fetch prior revisions"
                };

                if (Controller.FetchPriorHistory)
                {
                    HistoryCheckButton.State = NSCellStateValue.On;
                }

                HistoryCheckButton.SetButtonType(NSButtonType.Switch);

                AddButton = new NSButton()
                {
                    Title   = "Add",
                    Enabled = false
                };

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };


                Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) {
                    SparkleShare.Controller.Invoke(() => {
                        AddressTextField.StringValue = text;
                        AddressTextField.Enabled     = (state == FieldState.Enabled);
                        AddressHelpLabel.StringValue = example_text;
                    });
                };

                Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) {
                    SparkleShare.Controller.Invoke(() => {
                        PathTextField.StringValue = text;
                        PathTextField.Enabled     = (state == FieldState.Enabled);
                        PathHelpLabel.StringValue = example_text;
                    });
                };


                (AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, (int)TableView.SelectedRow);
                };

                (PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, (int)TableView.SelectedRow);
                };


                HistoryCheckButton.Activated += delegate {
                    Controller.HistoryItemChanged(HistoryCheckButton.State == NSCellStateValue.On);
                };

                AddButton.Activated += delegate {
                    Controller.AddPageCompleted(AddressTextField.StringValue, PathTextField.StringValue);
                };

                CancelButton.Activated += delegate { Controller.PageCancelled(); };

                Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) {
                    SparkleShare.Controller.Invoke(() => {
                        AddButton.Enabled = button_enabled;
                    });
                };

                ContentView.AddSubview(ScrollView);
                ContentView.AddSubview(AddressLabel);
                ContentView.AddSubview(AddressTextField);
                ContentView.AddSubview(AddressHelpLabel);
                ContentView.AddSubview(PathLabel);
                ContentView.AddSubview(PathTextField);
                ContentView.AddSubview(PathHelpLabel);
                ContentView.AddSubview(HistoryCheckButton);

                Buttons.Add(AddButton);
                Buttons.Add(CancelButton);

                Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, (int)TableView.SelectedRow);
            }

            if (type == PageType.Syncing)
            {
                Header      = "Adding project ‘" + Controller.SyncingFolder + "’…";
                Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?";

                ProgressIndicator = new NSProgressIndicator()
                {
                    Frame         = new CGRect(190, Frame.Height - 200, 640 - 150 - 80, 20),
                    Style         = NSProgressIndicatorStyle.Bar,
                    MinValue      = 0.0,
                    MaxValue      = 100.0,
                    Indeterminate = false,
                    DoubleValue   = Controller.ProgressBarPercentage
                };

                ProgressIndicator.StartAnimation(this);

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };

                FinishButton = new NSButton()
                {
                    Title   = "Finish",
                    Enabled = false
                };

                ProgressLabel       = new SparkleLabel("Preparing to fetch files…", NSTextAlignment.Right);
                ProgressLabel.Frame = new CGRect(Frame.Width - 40 - 250, 185, 250, 25);


                Controller.UpdateProgressBarEvent += delegate(double percentage, string speed) {
                    SparkleShare.Controller.Invoke(() => {
                        ProgressIndicator.DoubleValue = percentage;
                        ProgressLabel.StringValue     = speed;
                    });
                };


                CancelButton.Activated += delegate { Controller.SyncingCancelled(); };


                ContentView.AddSubview(ProgressLabel);
                ContentView.AddSubview(ProgressIndicator);

                Buttons.Add(FinishButton);
                Buttons.Add(CancelButton);
            }

            if (type == PageType.Error)
            {
                Header      = "Oops! Something went wrong…";
                Description = "Please check the following:";

                // Displaying marked up text with Cocoa is
                // a pain, so we just use a webview instead
                WebView web_view = new WebView();
                web_view.Frame = new CGRect(190, Frame.Height - 525, 375, 400);

                string html = "<style>" +
                              "* {" +
                              "  font-family: -apple-system, '" + UserInterface.FontName + "';" +
                              "  font-size: 12px; cursor: default;" +
                              "}" +
                              "body {" +
                              "  -webkit-user-select: none;" +
                              "  margin: 0;" +
                              "  padding: 3px;" +
                              "}" +
                              "li {" +
                              "  margin-bottom: 16px;" +
                              "  margin-left: 0;" +
                              "  padding-left: 0;" +
                              "  line-height: 20px;" +
                              "  word-wrap: break-word;" +
                              "}" +
                              "ul {" +
                              "  padding-left: 24px;" +
                              "}" +
                              "</style>" +
                              "<ul>" +
                              "  <li><b>" + Controller.PreviousUrl + "</b> is the address we’ve compiled. Does this look alright?</li>" +
                              "  <li>Is this computer’s Client ID known by the host?</li>" +
                              "</ul>";

                if (warnings.Length > 0)
                {
                    string warnings_markup = "";

                    foreach (string warning in warnings)
                    {
                        warnings_markup += "<br><b>" + warning + "</b>";
                    }

                    html = html.Replace("</ul>", "<li>Here’s the raw error message: " + warnings_markup + "</li></ul>");
                }

                web_view.MainFrame.LoadHtmlString(html, new NSUrl(""));
                web_view.DrawsBackground = false;

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };
                TryAgainButton = new NSButton()
                {
                    Title = "Retry"
                };


                CancelButton.Activated   += delegate { Controller.PageCancelled(); };
                TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted(); };


                ContentView.AddSubview(web_view);

                Buttons.Add(TryAgainButton);
                Buttons.Add(CancelButton);
            }

            if (type == PageType.StorageSetup)
            {
                Header      = string.Format("Storage type for ‘{0}’", Controller.SyncingFolder);
                Description = "What type of storage would you like to use?";


                storage_type_descriptions = new List <NSTextField> ();

                ButtonCellProto = new NSButtonCell();
                ButtonCellProto.SetButtonType(NSButtonType.Radio);
                ButtonCellProto.Font = NSFont.BoldSystemFontOfSize(12);

                Matrix = new NSMatrix(new CGRect(202, Frame.Height - 256 - 128, 256, 256), NSMatrixMode.Radio,
                                      ButtonCellProto, SparkleShare.Controller.FetcherAvailableStorageTypes.Count, 1);

                Matrix.CellSize         = new CGSize(256, 36);
                Matrix.IntercellSpacing = new CGSize(32, 32);

                int i = 0;
                foreach (StorageTypeInfo storage_type in SparkleShare.Controller.FetcherAvailableStorageTypes)
                {
                    Matrix.Cells [i].Title = " " + storage_type.Name;

                    NSTextField storage_type_description = new SparkleLabel(storage_type.Description, NSTextAlignment.Left)
                    {
                        TextColor = NSColor.DisabledControlText,
                        Frame     = new CGRect(223, Frame.Height - 190 - (68 * i), 256, 32)
                    };

                    storage_type_descriptions.Add(storage_type_description);
                    ContentView.AddSubview(storage_type_description);

                    i++;
                }

                ContentView.AddSubview(Matrix);


                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };
                ContinueButton = new NSButton()
                {
                    Title = "Continue"
                };

                ContinueButton.Activated += delegate {
                    StorageTypeInfo selected_storage_type = SparkleShare.Controller.FetcherAvailableStorageTypes [(int)Matrix.SelectedRow];
                    Controller.StoragePageCompleted(selected_storage_type.Type);
                };

                CancelButton.Activated += delegate { Controller.SyncingCancelled(); };

                Buttons.Add(ContinueButton);
                Buttons.Add(CancelButton);


                NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest);
            }

            if (type == PageType.CryptoSetup || type == PageType.CryptoPassword)
            {
                if (type == PageType.CryptoSetup)
                {
                    Header      = "Set up file encryption";
                    Description = "Please a provide a strong password that you don’t use elsewhere.";
                }
                else
                {
                    Header      = "This project contains encrypted files";
                    Description = "Please enter the password to see their contents.";
                }

                int extra_pos_y = 0;

                if (type == PageType.CryptoPassword)
                {
                    extra_pos_y = 20;
                }

                PasswordLabel = new SparkleLabel("Password:"******"Show password",
                    State = NSCellStateValue.Off
                };

                ShowPasswordCheckButton.SetButtonType(NSButtonType.Switch);

                WarningImage      = NSImage.ImageNamed("NSInfo");
                WarningImage.Size = new CGSize(24, 24);

                WarningImageView = new NSImageView()
                {
                    Image = WarningImage,
                    Frame = new CGRect(200, Frame.Height - 320, 24, 24)
                };

                WarningTextField = new SparkleLabel("This password can’t be changed later, and your files can’t be recovered if it’s forgotten.", NSTextAlignment.Left)
                {
                    Frame = new CGRect(235, Frame.Height - 390, 325, 100),
                };

                CancelButton = new NSButton()
                {
                    Title = "Cancel"
                };

                ContinueButton = new NSButton()
                {
                    Title   = "Continue",
                    Enabled = false
                };


                Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) {
                    SparkleShare.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; });
                };

                Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) {
                    SparkleShare.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; });
                };

                ShowPasswordCheckButton.Activated += delegate {
                    if (PasswordTextField.Superview == ContentView)
                    {
                        PasswordTextField.RemoveFromSuperview();
                        ContentView.AddSubview(VisiblePasswordTextField);
                    }
                    else
                    {
                        VisiblePasswordTextField.RemoveFromSuperview();
                        ContentView.AddSubview(PasswordTextField);
                    }
                };

                (PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    VisiblePasswordTextField.StringValue = PasswordTextField.StringValue;

                    if (type == PageType.CryptoSetup)
                    {
                        Controller.CheckCryptoSetupPage(PasswordTextField.StringValue);
                    }
                    else
                    {
                        Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue);
                    }
                };

                (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate {
                    PasswordTextField.StringValue = VisiblePasswordTextField.StringValue;

                    if (type == PageType.CryptoSetup)
                    {
                        Controller.CheckCryptoSetupPage(PasswordTextField.StringValue);
                    }
                    else
                    {
                        Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue);
                    }
                };

                ContinueButton.Activated += delegate {
                    if (type == PageType.CryptoSetup)
                    {
                        Controller.CryptoSetupPageCompleted(PasswordTextField.StringValue);
                    }
                    else
                    {
                        Controller.CryptoPasswordPageCompleted(PasswordTextField.StringValue);
                    }
                };

                CancelButton.Activated += delegate { Controller.CryptoPageCancelled(); };


                ContentView.AddSubview(PasswordLabel);
                ContentView.AddSubview(PasswordTextField);
                ContentView.AddSubview(ShowPasswordCheckButton);

                if (type == PageType.CryptoSetup)
                {
                    ContentView.AddSubview(WarningImageView);
                    ContentView.AddSubview(WarningTextField);
                }

                Buttons.Add(ContinueButton);
                Buttons.Add(CancelButton);

                MakeFirstResponder((NSResponder)PasswordTextField);
                NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest);
            }


            if (type == PageType.Finished)
            {
                Header      = "Your shared project is ready!";
                Description = "You can find the files in your SparkleShare folder.";

                if (warnings.Length > 0)
                {
                    WarningImage      = NSImage.ImageNamed("NSInfo");
                    WarningImage.Size = new CGSize(24, 24);

                    WarningImageView = new NSImageView()
                    {
                        Image = WarningImage,
                        Frame = new CGRect(200, Frame.Height - 175, 24, 24)
                    };

                    WarningTextField       = new SparkleLabel(warnings [0], NSTextAlignment.Left);
                    WarningTextField.Frame = new CGRect(235, Frame.Height - 245, 325, 100);

                    ContentView.AddSubview(WarningImageView);
                    ContentView.AddSubview(WarningTextField);
                }

                ShowFilesButton = new NSButton()
                {
                    Title = "Show Files"
                };
                FinishButton = new NSButton()
                {
                    Title = "Finish"
                };


                ShowFilesButton.Activated += delegate { Controller.ShowFilesClicked(); };
                FinishButton.Activated    += delegate { Controller.FinishPageCompleted(); };


                Buttons.Add(FinishButton);
                Buttons.Add(ShowFilesButton);

                NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest);
            }
        }
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data
            NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this);

            if (view == null)
            {
                view                 = new NSTextField();
                view.Identifier      = CellIdentifier;
                view.BackgroundColor = NSColor.Clear;
                view.Bordered        = false;
                view.Selectable      = false;
                view.Alignment       = NSTextAlignment.Center;
                if (tableColumn.Title == "Total")
                {
                    view.Alignment = NSTextAlignment.Right;
                }
                view.Tag = row;
                if (row == 5)
                {
                    NSFont font = NSFont.BoldSystemFontOfSize(12);
                    //NSFont.ofsi
                    view.Font = font;
                }
                view.EditingEnded += (sender, e) => {
                    // Take action based on type
                    switch (tableColumn.Title)
                    {
                    case "Export":
                        DataSource.Products[(int)view.Tag].ExportCount = view.StringValue;
                        DataSource.Products[(int)view.Tag].ExportValue =
                            Convert.ToString(view.IntValue * multiplier[row]);
                        //DataSource.Products[(int)view.Tag].Title = view.StringValue;
                        break;

                    case "Total":
                        view.Alignment = NSTextAlignment.Right;
                        //DataSource.Products[(int)view.Tag].Description = view.StringValue;
                        break;
                    }
                    tableView.ReloadData();
                };
            }

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "Denomination":
                view.StringValue = DataSource.Products[(int)row].Denomination;
                break;

            case "Count":
                view.StringValue = DataSource.Products[(int)row].NotesCount;
                break;

            case "Total":
                view.StringValue = DataSource.Products[(int)row].NotesValue;
                break;

            case "Export":
                view.StringValue = DataSource.Products[(int)row].ExportCount;
                break;

            case "Export Value":
                view.StringValue = DataSource.Products[(int)row].ExportValue;
                break;
            }


            return(view);
        }