public void CreatePlaceholder()
        {
            ExtendedEditorControl element = Element as ExtendedEditorControl;

            _placeholderLabel = new UILabel
            {
                Text = element?.Placeholder,
                TextColor = element.PlaceholderColor.ToUIColor(),
                BackgroundColor = UIColor.Clear
            };

            UIEdgeInsets edgeInsets = Control.TextContainerInset;
            System.nfloat lineFragmentPadding = Control.TextContainer.LineFragmentPadding;

            Control.AddSubview(_placeholderLabel);

            NSLayoutConstraint[] vConstraints = NSLayoutConstraint.FromVisualFormat(
                "V:|-" + edgeInsets.Top + "-[PlaceholderLabel]-" + edgeInsets.Bottom + "-|", 0, new NSDictionary(),
                NSDictionary.FromObjectsAndKeys(
                    new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") })
            );

            NSLayoutConstraint[] hConstraints = NSLayoutConstraint.FromVisualFormat(
                "H:|-" + lineFragmentPadding + "-[PlaceholderLabel]-" + lineFragmentPadding + "-|",
                0, new NSDictionary(),
                NSDictionary.FromObjectsAndKeys(
                    new NSObject[] { _placeholderLabel }, new NSObject[] { new NSString("PlaceholderLabel") })
            );

            _placeholderLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            Control.AddConstraints(hConstraints);
            Control.AddConstraints(vConstraints);
        }
        protected override void OnAttached()
        {
            if (Element is Editor edit)
            {
                editor = edit;
            }

            if (Control != null)
            {
                if (Control is UITextView view)
                {
                    editView = view;

                    // If the EditText has by default a text, we set the caret to the end
                    if (editView.Text?.Length > 0)
                    {
                        editView.SelectedTextRange = editView.GetTextRange(editView.EndOfDocument, editView.EndOfDocument);
                    }

                    if (maxLines > 0)
                    {
                        maxHeight         = editView.Font.LineHeight * maxLines;
                        editView.Changed += EditView_Changed;
                    }
                }
                else if (Control is UITextField field)
                {
                    editText  = field;

                    // If the EditText has by default a text, we set the caret to the end
                    if (editText.Text?.Length > 0)
                    {
                        editText.SelectedTextRange = editText.GetTextRange(editText.EndOfDocument, editText.EndOfDocument);
                    }
                }

                if ((editView != null) || (editText != null))
                {
                    entryEffect = (MultiPlatformApplication.Effects.EntryEffect)Element.Effects.FirstOrDefault(e => e is MultiPlatformApplication.Effects.EntryEffect);

                    if (MultiPlatformApplication.Effects.EntryEffect.GetNoBorder(Element) == true)
                    {
                        NoBorder();
                    }

                    RegisterKeyboardObserver();
                }
            }

            //SetTintColor();
        }
            private NSString GetToolTip(NSCell cell, CGRect rect, NSTableColumn tableColumn, nint row, CGPoint mouse)
            {
                var programDescription = Programs.ArrangedObjects()[row] as ProgramDescriptionViewModel;
                var toolTip            = string.Empty;

                if (cell is NSImageCell)
                {
                    if (tableColumn.Identifier == "icon")
                    {
                        toolTip = programDescription.RomFileStatus;
                    }
                    else if (tableColumn.Identifier == "features")
                    {
                        var    space           = INTV.Shared.Converter.ProgramFeaturesToImageTransformer.Padding;
                        var    offsetIntoImage = mouse.X - rect.X;
                        nfloat leftEdgeOfImage = 0;
                        for (int i = 0; string.IsNullOrEmpty(toolTip) && (i < programDescription.Features.Count); ++i)
                        {
                            var feature          = programDescription.Features[i];
                            var rightEdgeOfImage = leftEdgeOfImage + feature.Image.Size.Width + (space / 2);
                            if ((leftEdgeOfImage <= offsetIntoImage) && (offsetIntoImage <= rightEdgeOfImage))
                            {
                                toolTip = feature.ToolTip;
                            }
                            else
                            {
                                leftEdgeOfImage += feature.Image.Size.Width + space;
                            }
                        }
                    }
                }
#if false
                // By leaving the string as empty, we get default behavior for tool tip, which is preferred.
                // It will display the full text only when it's too long to show in the cell.
                else if (tableColumn.Identifier == "name")
                {
                    toolTip = programDescription.Name;
                }
                else if (tableColumn.Identifier == "vendor")
                {
                    toolTip = programDescription.Vendor;
                }
#endif // false
                else if (tableColumn.Identifier == "romFile")
                {
                    toolTip = programDescription.RomFile;
                }
                return(new NSString(toolTip.SafeString()));
            }
Example #4
0
        public NetworkActionButton(NetworkAction networkAction,
                                   ViewModelNetworksSettings networksSettingsModel,
                                   float width) : base()
        {
            NetworkAction         = networkAction;
            NetworksSettingsModel = networksSettingsModel;
            const int constButtonHeight = 35;
            const int constImgHeight    = 16;

            Bordered = false;
            Title    = "";
            Frame    = new CGRect(0, 0, width, constButtonHeight);

            // wifi icon
            var wifiIconView = new NSImageView();

            wifiIconView.Frame = new CGRect(20, (constButtonHeight - constImgHeight) / 2, constImgHeight, constImgHeight);
            wifiIconView.Image = NSImage.ImageNamed("iconWiFiSmallBlue");
            AddSubview(wifiIconView);

            // title
            __Title           = UIUtils.NewLabel(networkAction.Network.SSID);
            __Title.Frame     = new CGRect(49, wifiIconView.Frame.Y, width / 2, 18);
            __Title.TextColor = NSColor.FromRgb(38, 57, 77);
            AddSubview(__Title);

            WiFiActionTypeEnum action = networkAction.Action;

            if (action == WiFiActionTypeEnum.Default)
            {
                action = networksSettingsModel.NetworkActions.DefaultActionType;
            }

            System.nfloat xpos = __Title.Frame.Width + __Title.Frame.X + 20;

            //action
            __PopUpButton          = new NSPopUpButton();
            __PopUpButton.Bordered = false;
            __PopUpButton.Frame    = new CGRect(xpos, (constButtonHeight - 24) / 2, width - xpos - 10, 24);
            AddSubview(__PopUpButton);

            networkAction.PropertyChanged += NetworkAction_PropertyChanged;
            NetworksSettingsModel.NetworkActions.PropertyChanged += NetworkActions_PropertyChanged;

            CreatePopupButtonElements();
        }
        /// <inheritdoc/>
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            View.Hidden     = true;
            View.WantsLayer = true;
            var colorSpace      = CGColorSpace.CreateDeviceRGB();
            var colorComponents = new nfloat[4];

            NSColor.LightGray.UsingColorSpace(NSColorSpace.DeviceRGB).GetComponents(out colorComponents);
            colorComponents[3]         = 0.18f;
            View.Layer.BackgroundColor = new CGColor(colorSpace, colorComponents);
            NSColor.ControlBackground.UsingColorSpace(NSColorSpace.DeviceRGBColorSpace).GetComponents(out colorComponents);
            FeedbackArea.WantsLayer            = true; // macOS 10.13 (High Sierra) changed behavior of how WantsLayer works to apparently no longer create layers for all children immediately.
            FeedbackArea.Layer.BackgroundColor = new CGColor(colorSpace, colorComponents);
            FeedbackArea.Layer.BorderWidth     = 1;
            RomListCommandGroup.CancelRomsImportCommand.Visual = Cancel;
            Cancel.Activated += HandleActivated; // Doesn't go through command mechanism
            _loadedFromNib    = true;            // FIXME This is wrong
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            if (Control != null && Element != null && !string.IsNullOrWhiteSpace(Element.Text))
            {
                var attr    = new NSAttributedStringDocumentAttributes();
                var nsError = new NSError();
                attr.DocumentType = NSDocumentType.HTML;

                UIKit.UIFont  font         = Control.Font;
                string        fontName     = font.Name;
                System.nfloat fontSize     = font.PointSize;
                string        htmlContents = "<span style=\"font-family: '" + fontName + "'; font-size: " + fontSize + "\">" + Element.Text + "</span>";
                var           myHtmlData   = NSData.FromString(htmlContents, NSStringEncoding.Unicode);
                Control.Lines          = 0;
                Control.AttributedText = new NSAttributedString(myHtmlData, attr, ref nsError);
            }
        }
        public override void ViewDidLoad()
        {
            var scrollView = new UIScrollView {
                BackgroundColor = UIColor.White, ScrollEnabled = true
            };

            System.nfloat y = 0, w = 0;
            foreach (var latex in Rendering.Tests.TestRenderingMathData.AllConstants.Values)
            {
                var latexView = IosMathLabels.MathView(latex, 50); // WJWJWJ latex here
                var size      = latexView.SizeThatFits(new CoreGraphics.CGSize(370, 280));
                latexView.Frame = new CoreGraphics.CGRect(0, y, size.Width, size.Height);
                scrollView.Add(latexView);
                y += size.Height;
                w  = size.Width > w ? size.Width : w;
                y += 10;
            }
            scrollView.ContentSize = new CoreGraphics.CGSize(w, y);
            View = scrollView;
        }
