void CreateFilters(FileFilter [] filters) { if (filters.Any()) { var label = new NSTextField(); var fileTypes = new NSPopUpButton(); fileTypes.AddItems(filters.Select(f => f.Label).ToArray()); var fileTypeView = new NSView(); fileTypeView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; const int padding = 15; label.StringValue = "Show Files"; label.DrawsBackground = false; label.Bordered = false; label.Bezeled = false; label.Editable = false; label.Selectable = false; label.SizeToFit(); fileTypeView.AddSubview(label); fileTypes.SizeToFit(); fileTypes.Activated += (sender, e) => { var currentFilter = filters.FirstOrDefault(f => f.Label == fileTypes.TitleOfSelectedItem); SetCurrentItem(currentFilter); // THIS DOES NOT WORK ON MAC OS FROM MAVERICS TO YOSEMITE // There exists hacks, however they are dependent on OS X version // I have filed bug as many others, but I guess this will never be fixed _panel.ValidateVisibleColumns(); _panel.Update(); }; fileTypeView.AddSubview(fileTypes); fileTypes.SetFrameOrigin(new CGPoint(label.Frame.Width + 10, padding)); label.SetFrameOrigin(new CGPoint(0, padding + (fileTypes.Frame.Height - label.Frame.Height) / 2)); fileTypeView.Frame = new CGRect(0, 0, fileTypes.Frame.Width + label.Frame.Width + 10, fileTypes.Frame.Height + padding * 2); _panel.AccessoryView = fileTypeView; if (filters.Any()) { SetCurrentItem(filters.First()); } } else { _panel.AccessoryView = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); var gradientLayer = new CAGradientLayer(); List <CGColor> colors = new List <CGColor>(); colors.Add(OxyColors.GreenYellow.ToCGColor()); colors.Add(OxyColors.LightSkyBlue.ToCGColor()); gradientLayer.Colors = colors.ToArray(); gradientLayer.StartPoint = new CGPoint(.0, 1.0); gradientLayer.EndPoint = new CGPoint(.0, .0); IntervalCell.StringValue = "10.8\n0.7"; IntervalCell.Bordered = true; IntervalCell.Font = NSFont.FromFontName("Helvetica Neue", 11); gradientLayer.Frame = new CGRect(new CGPoint(0, 0), IntervalCell.FittingSize); IntervalCellStack.SetFrameSize(IntervalCell.FittingSize); IntervalCellStack.AutoresizesSubviews = true; IntervalCellStack.WantsLayer = true; IntervalCellStack.Layer.AddSublayer(gradientLayer); var exprView = new NSTextField { Alignment = NSTextAlignment.Center, Selectable = false, Editable = false, DrawsBackground = false, Bordered = false, LineBreakMode = NSLineBreakMode.Clipping, Font = NSFont.FromFontName("Helvetica Neue", 11) }; exprView.StringValue = "12"; exprView.RotateByAngle(90); exprView.SetFrameOrigin(new CGPoint(167, 76)); exprView.SetFrameSize(new CGSize(13, 28)); var line = new NSBox { BoxType = NSBoxType.NSBoxSeparator }; line.SetFrameSize(new CGSize(2, 23)); line.SetFrameOrigin(new CGPoint(163, 79)); View.AddSubview(exprView); View.AddSubview(line); }
void RecalculateSizes() { if (logo != null) { logo.Frame = new CGRect(14, (FixedButtonHeight / 2) - (logo.Frame.Height / 2), logo.Frame.Width, logo.Frame.Height); } if (label != null) { nfloat fontY = label.IntrinsicContentSize.Height / 2f; var leftPadding = logo != null ? 15 : 6; label.SetFrameOrigin(new CGPoint(leftPadding + (FixedButtonWidth / 2) - (label.IntrinsicContentSize.Width / 2), (FixedButtonHeight / 2) - fontY)); } }
void Create() { if (Control.AccessoryView != null) { return; } var fileTypeView = new NSView(); fileTypeView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; const int padding = 15; if (Widget.Filters.Count > 0) { var label = new NSTextField(); label.StringValue = "Format"; label.DrawsBackground = false; label.Bordered = false; label.Bezeled = false; label.Editable = false; label.Selectable = false; label.SizeToFit(); fileTypeView.AddSubview(label); fileTypes.SizeToFit(); fileTypes.Activated += (sender, e) => { SetCurrentItem(); Control.ValidateVisibleColumns(); Control.Update(); }; fileTypeView.AddSubview(fileTypes); fileTypes.SetFrameOrigin(new CGPoint((nfloat)label.Frame.Width + 10, padding)); label.SetFrameOrigin(new CGPoint(0, (nfloat)(padding + (fileTypes.Frame.Height - label.Frame.Height) / 2))); fileTypeView.Frame = new CGRect(0, 0, (nfloat)(fileTypes.Frame.Width + label.Frame.Width + 10), (nfloat)(fileTypes.Frame.Height + padding * 2)); Control.AccessoryView = fileTypeView; SetCurrentItem(); } else { Control.AccessoryView = null; } }
void Create() { if (Control.AccessoryView != null) { return; } var fileTypeView = new NSView(); fileTypeView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable; int padding = 15; if (macfilters != null && macfilters.Count > 0) { var label = new NSTextField(); label.StringValue = "Format"; label.DrawsBackground = false; label.Bordered = false; label.Bezeled = false; label.Editable = false; label.Selectable = false; label.SizeToFit(); fileTypeView.AddSubview(label); fileTypes.SizeToFit(); fileTypes.Activated += (sender, e) => { SetFilters(); Control.ValidateVisibleColumns(); // SetFilters (); Control.Update(); }; fileTypeView.AddSubview(fileTypes); fileTypes.SetFrameOrigin(new System.Drawing.PointF(label.Frame.Width + 10, padding)); label.SetFrameOrigin(new System.Drawing.PointF(0, padding + (fileTypes.Frame.Height - label.Frame.Height) / 2)); fileTypeView.Frame = new System.Drawing.RectangleF(0, 0, fileTypes.Frame.Width + label.Frame.Width + 10, fileTypes.Frame.Height + padding * 2); Control.AccessoryView = fileTypeView; } else { Control.AccessoryView = null; } }
void SetupDMXView() { float textWidth = 35; float textHeight = 20; float width = (float)dataView.Frame.Width; float height = (float)dataView.Frame.Height; int itemsPerRow = (int)(width / textWidth); int heightIndex = 0; for (int i = 0; i < dataViews.Length; i++) { if (i % itemsPerRow == 0) { heightIndex++; } var view = new NSTextField(); view.Alignment = NSTextAlignment.Center; view.SetFrameSize(new CGSize(textWidth, textHeight)); view.StringValue = "0"; view.Editable = false; view.Selectable = false; view.BackgroundColor = NSColor.FromRgba(color.RedComponent, color.GreenComponent, color.BlueComponent, 0); view.Bordered = false; float x = textWidth * (i % itemsPerRow); float y = height - (textHeight * heightIndex); view.SetFrameOrigin(new CGPoint(x, y)); dataViews[i] = view; dataView.AddSubview(view); } }
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); }
public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { NSClipView view = (NSClipView)outlineView.MakeView(CellIdentifier, this); NSTextField exprView = (NSTextField)(view == null ? null : view.Subviews[0]); NSTextField textView; NSTextField textView1 = (NSTextField)(view == null ? null : view.Subviews[3]); // Cast item var interval = item as Interval; if (view == null) { view = new NSClipView { Identifier = CellIdentifier, AutoresizesSubviews = true, BackgroundColor = NSColor.Clear, AutoresizingMask = NSViewResizingMask.WidthSizable, WantsLayer = true }; 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)); NSBox line = new NSBox { BoxType = NSBoxType.NSBoxSeparator }; line.SetFrameSize(new CGSize(2, 23)); line.SetFrameOrigin(new CGPoint(exprView.Frame.Width + 3, 5)); textView = new NSTextField { Selectable = false, Editable = false, DrawsBackground = false, Bordered = false }; textView.StringValue = "Время вып.\nКоэф.эффект."; textView.SetFrameSize(textView.FittingSize); textView.SetFrameOrigin(new CGPoint(line.Frame.Location.X + 10, 0)); textView1 = new NSTextField { Selectable = false, Editable = false, DrawsBackground = false, Bordered = false }; textView1.SetFrameOrigin(new CGPoint(textView.Frame.Location.X + textView.Frame.Width + 3, 0)); view.AddSubview(exprView); view.AddSubview(line); view.AddSubview(textView); view.AddSubview(textView1); } CAGradientLayer gradientLayer = new CAGradientLayer(); List<CGColor> colors = new List<CGColor>(); colors.Add(OxyColors.Transparent.ToCGColor()); if (interval.Info.times.comm >= 0.2 * viewController.plotStatMaxTime) { colors.Insert(0, OxyColors.Transparent.ToCGColor()); colors.Add(OxyColors.GreenYellow.ToCGColor()); } if (interval.Info.times.idle >= 0.2 * viewController.plotStatMaxTime) { colors.Insert(0, OxyColors.Transparent.ToCGColor()); colors.Add(OxyColors.LightSkyBlue.ToCGColor()); } if (interval.Info.times.insuf_user >= 0.2 * viewController.plotStatMaxTime) { colors.Insert(0, OxyColors.Transparent.ToCGColor()); colors.Add(OxyColors.Orchid.ToCGColor()); } if (interval.Info.times.insuf_sys >= 0.2 * viewController.plotStatMaxTime) { colors.Insert(0, OxyColors.Transparent.ToCGColor()); colors.Add(OxyColors.Pink.ToCGColor()); } if (colors.Count == 1) colors.Add(colors[0]); gradientLayer.Colors = colors.ToArray(); gradientLayer.StartPoint = new CGPoint(.0, .0); gradientLayer.EndPoint = new CGPoint(1.0, .0); view.Layer = gradientLayer; // Setup view based on the column selected 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; } textView1.StringValue = "➢ " + interval.Info.times.exec_time.ToString("F3") + "s\n" + "➢ " + interval.Info.times.efficiency.ToString("F3"); textView1.SetFrameSize(textView1.FittingSize); return view; }