Пример #1
0
 private void Ico_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         if (tray1 == null)
         {
             if (this.Visibility == Visibility.Visible)
             {
                 this.Visibility = Visibility.Hidden;
             }
             else
             {
                 this.Visibility = Visibility.Visible;
             }
         }
         else
         {
             tray1.Close();
             tray1 = null;
         }
     }
     else
     {
         if (tray1 == null)
         {
             tray1 = new Tray(this);
             tray1.Show();
             if (tray1 != null)
             {
                 if (System.Windows.Forms.Cursor.Position.Y < System.Windows.SystemParameters.PrimaryScreenHeight - 100 && System.Windows.Forms.Cursor.Position.X > System.Windows.SystemParameters.PrimaryScreenWidth - 100)
                 {
                     dd  = -tray1.Height;
                     dd2 = -tray1.Width;
                 }
                 else if (System.Windows.Forms.Cursor.Position.Y < 100)
                 {
                     dd  = 0;
                     dd2 = 0;
                 }
                 else
                 {
                     dd  = -1 * tray1.Height;
                     dd2 = 0;
                 }
                 tray1.Top  = System.Windows.Forms.Cursor.Position.Y + dd;
                 tray1.Left = System.Windows.Forms.Cursor.Position.X + dd2;
                 bl         = true;
             }
         }
     }
 }
Пример #2
0
 protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
 {
     if (inf.bl_lock == false)
     {
         this.DragMove();
         base.OnMouseLeftButtonDown(e);
         inf.locX = this.Left;
         inf.locY = this.Top;
     }
     if (tray1 != null)
     {
         tray1.Close();
         tray1 = null;
     }
 }
Пример #3
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;

            if (tray1 != null && bl == true)
            {
                if (System.Windows.Forms.Cursor.Position.X < tray1.Left - 15.0 || System.Windows.Forms.Cursor.Position.Y < tray1.Top - 15.0 || System.Windows.Forms.Cursor.Position.X > (tray1.Left + tray1.Width + 15) || System.Windows.Forms.Cursor.Position.Y > (tray1.Top + tray1.Height + 15))
                {
                    tray1.Close();
                    tray1 = null;
                    bl    = false;
                }
            }

            if (dt.ToLongTimeString().IndexOf(':') == 2)
            {
                Time.Text = dt.ToLongTimeString().Substring(0, 5);
            }
            else
            {
                Time.Text = dt.ToLongTimeString().Substring(0, 4);
            }
            Date.Text = dt.ToShortDateString();

            if (dt.Second > 58)
            {
                Seconds.EndAngle = -6 * 50 * (dt.Second + dt.Millisecond / 1000.0);
            }
            else
            {
                Seconds.EndAngle = 6 * dt.Second;
            }

            if (dt.Minute > 58 && dt.Second > 58)
            {
                Minutes.EndAngle = -6 * 50 * (dt.Second + dt.Millisecond / 1000.0);
            }
            else
            {
                Minutes.EndAngle = 6 * dt.Minute;
            }

            if ((dt.Hour == 11 || dt.Hour == 23) && dt.Minute > 58 && dt.Second > 58)
            {
                Hours.EndAngle = -6 * 50 * (dt.Second + dt.Millisecond / 1000.0);
            }
            else if (dt.Hour <= 11)
            {
                Hours.EndAngle = 30 * dt.Hour;
            }
            else if (dt.Hour > 11)
            {
                Hours.EndAngle = 30 * (dt.Hour % 12);
            }
            if (transition != DateTime.Now.Hour && inf.bl == true)
            {
                if (inf.colorInd == 12)
                {
                    buttonRed_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 1)
                {
                    buttonPink_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 2)
                {
                    buttonPurple_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 3)
                {
                    buttonIndigo_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 4)
                {
                    buttonBlue_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 5)
                {
                    buttonCyan_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 6)
                {
                    buttonTeal_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 7)
                {
                    buttonGreen_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 8)
                {
                    buttonLime_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 9)
                {
                    buttonYellow_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 10)
                {
                    buttonAmber_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
                else if (inf.colorInd == 11)
                {
                    buttonOrange_Click(new object(), new RoutedEventArgs());
                    transition = DateTime.Now.Hour;
                }
            }
        }