void timer_Tick(object sender, EventArgs e) { if (counter == 50) { Point p = Picker.GetMousePoint(); ColorCode code = new ColorCode(Picker.GetPixelColor((int)p.X, (int)p.Y)); tipsWin.ShowTips(code, p); counter = -1; //System.Console.WriteLine("------------"+counter); return; } //System.Console.WriteLine(counter); Point mouseCurPoint = Picker.GetMousePoint(); if (Math.Abs(mousePoint.X - mouseCurPoint.X) < 5 && Math.Abs(mousePoint.Y - mouseCurPoint.Y) < 5) { if (counter > -1) { counter++; } } else { counter = 0; mousePoint = mouseCurPoint; } }
public MainWindow() { InitializeComponent(); //初始化变量 pickerCursor = new Cursor(new MemoryStream(Properties.Resources.picker)); autoPick = false; tipsWin = new ColorTipsWindow(); counter = 0; mousePoint = Picker.GetMousePoint(); // MessageBox.Show(timer.Interval.ToString()); //初始化事件 this.Loaded += MainWindow_Loaded; this.MouseLeftButtonDown += delegate { this.DragMove(); }; gdTutorials.PreviewMouseLeftButtonDown += delegate { gdTutorials.Visibility = Visibility.Collapsed; }; colorBtn1.PreviewMouseLeftButtonUp += ColorBtn_OnMouseLeftButtonUp; colorBtn2.PreviewMouseLeftButtonUp += ColorBtn_OnMouseLeftButtonUp; colorBtn3.PreviewMouseLeftButtonUp += ColorBtn_OnMouseLeftButtonUp; colorBtn4.PreviewMouseLeftButtonUp += ColorBtn_OnMouseLeftButtonUp; BtnCpyCode1.Click += delegate { Clipboard.SetDataObject(TbColorCode1.Text); }; BtnCpyCode2.Click += delegate { Clipboard.SetDataObject(TbColorCode2.Text); }; BtnClose.Click += BtnClose_Click; BtnMin.Click += delegate { this.WindowState = WindowState.Minimized; }; BtnFix.Click += BtnFix_Click; BtnAuto.Click += BtnAuto_Click; }