コード例 #1
0
ファイル: ToDoEvent.cs プロジェクト: nicksi/tdw
        /// <summary>
        /// Draw event on 64 x 48 bitmap
        /// </summary>
        /// <param name="bitmap">Bitmap to draw on</param>
        /// <param name="time">Current time</param>
        public void PaintEvent(Bitmap bitmap, DateTime time)
        {
            Font timeFont = Resources.GetFont(Resources.FontResources.ubuntu16c);
            Font smallFont = Resources.GetFont(Resources.FontResources.ubuntu12c);
            Painter painter = new Painter(bitmap);
            TimeSpan ts = DueDate - time;
            Bitmap todotypes;

            // draw separator
            bitmap.DrawLine(Color.White, 1, 0, 0, 64, 0);

            // if inverse draw background and use inverted icons
            if (_inverse)
            {
                bitmap.DrawRectangle(Color.White, 0, 0, 3, 64, 18, 0, 0, Color.White, 0, 0, Color.White, 64, 48, 0xFF);
                todotypes = new Bitmap(Resources.GetBytes(Resources.BinaryResources.todotypes_inverted), Bitmap.BitmapImageType.Gif);
            }
            else
                todotypes = new Bitmap(Resources.GetBytes(Resources.BinaryResources.todotypes), Bitmap.BitmapImageType.Gif);

            //// draw icon
            bitmap.DrawImage(0, 5, todotypes, 0, (int)Type * 16, 16, 16);

            if (ts.Days > 0)

                bitmap.DrawTextInRect(
                    ts.Days + "days",
                    16,
                    0,
                    48,
                    18,
                    Bitmap.DT_AlignmentCenter,
                    _inverse?Color.Black:Color.White,
                    timeFont
                    );
            else if ( ts.Days == 0 && ts.Minutes <= 0 )
                bitmap.DrawTextInRect(
                    "NOW!",
                    16,
                    0,
                    48,
                    20,
                    Bitmap.DT_AlignmentCenter,
                    _inverse ? Color.Black : Color.White,
                    timeFont
                    );

            else
                bitmap.DrawTextInRect(
                    ts.Hours + "h " + ts.Minutes + "m",
                    16,
                    0,
                    48,
                    20,
                    Bitmap.DT_AlignmentCenter,
                    _inverse ? Color.Black : Color.White,
                    timeFont
                    );

            if (Label.Length > 0)
            {
                bitmap.DrawTextInRect(Label, 0, 19, 64, 30, Bitmap.DT_WordWrap|Bitmap.DT_TruncateAtBottom, Color.White, smallFont);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: nicksi/tdw
        static void DrawFace(bool SwitchToFirst)
        {
            Painter painter = new Painter(screen);

            // clear our display buffer
            screen.Clear();

            //update our local time reference
            //Device.Time.CurrentTime = DateTime.Now; //just normal
            //currentTime = currentTime.AddMinutes(1); //speedy time

            // Get current time
            currentTime = DateTime.Now;
            int nowSecond = currentTime.Second;
            int nowMinute = currentTime.Minute;
            int nowHour = currentTime.Hour;

            #region draw hours
            // use big spritesheet for now
            screen.DrawImage(0, 0, ReadHrs(nowHour%12), 0,  0, screen.Width, screen.Height);
            #endregion

            #region draw minutes
                DrawTicks(nowMinute );
            #endregion

            #region draw date
            Font bigFont = Resources.GetFont(Resources.FontResources.ubuntu15c);
            painter.PaintCentered(currentTime.ToString("dd MMM, ddd").ToUpper(), bigFont, false, SCREEN_SIZE/4 );

            #endregion

            #region draw todo
            //screen.DrawRectangle(Color.White, 1, 32, 48, 64, 48, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);
            // if three are some events
            if (tde.Count > 0)
            {

                ToDoEvent evt = (ToDoEvent)tde[ActiveTde];
                // if active evenet is overdue for more than 1 minute - remove from the list
                if (evt.TotalSeconds(currentTime) < -40)
                {
                    tde.RemoveAt(ActiveTde);
                    ActiveTde = 0;

                    if (tde.Count > 0)
                        // draw next event
                        ((ToDoEvent)tde[ActiveTde]).DrawEvent(screen, currentTime);

                    StopTicking();
                }
                // else if Active  event is not the first one check if the first one is due next minutes and switch
                else if (ActiveTde != 0)
                {
                    long interval = ((ToDoEvent)tde[0]).TotalSeconds(currentTime);

                    if (interval < 120)
                    {
                        if (SwitchToFirst) ActiveTde = 0; // do not switch events if Middle Button has been pressed
                    }

                    if (interval < 60 + BLINK_BEFORE)
                    {
                        StartTicking((int)(interval - BLINK_BEFORE));
                    }

                    ((ToDoEvent)tde[ActiveTde]).DrawEvent(screen, currentTime);
                }
                // if current event is the first one - check if it is time to start ticking
                else if (ActiveTde == 0)
                {
                    long interval = ((ToDoEvent)tde[0]).TotalSeconds(currentTime);
                    if (interval < 60 + BLINK_BEFORE)
                    {
                        StartTicking((int)(interval - BLINK_BEFORE));
                    }
                    ((ToDoEvent)tde[ActiveTde]).DrawEvent(screen, currentTime);
                }
            }
            else
            {
                // no events - stop ticking just in case
                StopTicking();
            }
            #endregion

            screen.Flush(); // flush the display buffer to the display
        }