Mini Kabibi Habibi
using DevExpress.Core;
using DevExpress.UI.Xaml.Layout;
using DXCRM.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace DXCRM
{
sealed partial class App : Application
{
static App() {
}
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
protected override async void OnLaunched(LaunchActivatedEventArgs args) {
if(args.PreviousExecutionState == ApplicationExecutionState.Running) {
Window.Current.Activate();
return;
}
SettingsPane.GetForCurrentView().CommandsRequested -= App_CommandsRequested;
SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;
DXFrameExt rootFrame = new DXFrameExt() { NavigationTypeProvider = new NavigationTypeProvider() };
rootFrame.KeyDown += OnRootFrameKeyDown;
DataProvider.BeginInit();
DataProvider.ServiceContainer.RegisterService(new NavigationServiceExt(new NavigationService() { Frame = rootFrame }, rootFrame));
DataProvider.ServiceContainer.RegisterService(new MessageDialogService());
DataProvider.ServiceContainer.RegisterService(new VisualStateService() { Frame = rootFrame });
DataProvider.ServiceContainer.RegisterService(new DXMessageDialogService());
DataProvider.ServiceContainer.RegisterService(new ValidationService());
DataProvider.EndInit();
if(args.PreviousExecutionState == ApplicationExecutionState.Terminated ||
args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser) {
await SuspensionManager.RestoreAsync();
}
SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
Window.Current.Content = rootFrame;
if(rootFrame.Content == null) {
if(!rootFrame.Navigate(typeof(MainPage), "AllGroups")) {
throw new Exception("Failed to create initial page");
}
}
Window.Current.Activate();
}
void App_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args) {
args.Request.ApplicationCommands.Add(new AboutFlyoutView().ShowFlayoutCommand);
}
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
await SuspensionManager.SaveAsync();
deferral.Complete();
}
#region Debug
void OnRootFrameKeyDown(object sender, KeyRoutedEventArgs e) {
if(e.Key == Windows.System.VirtualKey.Q && DevExpress.Utils.KeyboardHelper.IsCtrlPressed && DevExpress.Utils.KeyboardHelper.IsShiftPressed)
RuntimeHelper.Run();
}
#endregion
}
}