Пример #1
0
        // Do not add any additional code to this method
        private async void InitializePhoneApplication()
        {
            if (phoneApplicationInitialized)
            {
                return;
            }

            // Create the frame but don't set it as RootVisual yet; this allows the splash
            // screen to remain active until the application is ready to render.
            RootFrame = new RadPhoneApplicationFrame
            {
                // Add default page transitions animations
                Transition = new RadTransition()
                {
                    ForwardInAnimation   = AnimationService.GetPageInAnimation(),
                    ForwardOutAnimation  = AnimationService.GetPageOutAnimation(),
                    BackwardInAnimation  = AnimationService.GetPageInAnimation(),
                    BackwardOutAnimation = AnimationService.GetPageOutAnimation(),
                }
            };

            RootFrame.Navigated += CompleteInitializePhoneApplication;

            // Handle navigation failures
            RootFrame.NavigationFailed += RootFrame_NavigationFailed;

            // Handle reset requests for clearing the backstack
            RootFrame.Navigated += CheckForResetNavigation;

#if WINDOWS_PHONE_81
            RootFrame.Navigating += RootFrameOnNavigating;

            // Handle contract activation such as returned values from file open or save picker
            PhoneApplicationService.Current.ContractActivated += CurrentOnContractActivated;
#endif

            // Assign the URI-mapper class to the application frame.
            RootFrame.UriMapper = new AssociationUriMapper();

            // Initialize the application information
            AppInformation = new AppInformation();

            // Initialize the links information
            LinkInformation = new LinkInformation();

            //The next line enables a custom logger, if this function is not used OutputDebugString() is called
            //in the native library and log messages are only readable with the native debugger attached.
            //The default behavior of MegaLogger() is to print logs using Debug.WriteLine() but it could
            //be used to sends log to a file, for example.
            LogService.SetLoggerObject(new MegaLogger());

            //You can select the maximum output level for debug messages.
            //By default FATAL, ERROR, WARNING and INFO will be enabled
            //DEBUG and MAX can only be enabled in Debug builds, they are ignored in Release builds
            LogService.SetLogLevel(MLogLevel.LOG_LEVEL_DEBUG);

            //You can send messages to the logger using LogService.Log(), those messages will be received
            //in the active logger
            LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Example log message");

            // Set the ID for statistics
            MegaSDK.setStatsID(Convert.ToBase64String((byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId")));

            // Initialize the main MegaSDK instance
            MegaSdk = new MegaSDK(AppResources.AppKey, String.Format("{0}/{1}/{2}",
                                                                     AppService.GetAppUserAgent(), DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceName),
                                  ApplicationData.Current.LocalFolder.Path, new MegaRandomNumberProvider());

            // Initialize the MegaSDK instance for Folder Links
            MegaSdkFolderLinks = new MegaSDK(AppResources.AppKey, String.Format("{0}/{1}/{2}",
                                                                                AppService.GetAppUserAgent(), DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceName),
                                             ApplicationData.Current.LocalFolder.Path, new MegaRandomNumberProvider());

            // Initialize the main drive
            CloudDrive = new CloudDriveViewModel(MegaSdk, AppInformation);
            // Add notifications listener. Needs a DriveViewModel
            GlobalDriveListener = new GlobalDriveListener(AppInformation);
            MegaSdk.addGlobalListener(GlobalDriveListener);
            // Add a global request listener to process all.
            MegaSdk.addRequestListener(this);
            // Add a global transfer listener to process all transfers.
            GlobalTransferListener = new GlobalTransferListener();
            MegaSdk.addTransferListener(GlobalTransferListener);
            // Initialize the transfer listing
            MegaTransfers = new TransferQueu();
            // Initialize Folders
            AppService.InitializeAppFolders();
            // Set the current resolution that we use later on for our image selection
            AppService.CurrentResolution = ResolutionHelper.CurrentResolution;
            // Clear settings values we do no longer use
            AppService.ClearObsoleteSettings();
            // Save the app version information for future use (like deleting settings)
            AppService.SaveAppInformation();
            // Set MEGA red as Accent Color
            ((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = (Color)Resources["MegaRedColor"];

            // Ensure we don't initialize again
            phoneApplicationInitialized = true;
        }