Example #1
0
        public ColumnDetail(string name, float width, ColumnAlignment alignment = ColumnAlignment.Left, ColumnType columnType = ColumnType.TextBox)
        {
            ColumnName   = name;
            ColumnWidth  = width;
            TypeofColumn = columnType;
#if __PC__
            switch (alignment)
            {
            case ColumnAlignment.Left: Alignment = DataGridViewContentAlignment.MiddleLeft; break;

            case ColumnAlignment.Right: Alignment = DataGridViewContentAlignment.MiddleRight; break;

            case ColumnAlignment.Center: Alignment = DataGridViewContentAlignment.MiddleCenter; break;
            }
#elif __MACOS__
            switch (alignment)
            {
            case ColumnAlignment.Left: Alignment = NSTextAlignment.Left; break;

            case ColumnAlignment.Right: Alignment = NSTextAlignment.Right; break;

            case ColumnAlignment.Center: Alignment = NSTextAlignment.Center; break;
            }
#endif
        }
Example #2
0
        internal static NSTextField CreateTextField(
            string text, NSTextAlignment alignment, NSColor color)
        {
            NSTextField result = new NSTextField();

            result.Cell = CreateTextFieldCell(text, alignment, color);
            return(result);
        }
Example #3
0
 public static NSTextField CreateTextEntry(string text, NSFont font = null, NSTextAlignment alignment = NSTextAlignment.Left, bool translatesAutoresizingMaskIntoConstraints = false)
 {
     return(new NSTextField {
         StringValue = text ?? "",
         Font = font ?? GetSystemFont(false),
         Alignment = alignment, TranslatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints
     });
 }
Example #4
0
        static NSTextFieldCell CreateTextFieldCell(
            string text, NSTextAlignment alignment, NSColor color)
        {
            NSTextFieldCell result = new NSTextFieldCell(text);

            result.LineBreakMode = NSLineBreakMode.ByWordWrapping;
            result.Alignment     = alignment;
            result.TextColor     = color;
            return(result);
        }
        internal NSTableCellView GetFTAnalyzerGridCell(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            var index = Array.IndexOf(_fieldNames, tableColumn.Identifier);

            if (index < 0 || index > _properties.Length)
            {
                return(null);
            }
            var             property  = _properties[index];
            NSTextAlignment alignment = NSTextAlignment.Left;
            var             width     = tableColumn.Width;

            ColumnDetail[] x = property.GetCustomAttributes(typeof(ColumnDetail), false) as ColumnDetail[];
            if (x?.Length == 1)
            {
                alignment = x[0].Alignment;
                width     = x[0].ColumnWidth;
            }
            if (!(tableView.MakeView(CellIdentifier, this) is NSTableCellView cellView))
            {
                var textField = new NSTextField
                {
                    BackgroundColor     = NSColor.Clear,
                    LineBreakMode       = NSLineBreakMode.TruncatingTail,
                    Bordered            = false,
                    Selectable          = false,
                    Editable            = false,
                    Alignment           = alignment,
                    AutoresizingMask    = NSViewResizingMask.MinYMargin | NSViewResizingMask.WidthSizable,
                    AutoresizesSubviews = true,
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    AllowsDefaultTighteningForTruncation      = true,
                };
                if (tableView.AutosaveName == "PrintView")
                {
                    textField.Font = NSFont.SystemFontOfSize(8);
                }
                cellView = new NSTableCellView
                {
                    Identifier          = CellIdentifier,
                    TextField           = textField,
                    AutoresizesSubviews = true,
                    AutoresizingMask    = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable
                };
                cellView.AddSubview(textField);
                var views = new NSMutableDictionary
                {
                    { new NSString("textField"), textField }
                };
                cellView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|[textField({width}@750)]|", NSLayoutFormatOptions.AlignAllTop, null, views));
                cellView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[textField]|", NSLayoutFormatOptions.AlignAllTop, null, views));
                NSLayoutConstraint.ActivateConstraints(cellView.Constraints);
            }
            return(cellView);
        }
Example #6
0
        public static Alignment ToAlignment(this NSTextAlignment align)
        {
            switch (align)
            {
            case NSTextAlignment.Center: return(Alignment.Center);

            case NSTextAlignment.Right: return(Alignment.End);

            default: return(Alignment.Start);
            }
        }
Example #7
0
        public static HorizontalAlignment ToHorizontalAlignment(this NSTextAlignment self)
        {
            switch (self)
            {
            case NSTextAlignment.Center: return(HorizontalAlignment.Center);

            case NSTextAlignment.Right: return(HorizontalAlignment.Right);

            default: return(HorizontalAlignment.Left);
            }
        }
Example #8
0
        public SparkleLabel(string label, NSTextAlignment alignment)
        {
            if (!string.IsNullOrEmpty(label))
            {
                StringValue = label;
            }

            Alignment       = alignment;
            BackgroundColor = NSColor.WindowBackground;
            Bordered        = false;
            Editable        = false;
        }
