Exemplo n.º 1
0
 public void SetToDisabled()
 {
     DisabledBackground.SetActive(true);
     NoTargetBackground.SetActive(false);
     Background.SetActive(false);
     Values.SetActive(false);
     Toggle.isOn         = false;
     Toggle.interactable = false;
 }
Exemplo n.º 2
0
    public void SetToFeature(string idPlus)
    {
        var idSplit = idPlus.Split(',');
        var id      = idSplit[0];

        for (int i = 0; i < FeatureBin.transform.childCount; i++)
        {
            if (FeatureBin.transform.GetChild(i).gameObject.name == id)
            {
                Background.SetActive(true);
                DisabledBackground.SetActive(false);
                NoTargetBackground.SetActive(false);
                Values.SetActive(true);
                Toggle.isOn         = true;
                Toggle.interactable = true;
                SetStats(idSplit);
                return;
            }
        }
        SetToNoTarget();
    }
Exemplo n.º 3
0
        /// <summary>
        /// Draw the specified canvas.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        /// <param name="rect">Rect.</param>
        public void DrawCalendar(NGraphics.ICanvas canvas, NGraphics.Rect rect)
        {
            _monthYearLabel.Text = _currentMonth.ToString("MMMMM yyyy");

            base.Draw(canvas, rect);

            // Should we use last line?
            // var drawLastLine = true;

            var colWidth    = rect.Width / 7;
            var rowHeight   = rect.Height / 6;
            var hasEmptyRow = false;

            // Find first week of day
            var firstWeekDay = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
            var date         = _currentMonth;

            while (date.DayOfWeek != firstWeekDay)
            {
                date = date.AddDays(-1);
            }
            _firstDate = date;

            // Set up brushes
            var selectedBrush   = new NGraphics.SolidBrush(SelectedBackground.ToNColor());
            var regularBrush    = new NGraphics.SolidBrush(RegularBackground.ToNColor());
            var weekendBrush    = new NGraphics.SolidBrush(WeekendBackground.ToNColor());
            var notInMonthBrush = new NGraphics.SolidBrush(NotInMonthBackground.ToNColor());
            var disabledBrush   = new NGraphics.SolidBrush(DisabledBackground.ToNColor());

            var col = 0;
            var row = 0;

            for (int d = 0; d < _dayNumberLabels.Length; d++)
            {
                // Update text
                var label = _dayNumberLabels[d];
                label.XAlign = TextAlignment.Center;
                label.YAlign = TextAlignment.Center;

                if (hasEmptyRow || (date.DayOfWeek == firstWeekDay && date >= _currentMonth.AddMonths(1)))
                {
                    hasEmptyRow     = true;
                    label.IsVisible = false;
                }
                else
                {
                    label.IsVisible = true;
                    label.Text      = date.Day.ToString();
                    _lastDate       = date;

                    if (HighlightDisabled && (date < MinDate - MinDate.TimeOfDay || date > MaxDate))
                    {
                        _dayNumberLabels[d].TextColor = DisabledColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight,
                                                                colWidth, rowHeight), null, disabledBrush);
                    }
                    else if (IsSameDay(SelectedDate, date))
                    {
                        // Selected date
                        _dayNumberLabels[d].TextColor = SelectedColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight,
                                                                colWidth, rowHeight), null, selectedBrush);
                    }
                    else if (date.Month != _currentMonth.Month)
                    {
                        // Prev/next month
                        _dayNumberLabels[d].TextColor = NotInMonthColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight, colWidth, rowHeight), null, notInMonthBrush);
                    }
                    else if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        // Weekends
                        _dayNumberLabels[d].TextColor = WeekendColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight, colWidth, rowHeight), null, weekendBrush);
                    }
                    else
                    {
                        // Regular days
                        _dayNumberLabels [d].TextColor = RegularColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight, colWidth, rowHeight), null, regularBrush);
                    }


                    if (IsSameDay(DateTime.Now, date))
                    {
                        // Today

                        // Background and color if not selected
                        if (!IsSameDay(SelectedDate, date))
                        {
                            _dayNumberLabels[d].TextColor = TodayColor;

                            var wh = Math.Min(colWidth, rowHeight);
                            var dx = (colWidth - wh) / 2;
                            var dy = (rowHeight - wh) / 2;
                            var rc = new NGraphics.Rect((col * colWidth) + dx, (row * rowHeight) + dy, wh, wh);
                            rc.Inflate(-1, -1);

                            canvas.DrawEllipse(rc, null, new NGraphics.SolidBrush(TodayBackground.ToNColor()));
                        }
                        else
                        {
                            _dayNumberLabels[d].TextColor = TodayBackground;
                        }
                    }
                }

                // Col/row-counter
                col++;
                if (col == 7)
                {
                    col = 0;
                    row++;
                }

                date = date.AddDays(1);
            }

            var colRowPen = new NGraphics.Pen(GridColor.ToNColor(), 1);

            // Draw row lines
            for (var r = 0; r < (hasEmptyRow ? 6 : 7); r++)
            {
                canvas.DrawPath(new NGraphics.PathOp[] {
                    new NGraphics.MoveTo(0, r * rowHeight),
                    new NGraphics.LineTo(rect.Width, r * rowHeight)
                }, colRowPen);
            }

            // Draw col lines
            for (var c = 0; c < 7; c++)
            {
                canvas.DrawPath(new NGraphics.PathOp[] {
                    new NGraphics.MoveTo(c * colWidth, 0),
                    new NGraphics.LineTo(c * colWidth, hasEmptyRow ? rect.Height - rowHeight : rect.Height)
                }, colRowPen);
            }
        }