NSView CreateRow(string label, string [] items, int selectedItem, Action <int> handler) { var stackView = new NSStackView { Orientation = NSUserInterfaceLayoutOrientation.Horizontal, Distribution = NSStackViewDistribution.Fill, Spacing = 8 }; var labelView = new Views.XILabel { StringValue = label }; labelView.SizeToFit(); stackView.AddView(labelView, NSStackViewGravity.Leading); var menuView = new NSPopUpButton(); menuView.AddItems(items); menuView.SelectItem(selectedItem); stackView.AddView(menuView, NSStackViewGravity.Trailing); menuView.Activated += (sender, e) => handler((int)menuView.IndexOfSelectedItem); return(stackView); }
public override void LoadView() { var stack = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Vertical }; this.materialEditor = new MaterialView { ViewModel = ViewModel?.MaterialDesign }; this.alphaChannelEditor = new AlphaChannelEditor(); this.alphaSpinEditor = new ComponentSpinEditor(this.hostResources, this.alphaChannelEditor) { BackgroundColor = NSColor.Clear }; this.alphaSpinEditor.ValueChanged += UpdateComponent; var alphaStack = new NSStackView() { Orientation = NSUserInterfaceLayoutOrientation.Horizontal }; var alphaLabel = new UnfocusableTextField { StringValue = $"{Properties.Resources.Alpha}:", Alignment = NSTextAlignment.Left, }; alphaLabel.Cell.LineBreakMode = NSLineBreakMode.Clipping; alphaStack.AddView(alphaLabel, NSStackViewGravity.Trailing); alphaStack.AddView(this.alphaSpinEditor, NSStackViewGravity.Trailing); stack.AddView(this.materialEditor, NSStackViewGravity.Leading); stack.AddView(alphaStack, NSStackViewGravity.Trailing); View = stack; }
public void GenerateStatusView(List <string> elements) { CleanViews(); NSTextField label = null; foreach (var item in elements) { label = GetLabel(item); stackContainer.AddView(label, NSStackViewGravity.Leading); var content = label.GetContentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Vertical); label.SetContentHuggingPriorityForOrientation(750, NSLayoutConstraintOrientation.Vertical); } if (label != null) { label.SetContentHuggingPriorityForOrientation(300, NSLayoutConstraintOrientation.Vertical); } }
public void NSStackViewShouldAddView() { view.AddView(new NSView(), NSStackViewGravity.Bottom); Assert.IsTrue(view.Views.Length == 1, "NSStackViewShouldAddView - Failed to add view - length was 0"); }
public override bool PrepareSavePanel(NSSavePanel savePanel) { workbookSaveOperation = Session.CreateWorkbookSaveOperation(); if (workbookSaveOperation.SupportedOptions == WorkbookSaveOptions.None) { return(true); } var stackView = new NSStackView { Orientation = NSUserInterfaceLayoutOrientation.Vertical, Spacing = 8, EdgeInsets = new NSEdgeInsets(12, 12, 12, 12) }; Action <NSView> addRow = row => { stackView.AddView(row, NSStackViewGravity.Top); stackView.AddConstraint(NSLayoutConstraint.Create( row, NSLayoutAttribute.Width, NSLayoutRelation.Equal, stackView, NSLayoutAttribute.Width, 1, 0)); }; if (workbookSaveOperation.SupportedOptions.HasFlag(WorkbookSaveOptions.Archive)) { addRow(CreateRow( Catalog.GetString("Workbook Format:"), new [] { Catalog.GetString("Package Directory"), Catalog.GetString("Archive") }, workbookSaveOperation.Options.HasFlag(WorkbookSaveOptions.Archive) ? 1 : 0, index => { switch (index) { case 0: workbookSaveOperation.Options &= ~WorkbookSaveOptions.Archive; break; case 1: workbookSaveOperation.Options |= WorkbookSaveOptions.Archive; break; default: throw new IndexOutOfRangeException(); } })); } #if false // stubbed UI for signing is unused for now if (workbookSaveOperation.SupportedOptions.HasFlag(WorkbookSaveOptions.Sign)) { addRow(CreateRow( Catalog.GetString("Signing Key:"), new [] { Catalog.GetString("None") }, 0, index => { })); } #endif savePanel.AccessoryView = stackView; return(true); }
public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // 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 NSClipView view = (NSClipView)outlineView.MakeView(CellIdentifier, this); NSTextField exprView = (NSTextField)(view == null ? null : view.Subviews[0]); NSBox line = (NSBox)(view == null ? null : view.Subviews[1]); // Cast item var interval = item as Interval; var intervals = ViewController.CompareList.IntervalsList[interval.Row]; if (view == null) { view = new NSClipView { Identifier = CellIdentifier, AutoresizesSubviews = true, DrawsBackground = false, WantsLayer = true, AutoresizingMask = NSViewResizingMask.WidthSizable }; exprView = new NSTextField { Alignment = NSTextAlignment.Center, Selectable = false, Editable = false, DrawsBackground = false, Bordered = false, LineBreakMode = NSLineBreakMode.Clipping }; exprView.RotateByAngle(-90); exprView.SetFrameOrigin(new CGPoint(0, 2)); exprView.SetFrameSize(new CGSize(13, 28)); line = new NSBox { BoxType = NSBoxType.NSBoxSeparator }; line.SetFrameSize(new CGSize(2, 23)); line.SetFrameOrigin(new CGPoint(exprView.Frame.Width + 3, 5)); view.AddSubview(exprView); view.AddSubview(line); } else { for (int i = view.Subviews.Length - 1; i > 1; --i) { view.Subviews[i].RemoveFromSuperview(); } } if (ViewController.CompareList.GetCount() <= 4) { view.Layer = null; //--- Создаем ячейки для интервалов ---// nfloat offset = 0; for (var i = intervals.Count - 1; i >= 0; --i) { var gradientLayer = MakeGradLayer(intervals[i]); var interStack = new NSStackView { Orientation = NSUserInterfaceLayoutOrientation.Vertical, WantsLayer = true, AutoresizesSubviews = false }; var val = new NSTextField { Alignment = NSTextAlignment.Center, Selectable = false, Editable = false, DrawsBackground = false, Bordered = false, BackgroundColor = NSColor.Clear, WantsLayer = true }; val.StringValue = intervals[i].times.exec_time.ToString("F1") + "\n" + intervals[i].times.efficiency.ToString("F1"); gradientLayer.Frame = new CGRect(new CGPoint(0, 0), val.FittingSize); interStack.Layer.InsertSublayerBelow(gradientLayer, val.Layer); interStack.Alignment = NSLayoutAttribute.CenterY; interStack.SetFrameSize(val.FittingSize); interStack.AddView(val, NSStackViewGravity.Top); offset += val.FittingSize.Width; interStack.AutoresizingMask = NSViewResizingMask.MinXMargin; interStack.SetFrameOrigin(new CGPoint(view.Bounds.Width - offset, 0)); view.AddSubview(interStack); } } else { int maxNum, minNum, maxLostNum; (maxNum, minNum, maxLostNum) = GetMaxMinStats(intervals); NSTextField textView = new NSTextField { Selectable = false, Editable = false, DrawsBackground = false, Bordered = false }; textView.StringValue = "Max " + ViewController.CompareList .At(maxNum).Info.p_heading.Replace('*', 'x') + "\nMin " + ViewController.CompareList .At(minNum).Info.p_heading.Replace('*', 'x'); textView.SetFrameSize(textView.FittingSize); textView.SetFrameOrigin(new CGPoint(line.Frame.Location.X + 10, 0)); NSTextField textView1 = new NSTextField { Selectable = false, Editable = false, DrawsBackground = false, Bordered = false }; textView1.SetFrameOrigin(new CGPoint(textView.Frame.Location.X + textView.Frame.Width + 4, 0)); textView1.StringValue = " ➢ " + intervals[maxNum].times.exec_time.ToString("F3") + "s\n" + " ➢ " + intervals[minNum].times.exec_time.ToString("F3") + "s"; textView1.SetFrameSize(textView1.FittingSize); var gradientLayer = MakeGradLayer(intervals[maxLostNum], false); view.WantsLayer = true; view.Layer = gradientLayer; view.AddSubview(textView); view.AddSubview(textView1); } //--- Устанавливаем значение Expr ---// switch (interval.Info.id.t) { case (int)InterTypes.USER: exprView.StringValue = interval.Info.id.expr.ToString(); break; case (int)InterTypes.SEQ: exprView.StringValue = "Посл"; exprView.Font = NSFont.FromFontName("Helvetica Neue", 10); break; case (int)InterTypes.PAR: exprView.StringValue = "Пар"; exprView.Font = NSFont.FromFontName("Helvetica Neue", 10); break; } return(view); }