internal void RepositionStatusIcons() { nfloat right = Frame.Width - 6; foreach (var item in statusIcons) { right -= item.Bounds.Width + 1; item.Frame = new CGRect(right, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 4 : 3, item.Bounds.Width, item.Bounds.Height); } PositionBuildResults(right); PositionCancelButton(right); right -= 2; if (!cancelButton.Hidden) // We have a cancel button. { right = cancelButton.Frame.X; } else if (!buildResults.Hidden) // We have a build result layer. { right = buildResults.Frame.X; } textField.SetFrameSize(new CGSize(right - 3 - textField.Frame.Left, Frame.Height)); }
public FixedFlatButton(string title, NSView logo = null) { Alignment = NSTextAlignment.Center; WantsLayer = true; BezelStyle = NSBezelStyle.ShadowlessSquare; ShowsBorderOnlyWhileMouseInside = true; Layer.CornerRadius = 3; BackgroundColor = NSColor.Clear; BorderColor = NSColor.White; BorderWidth = 1.0f; Title = ""; if (logo != null) { this.logo = logo; AddSubview(logo); } label = ViewsHelper.CreateLabel(title); label.StringValue = title; label.Alignment = NSTextAlignment.Center; label.TextColor = NSColor.White; label.Font = NSFont.SystemFontOfSize(15); label.SetFrameSize(label.IntrinsicContentSize); AddSubview(label); //WidthAnchor.ConstraintEqualToConstant(FixedButtonWidth).Active = true; //HeightAnchor.ConstraintEqualToConstant(FixedButtonHeight).Active = true; RecalculateSizes(); }
private void DisplayResults(string resultText) { _filmsDocumentView.StringValue = resultText; var fit = _filmsDocumentView.SizeThatFits(_filmsDocumentView.Frame.Size); _filmsDocumentView.SetFrameSize(fit); var yScroll = _filmsDocumentView.Frame.Height - _filmsScrollView.Frame.Height; _filmsScrollView.ContentView.ScrollToPoint(new CGPoint(0, yScroll)); }
internal void RepositionStatusIcons() { nfloat right = Frame.Width; foreach (var item in statusIcons) { right -= item.Bounds.Width + 6; item.Frame = new CGRect(right, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 5 : 4, item.Bounds.Width, item.Bounds.Height); } PositionBuildResults(right); if (!buildResults.Hidden) // We have a build result layer. { textField.SetFrameSize(new CGSize(buildResults.Frame.X - 6 - textField.Frame.Left, Frame.Height)); } else { textField.SetFrameSize(new CGSize(right - 6 - textField.Frame.Left, Frame.Height)); } }
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); }
private NSTextField MakeLabel(string s, bool bold = false) { var label = new NSTextField { Bordered = false, Editable = false, DrawsBackground = false, Font = NSFont.FromFontName("Helvetica Neue" + (bold ? " Bold" : ""), 11), StringValue = s }; label.SetFrameSize(label.FittingSize); return(label); }
private void CreateFilmSummaryBox(float boxHeight) { // Create a text box to contain the film info. var docRect = new CGRect(0, 0, _contentWidth, _summaryBoxHeight); _summaryField = new NSTextField(docRect); InitiateSummaryFieldText(); var fit = _summaryField.SizeThatFits(_summaryField.Frame.Size); _summaryField.SetFrameSize(fit); // Create a scroll view to display the film info. _yCurr -= boxHeight; var rect = new CGRect(_xMargin, _yCurr, _contentWidth, boxHeight); _summaryScrollView = ControlsFactory.NewStandardScrollView(rect, _summaryField); _summaryScrollView.ContentView.ScrollToPoint(new CGPoint(0, 0)); View.AddSubview(_summaryScrollView); }
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 StatusBar() { AllowsEditingTextAttributes = Selectable = Editable = false; textField.Cell = new VerticallyCenteredTextFieldCell(yOffset: -0.5f); textField.Cell.StringValue = ""; textField.Cell.PlaceholderAttributedString = GetStatusString(BrandingService.ApplicationName, NSColor.DisabledControlText); imageView.Image = ImageService.GetIcon(Stock.StatusSteady).ToNSImage(); // Fixes a render glitch of a whiter bg than the others. if (MacSystemInformation.OsVersion >= MacSystemInformation.Yosemite) { BezelStyle = NSTextFieldBezelStyle.Rounded; } WantsLayer = true; Layer.CornerRadius = MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 6 : 4; ctxHandler = new StatusBarContextHandler(this); updateHandler = delegate { int ec = 0, wc = 0; foreach (Task t in TaskService.Errors) { if (t.Severity == TaskSeverity.Error) { ec++; } else if (t.Severity == TaskSeverity.Warning) { wc++; } } DispatchService.GuiDispatch(delegate { if (ec > 0) { buildResultVisible = true; buildResultText.AttributedString = new NSAttributedString(ec.ToString(), foregroundColor: NSColor.Text, font: NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize - 1)); buildResultText.ContentsScale = Window.BackingScaleFactor; buildResultIcon.SetImage(buildImageId = "md-status-error-count", Window.BackingScaleFactor); } else if (wc > 0) { buildResultVisible = true; buildResultText.AttributedString = new NSAttributedString(wc.ToString(), foregroundColor: NSColor.Text, font: NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize - 1)); buildResultText.ContentsScale = Window.BackingScaleFactor; buildResultIcon.SetImage(buildImageId = "md-status-warning-count", Window.BackingScaleFactor); } else { buildResultVisible = false; } CATransaction.DisableActions = true; nfloat buildResultPosition = DrawBuildResults(); CATransaction.DisableActions = false; if (buildResultPosition == nfloat.PositiveInfinity) { return; } textField.SetFrameSize(new CGSize(buildResultPosition - 6 - textField.Frame.Left, Frame.Height)); }); }; updateHandler(null, null); TaskService.Errors.TasksAdded += updateHandler; TaskService.Errors.TasksRemoved += updateHandler; NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidChangeBackingPropertiesNotification, notif => DispatchService.GuiDispatch(() => { if (Window == null) { return; } ReconstructString(updateTrackingAreas: true); foreach (var layer in Layer.Sublayers) { if (layer.Name != null && layer.Name.StartsWith(StatusIconPrefixId, StringComparison.Ordinal)) { layer.SetImage(layerToStatus [layer.Name].Image, Window.BackingScaleFactor); } } if (buildResultVisible) { buildResultIcon.SetImage(buildImageId, Window.BackingScaleFactor); buildResultText.ContentsScale = Window.BackingScaleFactor; } })); AddSubview(imageView); AddSubview(textField); }
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; }