/// <summary> /// 检查窗体是否隐藏 /// </summary> private void CheckHidden() { if (this.bdrMain.Opacity < AppInfoOperations.GetMaxOpacity()) { Animation.UniversalBeginDoubleAnimation <Border>(ref this.bdrMain, OpacityProperty, 0.2, AppInfoOperations.GetMaxOpacity()); } }
/// <summary> /// 位置改变时响应函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_LocationChanged(object sender, EventArgs e) { //检查信息是否已初始化 if (IsInformationsInitialized) { //保存位置信息 AppInfoOperations.SetLeft(this.Left); AppInfoOperations.SetTop(this.Top); //更新Manage类的主窗体位置信息 Manage.WindowMainRect.left = (int)this.Left; Manage.WindowMainRect.right = (int)(this.Left + this.ActualWidth); Manage.WindowMainRect.top = (int)this.Top; Manage.WindowMainRect.bottom = (int)(this.Top + this.ActualHeight); //边缘吸附 if (this.Left <= 50 && this.Left > 0) { this.Left = 0; } if (this.Top <= 50 && this.Top > 0) { this.Top = 0; } } }
private void LoadData() { this.MaxOpacity = AppInfoOperations.GetMaxOpacity(); this.MinOpacity = AppInfoOperations.GetMinOpacity(); this.Fadein = AppInfoOperations.GetShowTimeSpan(); this.Fadeout = AppInfoOperations.GetHideTimeSpan(); this.ItemSize = AppInfoOperations.GetItemSize(); }
/// <summary> /// 还原 /// </summary> /// <param name="wnd"></param> public void SetNormal(Window wnd) { DoubleAnimation da1 = new DoubleAnimation(); da1.Duration = TimeSpan.FromSeconds(0.5); wnd.BeginAnimation(Window.TopProperty, da1); OpacityChange(wnd, 0, AppInfoOperations.GetMaxOpacity(), TimeSpan.FromSeconds(0.5)); }
/// <summary> /// 窗体大小发生改变时的事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Window_SizeChanged(object sender, SizeChangedEventArgs e) { wndMain wnd = (wndMain)sender; wnd.UpdateLayout(); if (wnd.Opacity == 0 && wnd.WindowState == WindowState.Normal) { wnd.WindowState = WindowState.Minimized; } if (wnd.IsInformationsInitialized) { AppInfoOperations.SetWidth(wnd.ActualWidth); AppInfoOperations.SetHeight(wnd.ActualHeight); } }
private void Da_Completed(object sender, EventArgs e) { if (Closing) { this.wnd.Close(); } if (Way == 0) { wnd.WindowState = WindowState.Maximized; OpacityChange(wnd, 0, AppInfoOperations.GetMaxOpacity(), TimeSpan.FromSeconds(0.3)); } else { wnd.WindowState = WindowState.Normal; OpacityChange(wnd, 0, AppInfoOperations.GetMaxOpacity(), TimeSpan.FromSeconds(0.3)); Way = 0; } }
private static void PropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { wndSettings Base = (wndSettings)sender; switch (e.Property.ToString()) { case "MaxOpacity": AppInfoOperations.SetMaxOpacity((double)e.NewValue); break; case "MinOpacity": AppInfoOperations.SetMinOpacity((double)e.NewValue); break; case "Fadein": AppInfoOperations.SetShowTimeSpan((double)e.NewValue); break; case "Fadeout": AppInfoOperations.SetHideTimeSpan((double)e.NewValue); break; case "ItemSize": AppInfoOperations.SetItemSize((double)e.NewValue); foreach (Item i in Manage.WindowMain.Recent.Children) { i.Length = (double)e.NewValue; } break; default: break; } }
/// <summary> /// 还原 /// </summary> /// <param name="wnd"></param> public void SetNormal(Window wnd) { OpacityChange(wnd, 0, AppInfoOperations.GetMaxOpacity(), TimeSpan.FromSeconds(0.5)); }
/// <summary> /// 初始化窗体border的样式 /// </summary> /// <param name="bdr"></param> public void InitBdrStyle(ref Border bdr) { //获取最小透明度 double minOpa = AppInfoOperations.GetMinOpacity(); //获取最大透明度 double maxOpa = AppInfoOperations.GetMaxOpacity(); //获取显示时长 double showTimeSpan = AppInfoOperations.GetShowTimeSpan(); //获取隐藏时长 double hideTimeSpan = AppInfoOperations.GetHideTimeSpan(); //获取超时时长 double TimeoutSpan = AppInfoOperations.GetTimeoutTimeSpan(); DoubleAnimation daShow = new DoubleAnimation(); DoubleAnimation daHide = new DoubleAnimation(); Storyboard sbShow = new Storyboard(); Storyboard sbHide = new Storyboard(); BeginStoryboard bsShow = new BeginStoryboard(); BeginStoryboard bsHide = new BeginStoryboard(); EventTrigger etShow = new EventTrigger(Mouse.MouseEnterEvent); EventTrigger etHide = new EventTrigger(Mouse.MouseLeaveEvent); Style style = new Style(); //show daShow.To = maxOpa; daShow.Duration = TimeSpan.FromSeconds(showTimeSpan); Storyboard.SetTargetProperty(daShow, new PropertyPath(UIElement.OpacityProperty)); Storyboard.SetDesiredFrameRate(sbShow, 60); sbShow.Children.Add(daShow); bsShow.Storyboard = sbShow; etShow.Actions.Add(bsShow); style.Triggers.Add(etShow); //hide daHide.To = minOpa; daHide.Duration = TimeSpan.FromSeconds(hideTimeSpan); Storyboard.SetTargetProperty(daHide, new PropertyPath(UIElement.OpacityProperty)); sbHide.BeginTime = TimeSpan.FromSeconds(TimeoutSpan); Storyboard.SetDesiredFrameRate(sbHide, 60); sbHide.Children.Add(daHide); bsHide.Storyboard = sbHide; etHide.Actions.Add(bsHide); style.Triggers.Add(etHide); //apply bdr.Style = style; }
/// <summary> /// 初始化操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { #region Register Hot Key Manage.WindowMainHandle = new WindowInteropHelper(this).Handle;; HotKeyVisualItem hkvi = new HotKeyVisualItem(); hkvi.HotKeysString = AppInfoOperations.GetHotKey(); if (hkvi.Available) { if (!HotKey.TestHotKey(3, System.Windows.Forms.Keys.D1, HotKey.QUICK_SEARCH_HOTKEY_ID, false)) { if (!HotKey.TestHotKey(3, System.Windows.Forms.Keys.D1, HotKey.QUICK_SEARCH_HOTKEY_ID, false)) { tipMainForm.ShowFixed(this, "Hot Key Register failed"); } } } else { if (!HotKey.TestHotKey(3, System.Windows.Forms.Keys.D1, HotKey.QUICK_SEARCH_HOTKEY_ID, false)) { tipMainForm.ShowFixed(this, "Hot Key Register failed"); } } //(uint)HotKey.KeyModifiers.Ctrl | (uint)HotKey.KeyModifiers.Alt hkvi = null; #endregion #region Initialize Visual Settings this.WindowState = WindowState.Normal; double ScreenWidth = SystemParameters.PrimaryScreenWidth; double ScreenHeight = SystemParameters.PrimaryScreenHeight; //获取位置 //并检查合法性 double readLeft = AppInfoOperations.GetLeft(); double readTop = AppInfoOperations.GetTop(); if (readLeft > 2) { this.Left = readLeft - 2; } else { this.Left = 0; } if (readTop > 1) { this.Top = readTop - 1; } else { this.Top = 0; } //获取宽高 double readWidth = AppInfoOperations.GetWidth(); double readHeight = AppInfoOperations.GetHeight(); //检查数值合法性 if (readWidth > ScreenWidth) { readWidth = ScreenWidth; } if (readHeight > ScreenHeight) { readHeight = ScreenHeight; } //应用宽高 this.Width = readWidth; this.Height = readHeight; #endregion #region Initialize Background Data //用于自动存储位置大小的开关指示 IsInformationsInitialized = true; //初始化后台数据 Manage.InitializeData(this); //初始化删除计时器 Manage.timer.Interval = TimeSpan.FromSeconds(3); Manage.timer.Stop(); Manage.timer.Tick += Timer_Tick; //其他 MELeave.RoutedEvent = Border.MouseLeaveEvent; MEEnter.RoutedEvent = Border.MouseEnterEvent; tipMainForm.Show(); //获取插件 Anything_wpf_main_.cls.Plugins.GetPlugins(); //关联事件处理 this.StateChanged += new EventHandler(animationInstance.Window_StateChanged); this.SizeChanged += new SizeChangedEventHandler(animationInstance.Window_SizeChanged); //设置窗体渐隐与显示 animationInstance.InitBdrStyle(ref this.bdrMain); //关闭加载窗体 Manage.WindowLoading.Close(); #endregion }
/// <summary> /// 初始化操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { wndProgressBar wndpb = new wndProgressBar(AllLoadHeader, AllLoadFooter, 100); #region Load language and register hotkey //加载语言 Manage.LoadingLanguage(); //注册热键 Manage.WindowMainHandle = new WindowInteropHelper(this).Handle;; HotKeyVisualItem hkvi = new HotKeyVisualItem(); if (hkvi.OuterGetKeys(AppInfoOperations.GetHotKey())) { if (!HotKey.TestHotKey(3, System.Windows.Forms.Keys.D1, HotKey.QUICK_SEARCH_HOTKEY_ID, false)) { tipMainForm.ShowFixed(this, this.HotKeyFailed); } } else { if (!HotKey.TestHotKey(3, System.Windows.Forms.Keys.D1, HotKey.QUICK_SEARCH_HOTKEY_ID, false)) { tipMainForm.ShowFixed(this, this.HotKeyFailed); } } hkvi = null; wndpb.Increase(25); #endregion #region Initialize Visual Settings this.WindowState = WindowState.Normal; double ScreenWidth = SystemParameters.PrimaryScreenWidth; double ScreenHeight = SystemParameters.PrimaryScreenHeight; //获取位置 //并检查合法性 double readLeft = AppInfoOperations.GetLeft(); double readTop = AppInfoOperations.GetTop(); if (readLeft > 2) { this.Left = readLeft - 2; } else { this.Left = 0; } if (readTop > 1) { this.Top = readTop - 1; } else { this.Top = 0; } //获取宽高 double readWidth = AppInfoOperations.GetWidth(); double readHeight = AppInfoOperations.GetHeight(); //检查数值合法性 if (readWidth > ScreenWidth) { readWidth = ScreenWidth; } if (readHeight > ScreenHeight) { readHeight = ScreenHeight; } //应用宽高 this.Width = readWidth; this.Height = readHeight; wndMainCB = new ControlBackground(Manage.CurrentPath + "Background\\", new Packer(this.bdrMainForm), ApplicationInformations.Anything.AppInfoOperations.GetBackgroundIntervalMilliseconds(), true); ClearSearch(); wndpb.Increase(25); #endregion #region Initialize Background Data //用于自动存储位置大小的开关指示 IsInformationsInitialized = true; //初始化后台数据 Manage.InitializeProgram(); wndpb.Increase(25); ////初始化删除计时器 //Manage.timer.Interval = TimeSpan.FromSeconds(3); //Manage.timer.Stop(); //Manage.timer.Tick += Timer_Tick; //其他 MELeave.RoutedEvent = Border.MouseLeaveEvent; MEEnter.RoutedEvent = Border.MouseEnterEvent; //获取插件 Class.Plugins.GetPlugins(); //关联事件处理 this.StateChanged += new EventHandler(animationInstance.Window_StateChanged); this.SizeChanged += new SizeChangedEventHandler(animationInstance.Window_SizeChanged); //设置窗体渐隐与显示 animationInstance.InitBdrStyle(ref this.bdrMain); //关闭加载窗体 //Manage.WindowLoading.Close(); wndpb.Increase(25); #endregion wndpb.Increase(); }