官术网_书友最值得收藏!

Inside the AppView class

The AppViewSource.cs and AppView.cs files contain the AppViewSource and AppView classes, respectively. These are the boilerplate code files that launch our scene in the app. AppViewSource is used in Program.cs, and all it does is start a new AppView. AppView is where most of the Holographic magic happens.

The following are the five different things this AppView class does:

  • Housekeeping: The constructor and the Dispose() method live here. The code needs to be IDisposable since most DirectX-based code is unmanaged. This means we need to clean things up when needed.

  • IFrameworkView members: IFrameworkView is the interface DirectX uses to draw its contents to. This contains the methods to load resources, run the view, and set a window that receives the graphics, and so on.

  • Application Lifecycle event handlers: If you have developed Store apps before, you will recognize these; this is where we handle suspension, reactivating, and other lifecycle events.

  • Window event handlers: Next to the lifecycle events, there are some other events that can occur during runtime: OnVisibilityChanged and OnWindowClosed can happen. This is where they are handled.

  • Input event handler: I mentioned before that you can hook up a Bluetooth keyboard to the device. If you do that, the user can press keys on that keyboard and you need to handle those. This is where that part is done. I would recommend against using this in normal scenarios. People walking around with a HoloLens will not normally carry a keyboard with them. However, in certain use cases, this might be desirable.

In the IFrameworkView.Initialize method, the app creates a new instance of the HelloHoloWorldMain class. This class is where our custom code is placed, so basically this is our entry point. The rest can be considered as boilerplate code, stuff the app needs to do anything at all.

In the following chapters, we will adapt this class heavily, but for now I want to show you another way to create HoloLens apps that will give you much nicer results much more easily. We will start to use Unity3D.

主站蜘蛛池模板: 宁城县| 泗阳县| 托里县| 保定市| 上栗县| 抚顺县| 朝阳市| 双峰县| 辉县市| 商都县| 堆龙德庆县| 兖州市| 通河县| 勐海县| 蕲春县| 井陉县| 耒阳市| 高平市| 邵东县| 盐边县| 孟州市| 凤翔县| 岳阳县| 南澳县| 西吉县| 偏关县| 方城县| 奉节县| 遵义县| 共和县| 嵊泗县| 湘阴县| 高安市| 临湘市| 天门市| 敦煌市| 峨眉山市| 永胜县| 八宿县| 札达县| 噶尔县|