// This sets up a NSTableView for demonstration internal static NSView SetupTableView(CGRect frame) { // Create our NSTableView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSTableView tableView = new NSTableView() { Frame = frame }; // Just like NSOutlineView, NSTableView expects at least one column tableView.AddColumn(new NSTableColumn("Values")); tableView.AddColumn(new NSTableColumn("Data")); // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. tableView.DataSource = new TableDataSource(); tableView.Delegate = new TableDelegate(); // NSTableView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView(frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = tableView; return(clipView); }
// This sets up a NSOutlineView for demonstration internal static NSView SetupOutlineView (CGRect frame) { // Create our NSOutlineView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSOutlineView outlineView = new NSOutlineView () { Frame = frame }; // Every NSOutlineView must have at least one column or your Delegate will not be called. NSTableColumn column = new NSTableColumn ("Values"); outlineView.AddColumn (column); // You must set OutlineTableColumn or the arrows showing children/expansion will not be drawn outlineView.OutlineTableColumn = column; // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. outlineView.Delegate = new OutlineViewDelegate (); outlineView.DataSource = new OutlineViewDataSource (); // NSOutlineView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView (frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = outlineView; return clipView; }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { // Get the cell view NSView cellview = tableView.MakeView(_cellIdentifier, this); // Get the data for the row ScreeningsPlan plan = _dataSource.Plan; DateTime day = plan.CurrDay; Screen screen = plan.CurrDayScreens[(int)row]; // Setup view based on the column selected switch (tableColumn.Identifier) { case "Screens": NSTextField label = (NSTextField)cellview; PopulateScreens(ref label); label.StringValue = screen.ToString(); return(label); case "Screenings": NSClipView clipview = (NSClipView)cellview; PopulateScreenings(ref clipview); _screeningsView.DrawScreenings(clipview, plan, day, screen); return(clipview); } return(cellview); }
// This sets up a NSOutlineView for demonstration internal static NSView SetupOutlineView(CGRect frame) { // Create our NSOutlineView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSOutlineView outlineView = new NSOutlineView() { Frame = frame }; // Every NSOutlineView must have at least one column or your Delegate will not be called. NSTableColumn column = new NSTableColumn("Values"); outlineView.AddColumn(column); // You must set OutlineTableColumn or the arrows showing children/expansion will not be drawn outlineView.OutlineTableColumn = column; // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. outlineView.Delegate = new OutlineViewDelegate(); outlineView.DataSource = new OutlineViewDataSource(); // NSOutlineView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView(frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = outlineView; return(clipView); }
public CodeEditorControlHandler() { try { te = new Controls.Mac.TextEditor(); te.Font = NSFont.FromFontName("Menlo", 11.0f); te.Editable = true; te.Selectable = true; te.AutoresizingMask = NSViewResizingMask.WidthSizable; te.MaxSize = new CGSize(1000, 10000000); te.Formatter = new LanguageFormatter(te, new PythonDescriptor()); sv = new NSScrollView { AutoresizesSubviews = true, BorderType = NSBorderType.NoBorder, HasVerticalScroller = true, HasHorizontalScroller = true, AutoresizingMask = NSViewResizingMask.WidthSizable }; var cv = new NSClipView { AutoresizesSubviews = true }; cv.DocumentView = te; sv.ContentView = cv; this.Control = sv; te.BecomeFirstResponder(); } catch (Exception ex) { string configfiledir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Documents", "DWSIM Application Data"); if (!Directory.Exists(configfiledir)) { Directory.CreateDirectory(configfiledir); } File.WriteAllText(System.IO.Path.Combine(configfiledir, "lasterror2.txt"), ex.ToString()); } }
void PopulateScreenings(ref NSClipView clipview) { if (clipview == null) { clipview = new NSClipView { Identifier = _cellIdentifier, DrawsBackground = false }; } }
public void NSClipViewConstrainBoundsRect() { Asserts.EnsureMavericks(); var clipView = new NSClipView(new CGRect(0, 0, 50, 50)); var rect = clipView.ConstrainBoundsRect(new CGRect(10, 10, 30, 30)); Assert.IsTrue(rect.X == 0, "NSClipViewConstrainBoundsRect - X value was not 0"); Assert.IsTrue(rect.Y == 0, "NSClipViewConstrainBoundsRect - Y value was not 0"); Assert.IsTrue(rect.Width == 30, "NSClipViewConstrainBoundsRect - Width value was not 30"); Assert.IsTrue(rect.Height == 30, "NSClipViewConstrainBoundsRect - Height value was not 30"); }
public override void ViewFrameDidChange(RectangleF newFrame) { base.ViewFrameDidChange(newFrame); // We need to recalculate the frame of the NSTextView when the frame changes. // This happens when a tab is created and when it's moved between windows. NSClipView clipView = (NSClipView)View.Subviews[0]; NSTextView tv = (NSTextView)clipView.Subviews[clipView.Subviews.Length - 1]; RectangleF frame = RectangleF.Empty; frame.Size = ((NSScrollView)View).ContentSize; tv.Frame = frame; }
private void PopulateControl(ref NSClipView control, NSTableColumn column) { if (control == null) { var side = column.TableView.RowHeight; control = new NSClipView { Identifier = column.Identifier, DrawsBackground = false, AutoresizingMask = NSViewResizingMask.WidthSizable, Frame = new CGRect(0, 0, side, side) }; } }
public void DrawScreenings(NSClipView view, ScreeningsPlan plan, DateTime day, Screen screen) { DisposeSubViews(view); var currScreening = plan.CurrScreening; var elegableScreenings = plan.ScreenScreenings[day][screen] .Where(s => s.Film.FilmInfo.CombinationProgramIds.Count == 0); foreach (var screening in elegableScreenings) { _controller.UpdateWarning(screening); _labelLeft = _superView.NumberOfPixelsFromTime(screening.StartTime); _labelWidth = _superView.NumberOfPixelsFromDuration(screening.Duration); CGRect rect = new CGRect(_labelLeft, _labelTop, _labelWidth, _labelHeight); var screeningControl = new ScreeningControl(rect, screening); screeningControl.Selected = screening == currScreening; screeningControl.ScreeningSelected += (s, e) => SegueToScreeningWindow((ScreeningControl)s); view.AddSubview(screeningControl); _controller.AddScreeningControl(screening, screeningControl); } }
public CodeEditorControlHandler() { //te = new Controls.Mac.TextEditor(); te = new NSTextView(); te.Font = NSFont.FromFontName("Menlo", 11.0f); te.Editable = true; te.Selectable = true; te.AutoresizingMask = NSViewResizingMask.WidthSizable; te.MaxSize = new CGSize(1000, 10000000); //te.Formatter = new LanguageFormatter(te, new PythonDescriptor()); sv = new NSScrollView { AutoresizesSubviews = true, BorderType = NSBorderType.NoBorder, HasVerticalScroller = true, HasHorizontalScroller = true, AutoresizingMask = NSViewResizingMask.WidthSizable }; var cv = new NSClipView { AutoresizesSubviews = true }; cv.DocumentView = te; sv.ContentView = cv; this.Control = sv; te.BecomeFirstResponder(); }
public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // Get the view cell. NSView cellView = outlineView.MakeView(tableColumn.Title, this); // Cast item. var filmOutlinable = item as IFilmOutlinable; // Setup view based on the column selected. switch (tableColumn.Title) { case "Not planned films": var filmLabel = (NSTextField)cellView; PopulateLabel(ref filmLabel, tableColumn.Title); filmOutlinable.SetTitle(filmLabel); return(filmLabel); case "Rating": var ratingLabel = (NSTextField)cellView; PopulateLabel(ref ratingLabel, tableColumn.Title); filmOutlinable.SetRating(ratingLabel); return(ratingLabel); case "Go": NSClipView control = (NSClipView)cellView; PopulateControl(ref control, tableColumn); filmOutlinable.SetGo(control); return(control); case "Info": var infoLabel = (NSTextField)cellView; PopulateLabel(ref infoLabel, tableColumn.Title); filmOutlinable.SetInfo(infoLabel); return(infoLabel); } return(cellView); }
// This sets up a NSTableView for demonstration internal static NSView SetupTableView (CGRect frame) { // Create our NSTableView and set it's frame to a reasonable size. It will be autosized via the NSClipView NSTableView tableView = new NSTableView () { Frame = frame }; // Just like NSOutlineView, NSTableView expects at least one column tableView.AddColumn (new NSTableColumn ("Values")); tableView.AddColumn (new NSTableColumn ("Data")); // Setup the Delegate/DataSource instances to be interrogated for data and view information // In Unified, these take an interface instead of a base class and you can combine these into // one instance. tableView.DataSource = new TableDataSource (); tableView.Delegate = new TableDelegate (); // NSTableView expects to be hosted inside an NSClipView and won't draw correctly otherwise NSClipView clipView = new NSClipView (frame) { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; clipView.DocumentView = tableView; return clipView; }
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; }