Example #8
0
            protected override UITableViewCell GetOrCreateCellFor(UITableView tableView, NSIndexPath indexPath, object item)
            {
                var cell = tableView.DequeueReusableCell(cellReuseIdentifier, indexPath);

                cell.BackgroundColor = UIColor.White;
                if (!originalLayerSet)
                {
                    cornerRadius     = cell.Layer.CornerRadius;
                    borderWidth      = cell.Layer.BorderWidth;
                    borderColor      = cell.Layer.BorderColor;
                    bgColor          = cell.BackgroundColor;
                    originalLayerSet = true;
                }
                else
                {
                    restoreCell(cell);
                }
                cell.TextLabel.Text = item.ToString();

                return(cell);
            }
 /// <inheritdoc/>
 public override nfloat ConstrainSplitPosition(NSSplitView splitView, nfloat proposedPosition, nint subviewDividerIndex)
 {
     return(proposedPosition);
 }
Example #10
0
        public static System.nfloat PlaneIntersect(SCNVector3 planeNormal, System.nfloat planeDist, SCNVector3 rayOrigin, SCNVector3 rayDirection)
#endif
        {
            return((planeDist - SCNVector3.Dot(planeNormal, rayOrigin)) / SCNVector3.Dot(planeNormal, rayDirection));
        }
 void UpdateCanvasInfo(CGRect frame, System.nfloat scale)
 {
     info = new SkiaSharp.SKImageInfo((int)(Frame.Width * scale), (int)(frame.Height * scale));
 }
Example #12
0
 public static UIKit.UIFont SFUIDisplay_Regular(System.nfloat size) => UIKit.UIFont.FromName("SFUIDisplay-Regular", size);
Example #13
0
 public static UIKit.UIFont Lato_Regular(System.nfloat size) => UIKit.UIFont.FromName("Lato-Regular", size);
Example #14
0
 public static UIKit.UIFont Lato_Bold(System.nfloat size) => UIKit.UIFont.FromName("Lato-Bold", size);