Пример #1
0
        public static StackLayout NoticeOdometerCells(int notifications, string odo, string reg)
        {
            var halfWidth = App.ScreenSize.Width / 2;

            var grid = new Grid
            {
                WidthRequest  = App.ScreenSize.Width,
                RowSpacing    = 0,
                ColumnSpacing = 0,
                HeightRequest = 40
            };

            grid.ColumnDefinitions = new ColumnDefinitionCollection
            {
                new ColumnDefinition {
                    Width = halfWidth - 1
                },
                new ColumnDefinition {
                    Width = 1
                },
                new ColumnDefinition {
                    Width = halfWidth
                },
            };
            grid.RowDefinitions = new RowDefinitionCollection
            {
                new RowDefinition {
                    Height = 1
                },
                new RowDefinition {
                    Height = 28
                },

                /*new RowDefinition {Height = 1},
                 * new RowDefinition {Height = 56},
                 * new RowDefinition {Height = 1}*/
            };

            var unreadHeader = new TextArrow(Langs.Const_Label_Notifications, halfWidth - 1, 28, true);

            unreadHeader.BackgroundColor = notifications <= 10 ? FormsConstants.AppyDarkRed : FormsConstants.AppyDarkShade;
            var odoHeader = new TextArrow(Langs.Const_Label_Odometer, halfWidth, 28, true);

            odoHeader.BackgroundColor = FormsConstants.AppyDarkShade;

            var horizLine = new BoxView {
                HeightRequest = 1, BackgroundColor = Color.White
            };
            var vertLine = new BoxView {
                HeightRequest = 28, WidthRequest = 1, BackgroundColor = Color.White
            };

            var noticationStack = new StackLayout
            {
                Padding           = new Thickness(12, 12, 0, 12),
                BackgroundColor   = notifications <= 10 ? FormsConstants.AppyRed : FormsConstants.AppyDarkShade,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                WidthRequest      = halfWidth - 1,
                HeightRequest     = 56,
                HorizontalOptions = LayoutOptions.Start,
                Children          =
                {
                    new Label
                    {
                        //Text = $"{notifications}",
                        Text       = Langs.Const_Label_Notifications,
                        TextColor  = Color.White,
                        FontFamily = Helper.RegFont,
                        //FontSize = 28
                    }
                }
            };

            noticationStack.GestureRecognizers.Add(new TapGestureRecognizer
            {
                NumberOfTapsRequired = 1,
                Command = new Command(() => MessagingCenter.Send <string>("notification", "open"))
            });

            var odoStack = new StackLayout
            {
                Padding           = new Thickness(12, 12, 0, 12),
                WidthRequest      = halfWidth,
                HeightRequest     = 56,
                BackgroundColor   = FormsConstants.AppyDarkShade,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Start,
                Orientation       = StackOrientation.Vertical,
                Children          =
                {
                    new Label
                    {
                        //Text = $"Reg {reg}",
                        Text       = Langs.Const_Label_Latest_Odometer,
                        TextColor  = Color.White,
                        FontFamily = Helper.RegFont,
                        FontSize   = 12
                    }/*,new Label
                      * {
                      * Text = odo,
                      * TextColor = Color.White,
                      * FontFamily = Helper.RegFont,
                      * FontSize = 18
                      * },*/
                }
            };

            /*grid.Children.Add(unreadHeader, 0, 0);
             * grid.Children.Add(vertLine, 1, 0);
             * grid.Children.Add(odoHeader, 2, 0);
             * grid.Children.Add(horizLine, 1, 1);*/
            grid.Children.Add(noticationStack, 0, 1);

            grid.Children.Add(odoStack, 2, 1);
            grid.Children.Add(vertLine, 1, 1);
            grid.Children.Add(horizLine, 0, 0);

            Grid.SetColumnSpan(horizLine, 4);
            Grid.SetRowSpan(vertLine, 2);

            return(new StackLayout
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                WidthRequest = App.ScreenSize.Width,
                HeightRequest = 40,
                Children = { grid }
            });
        }
Пример #2
0
    public void Render()
    {
        items = new List<CanvasItem>();
        lifeLines = new List<LifeLine>();
        Dictionary<string, LifeLine> llDict = new Dictionary<string, LifeLine>();
        double x_where = 50.5;
        double y_step = 25;
        y_current = 0;

        width = 0;
        height = 0;

        foreach(ElemObj elem in diagram.elements)
        {
            TextBox tb = new TextBox();
            tb.YTop = 10.5;
            tb.XCenter = x_where;
            x_where += 100;
            width += 100;
            tb.Width = 70;
            tb.BorderWidth = 3;
            tb.Text = elem.text;

            tb.Layout(cr);
            items.Add(tb);
            LifeLine ll = new LifeLine(elem.label, this, tb.XCenter, tb.Y1);
            lifeLines.Add(ll);
            llDict.Add(elem.label, ll);
            if(tb.Y1 > YCurrent)
            {
                YCurrent = tb.Y1;
            }
        }

        foreach(Step step in diagram.sequence)
        {
            if(step.amount == 0)
            {
                step.amount = (int)y_step;
            }

            YCurrent += step.amount;

            foreach(LifeLine ll in lifeLines)
            {
                ll.BeforeActivations();
            }

            foreach(Activation a in step.activations)
            {
                LifeLine ll = llDict[a.label];

                if(a.on)
                {
                    ll.Activate();
                }
                else
                {
                    ll.Deactivate();
                }
            }

            foreach(LifeLine ll in lifeLines)
            {
                ll.AfterActivations();
            }

            foreach(Arrow arrow in step.arrows)
            {
                TextArrow ta;
                LifeLine to = llDict[arrow.to];
                LifeLine from = llDict[arrow.from];

                if(to != from)
                {
                    ta = new TextArrow();
                    bool right = to.X > from.X;
                    ta.Y0 = YCurrent;
                    if(right)
                    {
                        ta.X0 = from.XRightAfter;
                        ta.X1 = to.XLeftAfter;
                        ta.XText = from.XClearRight;
                    }
                    else
                    {
                        ta.X0 = from.XLeftAfter;
                        ta.X1 = to.XRightAfter;
                        ta.XText = from.XClearLeft;
                    }
                }
                else
                {
                    SelfTextArrow sta = new SelfTextArrow();
                    sta.Y0 = YCurrent - 10;
                    sta.Y1 = YCurrent;
                    sta.X0 = from.XRightBefore;
                    sta.X0b = from.XRightAfter;
                    sta.X1 = from.XRightBefore + 30;
                    sta.XText = from.XClearRight;
                    ta = sta;
                }

                ta.Text = arrow.text;
                ta.ArrowKind = arrow.type;
                ta.Layout(cr);
                items.Add(ta);
            }
        }

        foreach(LifeLine ll in lifeLines)
        {
            ll.End();
        }

        height = YCurrent;
    }