private void AddTimeAnchor(int hour, int minute, int second, TransactionBoxControl boxControl,
                                   TransactionEvent transactionEvent)
        {
            var timeEvent = new TimeLineEvent(boxControl.Transaction.Identificator, transactionEvent, boxControl.HighlightColor);
            var anchor    = new FullTimeAnchor(hour, minute, second, currentX, timeEvent, transactionEvent.Completion);

            anchors.Add(anchor);

            layout.Children.Add(anchor, xConstraint: Constraint.RelativeToParent(p => anchor.LeftX));
            scrollView.ScrollToAsync(anchor, ScrollToPosition.End, true);

            currentX += (float)anchor.Width + FullTimeSpacing;
        }
        private void AddHourMinuteAnchor(TransactionBoxControl boxControl, TransactionEvent transactionEvent, int hour, int minute)
        {
            var timeEvent =
                new TimeLineEvent(boxControl.Transaction.Identificator, transactionEvent, boxControl.HighlightColor);
            var item = new HourMinuteAnchor(hour, minute, currentX, timeEvent, transactionEvent.Completion)
            {
                // BackgroundColor = Color.SandyBrown
            };

            anchors.Add(item);
            layout.Children.Add(item, xConstraint: Constraint.RelativeToParent(p => item.LeftX));

            currentX += (float)item.Width;
        }
        private void AddSecondsAnchor(TransactionBoxControl boxControl, TransactionEvent transactionEvent, int second)
        {
            var timeEvent = new TimeLineEvent(boxControl.Transaction.Identificator, transactionEvent, boxControl.HighlightColor);
            var item      = new SecondAnchor(second, currentX, timeEvent, transactionEvent.Completion)
            {
                //  BackgroundColor = Color.FromRgb(rnd.Next(150, 200), rnd.Next(150, 200), rnd.Next(150, 200))
            };

            anchors.Add(item);
            layout.Children.Add(item,
                                xConstraint: Constraint.RelativeToParent(p => item.LeftX),
                                yConstraint: Constraint.RelativeToParent(p => p.Height * 0.5 - item.Height * 0.5));

            currentX += (float)item.Width;
        }
        public void AssociateEvent(TransactionBoxControl boxControl, TransactionEvent transactionEvent)
        {
            var lastAnchor = anchors.LastOrDefault();

            var month  = transactionEvent.Created.Month;
            var day    = transactionEvent.Created.Day;
            var hour   = transactionEvent.Created.Hour;
            var minute = transactionEvent.Created.Minute;
            var second = transactionEvent.Created.Second;

            //different Day or Month insert separator
            if (lastDay == null || day != lastDay || month != lastMonth)
            {
                lastDay   = day;
                lastMonth = month;

                AddDayMonthSeparator(month, day);

                //and add event
                // AddHourMinuteAnchor(boxControl, transactionEvent, hour, minute);
                AddTimeAnchor(hour, minute, second, boxControl, transactionEvent);

                return;
            }

            if (lastAnchor != null && lastAnchor is TimeLineEventAnchor eventAnchor)
            {
                if (Math.Abs(minute - eventAnchor.Event.Created.Minute) > 1)
                {
                    AddSpacer(eventAnchor);
                }
                AddTimeAnchor(hour, minute, second, boxControl, transactionEvent);
            }
            else // not event anchor, put new Time
            {
                AddTimeAnchor(hour, minute, second, boxControl, transactionEvent);
            }
        }