private void UserControl_Unloaded(object sender, RoutedEventArgs e) { globalPicking = false; msHook.UnHook(); tColor.Stop(); mag.Close(); mag = null; }
void Init() { tColor = new DispatcherTimer(DispatcherPriority.Normal, App.Current.Dispatcher); tColor.Interval = new TimeSpan(0, 0, 0, 0, 33); tColor.Tick += TColor_Tick; tColor.Stop(); mag = new Magnifier(); mag.Owner = null; mag.Hide(); PrevColor.Background = new SolidColorBrush(Color.FromArgb(current.A, current.R, current.G, current.B)); SelectedColor.Background = new SolidColorBrush(Color.FromArgb(current.A, current.R, current.G, current.B)); alpha = current.A / 255.0f; msHook = new MouseHook(); msHook.MouseClickEvent += MsHook_MouseClickEvent; EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyDownEvent, new KeyEventHandler(OnKeyDown), true); }