public ToggleButton(string optionKey, bool selected, float width, float height)
        {
            OptionKey = optionKey;

            WidthAnchor.ConstraintEqualTo(width).Active   = true;
            HeightAnchor.ConstraintEqualTo(height).Active = true;

            Layer.CornerRadius = 5;

            Selected       = selected;
            TouchUpInside += (sender, args) => Selected = !Selected;
        }
Example #2
0
 public NSLine(NSUserInterfaceLayoutOrientation orientation, int lineWidth = 1)
 {
     BoxType = NSBoxType.NSBoxSeparator;
     if (orientation == NSUserInterfaceLayoutOrientation.Horizontal)
     {
         HeightAnchor.ConstraintEqualToConstant(lineWidth).Active = true;
     }
     else if (orientation == NSUserInterfaceLayoutOrientation.Vertical)
     {
         WidthAnchor.ConstraintEqualToConstant(lineWidth).Active = true;
     }
 }
Example #3
0
        public override void MovedToSuperview()
        {
            base.MovedToSuperview();

            TopAnchor.ConstraintEqualTo(Superview.TopAnchor).Active         = true;
            WidthAnchor.ConstraintEqualTo(Superview.WidthAnchor).Active     = true;
            CenterXAnchor.ConstraintEqualTo(Superview.CenterXAnchor).Active = true;
            //Actual value is set with bindings a few lines below
            var heightConstraint = HeightAnchor.ConstraintEqualTo(1);

            heightConstraint.Active = true;

            prepareTitleLabel();
            prepareSuggestionViews();

            SetNeedsLayout();
            LayoutIfNeeded();

            this.DelayBind(() =>
            {
                var heightConverter = new CollectionSizeToHeightConverter <Suggestion>(
                    emptyHeight: emptyHeight,
                    heightPerElement: suggestionHeight + distanceBetweenSuggestions,
                    additionalHeight: distanceAbowTitleLabel
                    + distanceBelowTitleLabel
                    + (float)titleLabel.Frame.Height
                    );
                heightConverter.MaxCollectionSize = suggestionViews.Count;

                var bindingSet = this.CreateBindingSet <SuggestionsView, SuggestionsViewModel>();

                bindingSet.Bind(this)
                .For(v => v.BindVisibility())
                .To(vm => vm.IsEmpty);

                bindingSet.Bind(heightConstraint)
                .For(c => c.BindConstant())
                .To(vm => vm.Suggestions)
                .WithConversion(heightConverter);

                for (int i = 0; i < suggestionViews.Count; i++)
                {
                    bindingSet.Bind(suggestionViews[i])
                    .For(v => v.Suggestion)
                    .To(vm => vm.Suggestions[i]);
                }

                bindingSet.Apply();
            });
        }
Example #4
0
        public override void MovedToSuperview()
        {
            base.MovedToSuperview();

            TopAnchor.ConstraintEqualTo(Superview.TopAnchor).Active         = true;
            WidthAnchor.ConstraintEqualTo(Superview.WidthAnchor).Active     = true;
            CenterXAnchor.ConstraintEqualTo(Superview.CenterXAnchor).Active = true;
            //Actual value is set with bindings a few lines below
            heightConstraint.Active = true;

            prepareTitleLabel();

            LayoutIfNeeded();
        }
Example #5
0
        private void ApplyDimensions()
        {
            if (Width == 0 && Height == 0)
            {
                return;
            }

            TranslatesAutoresizingMaskIntoConstraints = false;

            if (Width != 0)
            {
                WidthAnchor.ConstraintEqualTo(Width).Active = true;
            }
            if (Height != 0)
            {
                HeightAnchor.ConstraintEqualTo(Height).Active = true;
            }
        }
