界面显示
public enum PageType
{
Index,
Error,
Copy,
Wait,
None
}
public class UIController
{
public delegate void ChangeFrmMainDelegate(object content);
public static event ChangeFrmMainDelegate ChangeFrmMainEvent;
public static void PageShow(PageType page, string error = null)
{
switch (page)
{
case PageType.Index:
ChangeFrmMainEvent.Invoke(new Index());
break;
case PageType.Copy:
ChangeFrmMainEvent.Invoke(new Wpf_Page_Copy());
break;
case PageType.Error:
ChangeFrmMainEvent.Invoke(new Wpf_Page_Error(error));
break;
case PageType.Wait:
ChangeFrmMainEvent.Invoke(new Wpf_Page_Wait());
break;
case PageType.None:
break;
default:
break;
}
}
}
延时跳转
private DispatcherTimer dispatcherTimer = new DispatcherTimer();
private void Page_Loaded(object sender, RoutedEventArgs e)
{
//定时查询-定时器
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
dispatcherTimer.Start();
}
/// <summary>
/// 定时器回调函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
dispatcherTimer.Stop();
UIController.PageShow(PageType.Wait);
dispatcherTimer = null;
GC.Collect();
}
DoubleAnimation 渐隐渐现动画 (如果不需要动画,只想用这个界面显示的框架,只需要把ChangeFrmMain方法里面的代码 换成 this.frmMain.Navigate(content); 就可以了 frmMain 是一个Frame控件
private void ChangeFrmMain(object content)
{
this.content = content;
try
{
if (Content != null)
{
this.IsHitTestVisible = false;
DoubleAnimation da = new DoubleAnimation(0.3d, new Duration(TimeSpan.FromMilliseconds(300)));
da.Completed += FadeOutCompleted;
this.BeginAnimation(OpacityProperty, da);
}
}
catch
{
}
}
private void FadeOutCompleted(object sender, EventArgs e)
{
(sender as AnimationClock).Completed -= FadeOutCompleted;
this.IsHitTestVisible = true;
Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(ThreadStart)delegate ()
{
DoubleAnimation da = new DoubleAnimation(1.0d, new Duration(TimeSpan.FromMilliseconds(200)));
this.BeginAnimation(OpacityProperty, da);
});
this.frmMain.Navigate(content);
}
优快云下载 https://download.youkuaiyun.com/download/sun_zeliang/10636546 需两积分
百度云下载 链接:https://pan.baidu.com/s/1OJ5BMDDUi8r8ciEAijQdOA 密码:qmia 不需要积分