Exemplo n.º 1
0
        /// <summary>
        /// Displays the current wizard step.
        /// </summary>
        internal protected void DisplayWizardStep(WizardStep step, int currentStep, int totalSteps)
        {
            SuspendLayout();
            try
            {
                //step.Control.Visible = true;
                SetWizardBody(step.Control);

                this.Header = step.Header;
                if (step.NextButtonLabel != null)
                {
                    NextButtonText = step.NextButtonLabel;
                }
                else
                {
                    if (currentStep == totalSteps - 1)
                    {
                        NextButtonText = BUTTON_TEXT_FINISH;
                    }
                    else
                    {
                        NextButtonText = BUTTON_TEXT_NEXT;
                    }
                }

                if (currentStep == 0)
                {
                    buttonBack.Enabled = false;
                }
                else
                {
                    buttonBack.Enabled = true;
                }

                this.buttonBack.Visible = totalSteps > 1;

                //drive focus to the new body control (only if the step control didn't manually drive
                //focus to one of its sub-controls)
                if (step.Control.ActiveControl == null)
                {
                    if (step.WantsFocus)
                    {
                        wizardBody.Select();
                        wizardBody.SelectNextControl(wizardBody, true, true, true, true);
                    }
                    else
                    {
                        buttonNext.Select();
                    }
                }
            }
            finally
            {
                ResumeLayout();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new Wizard step.
 /// </summary>
 /// <param name="header">The image and label header to assign this step</param>
 /// <param name="control">The control to display when this step is activated.</param>
 /// <param name="verify">A verification callback that will be triggered prior to advancing
 /// past this step. If this callback returns false, the step will not advance.</param>
 /// <param name="next">A callback that will be triggered after the step has been verified
 /// and just before advancing to the next step. Steps can use this callback to add additional
 /// substeps prior to moving past this step.</param>
 /// <param name="back">A callback that will be triggered when the Wizard is going back one step.
 /// WizardSteps can use this callback to rollback any stateful side effects that may have occurred
 /// as a result of previously executing this step.</param>
 public WizardStep(UserControl control, StringId?header, WizardController.DisplayCallback display, WizardController.VerifyStepCallback verify, WizardController.NextCallback next, WizardController.NextCallback undoNext, WizardController.BackCallback back)
 {
     Control         = control;
     Header          = header;
     DisplayHandler  = display;
     VerifyHandler   = verify;
     NextHandler     = next;
     UndoNextHandler = undoNext;
     BackHandler     = back;
 }
Exemplo n.º 3
0
        private static StringId?TryGetTag(IReadOnlyList <StringId> pipTags, ImmutableDictionary <StringId, StringId> tagsToTrack, StringTable stringTable)
        {
            StringId?result = null;

            foreach (var tag in pipTags.AsStructEnumerable())
            {
                if (tagsToTrack.ContainsKey(tag))
                {
                    Contract.Check(result == null)?.Assert($"Pip contains more than one trackable tag: {tag.ToString(stringTable)}, {result.Value.ToString(stringTable)}");
                    result = tag;
                }
            }

            return(result);
        }
Exemplo n.º 4
0
    public void Convert(string[] ids, ISet <AssetType> assetTypes, Regex filePattern, Func <object, object> filter = null)
    {
        // Give the "from" universe's asset manager "to" the to exchange so we can import the assets.
        _toExchange.Attach(new AssetManager(_from));
        _fromExchange.Attach(new AssetManager(_from)); // From also needs an asset manager for the inventory post-processor etc

        var parsedIds = ids?.Select(AssetId.Parse).ToHashSet();
        var cache     = new Dictionary <(AssetId, string), object>();

        (object, AssetInfo) LoaderFunc(AssetId id, string language)
        {
            StringId?stringId = TextId.ValidTypes.Contains(id.Type)
                ? (TextId)id
                : null;

            if (stringId != null)
            {
                if (stringId.Value.Id == id)
                {
                    stringId = null;
                }
                else
                {
                    id = stringId.Value.Id;
                }
            }

            var info  = _from.GetAssetInfo(id, language);
            var asset = cache.TryGetValue((id, language), out var cached)
                ? cached
                : cache[(id, language)] = _from.LoadAsset(id, language);

            if (stringId.HasValue && asset is IStringCollection collection)
            {
                asset = collection.GetString(stringId.Value, language);
            }

            if (filter != null)
            {
                asset = filter(asset);
            }

            return(asset, info);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Clone and override select properties.
 /// </summary>
 public Process Override(
     FileArtifact?executable       = null,
     AbsolutePath?workingDirectory = null,
     PipData?arguments             = null,
     FileArtifact?responseFile     = null,
     PipData?responseFileData      = null,
     ReadOnlyArray <EnvironmentVariable>?environmentVariables = null,
     StandardInput?standardInput    = null,
     FileArtifact?standardOutput    = null,
     FileArtifact?standardError     = null,
     AbsolutePath?standardDirectory = null,
     TimeSpan?warningTimeout        = null,
     TimeSpan?timeout = null,
     ReadOnlyArray <FileArtifact>?dependencies = null,
     ReadOnlyArray <FileArtifactWithAttributes>?fileOutputs  = null,
     ReadOnlyArray <DirectoryArtifact>?directoryDependencies = null,
     ReadOnlyArray <DirectoryArtifact>?directoryOutputs      = null,
     ReadOnlyArray <PipId>?orderDependencies      = null,
     ReadOnlyArray <AbsolutePath>?untrackedPaths  = null,
     ReadOnlyArray <AbsolutePath>?untrackedScopes = null,
     ReadOnlyArray <StringId>?tags                   = null,
     ReadOnlyArray <int>?successExitCodes            = null,
     ReadOnlyArray <ProcessSemaphoreInfo>?semaphores = null,
     PipProvenance provenance = null,
     StringId?toolDescription = null,
     ReadOnlyArray <AbsolutePath>?additionalTempDirectories = null,
     RegexDescriptor?warningRegex         = null,
     RegexDescriptor?errorRegex           = null,
     AbsolutePath?uniqueOutputDirectory   = null,
     AbsolutePath?redirectedDirectoryRoot = null,
     AbsolutePath?tempDirectory           = null,
     Options?options                    = null,
     bool?testRetries                   = null,
     ServiceInfo serviceInfo            = null,
     ReadOnlyArray <int>?retryExitCodes = null,
     ReadOnlyArray <PathAtom>?allowedSurvivingChildProcessNames = null,
     TimeSpan?nestedProcessTerminationTimeout = null,
     AbsentPathProbeInUndeclaredOpaquesMode absentPathProbeMode = AbsentPathProbeInUndeclaredOpaquesMode.Unsafe,
     DoubleWritePolicy doubleWritePolicy             = DoubleWritePolicy.DoubleWritesAreErrors,
     ContainerIsolationLevel containerIsolationLevel = ContainerIsolationLevel.None)
 {
     return(new Process(
                executable ?? Executable,
                workingDirectory ?? WorkingDirectory,
                arguments ?? Arguments,
                responseFile ?? ResponseFile,
                responseFileData ?? ResponseFileData,
                environmentVariables ?? EnvironmentVariables,
                standardInput ?? StandardInput,
                standardOutput ?? StandardOutput,
                standardError ?? StandardError,
                standardDirectory ?? StandardDirectory,
                warningTimeout ?? WarningTimeout,
                timeout ?? Timeout,
                dependencies ?? Dependencies,
                fileOutputs ?? FileOutputs,
                directoryDependencies ?? DirectoryDependencies,
                directoryOutputs ?? DirectoryOutputs,
                orderDependencies ?? OrderDependencies,
                untrackedPaths ?? UntrackedPaths,
                untrackedScopes ?? UntrackedScopes,
                tags ?? Tags,
                successExitCodes ?? SuccessExitCodes,
                semaphores ?? Semaphores,
                provenance ?? Provenance,
                toolDescription ?? ToolDescription,
                additionalTempDirectories ?? AdditionalTempDirectories,
                warningRegex ?? WarningRegex,
                errorRegex ?? ErrorRegex,
                uniqueOutputDirectory ?? UniqueOutputDirectory,
                redirectedDirectoryRoot ?? UniqueRedirectedDirectoryRoot,
                tempDirectory ?? TempDirectory,
                options ?? ProcessOptions,
                testRetries ?? TestRetries,
                serviceInfo ?? ServiceInfo,
                retryExitCodes ?? RetryExitCodes,
                allowedSurvivingChildProcessNames,
                nestedProcessTerminationTimeout,
                absentPathProbeMode,
                doubleWritePolicy,
                containerIsolationLevel));
 }
 /// <summary>
 /// Creates a new Wizard step.
 /// </summary>
 /// <param name="header">The image and label header to assign this step</param>
 /// <param name="control">The control to display when this step is activated.</param>
 /// <param name="verify">A verification callback that will be triggered prior to advancing
 /// past this step. If this callback returns false, the step will not advance.</param>
 /// <param name="next">A callback that will be triggered after the step has been verified
 /// and just before advancing to the next step. Steps can use this callback to add additional
 /// substeps prior to moving past this step.</param>
 /// <param name="back">A callback that will be triggered when the Wizard is going back one step.
 /// WizardSteps can use this callback to rollback any stateful side effects that may have occurred
 /// as a result of previously executing this step.</param>
 public WizardStep(UserControl control, StringId? header, WizardController.DisplayCallback display, WizardController.VerifyStepCallback verify, WizardController.NextCallback next, WizardController.NextCallback undoNext, WizardController.BackCallback back)
 {
     Control = control;
     Header = header;
     DisplayHandler = display;
     VerifyHandler = verify;
     NextHandler = next;
     UndoNextHandler = undoNext;
     BackHandler = back;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Displays the current wizard step.
        /// </summary>
        internal protected void DisplayWizardStep(WizardStep step, int currentStep, int totalSteps)
        {
            SuspendLayout();
            try
            {
                //step.Control.Visible = true;
                SetWizardBody(step.Control);

                this.Header = step.Header;
                if (step.NextButtonLabel != null)
                {
                    NextButtonText = step.NextButtonLabel;
                }
                else
                {
                    if (currentStep == totalSteps - 1)
                    {
                        NextButtonText = BUTTON_TEXT_FINISH;
                    }
                    else
                    {
                        NextButtonText = BUTTON_TEXT_NEXT;
                    }
                }

                if (currentStep == 0)
                {
                    buttonBack.Enabled = false;
                }
                else
                {
                    buttonBack.Enabled = true;
                }

                this.buttonBack.Visible = totalSteps > 1;

                //drive focus to the new body control (only if the step control didn't manually drive
                //focus to one of its sub-controls)
                if (step.Control.ActiveControl == null)
                {
                    if (step.WantsFocus)
                    {
                        wizardBody.Select();
                        wizardBody.SelectNextControl(wizardBody, true, true, true, true);
                    }
                    else
                    {
                        buttonNext.Select();
                    }
                }
            }
            finally
            {
                ResumeLayout();
            }
        }
Exemplo n.º 8
0
 public WizardSubStep(UserControl control, StringId?header, WizardController.DisplayCallback display, WizardController.VerifyStepCallback verify, WizardController.NextCallback next, WizardController.NextCallback undoNext, WizardController.BackCallback back) :
     base(control, header, display, verify, next, undoNext, back)
 {
 }
Exemplo n.º 9
0
 protected virtual Control CreateHeaderFromString(StringId?value)
 {
     return(null);
 }
Exemplo n.º 10
0
        public static void Convert(
            IFileSystem disk,
            IJsonUtil jsonUtil,
            string fromMod,
            string toMod,
            string[] ids,
            ISet <AssetType> assetTypes,
            Regex filePattern)
        {
            if (disk == null)
            {
                throw new ArgumentNullException(nameof(disk));
            }
            if (jsonUtil == null)
            {
                throw new ArgumentNullException(nameof(jsonUtil));
            }

            var baseDir = ConfigUtil.FindBasePath(disk);

            var(from, fromExchange, fromLoaderRegistry) = BuildModApplier(baseDir, fromMod, disk, jsonUtil);
            var(to, toExchange, toLoaderRegistry)       = BuildModApplier(baseDir, toMod, disk, jsonUtil);

            using (fromExchange)
                using (fromLoaderRegistry)
                    using (toExchange)
                        using (toLoaderRegistry)
                        {
                            // Give the "from" universe's asset manager "to" the to exchange so we can import the assets.
                            toExchange.Attach(new AssetManager(from));
                            fromExchange.Attach(new AssetManager(from)); // From also needs an asset manager for the inventory post-processor etc

                            var parsedIds = ids?.Select(AssetId.Parse).ToHashSet();
                            var cache     = new Dictionary <(AssetId, string), object>();

                            (object, AssetInfo) LoaderFunc(AssetId id, string language)
                            {
                                StringId?stringId = TextId.ValidTypes.Contains(id.Type)
                        ? (TextId)id
                        : (StringId?)null;

                                if (stringId != null)
                                {
                                    if (stringId.Value.Id == id)
                                    {
                                        stringId = null;
                                    }
                                    else
                                    {
                                        id = stringId.Value.Id;
                                    }
                                }

                                var info  = from.GetAssetInfo(id, language);
                                var asset = cache.TryGetValue((id, language), out var cached)
                        ? cached
                        : cache[(id, language)] = from.LoadAsset(id, language);

                                if (stringId.HasValue && asset is IStringCollection collection)
                                {
                                    asset = collection.GetString(stringId.Value, language);
                                }

                                return(asset, info);
                            }

                            to.SaveAssets(LoaderFunc, () => cache.Clear(), parsedIds, assetTypes, filePattern);
                        }