Example #6
0
 public CustomFloatingactionbutton(ActionButtonView View)
 {
     _view = View;
     SetIcon();
     Layer.CornerRadius      = (nfloat)_view.HeightRequest / 2;
     BackgroundColor         = _view.BackgroundColor.ToUIColor();
     heightConstraint        = HeightAnchor.ConstraintEqualTo((nfloat)View.HeightRequest);
     heightConstraint.Active = true;
     widthConstraint         = WidthAnchor.ConstraintEqualTo((nfloat)View.HeightRequest);
     widthConstraint.Active  = true;
     TouchDown += delegate(object sender, EventArgs e)
     {
         UIView.Animate(0.1, 0, UIViewAnimationOptions.Autoreverse,
                        () => { BackgroundColor = View.SelectedColor.ToUIColor(); },
                        () => { BackgroundColor = View.BackgroundColor.ToUIColor(); });
         View.ClickAction();
     };
     _view.PropertyChanged += _view_PropertyChanged;
 }
Example #7
0
        public CustomSearchField()
        {
            TranslatesAutoresizingMaskIntoConstraints = false;

            Cell       = cell = new SearchFieldCell(this);
            WantsLayer = true;

            var internalLayer = new CoreAnimation.CALayer();

            internalLayer.BorderWidth  = 1;
            internalLayer.BorderColor  = NSColor.FromRgba(red: 0.75f, green: 0.75f, blue: 0.75f, 0.45f).CGColor;
            internalLayer.Frame        = new CGRect(1, 0, DefaultWidth + 2, DefaultHeight);
            internalLayer.CornerRadius = 2;
            Layer.AddSublayer(internalLayer);

            Font = NSFont.SystemFontOfSize(SearchFontSize, NSFontWeight.Thin);

            //default size needs to be changed before change cell
            WidthAnchor.ConstraintEqualToConstant(DefaultWidth).Active   = true;
            HeightAnchor.ConstraintEqualToConstant(DefaultHeight).Active = true;
        }
Example #8
0
        public PinnedWatchView(PinnedWatch watch, StackFrame frame)
        {
            this.watch = watch ?? throw new ArgumentNullException(nameof(watch));
            this.frame = frame;

            controller = new ObjectValueTreeViewController();
            controller.SetStackFrame(frame);
            controller.AllowEditing   = true;
            controller.AllowExpanding = false;

            treeView = controller.GetMacControl(ObjectValueTreeViewFlags.PinnedWatchFlags);

            controller.PinnedWatch = watch;

            if (watch.Value != null)
            {
                controller.AddValue(objectValue = watch.Value);
            }

            var rect = treeView.Frame;

            if (rect.Height < 1)
            {
                treeView.Frame = new CoreGraphics.CGRect(rect.X, rect.Y, rect.Width, 19);
            }

            AddSubview(treeView);
            Frame = treeView.Frame;

            heightConstraint        = HeightAnchor.ConstraintEqualToConstant(treeView.Frame.Height);
            heightConstraint.Active = true;

            widthConstraint        = WidthAnchor.ConstraintEqualToConstant(treeView.Frame.Width);
            widthConstraint.Active = true;

            DebuggingService.ResumedEvent += OnDebuggerResumed;
            DebuggingService.PausedEvent  += OnDebuggerPaused;
            treeView.Resized += OnTreeViewResized;

            AddTrackingArea(new NSTrackingArea(
Example #9
0
        public PinnedWatchView(PinnedWatch watch, StackFrame frame)
        {
            HasVerticalScroller = true;
            AutohidesScrollers  = true;

            controller = new ObjectValueTreeViewController();
            controller.SetStackFrame(frame);
            controller.AllowEditing = true;

            treeView = controller.GetMacControl(headersVisible: false, compactView: true, allowPinning: true);

            controller.PinnedWatch = watch;

            if (watch.Value != null)
            {
                controller.AddValue(watch.Value);
            }

            var rect = treeView.Frame;

            if (rect.Height < 1)
            {
                treeView.Frame = new CoreGraphics.CGRect(rect.X, rect.Y, rect.Width, 19);
            }

            DocumentView = treeView;
            Frame        = treeView.Frame;

            heightConstraint        = HeightAnchor.ConstraintEqualToConstant(treeView.Frame.Height);
            heightConstraint.Active = true;

            widthConstraint        = WidthAnchor.ConstraintEqualToConstant(treeView.Frame.Width);
            widthConstraint.Active = true;

            DebuggingService.ResumedEvent += OnDebuggerResumed;
            DebuggingService.PausedEvent  += OnDebuggerPaused;
            treeView.Resized += OnTreeViewResized;
        }