Esempio n. 1
0
        private async void BuildingVHDPage_Loaded(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");

            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder == null)
            {
                Application.Current.Exit();
            }

            var sku = await InputTextDialogAsync("Please enter the Sku you would like");

            var lang = await InputTextDialogAsync("Please enter the Language you would like");

            ISOConversion job = new ISOConversion()
            {
                UUPPath          = folder.Path,
                ISOPath          = $@"{folder.Path}\uup.iso",
                Edition          = sku,
                LanguageCode     = lang,
                CompressionType  = CompressionType.LZX,
                IntegrateUpdates = false
            };

            var comm = new Common.InterCommunication()
            {
                InterCommunicationType = Common.InterCommunicationType.StartISOConversionProcess, ISOConversion = job
            };

            var val = new ValueSet();

            val.Add("InterCommunication", JsonSerializer.Serialize(comm));

            await App.Connection.SendMessageAsync(val);
        }
        private void Connection_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            ValueSet message = args.Request.Message;

            if (message.ContainsKey("InterCommunication"))
            {
                Common.InterCommunication interCommunication = JsonSerializer.Deserialize <Common.InterCommunication>(message["InterCommunication"] as string);

                switch (interCommunication.InterCommunicationType)
                {
                case Common.InterCommunicationType.Exit:
                {
                    connection.Dispose();
                    Application.Exit();
                    break;
                }

                case Common.InterCommunicationType.StartISOConversionProcess:
                {
                    async void callback(Common.ProcessPhase phase, bool IsIndeterminate, int ProgressInPercentage, string SubOperation)
                    {
                        var prog = new Common.ISOConversionProgress()
                        {
                            Phase                = phase,
                            IsIndeterminate      = IsIndeterminate,
                            ProgressInPercentage = ProgressInPercentage,
                            SubOperation         = SubOperation
                        };

                        var comm = new Common.InterCommunication()
                        {
                            InterCommunicationType = Common.InterCommunicationType.ReportISOConversionProgress, ISOConversionProgress = prog
                        };

                        var val = new ValueSet();

                        val.Add("InterCommunication", JsonSerializer.Serialize(comm));

                        await SendToUWP(val);
                    }

                    Thread thread = new Thread(async() =>
                        {
                            try
                            {
                                MediaCreationLib.MediaCreator.CreateISOMedia(
                                    interCommunication.ISOConversion.ISOPath,
                                    interCommunication.ISOConversion.UUPPath,
                                    interCommunication.ISOConversion.Edition,
                                    interCommunication.ISOConversion.LanguageCode,
                                    interCommunication.ISOConversion.IntegrateUpdates,
                                    interCommunication.ISOConversion.CompressionType,
                                    callback);
                            }
                            catch (Exception ex)
                            {
                                var prog = new Common.ISOConversionProgress()
                                {
                                    Phase                = Common.ProcessPhase.Error,
                                    IsIndeterminate      = true,
                                    ProgressInPercentage = 0,
                                    SubOperation         = ex.ToString()
                                };

                                var comm = new Common.InterCommunication()
                                {
                                    InterCommunicationType = Common.InterCommunicationType.ReportISOConversionProgress, ISOConversionProgress = prog
                                };

                                var val = new ValueSet();
                                val.Add("InterCommunication", JsonSerializer.Serialize(comm));

                                await SendToUWP(val);
                            }
                        });

                    thread.Start();
                    break;
                }
                }
            }
        }