Example #9
0
        public static string CreateLabelToDesignerString(string text, NSTextAlignment alignment = NSTextAlignment.Left)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(string.Format("new {0}() {{", nameof(NSTextField)));
            builder.AppendLine(string.Format("    StringValue = \"{0}\",", text));
            builder.AppendLine("Editable = false,");
            builder.AppendLine("Bordered = false,");
            builder.AppendLine("Bezeled = false,");
            builder.AppendLine("DrawsBackground = false,");
            builder.AppendLine(string.Format("Alignment = {0},", alignment.ToDesignerString()));
            builder.Append("}");
            return(builder.ToString());
        }
 public static NSTextField CreateLabel(string text, NSTextAlignment alignment = NSTextAlignment.Left, NSFont font = null)
 {
     return(new NSTextField()
     {
         StringValue = text ?? "",
         Font = font ?? GetSystemFont(false),
         Editable = false,
         Bordered = false,
         Bezeled = false,
         DrawsBackground = false,
         Selectable = false,
         Alignment = alignment,
         TranslatesAutoresizingMaskIntoConstraints = false
     });
 }
Example #11
0
        public static HorizontalAlign ToEto(this NSTextAlignment align)
        {
            switch (align)
            {
            default:
            case NSTextAlignment.Left:
                return(HorizontalAlign.Left);

            case NSTextAlignment.Right:
                return(HorizontalAlign.Right);

            case NSTextAlignment.Center:
                return(HorizontalAlign.Center);
            }
        }
Example #12
0
        public static NSTextField CreateLabel(string text, NSFont font = null, NSTextAlignment alignment = NSTextAlignment.Left)
        {
            var label = new NSTextField();

            label.Cell            = new VerticalAlignmentTextCell();
            label.StringValue     = text ?? "";
            label.Font            = font ?? GetSystemFont(false);
            label.Editable        = false;
            label.Bordered        = false;
            label.Bezeled         = false;
            label.DrawsBackground = false;
            label.Selectable      = false;
            label.Alignment       = alignment;
            return(label);
        }
Example #13
0
        public static NSTextAlignment ToNSTextAlignment(this ContentAlignment alignment)
        {
            NSTextAlignment retval = NSTextAlignment.Center;

            switch (alignment)
            {
            case ContentAlignment.BottomCenter:
                retval = NSTextAlignment.Center;
                break;

            case ContentAlignment.BottomLeft:
                retval = NSTextAlignment.Left;
                break;

            case ContentAlignment.BottomRight:
                retval = NSTextAlignment.Right;
                break;

            case ContentAlignment.MiddleCenter:
                retval = NSTextAlignment.Center;
                break;

            case ContentAlignment.MiddleLeft:
                retval = NSTextAlignment.Left;
                break;

            case ContentAlignment.MiddleRight:
                retval = NSTextAlignment.Right;
                break;

            case ContentAlignment.TopCenter:
                retval = NSTextAlignment.Center;
                break;

            case ContentAlignment.TopLeft:
                retval = NSTextAlignment.Left;
                break;

            case ContentAlignment.TopRight:
                retval = NSTextAlignment.Right;
                break;

            default:
                retval = NSTextAlignment.Center;
                break;
            }
            return(retval);
        }
Example #14
0
        public static NSTextField CreateLabel(string text, NSFont font = null, NSTextAlignment alignment = NSTextAlignment.Left, bool translatesAutoresizingMaskIntoConstraints = false)
        {
            var label = new NSTextField()
            {
                StringValue     = text ?? "",
                Font            = font ?? ViewsHelper.GetSystemFont(false),
                Editable        = false,
                Bordered        = false,
                Bezeled         = false,
                DrawsBackground = false,
                Selectable      = false,
                Alignment       = alignment
            };

            label.TranslatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints;
            return(label);
        }
        public static nuint ToNative(NSTextAlignment value)
        {
            // For backwards compat reasons, the values we have in managed code corresponds with the X64 values.
            if (Runtime.IsARM64CallingConvention)
            {
                // Center and Right are switched on arm64 on macOS
                switch (value)
                {
                case (NSTextAlignment)2:
                    value = (NSTextAlignment)1;
                    break;

                case (NSTextAlignment)1:
                    value = (NSTextAlignment)2;
                    break;
                }
            }
            return((nuint)(ulong)value);
        }
Example #16
0
 public void SetAlignmentrange(NSTextAlignment alignment, NSRange range)
 {
     SetAlignmentRange(alignment, range);
 }
Example #17
0
		public CCTexture2D (string text, SizeF dimensions, NSTextAlignment alignment, CCVerticalTextAlignment vertAlignment, string fontName, float fontSize) : this (text, fontName, fontSize, dimensions, alignment, vertAlignment)
Example #18
0
		public CCLabelTTF (string label, SizeF dimensions, NSTextAlignment alignment, NSLineBreakMode lineBreakMode, string fontName, float fontSize) : this (label, fontName, fontSize, dimensions, alignment, lineBreakMode)
