商店应用的进程模型 -- 管理App

WinRT提供了一个Windows.ApplicationModel.Core.CoreApplication类:

public static class CoreApplication {
// Returns the CoreApplicationView associated with the calling thread
public static CoreApplicationView GetCurrentView();
// Returns all CoreApplicationViews existing within the process
public static IReadOnlyList<CoreApplicationView> Views { get; }
// Returns the main view thread's CoreApplicationView
public static CoreApplicationView MainView { get; }
// These events are discussed later in this chapter
public static event EventHandler<Object> Resuming;
public static event EventHandler<SuspendingEventArgs> Suspending;
// These events are for debugging only
public static event EventHandler<Object> Exiting;
public static event EventHandler<UnhandledErrorDetectedEventArgs> UnhandledErrorDetected;
// This method allows you to create multiple main view windows
public static CoreApplicationView CreateNewView();
// Some members not shown here...
}

此静态类管理整个app。但是静态类破坏了面向对象,所以微软用单例的Application对象封装了此CoreApplication类。

public class Application {
// Static members:
public static void Start(ApplicationInitializationCallback callback);
public static Application Current { get; }
// The same Resuming & Suspending events offered by the CoreApplication class
public event EventHandler<object> Resuming;
public event SuspendingEventHandler Suspending;
// XAML-specific properties and events:
public DebugSettings DebugSettings { get; }
public ApplicationTheme RequestedTheme { get; set; }
public ResourceDictionary Resources { get; set; }
public event UnhandledExceptionEventHandler UnhandledException;
// The virtual methods shown earlier and some other members are not shown here...
}

App类派生自Application类,继承了所有成员。

CoreApplication类有很多成员都返回CoreApplicationView对象。而CoreApplicationView类有这些成员:

public sealed class CoreApplicationView {
public CoreDispatcher Dispatcher { get; }
public CoreWindow CoreWindow { get; }
public Boolean IsMain { get; }
public Boolean IsHosted { get; }
public event TypedEventHandler<CoreApplicationView, IActivatedEventArgs> Activated;
}

注意有一个CoreDispatcher(分发Windows消息)和一个CoreWindow(主绘制窗口),另外还有标识激活方式的属性。

CoreWindow中的字段标识了矩形窗口大小,以及是否可以交互,显示光标,是否可见等。还有Activated,Close,SizeChanged等事件。

有一个Window类轻度封装了这个CoreWindow对象:

public sealed class Window {
public static Window Current { get; } // Returns calling thread's Window
public CoreWindow CoreWindow { get; }
public CoreDispatcher Dispatcher { get; } // Same as CoreApplicationView.Dispatcher
// The Content property is how XAML integrates with the window's drawing surface:
public UIElement Content { get; set; }
// This class exposes some of the same properties (Bounds, Visible)
// This class exposes some of the same events (Activated, Closed,
// SizeChanged, VisibilityChanged)
// This class exposes some of the same methods (Activate, Close)
}

CoreDispatcher类是这样的:

public sealed class CoreDispatcher {
// Returns true if the calling thread is the same thread
// that this CoreDispatcher object is associated with
public Boolean HasThreadAccess { get; }
// Call this to have the CoreDispatcher's thread execute the agileCallback
// with a priority of Idle, Low, Normal, or High
public IAsyncAction RunAsync(
CoreDispatcherPriority priority, DispatchedHandler agileCallback);
// Call this to get/set the priority of the code that dispatcher is currently executing
public CoreDispatcherPriority CurrentPriority { get; set; }
// Other members not shown...
}

当非UI线程想更新UI时使用。

CoreApplication的静态方法CreateNewView可以创建新的视图和线程,用于显示更多内容。新的线程会附着于原CoreWindow,并返回CoreApplicationView。而CoreApplicationView的IsMain和IsHosted属性都返回false。另外,OnWindowCreated也属于新的线程。可以按照下面的方式创建新的视图:

private async Task CreateNewViewWindow() {
// Have Windows create a new thread, CoreDispatcher, CoreWindow, and CoreApplicationView
CoreApplicationView cav = CoreApplication.CreateNewView();
CoreWindow newAppViewWindow = null; // This will hold the new view's window
// Have the new thread initialize the new view's content
await cav.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
// Give the new thread's window back to the creating thread
newAppViewWindow = Window.Current.CoreWindow;
// Create the desired UI element tree and make it the content of the new window
Window.Current.Content = new MyPage();
Window.Current.Activate();
});
// After the new thread initializes its view, the creating thread makes it appear
Int32 newAppViewId = ApplicationView.GetApplicationViewIdForWindow(newAppViewWindow);
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newAppViewId,
ViewSizePreference.UseLess);
// The SDK documentation for Windows.UI.ViewManagement.ApplicationViewSwitcher explains
// its other methods, allowing you to control switching between your app's views.
}

前面的代码使用了Windows.UI.ViewManagement.ApplicationView类,这个类中的属性经常变,类如下:

public sealed class ApplicationView {
// Gets the view for the calling thread
public static ApplicationView GetForCurrentView();
// Gets the unique window ID corresponding to a specific CoreWindow
public static Int32 GetApplicationViewIdForWindow(ICoreWindow window);
// Gets a unique ID identifying this view. NOTE: This ID is passed to
// an XxxActivatedEventArgs' CurrentlyShownApplicationViewId property
public Int32 Id { get; }
// Gets/sets the view's title (shown in task switchers) & if PrtScn can capture its content
public String Title { get; set; }
public Boolean IsScreenCaptureEnabled { get; set; }
// Read-only properties related to view's position & size
public ApplicationViewOrientation Orientation { get; } // Landscape or Portrait
public Boolean AdjacentToLeftDisplayEdge { get; }
public Boolean AdjacentToRightDisplayEdge { get; }
public Boolean IsFullScreen { get; }
public Boolean IsOnLockScreen { get; }
// Raised when the view is removed from task switcher (if user closes the view)
public event TypedEventHandler<ApplicationView, ApplicationViewConsolidatedEventArgs>
Consolidated;
// Indicates if app terminates when all views close (Default=false)
public static Boolean TerminateAppOnFinalViewClose { get; set; }
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的体育馆管理系统,源码+数据库+毕业论文+视频演示 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本体育馆管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此体育馆管理系统利用当下成熟完善的SpringBoot框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了用户在线选择试题并完成答题,在线查看考核分数。管理管理收货地址管理、购物车管理、场地管理、场地订单管理、字典管理、赛事管理、赛事收藏管理、赛事评价管理、赛事订单管理、商品管理、商品收藏管理、商品评价管理、商品订单管理、用户管理管理管理等功能。体育馆管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 关键词:体育馆管理系统;SpringBoot框架;Mysql;自动化
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值