private void StartInstallStep(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     StinkyFile.Installation.AutoInstall.InstallationType type = AutoInstall.InstallationType.Unknown;
     if (sender.Equals(ExtractionStepBorder))
     {
         type = AutoInstall.InstallationType.ExtractContent;
     }
     if (sender.Equals(FontBorder))
     {
         type = AutoInstall.InstallationType.CreateFont;
     }
     if (sender.Equals(ModelsBorder))
     {
         type = AutoInstall.InstallationType.CreateModels;
     }
     if (sender.Equals(PatchingBorder)) // patching step handled outside of StinkyFile
     {
         PatchKrabbyQuest(true);
         return;
     }
     if (type != default)
     {
         StartInstallation(type);
     }
 }
 void StepStarted(object s, StinkyFile.Installation.AutoInstall.InstallationType Type)
 {
     if (Type == AutoInstall.InstallationType.CreateModels)
     {
         Dispatcher.Invoke(PromptBlenderPlugin);
     }
     if (Type == AutoInstall.InstallationType.Finish)
     {
         if (isPartialInstall)
         {
             return;
         }
         Installation.Paused = true;
         //Patch krabby quest, then finally check the manifest in the finalization step
         PatchKrabbyQuest(false).ContinueWith(delegate { Installation.Paused = false; });
     }
 }
        void StartInstallation(StinkyFile.Installation.AutoInstall.InstallationType Type = default)
        {
            if (Installing)
            {
                MessageBox.Show("An installation is in progress. The current installation must be canceled or complete " +
                                "to start another one.", "Cannot Start Installation");
                return;
            }
            //Save user prefs
            SaveUserPrefs();
            //UI enable/disable
            PreferencesGrid.IsEnabled = false;
            //clear errors
            ErrorStack.Children.Clear();
            //started text
            var textBlock = new TextBlock()
            {
                Text = $"{(Type == default ? "Full" : AutoInstall.GetFriendlyStepName(Type))}" +
                       $" Installation starting...",
                Foreground   = Brushes.DarkCyan,
                FontWeight   = FontWeights.Bold,
                TextWrapping = TextWrapping.Wrap
            };

            ErrorStack.Children.Add(textBlock);
            //create installation context
            Installation = new StinkyFile.Installation.AutoInstall()
            {
                DestinationDirectory = WorkspaceDir.Text,
                BlenderPath          = BlenderPath.Text,
                SourceDirectory      = InstallPath.Text,
                OnTgaExtracting      = (object s, (string path, StinkyFile.ManifestChunk chunk, RefPrim <bool> success)tuple) =>
                                       ExtractTarGA(tuple.path, tuple.chunk, tuple.success),
                OnFontCreate = (object s, (string path, RefPrim <bool> success)tuple) =>
                               RunFontConverter(tuple.path, tuple.success),
                OnProgressChanged = (object s, InstallationCompletionInfo info) => InstallationInformationChanged(info),
                OnStepStarted     = StepStarted,
                OnErrorRaised     = (object s, string error) => SafePushError(error, Brushes.Red)
            };
            Installation.OnPausedStateChanged += Installation_OnPausedStateChanged;
            Installing = true;
            if (Type != default)
            {
                isPartialInstall = true;
                partialTitle     = AutoInstall.GetFriendlyStepName(Type);
                PartialType      = Type;
            }
            else
            {
                isPartialInstall = false;
            }
            //run async task
            Task.Run(() =>
            {
                if (Type == default)
                {
                    return(Installation.Start());
                }
                else
                {
                    return(Installation.Start(Type));
                }
            }).ContinueWith((Task <bool> task) => OnInstallationCompleted(task));
        }