Example #19
0
        public static NSMutableAttributedString WithAlignment(this NSMutableAttributedString ns, NSTextAlignment alignment)
        {
            if (ns == null)
            {
                return(null);
            }

            ns.BeginEditing();
            var r = new NSRange(0, ns.Length);

            ns.RemoveAttribute(NSStringAttributeKey.ParagraphStyle, r);
            var pstyle = NSParagraphStyle.DefaultParagraphStyle.MutableCopy() as NSMutableParagraphStyle;

            pstyle.Alignment = alignment;
            ns.AddAttribute(NSStringAttributeKey.ParagraphStyle, pstyle, r);
            ns.EndEditing();
            return(ns);
        }
Example #20
0
		public CCLabelTTF (string label, SizeF dimensions, NSTextAlignment alignment, string fontName, float fontSize) : this (label, fontName, fontSize, dimensions, alignment)
Example #21
0
        public static NSAttributedString AttributedPartialTitle(string title, List <string> keyWordsList, NSColor fontColor,
                                                                string fontName, float fontSize, NSTextAlignment textAlignment, NSLineBreakMode breakMode)
        {
            string patten = "\\b(";
            int    i      = 0;

            foreach (var item in keyWordsList)
            {
                if (i != 0)
                {
                    patten = patten + "|" + item;
                }
                else
                {
                    patten = patten + item;
                }
                i++;
            }
            patten = patten + ")\\b";
            string [] results = Regex.Split(title, patten);

            NSMutableParagraphStyle ps = new NSMutableParagraphStyle();

            ps.Alignment     = textAlignment;
            ps.LineBreakMode = breakMode;

            NSMutableAttributedString attrTitle = new NSMutableAttributedString();

            foreach (var item in results)
            {
                //Console.WriteLine ("result:{0}", item);
                if (item.Length == 0)
                {
                    continue;
                }
                if (keyWordsList.Contains(item))
                {
                    NSStringAttributes attributes = new NSStringAttributes();

                    attributes.Font            = NSFont.FromFontName(fontName + " Bold Italic", fontSize);
                    attributes.ForegroundColor = Utility.ColorWithRGB(0, 0, 0, 0.45f);
                    attributes.ParagraphStyle  = ps;

                    NSAttributedString attrString = new NSAttributedString(item, attributes);
                    attrTitle.Append(attrString);
                }
                else
                {
                    NSStringAttributes attributes = new NSStringAttributes();
                    attributes.Font            = NSFont.FromFontName(fontName, fontSize);
                    attributes.ForegroundColor = fontColor;
                    attributes.ParagraphStyle  = ps;
                    NSAttributedString attrString = new NSAttributedString(item, attributes);
                    attrTitle.Append(attrString);
                }
            }

            return(attrTitle);
        }
Example #22
0
 internal static NSTextField CreateTextField(
     string text, NSTextAlignment alignment)
 {
     return(CreateTextField(text, alignment, NSColor.ControlText));
 }
Example #23
0
        public static NSAttributedString AttributedTitle(string title, NSColor color, String fontName, float fontSize, NSTextAlignment textAlignment)
        {
            NSMutableParagraphStyle ps = new NSMutableParagraphStyle();

            ps.Alignment   = textAlignment;
            ps.LineSpacing = 0.0f;
            NSColor fontColor = color;
            NSFont  font      = NSFont.FromFontName(fontName, fontSize);

            if (font == null)
            {
                font = NSFont.SystemFontOfSize(fontSize);
            }
            NSString titleObj = new NSString(title);

            NSStringAttributes attributes = new NSStringAttributes();

            attributes.Font            = font;
            attributes.ForegroundColor = fontColor;
            attributes.ParagraphStyle  = ps;
            attributes.ToolTip         = titleObj;
            NSAttributedString buttonString = new NSAttributedString(title, attributes);

            return(buttonString);
        }
Example #24
0
 public static string ToDesignerString(this NSTextAlignment alignment)
 {
     return(string.Format("{0}.{1}", nameof(NSTextAlignment), alignment.ToString()));
 }
Example #25
0
 public void SetVAlign(string alignDesc)
 {
     VAlign = ParseAlignment(alignDesc);
 }
 public void SetVAlign(string alignDesc)
 {
     VAlign = ParseAlignment (alignDesc);
 }
Example #27
0
 public static string ToDesignerString(this NSTextAlignment alignment)
 {
     return(typeof(NSTextAlignment).WithProperty(alignment.ToString()));
 }
Example #28
0
 public void SetAlignmentrange(NSTextAlignment alignment, NSRange range)
 {
     SetAlignmentRange (alignment, range);
 }
Example #29
0
        public SparkleLabel (string label, NSTextAlignment alignment)
        {
            if (!string.IsNullOrEmpty (label))
                StringValue = label;

            Alignment       = alignment;
            BackgroundColor = NSColor.WindowBackground;
            Bordered        = false;
            Editable        = false;
            Font            = SparkleUI.Font;
        }
Example #30
0
 public static string CreateLabelToDesignerString(string text, NSTextAlignment alignment = NSTextAlignment.Left, Func <string, (string data, bool translated)> tranlationHandler = null)
Example #31
0
 public NSTextTab(NSTextAlignment textAlignment, CGFloat location, Dictionary <NSObject, AnyObject> options)
 {
 }