Exemplo n.º 1
0
        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);
        }
        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);
        }
Exemplo n.º 3
0
        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;
        }