Esempio n. 3
0
        private async void Connection_RequestReceived(Windows.ApplicationModel.AppService.AppServiceConnection sender, Windows.ApplicationModel.AppService.AppServiceRequestReceivedEventArgs args)
        {
            ValueSet message = args.Request.Message;

            if (message.ContainsKey("InterCommunication"))
            {
                Common.InterCommunication interCommunication = JsonSerializer.Deserialize <Common.InterCommunication>(message["InterCommunication"] as string);

                switch (interCommunication.InterCommunicationType)
                {
                case Common.InterCommunicationType.ReportISOConversionProgress:
                {
                    await coreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            switch (interCommunication.ISOConversionProgress.Phase)
                            {
                            case ProcessPhase.ReadingMetadata:
                                {
                                    ReadingMetadataGlyph.Glyph = "\uF167";
                                    break;
                                }

                            case ProcessPhase.PreparingFiles:
                                {
                                    ReadingMetadataGlyph.Glyph = "\uEC61";
                                    PreparingFilesGlyph.Glyph  = "\uF167";
                                    break;
                                }

                            case ProcessPhase.CreatingWindowsInstaller:
                                {
                                    ReadingMetadataGlyph.Glyph          = "\uEC61";
                                    PreparingFilesGlyph.Glyph           = "\uEC61";
                                    CreatingWindowsInstallerGlyph.Glyph = "\uF167";
                                    break;
                                }

                            case ProcessPhase.ApplyingImage:
                                {
                                    ReadingMetadataGlyph.Glyph          = "\uEC61";
                                    PreparingFilesGlyph.Glyph           = "\uEC61";
                                    CreatingWindowsInstallerGlyph.Glyph = "\uEC61";
                                    ApplyingImageGlyph.Glyph            = "\uF167";
                                    break;
                                }

                            case ProcessPhase.IntegratingWinRE:
                                {
                                    ReadingMetadataGlyph.Glyph          = "\uEC61";
                                    PreparingFilesGlyph.Glyph           = "\uEC61";
                                    CreatingWindowsInstallerGlyph.Glyph = "\uEC61";
                                    ApplyingImageGlyph.Glyph            = "\uEC61";
                                    IntegratingWinREGlyph.Glyph         = "\uF167";
                                    break;
                                }

                            case ProcessPhase.CapturingImage:
                                {
                                    ReadingMetadataGlyph.Glyph          = "\uEC61";
                                    PreparingFilesGlyph.Glyph           = "\uEC61";
                                    CreatingWindowsInstallerGlyph.Glyph = "\uEC61";
                                    ApplyingImageGlyph.Glyph            = "\uEC61";
                                    IntegratingWinREGlyph.Glyph         = "\uEC61";
                                    CapturingImageGlyph.Glyph           = "\uF167";
                                    break;
                                }

                            case ProcessPhase.CreatingISO:
                                {
                                    ReadingMetadataGlyph.Glyph          = "\uEC61";
                                    PreparingFilesGlyph.Glyph           = "\uEC61";
                                    CreatingWindowsInstallerGlyph.Glyph = "\uEC61";
                                    ApplyingImageGlyph.Glyph            = "\uEC61";
                                    IntegratingWinREGlyph.Glyph         = "\uEC61";
                                    CapturingImageGlyph.Glyph           = "\uEC61";
                                    CreatingISOGlyph.Glyph = "\uF167";
                                    break;
                                }

                            case ProcessPhase.Error:
                                {
                                    switch (lastPhase)
                                    {
                                    case ProcessPhase.ReadingMetadata:
                                        {
                                            ReadingMetadataGlyph.Glyph = "\uEB90";
                                            break;
                                        }

                                    case ProcessPhase.PreparingFiles:
                                        {
                                            PreparingFilesGlyph.Glyph = "\uEB90";
                                            break;
                                        }

                                    case ProcessPhase.CreatingWindowsInstaller:
                                        {
                                            CreatingWindowsInstallerGlyph.Glyph = "\uEB90";
                                            break;
                                        }

                                    case ProcessPhase.ApplyingImage:
                                        {
                                            ApplyingImageGlyph.Glyph = "\uEB90";
                                            break;
                                        }

                                    case ProcessPhase.IntegratingWinRE:
                                        {
                                            IntegratingWinREGlyph.Glyph = "\uEB90";
                                            break;
                                        }

                                    case ProcessPhase.CapturingImage:
                                        {
                                            CapturingImageGlyph.Glyph = "\uEB90";
                                            break;
                                        }

                                    case ProcessPhase.CreatingISO:
                                        {
                                            CreatingISOGlyph.Glyph = "\uEB90";
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }

                            if (interCommunication.ISOConversionProgress.Phase == ProcessPhase.Done)
                            {
                                // Move to finish page when done, for now, welcome page
                                Frame.Navigate(typeof(WelcomePage));
                                return;
                            }

                            lastPhase                   = interCommunication.ISOConversionProgress.Phase;
                            ProgressBar.Value           = interCommunication.ISOConversionProgress.ProgressInPercentage;
                            ProgressBar.IsIndeterminate = interCommunication.ISOConversionProgress.IsIndeterminate;
                            StatusText.Text             = interCommunication.ISOConversionProgress.SubOperation;
                        });

                    break;
                }
                }
            }
        }