private void LoadData() { this.MaxOpacity = AppInfoOperations.GetMaxOpacity(); this.MinOpacity = AppInfoOperations.GetMinOpacity(); this.Fadein = AppInfoOperations.GetShowTimeSpan(); this.Fadeout = AppInfoOperations.GetHideTimeSpan(); this.ItemSize = AppInfoOperations.GetItemSize(); }
/// <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; }