コード例 #1
0
ファイル: CreateKey.cs プロジェクト: vu111293/pat-design
        void OkButtonClick(object sender, EventArgs e)
        {
            KeyFile = KeyFile.Trim();
            if (KeyFile.Length == 0)
            {
                MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.EnterKeyName}");
                return;
            }
            bool usePassword = Get <CheckBox>("usePassword").Checked;

            if (usePassword)
            {
                if (!CheckPassword(ControlDictionary["passwordTextBox"],
                                   ControlDictionary["confirmPasswordTextBox"]))
                {
                    return;
                }
                MessageService.ShowMessage("Creating a key file with a password is currently not supported.");
                return;
            }
            if (!KeyFile.EndsWith(".snk") && !KeyFile.EndsWith(".pfx"))
            {
                KeyFile += ".snk";
            }
            if (CreateKey(Path.Combine(baseDirectory, KeyFile)))
            {
                this.DialogResult = DialogResult.OK;
                Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// Event handler for when the OK button is clicked. Makes a final check on the temp directory and gives a warning if theres no space or cancels the ok if no value has been entered for it.
        /// </summary>
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            //Make sure the directory that's been entered is not an empty string and that it actually exists. If not, show an error message and stay on the options dialog.
            if (TempDirectory.Length == 0)
            {
                MessageBox.Show(this, Properties.Resources.MustSelectValidFolderText, Properties.Resources.InvalidTempFolderStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (!Directory.Exists(TempDirectory))
            {
                try
                {
                    Directory.CreateDirectory(TempDirectory);
                }
                catch
                {
                    MessageBox.Show(this, Properties.Resources.ErrorUnableToCreateTempDirStr + TempDirectory, Properties.Resources.ErrorUnableToCreateDirShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            //Make sure the drive the temp folder is on has enough space for at least a single layer DVD
            if (!Utils.CheckTempForSpace(TempDirectory))
            {
                // If there isnt enough space, show a warning and give the user the option to go ahead anyway.
                MessageBoxResult result = MessageBox.Show(this, Properties.Resources.WarningNotEnoughSpaceTempStr, Properties.Resources.ErrorNotEnoughSpaceShortStr, MessageBoxButton.OKCancel, MessageBoxImage.Warning);
                if (result != MessageBoxResult.OK)     //If the user hits cancel, they've decided not to go ahead with the selected directory which doesnt have enough space.
                {
                    return;
                }
            }
            if (EnableChannelCreation && (SrcWadFile.Trim().Length == 0 || LoaderFile.Trim().Length == 0 || KeyFile.Trim().Length == 0 || OriginalTitleId.Trim().Length == 0))
            {
                MessageBox.Show(this, Properties.Resources.ErrorInvalidChanCreationValsStr, Properties.Resources.ErrorInvalidValsShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (PartitionsToUseComboBox.SelectedIndex < 0)
            {
                MessageBox.Show(this, Properties.Resources.ErrorInvalidPartitionSettingStr, Properties.Resources.ErrorInvalidValsShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (PartitionsToUseComboBox.SelectedIndex == 0)
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ONLY_GAME_PARTITION;
            }
            else if (PartitionsToUseComboBox.SelectedIndex == 1)
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.REMOVE_UPDATE_PARTITION;
            }
            else
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ALL_PARTITIONS;
            }

            _allowClosing = true;       //Allow closing now that everything checks out.
            DialogResult  = true;       //Set the result of this dialog to true, meaning the OK button was clicked and was successful. This automatically closes the dialog since it's shown modally.
        }
コード例 #3
0
        /// <summary>
        /// Returns a string value containing the command line arguments to pass directly to the executable file.
        /// </summary>
        /// <returns>
        /// A string value containing the command line arguments to pass directly to the executable file.
        /// </returns>
        protected override string GenerateCommandLineCommands()
        {
            const string errorReturnValue = "";

            if (false == ValidateInputAssemblies() ||
                false == ValidateOutputFile())
            {
                return(errorReturnValue);
            }


            #region " ILMerge.exe Command-Line Arguments "

            /*
             * [/lib:directory]*
             * [/log[:filename]]
             * [/keyfile:filename [/delaysign]]
             * [/internalize[:filename]]
             * [/t[arget]:(library|exe|winexe)]
             * [/closed]
             * [/ndebug]
             * [/ver:version]
             * [/copyattrs [/allowMultiple]]
             * [/xmldocs]
             * [/attr:filename]
             * ([/targetplatform:<version>[,<platformdir>]]|v1|v1.1|v2|v4)
             * [/useFullPublicKeyForReferences]
             * [/zeroPeKind]
             * [/wildcards]
             * [/allowDup[:typename]]*
             * [/allowDuplicateResources]
             * [/union]
             * [/align:n]
             * /out:filename
             * <primary assembly> [<other assemblies>...]
             */
            #endregion " ILMerge.exe Command-Line Arguments "

            var builder = new CommandLineBuilder();

            if (null != DuplicateTypeNames && DuplicateTypeNames.Length > 0)
            {
                foreach (var item in DuplicateTypeNames)
                {
                    var typeName = item.ItemSpec;
                    builder.AppendSwitch(string.Format("/allowDup:{0}", typeName.Trim()));
                }
            }
            else if (AllowDuplicateTypeNames)
            {
                builder.AppendSwitch("/allowDup");
            }

            if (AllowMultipleAssemblyLevelAttributes)
            {
                builder.AppendSwitch("/allowMultiple");
            }

            if (AllowWildCards)
            {
                builder.AppendSwitch("/wildcards");
            }

            if (AllowZeroPeKind)
            {
                builder.AppendSwitch("/zeroPeKind");
            }

            if (false == string.IsNullOrWhiteSpace(AttributeFile))
            {
                builder.AppendSwitch(string.Format("/attr:\"{0}\"", AttributeFile.Trim()));
            }

            if (Closed)
            {
                builder.AppendSwitch("/closed");
            }

            if (CopyAttributes)
            {
                builder.AppendSwitch("/copyattrs");
            }

            if (false == DebugInfo)
            {
                builder.AppendSwitch("/ndebug");
            }

            if (DelaySign)
            {
                builder.AppendSwitch("/delaysign");
            }

            if (FileAlignment != DefaultFileAlignment)
            {
                builder.AppendSwitch(string.Format("/align:{0}", FileAlignment));
            }

            if (Internalize)
            {
                builder.AppendSwitch(string.Format("/internalize{0}", string.IsNullOrWhiteSpace(ExcludeFile) ? "" : string.Format(":\"{0}\"", ExcludeFile.Trim())));
            }

            if (false == string.IsNullOrWhiteSpace(KeyFile))
            {
                builder.AppendSwitch(string.Format("/keyfile:\"{0}\"", KeyFile.Trim()));
            }

            if (false == string.IsNullOrWhiteSpace(LogFile))
            {
                builder.AppendSwitch(string.Format("/log:\"{0}\"", LogFile.Trim()));
            }

            if (false == PublicKeyTokens)
            {
                builder.AppendSwitch("/useFullPublicKeyForReferences");
            }

            if (null != SearchDirectories && SearchDirectories.Length > 0)
            {
                foreach (var item in SearchDirectories)
                {
                    var directory = item.ItemSpec;
                    builder.AppendSwitch(string.Format("/lib:\"{0}\"", directory.Trim()));
                }
            }

            // Target Platform
            if (false == string.IsNullOrWhiteSpace(TargetPlatformDirectory) &&
                false == string.IsNullOrWhiteSpace(TargetPlatformVersion))
            {
                var value = string.Format("{0},\"{1}\"", TargetPlatformVersion.Trim().ToLowerInvariant(), TargetPlatformDirectory.Trim());
                builder.AppendSwitch(string.Format("/targetplatform:{0}", value));
            }

            if (false == string.IsNullOrWhiteSpace(TargetType))
            {
                builder.AppendSwitch(string.Format("/target:{0}", TargetType.Trim().ToLowerInvariant()));
            }

            if (UnionMerge)
            {
                builder.AppendSwitch("/union");
            }

            if (XmlDocumentation)
            {
                builder.AppendSwitch("/xmldocs");
            }

            if (false == string.IsNullOrWhiteSpace(Version))
            {
                builder.AppendSwitch(string.Format("/ver:{0}", Version.Trim()));
            }

            // OutputFile is added after all other switches and before the InputAssemblies.
            builder.AppendSwitch(string.Format("/out:\"{0}\"", OutputFile));

            // InputAssemblies must be added after all other switches.
            if (null != InputAssemblies && InputAssemblies.Length > 0)
            {
                foreach (var inputAssemblyPath in InputAssemblies)
                {
                    builder.AppendTextUnquoted(string.Format(" \"{0}\"", inputAssemblyPath));
                }
            }

            return(builder.ToString());
        }