CodeImp.Gluon.OverviewDisplayPanel.animatetoptimer_Tick C# (CSharp) Метод

animatetoptimer_Tick() приватный Метод

private animatetoptimer_Tick ( object sender, EventArgs e ) : void
sender object
e EventArgs
Результат void
        private void animatetoptimer_Tick(object sender, EventArgs e)
        {
            animatetoptimer.Stop();

            if(agendaupdateneeded)
                UpdateAgenda();

            if(notesupdateneeded)
                UpdateNotes();

            // A negative value means we must clear the list
            if(agendadisplayindex < 0)
            {
                agendaitemindex = 0;
                lastagendaitemday = 0;
                for(int i = 0; i < NUM_AGENDA_ITEMS; i++)
                {
                    agendaitems[i].Visible = false;
                    agendatimes[i].Visible = false;
                }
            }

            // A negative value means we must clear the list
            if(notesitemindex < 0)
            {
                for(int i = 0; i < NUM_NOTES_ITEMS; i++)
                    notesitems[i].Visible = false;
            }

            // We animate in sequence: We do the agenda items first, then the notes.
            if((agendadata != null) && (agendadisplayindex < NUM_AGENDA_ITEMS))
            {
                // Show next item?
                if(agendadisplayindex >= 0)
                {
                    if(agendaitemindex < agendadata.Count)
                    {
                        // Setup time
                        AgendaItem itemdata = agendadata[agendaitemindex];
                        if(itemdata.startdate.Day != lastagendaitemday)
                        {
                            // Use an item for the date
                            if(agendadisplayindex < (NUM_AGENDA_ITEMS - 1))
                            {
                                lastagendaitemday = itemdata.startdate.Day;

                                // Time
                                agendatimes[agendadisplayindex].Text = " ";
                                agendatimes[agendadisplayindex].ColorText = ColorIndex.ControlColor4;
                                agendatimes[agendadisplayindex].SetupColors(General.Colors);
                                agendatimes[agendadisplayindex].Visible = true;

                                // Description
                                if(lastagendaitemday == DateTime.Today.Day)
                                    agendaitems[agendadisplayindex].Text = "Today";
                                else
                                    agendaitems[agendadisplayindex].Text = itemdata.startdate.ToString("dddd, MMMM d");
                                agendaitems[agendadisplayindex].ColorText = ColorIndex.ControlColor4;
                                agendaitems[agendadisplayindex].SetupColors(General.Colors);
                                agendaitems[agendadisplayindex].Visible = true;
                            }

                            agendadisplayindex++;
                        }

                        if(agendadisplayindex < NUM_AGENDA_ITEMS)
                        {
                            // Time
                            if(itemdata.recur == AgendaItemRecur.Annually)
                                agendatimes[agendadisplayindex].Text = "-";
                            else
                                agendatimes[agendadisplayindex].Text = itemdata.startdate.Hour + ":" + itemdata.startdate.Minute.ToString("00");
                            agendatimes[agendadisplayindex].ColorText = ColorIndex.ControlColor3;
                            agendatimes[agendadisplayindex].SetupColors(General.Colors);
                            agendatimes[agendadisplayindex].Visible = true;

                            // Description
                            agendaitems[agendadisplayindex].Text = itemdata.ToString();
                            agendaitems[agendadisplayindex].ColorText = itemdata.color;
                            agendaitems[agendadisplayindex].SetupColors(General.Colors);
                            agendaitems[agendadisplayindex].Visible = true;
                        }
                    }
                    else
                    {
                        // No item
                        agendaitems[agendadisplayindex].Visible = false;
                        agendatimes[agendadisplayindex].Visible = false;
                    }

                    agendaitemindex++;
                }

                agendadisplayindex++;
                animatetoptimer.Interval = 100;
            }
            else if((notesdata != null) && (notesitemindex < notesdata.Count) && (notesitemindex < NUM_NOTES_ITEMS))
            {
                // Show next item?
                if(notesitemindex >= 0)
                {
                    int toppos;
                    if(notesitemindex == 0)
                        toppos = noteitem1.Top;
                    else
                        toppos = notesitems[notesitemindex - 1].Bottom + noteitemspacing;

                    if(toppos - noteitemspacing < noteitem10.Bottom)
                    {
                        string text = notesdata[notesitemindex].note;
                        text = text.Replace("\n", "\n    ");
                        notesitems[notesitemindex].AutoSizeHeight = true;
                        notesitems[notesitemindex].Top = toppos;
                        notesitems[notesitemindex].Text = "•  " + text;
                        notesitems[notesitemindex].Visible = true;
                        if(notesitems[notesitemindex].Bottom > noteitem10.Bottom)
                        {
                            notesitems[notesitemindex].AutoSizeHeight = false;
                            notesitems[notesitemindex].Height = noteitem10.Bottom - notesitems[notesitemindex].Top;

                            // End animation
                            notesitemindex += 999999;
                        }
                    }
                    else
                    {
                        // End animation
                        notesitemindex += 999999;
                    }
                }

                notesitemindex++;
                animatetoptimer.Interval = 100;
            }
            // Animation ended?
            else
            {
                // Set the timer to restart later
                agendadisplayindex = -5;
                notesitemindex = -1;
                animatetoptimer.Interval = 10000;
            }

            animatetoptimer.Start();
        }