private ChannelGroup CreateEditor(IHostResourceProvider hostResources, ChannelEditor editor)
        {
            var ce = new ChannelGroup {
                Label = new UnfocusableTextField {
                    StringValue = $"{editor.Name}:",
                    Alignment   = NSTextAlignment.Right,
                    ToolTip     = editor.ToolTip
                },
                Editor = new ComponentSpinEditor(hostResources, editor)
                {
                    BackgroundColor = NSColor.Clear,
                    TranslatesAutoresizingMaskIntoConstraints = true
                },
                Gradient = new UnanimatedGradientLayer {
                    StartPoint  = new CGPoint(0, 0),
                    EndPoint    = new CGPoint(1, 0),
                    BorderWidth = .5f,
                }
            };

            ce.Editor.ValueChanged += UpdateComponent;
            ce.Editor.EditingEnded += UpdateComponent;
            AddSubview(ce.Label);
            AddSubview(ce.Editor);

            Layer.AddSublayer(ce.Gradient);
            return(ce);
        }
Esempio n. 2
0
 public ComponentSpinEditor(IHostResourceProvider hostResources, ChannelEditor component)
     : base(hostResources)
 {
     ComponentEditor = component;
     MinimumValue    = component.MinimumValue;
     MaximumValue    = component.MaximumValue;
     IncrementValue  = component.IncrementValue;
     Digits          = 3;
     FocusedFormat   = component.FocusedFormat;
     DisplayFormat   = component.DisplayFormat;
     if (Formatter is NSNumberFormatter numberFormatter && DisplayFormat != null)
     {
         numberFormatter.PositiveFormat = DisplayFormat;
     }
 }