private void Replace_Click(object sender, EventArgs e) { Button ReplaceModeeButton = sender as Button; string replace = ReplaceModeeButton.Tag.ToString(); ReplaceCheck = true; switch (replace) { case "TextChange": { TextChangMode = ReplaceMode.TextChange; ReplaceText = ReplaceTextBox.Text; ReplaceTextToForm(SearchTextBox.Text); break; } case "AllTextChange": { TextChangMode = ReplaceMode.AllTextChange; ReplaceText = ReplaceTextBox.Text; ReplaceTextToForm(SearchTextBox.Text); break; } } }
/// <summary> /// Initializes a new instance of PronunciationRule /// </summary> /// <param name="word">The base word or phrase</param> /// <param name="pronunciation">The pronunciation string of the base word of phrase</param> /// <param name="replaceMode">The replacement mode for pronunciation rules</param> /// <param name="priority">An integer value used to sort the pronuniation rules</param> public PronunciationRule(string word, string pronunciation, ReplaceMode replaceMode, int priority) : this() { this.Word = word; this.Pronunciation = pronunciation; this.ReplaceMode = replaceMode; this.Priority = priority; }
/// <summary> /// It replaces the image of the picture box. /// </summary> /// <param name="replaceMode">The way the image must be changed.</param> private void ReplaceImage(ReplaceMode replaceMode) { Color notToChangeC = cbSpriteMode.Checked ? pnlSpriteMode.BackColor : Color.Empty; if (replaceMode == ReplaceMode.HSB) { pbImage.Image = Colorer.ReplaceColor((Image)m_currentSettings[0], pnlOldColor.BackColor, tbTolerance.Value, tbHue.Value, tbSaturation.Value / 100f, tbBrightness.Value / 100f, new List <Color>() { notToChangeC }); } else if (replaceMode == ReplaceMode.RGB) { pbImage.Image = Colorer.ReplaceColor((Image)m_currentSettings[0], pnlOldColor.BackColor, pnlNewColor.BackColor, tbTolerance.Value, new List <Color>() { notToChangeC }, cbAutoMode.Checked); } else { pbImage.Image = m_baseImage; } // Change the old panel color so the good color is always edited. if (!cbAutoMode.Checked) { cdOldColor.Color = pnlNewColor.BackColor; pnlOldColor.BackColor = cdOldColor.Color; } }
public bool Copy(ILocation sourceLocation, ILocation destinationLocation, ReplaceMode replaceMode) { if (replaceMode == ReplaceMode.UserAsking) throw new Exception ("Use Copy(ILocation,ILocation,Func<ReplaceMode>) call."); return Copy (sourceLocation, destinationLocation, replaceMode, null); }
public DmlReplaceStatement(ReplaceMode mode, Identifier table, IList <Identifier> columnNameList, IQueryExpression select) : base(table, columnNameList, select) { Mode = mode; }
public DmlReplaceStatement(ReplaceMode mode, Identifier table, IList<Identifier> columnNameList, IList<RowExpression> rowList) : base(table, columnNameList, rowList) { Mode = mode; }
public DmlReplaceStatement(ReplaceMode mode, Identifier table, IList <Identifier> columnNameList, IList <RowExpression> rowList) : base(table, columnNameList, rowList) { Mode = mode; }
public DmlReplaceStatement(ReplaceMode mode, Identifier table, IList<Identifier> columnNameList, IQueryExpression select) : base(table, columnNameList, select) { Mode = mode; }
/// <summary> /// Initializes a new instance of PronunciationRule /// </summary> public PronunciationRule() { this.word = null; this.pronunciation = null; this.rxPronunciationReplacer = null; this.priority = 0; this.replaceMode = ReplaceMode.FullWords; evaluator = new MatchEvaluator(Evaluator); }
public PushRequest BeginPush(ILocation destinationLocation, ReplaceMode replaceMode) { var request = CreateRequest (destinationLocation.ItemUri, WebRequestMethods.Ftp.UploadFile, Credentials); var pushRequest = new FtpPushRequest { OutputStream = request.GetRequestStream(), }; return pushRequest; }
/// <summary> /// Adds a new PronunciationRule object to the PronunciationRuleList /// </summary> /// <param name="word">The base word or phrase</param> /// <param name="pronunciation">The pronunciation string of the base word of phrase</param> /// <param name="replaceMode">The replacement mode for pronunciation rules</param> /// <param name="priority">An integer value used to sort the pronuniation rules</param> public void Add(string word, string pronunciation, ReplaceMode replaceMode, int priority) { int ix; ix = IndexOf(word); if (ix != -1) { this.RemoveAt(ix); } base.Add(new PronunciationRule(word, pronunciation, replaceMode, priority)); }
static public VoxelChannel AND(VoxelChannel a, VoxelChannel b, ReplaceMode rep) { int x, y, z; for (z = 0; z < a.ZScale; z++) { for (y = 0; y < a.YScale; y++) { for (x = 0; x < a.XScale; x++) { bool As = a.IsSolid(x, y, z); bool Bs = b.IsSolid(x, y, z); if (As && Bs) { a.SetVoxel(x, y, z, b.GetVoxel(x, y, z)); } } } } return(a); }
public static void ProduceWord2007UP(string TmplPath, string targetPath, Dictionary<string, Object> marks, ReplaceMode mode) { string tempPath = Path.GetTempFileName(); try { if (!dict.ContainsKey(TmplPath)) dict.Add(TmplPath, new Object()); } catch (Exception) { } object lockobj = dict[TmplPath]; if (lockobj != null) { lock (lockobj) { #region 产生Word ProduceWord(TmplPath, targetPath, tempPath, marks, false, mode); #endregion } } }
private static void TRSuffix(this JavascriptFormatter formatter, ReplaceMode replaceMode) { switch (replaceMode) { case ReplaceMode.In: formatter.Dot(); formatter.Identifier("TIn"); break; case ReplaceMode.Out: formatter.Dot(); formatter.Identifier("TOut"); break; case ReplaceMode.Instance: formatter.Dot(); formatter.Identifier("Instance"); break; default: throw new ArgumentOutOfRangeException("replaceMode"); } }
private static void ProduceWord(string TmplPath, string targetPath, string tempPath, Dictionary<string, object> Marks, bool IsNeedToDoc, ReplaceMode mode) { try { //其实等效于把模板经行一个拷贝 using (FileStream fsSource = new FileStream(TmplPath, FileMode.Open, FileAccess.Read)) // 先读取源文件 { using (FileStream fsDes = new FileStream(tempPath, FileMode.Create, FileAccess.Write)) //避免存在不能创建的问题,直接覆盖 { fsSource.CopyTo(fsDes); fsSource.Flush(); fsDes.Close(); fsSource.Close(); } } //把新产生的文件按批注替换 switch (mode) { case ReplaceMode.comment: OpenXmlHelper.ReplaceComments(tempPath, Marks); break; case ReplaceMode.bookmark: OpenXmlHelper.ReplaceBookMarks(tempPath, Marks); break; default: throw new Exception("未使用正确模板替换模式"); break; } // if (IsNeedToDoc) OfficeCOM.DocxToDoc(tempPath, targetPath); else { File.Copy(tempPath, targetPath, true); } } catch (Exception ex) { throw ex; } finally { File.Delete(tempPath); } }
private FileMode GetFileMode(ReplaceMode replaceMode) { if (replaceMode == ReplaceMode.Ignore) return FileMode.CreateNew; if (replaceMode == ReplaceMode.Resume) return FileMode.Append; if ((replaceMode & ReplaceMode.ReplaceIfDifferentSize) == ReplaceMode.ReplaceIfDifferentSize) return FileMode.Create; if (replaceMode == ReplaceMode.Replace) return FileMode.Create; if (replaceMode == ReplaceMode.Rename) return FileMode.CreateNew; if (replaceMode == ReplaceMode.UserAsking) throw new NotImplementedException ("UserAsking is not not a valid ReplaceMode."); if ((replaceMode & ReplaceMode.ReplaceIfNewer) == ReplaceMode.ReplaceIfNewer) return FileMode.Create; throw new NotSupportedException ("ReplaceMode not supported for UNC copy."); }
public PushRequest BeginPush(ILocation destinationLocation, ReplaceMode replaceMode) { #if DEBUG Trace.TraceInformation("Push : " + WindowsIdentity.GetCurrent().Name); #endif var filePath = GetPathFromLocation (destinationLocation); var pushRequest = new UncPushRequest {OutputStream = File.Open(filePath, GetFileMode(replaceMode))}; return pushRequest; }
public async Task <int> ReplaceStrings(string matchString, string newString, Encoding encoding, ReplaceMode replaceMode) { return(await ReplaceStrings(matchString, newString, null, encoding, replaceMode)); }
protected void OnGUI() { EditorGUIUtility.labelWidth = 100f; GUILayout.BeginVertical(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.top); GUILayout.BeginHorizontal(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.left); GUILayout.BeginVertical(); GUI.changed = false; this.m_Instance = EditorGUILayout.ObjectField("Sprite Packer", this.m_Instance, typeof(SPInstance), false) as SPInstance; if (GUI.changed) { // Save the instance id EditorPrefs.SetInt(SPTools.Settings_SavedInstanceIDKey, (this.m_Instance == null) ? 0 : this.m_Instance.GetInstanceID()); } GUILayout.Space(6f); GUILayout.BeginVertical(GUI.skin.box); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); EditorGUILayout.LabelField("Replace mode", GUILayout.Width(130f)); this.m_ReplaceMode = (ReplaceMode)EditorGUILayout.EnumPopup(this.m_ReplaceMode); GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Replace references in", GUILayout.Width(130f)); this.m_TargetMode = (TargetMode)EditorGUILayout.EnumPopup(this.m_TargetMode); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode, (int)this.m_TargetMode); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUI.changed = false; bool spriteRenderersOnly = GUILayout.Toggle(EditorPrefs.GetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly), " Replace references in Sprite Renderers only ?"); if (GUI.changed) { EditorPrefs.SetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly, spriteRenderersOnly); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.EndVertical(); GUILayout.Space(6f); if (this.m_Instance == null) { EditorGUILayout.HelpBox("Please set the sprite packer instance reference in order to use this feature.", MessageType.Info); } else { if (GUILayout.Button("Replace")) { int replacedCount = 0; switch (this.m_TargetMode) { case TargetMode.CurrentScene: { replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); break; } case TargetMode.ProjectOnly: { replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); break; } case TargetMode.CurrentSceneAndProject: { replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); break; } case TargetMode.AllScenes: { replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, false); break; } case TargetMode.AllScenesAndProject: { replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, true); break; } } EditorUtility.DisplayDialog("Reference Replacer", "Replaced references count: " + replacedCount.ToString(), "Okay"); } } GUILayout.EndVertical(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.right); GUILayout.EndHorizontal(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.bottom); GUILayout.EndVertical(); }
public static void MatchLibraryPath(ref string Dir, string BaseDir, Uri Url, ReplaceMode Mode, ILanguage Language) { if (Directory.Exists(BaseDir)) { string[] Dirs = Directory.GetDirectories(BaseDir, "*", SearchOption.TopDirectoryOnly); Dirs = (from x in Dirs select Path.GetFileName(x.TrimEnd('/', '\\'))).ToArray(); string[] MDirs = (from x in Dirs select MinifyString(x)).ToArray(); string MDir = MinifyString(Dir); for (int i = 0; i < MDirs.Length; i++) { if (MDir == MDirs[i]) { string CDir = Dirs[i]; //Search For Next New Folder Name or if this one is already Downloaded in any possible New Folder string NDir = CDir; int x = 0; do { NDir = CDir + (x++ == 0 ? "" : " (" + x.ToString("D2") + ")"); string OnlineUrl = Path.Combine(BaseDir, NDir, "Online.url"); if (!File.Exists(OnlineUrl)) { break; } try { var URI = Ini.GetConfig("InternetShortcut", "URL", OnlineUrl).Substring(null, "#", IgnoreMissmatch: true); if (URI.ToLower() == Url.AbsoluteUri.ToLower()) { Mode = ReplaceMode.NewFolder; break; } } catch { var OnlineData = string.Format(Properties.Resources.UrlFile, Url.AbsoluteUri); File.WriteAllText(OnlineUrl, OnlineData); } } while (true); if (CDir != NDir) { switch (Mode) { case ReplaceMode.Ask: var Reply = AccountTools.PromptOption(Language.ReplaceMode, new[] { Language.UpdateURL, Language.NewFolder }); if (Reply == Language.UpdateURL) { goto case ReplaceMode.UpdateURL; } else { goto case ReplaceMode.NewFolder; } case ReplaceMode.UpdateURL: break; case ReplaceMode.NewFolder: CDir = NDir; break; } } Dir = CDir; break; } } } Dir = new string((from x in Dir where !Path.GetInvalidFileNameChars().Contains(x) select x).ToArray()); }
public ReplaceStatement(ReplaceMode mode, bool ignore, Identifier table, IList <Identifier> columnList, IQueryExpression select) : base(table, columnList, select) { this.Mode = mode; }
public void Replace(int offset, int length, string text, ReplaceMode replaceMode = ReplaceMode.Normal) { _document.Replace(offset, length, text, (AvaloniaEdit.Document.OffsetChangeMappingType)replaceMode); }
private void Replace(ReplaceMode mode) { foreach (var collection in Collection.collections) { if (collection.name == _oriatlas) { string[] items; List <Frame> frames; switch (mode) { case ReplaceMode.Single: items = new string[] { _frame }; frames = collection.frames; break; case ReplaceMode.All: items = listBox8.Items.OfType <string>().ToArray(); frames = collection.frames; break; case ReplaceMode.Restore: items = listBox7.SelectedItems.OfType <string>().ToArray(); frames = new DirectoryInfo(folderpath).GetFiles("???-??-???[backup]??????.png", SearchOption.AllDirectories).Select(f => new Frame(f)).ToList(); break; default: items = new string[] { }; frames = collection.frames; break; } foreach (string item in items) { foreach (var frameneeded in frames) { if (frameneeded.info.Name == item) { Bitmap cutted = Cut(frameneeded); foreach (var frame in collection.frames) { if (frame.sprite.id == frameneeded.sprite?.id && frame.info.FullName != frameneeded.info.FullName || mode == ReplaceMode.Restore && frame.info.Name == frameneeded.info.Name.Remove(10, 14)) { string orig = frameneeded.info.FullName; string _orig = frameneeded.info.Name; string dst = frame.info.FullName; string _dst = frame.info.Name; if (backup && mode != ReplaceMode.Restore) { string bak = frame.info.DirectoryName + "\\" + frame.info.Name.Substring(0, frame.info.Name.Length - 4) + "[backup]" + DateTime.Now.ToString("HHmmss") + ".png"; string _bak = frame.info.Name.Substring(0, frame.info.Name.Length - 4) + "[backup]" + DateTime.Now.ToString("HHmmss") + ".png"; if (File.Exists(bak)) { File.Delete(bak); } File.Copy(dst, bak); Log("[" + GlobalData.GlobalLanguage.Main_CheckBox1 + "] " + _dst + " => " + _bak); } if (mode != ReplaceMode.Restore && fixedmode && !FramePixelEquals(frame, frameneeded)) { Bitmap fix = Fix(cutted, frame); if (File.Exists(dst)) { File.Delete(dst); } fix.Save(dst); } if (mode == ReplaceMode.Restore || !fixedmode && !FrameMD5HashEquals(frame, frameneeded)) { if (File.Exists(dst)) { File.Delete(dst); } File.Copy(orig, dst); if (mode == ReplaceMode.Restore && File.Exists(orig)) { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } File.Delete(orig); } } Log("[" + GlobalData.GlobalLanguage.Main_Button2 + "] " + _orig + " => " + _dst); } } } } } } } }
public static bool WriteTypeReference(this JavascriptFormatter formatter, TypeReference typeReference, TypeDefinition context, ReplaceMode replaceMode, bool useStandartSubstitution = true) { if (typeReference is ArrayType) { var arrayType = (ArrayType)typeReference; formatter.WriteRaw("$asmJsilCore.System."); formatter.Identifier(arrayType.IsVector ? "Vector" : "Array"); formatter.TRSuffix(replaceMode); formatter.WriteRaw("<"); formatter.WriteTypeReference(arrayType.ElementType, context, ReplaceMode.Instance); formatter.Comma(); formatter.WriteTypeReference(arrayType.ElementType, context, ReplaceMode.In); formatter.Comma(); formatter.WriteTypeReference(arrayType.ElementType, context, ReplaceMode.Out); if (!arrayType.IsVector) { formatter.Comma(); formatter.WriteRaw("\""); formatter.Value(arrayType.Dimensions.Count.ToString(CultureInfo.InvariantCulture)); formatter.WriteRaw("\""); } formatter.WriteRaw(">"); } else if (typeReference is ByReferenceType) { var byRefType = (ByReferenceType)typeReference; formatter.WriteRaw("$asmJsilCore.JSIL.Reference"); formatter.TRSuffix(replaceMode); formatter.WriteRaw("<"); formatter.WriteTypeReference(byRefType.ElementType, context, ReplaceMode.Instance); formatter.Comma(); formatter.WriteTypeReference(byRefType.ElementType, context, ReplaceMode.In); formatter.Comma(); formatter.WriteTypeReference(byRefType.ElementType, context, ReplaceMode.Out); formatter.WriteRaw(">"); } else if (typeReference is GenericParameter) { var gp = (GenericParameter)typeReference; DefinitelyTypedUtilities.GenericParemetersKeyedCollection map; if (gp.Owner is TypeDefinition) { map = DefinitelyTypedUtilities.BuildGenericParemetersMap(((TypeDefinition)gp.Owner).GenericParameters, null); } else if (gp.Owner is MethodDefinition) { map = DefinitelyTypedUtilities.BuildGenericParemetersMap(((MethodDefinition)gp.Owner).GenericParameters, ((MethodDefinition)gp.Owner).DeclaringType.GenericParameters); } else { throw new Exception("Unexpected generic parameter owner"); } var name = map[gp].Value; switch (replaceMode) { case ReplaceMode.Instance: formatter.Identifier(DefinitelyTypedUtilities.GetGenericParameterInstanceParameterName(name)); break; case ReplaceMode.Out: formatter.Identifier(DefinitelyTypedUtilities.GetGenericParameterOutParameterName(name)); break; case ReplaceMode.In: formatter.Identifier(DefinitelyTypedUtilities.GetGenericParameterInParameterName(name)); break; default: throw new ArgumentOutOfRangeException("replaceMode", replaceMode, null); } } else if (typeReference is GenericInstanceType) { var genericType = (GenericInstanceType)typeReference; if (formatter.WriteTypeReference(genericType.ElementType, context, replaceMode)) /*TODO*/ { formatter.WriteRaw("<"); formatter.CommaSeparatedList(genericType.GenericArguments, genericArgument => { formatter.WriteTypeReference(genericArgument, context, ReplaceMode.Instance); formatter.Comma(); formatter.WriteTypeReference(genericArgument, context, ReplaceMode.In); formatter.Comma(); formatter.WriteTypeReference(genericArgument, context, ReplaceMode.Out); }); formatter.WriteRaw(">"); } } else if (typeReference is PointerType || typeReference is OptionalModifierType || typeReference is RequiredModifierType || typeReference is PinnedType || typeReference is SentinelType || typeReference is FunctionPointerType || (!_coreTypes.Contains(typeReference.FullName) && formatter.TypeInfo.Get(typeReference).IsSuppressDeclaration)) { formatter.WriteRaw("Object"); // TODO! return(false); } else { string rawType; if (useStandartSubstitution && _rawTypes.TryGetValue(typeReference.FullName, out rawType)) { formatter.WriteRaw(rawType); } else { var definition = typeReference.Resolve(); var targetAssembly = JavascriptFormatter.GetContainingAssemblyName(typeReference); string assemblyRef; if (_coreTypes.Contains(definition.FullName)) { assemblyRef = "$asmJsilCore"; } else if (targetAssembly == formatter.Assembly.FullName) { assemblyRef = string.Empty; } else { assemblyRef = formatter.Manifest.Entries.FirstOrDefault(item => item.Value == targetAssembly).Key; } if (definition != null && assemblyRef != null) { if (assemblyRef != string.Empty) { formatter.Identifier(assemblyRef); formatter.Dot(); } else { formatter.Identifier("$private"); formatter.Dot(); } foreach (var part in DefinitelyTypedUtilities.GetFullNamespace(definition)) { formatter.Identifier(part); formatter.Dot(); } formatter.Identifier(DefinitelyTypedUtilities.GetClassName(definition)); /* Hack to solve ciruclar refrence in generics. * It could be improved, by we really need generic variance support or support of: * type T = something & I<T> (see Microsoft/TypeScript#6230) */ var fixedMode = (replaceMode != ReplaceMode.Instance && context == definition) ? ReplaceMode.Instance : replaceMode; formatter.TRSuffix(fixedMode); } else { //TODO: We was unable to resolve assembly. Think about JSIL Proxies formatter.WriteRaw("Object"); return(false); } } } return(true); }
/// <summary> /// Wrap converting and updating DAT file from any format to any format /// </summary> /// <param name="inputPaths">List of input filenames</param> /// <param name="basePaths">List of base filenames</param> /// /* Normal DAT header info */ /// <param name="datHeader">All DatHeader info to be used</param> /// /* Merging and Diffing info */ /// <param name="updateMode">Non-zero flag for diffing mode, zero otherwise</param> /// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param> /// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param> /// <param name="bare">True if the date should not be appended to the default name, false otherwise</param> /// /* Filtering info */ /// <param name="filter">Pre-populated filter object for DAT filtering</param> /// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param> /// /* Output DAT info */ /// <param name="outDir">Optional param for output directory</param> /// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param> /// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param> /// <param name="descAsName">True if descriptions should be used as names, false otherwise (default)</param> /// <param name="replaceMode">ReplaceMode representing what should be updated [only for base replacement]</param> /// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise [only for base replacement]</param> private static void InitUpdate( List <string> inputPaths, List <string> basePaths, /* Normal DAT header info */ DatHeader datHeader, /* Merging and Diffing info */ UpdateMode updateMode, bool inplace, bool skip, bool bare, /* Filtering info */ Filter filter, SplitType splitType, /* Output DAT info */ string outDir, bool clean, bool remUnicode, bool descAsName, ReplaceMode replaceMode, bool onlySame) { // Normalize the extensions datHeader.AddExtension = (String.IsNullOrWhiteSpace(datHeader.AddExtension) || datHeader.AddExtension.StartsWith(".") ? datHeader.AddExtension : "." + datHeader.AddExtension); datHeader.ReplaceExtension = (String.IsNullOrWhiteSpace(datHeader.ReplaceExtension) || datHeader.ReplaceExtension.StartsWith(".") ? datHeader.ReplaceExtension : "." + datHeader.ReplaceExtension); // If we're in a special update mode and the names aren't set, set defaults if (updateMode != 0) { // Get the values that will be used if (String.IsNullOrWhiteSpace(datHeader.Date)) { datHeader.Date = DateTime.Now.ToString("yyyy-MM-dd"); } if (String.IsNullOrWhiteSpace(datHeader.Name)) { datHeader.Name = (updateMode != 0 ? "DiffDAT" : "MergeDAT") + (datHeader.Type == "SuperDAT" ? "-SuperDAT" : "") + (datHeader.DedupeRoms != DedupeType.None ? "-deduped" : ""); } if (String.IsNullOrWhiteSpace(datHeader.Description)) { datHeader.Description = (updateMode != 0 ? "DiffDAT" : "MergeDAT") + (datHeader.Type == "SuperDAT" ? "-SuperDAT" : "") + (datHeader.DedupeRoms != DedupeType.None ? " - deduped" : ""); if (!bare) { datHeader.Description += " (" + datHeader.Date + ")"; } } if (String.IsNullOrWhiteSpace(datHeader.Category) && updateMode != 0) { datHeader.Category = "DiffDAT"; } if (String.IsNullOrWhiteSpace(datHeader.Author)) { datHeader.Author = "SabreTools"; } } // If no replacement mode is set, default to Names if (replaceMode == ReplaceMode.None) { replaceMode = ReplaceMode.ItemName; } // Populate the DatData object DatFile userInputDat = new DatFile(datHeader); userInputDat.DetermineUpdateType(inputPaths, basePaths, outDir, updateMode, inplace, skip, clean, remUnicode, descAsName, filter, splitType, replaceMode, onlySame); }
private void ReplaceText(IWin32Window window, string searchText, string replacementText, ReplaceMode mode, bool matchCase, bool wholeWord, bool isRegex, bool wrap) { if (searchText != null && replacementText != null) { int replacementLength = replacementText.Length; if (mode == ReplaceMode.Next) { if (_editor.SelectionStart == _editor.SelectionEnd) { SearchText(window, searchText, SearchDirection.Next, matchCase, wholeWord, isRegex, wrap); } if (_editor.SelectionStart < _editor.SelectionEnd) { int selStart = _editor.SelectionStart; _editor.ReplaceSelection(replacementText); _editor.ClearSelections(); _editor.GotoPosition(selStart + replacementLength); _editor.Focus(); } } else { Match match; int searchStart = 0; string text = _editor.Text; while ((match = GetSearchMatch(text, searchText, searchStart, SearchDirection.Next, matchCase, wholeWord, isRegex, false)) != null) { if (!match.Success) { break; } text = text.Insert(match.Index + match.Length, replacementText); text = text.Remove(match.Index, match.Length); searchStart = match.Index + replacementLength; } _editor.Text = text; } } }
private bool Copy(ILocation sourceLocation, ILocation destinationLocation, ReplaceMode replaceMode, Func<ReplaceMode> userAskHandler = null) { // // Check location manager inheritance contract conflict // var sourceManager = LocationFactory.GetSourceManager(sourceLocation); if (sourceManager is IStreamableLocationManager && sourceManager is IDirectLocationManager) throw new Exception (sourceManager.GetType () + " cannot inherit from IStreamableLocationManager and IDirectLocationManager"); var destinationManager = LocationFactory.GetDestinationManager(destinationLocation); if (destinationManager is IStreamableLocationManager && destinationManager is IDirectLocationManager) throw new Exception (destinationManager.GetType () + " cannot inherit from IStreamableLocationManager and IDirectLocationManager"); // // Check destination existance // var canCopy = false; var destinationExists = destinationManager.Exists (destinationLocation); if (!destinationExists) canCopy = true; // // Check if destination must be replaced // if (destinationExists && replaceMode == ReplaceMode.UserAsking) { if (userAskHandler == null) throw new Exception ("If the ReplaceMode is ReplaceMode.UserAsking, the UserAskHandler delegate shall be set."); replaceMode = userAskHandler (); } if (destinationExists && (replaceMode & ReplaceMode.ReplaceIfDifferentSize) == ReplaceMode.ReplaceIfDifferentSize) { var sourceSize = sourceManager.GetSize (sourceLocation); var destinationSize = destinationManager.GetSize (destinationLocation); if (sourceSize != destinationSize) canCopy = true; } if (destinationExists && replaceMode == ReplaceMode.Replace) canCopy = true; if (destinationExists && replaceMode == ReplaceMode.Rename) { destinationLocation.ItemUri = new Uri (Path.Combine (destinationLocation.ItemUri.AbsolutePath, Path.GetFileNameWithoutExtension (destinationLocation.ItemUri.AbsoluteUri) + "_" + DateTime.Now.TimeOfDay.ToString ("HHmmss") + Path.GetExtension (destinationLocation.ItemUri.AbsoluteUri))); canCopy = true; } if (canCopy) { if (sourceManager is IStreamableLocationManager && destinationManager is IStreamableLocationManager) { var streamableSourceManager = (IStreamableLocationManager)sourceManager; var streamableDestinationManager = (IStreamableLocationManager)destinationManager; using (var pushFile = streamableDestinationManager.BeginPush(destinationLocation, replaceMode)) { streamableSourceManager.BeginRetreive (sourceLocation, pushFile.BufferWriteCallback, pushFile.CopyDone); pushFile.Done.WaitOne (); } } else if (destinationManager is IDirectLocationManager) { var directDestinationManager = (IDirectLocationManager)destinationManager; directDestinationManager.DirectCopy (sourceLocation, destinationLocation, replaceMode); } else throw new NotImplementedException (); } return canCopy; }
static public VoxelChannel AND(VoxelChannel a,VoxelChannel b,ReplaceMode rep) { int x,y,z; for(z=0;z<a.ZScale;z++) { for(y=0;y<a.YScale;y++) { for(x=0;x<a.XScale;x++) { bool As=a.IsSolid(x,y,z); bool Bs=b.IsSolid(x,y,z); if(As && Bs) { a.SetVoxel(x,y,z,b.GetVoxel(x,y,z)); } } } } return a; }
public ReplaceStatement(ReplaceMode mode, bool ignore, Identifier table, IList <Identifier> columnList, IList <RowExpression> rowList) : base(table, columnList, rowList) { this.Mode = mode; }
/// <summary> /// Mask wildcard is '?'. Ex.: "xxx??xx". /// </summary> /// <param name="matchBytes"></param> /// <param name="newBytes"></param> /// <param name="mask"></param> /// <param name="replaceMode"></param> /// <returns></returns> public async Task <int> ReplaceBytes(byte[] matchBytes, byte[] newBytes, string mask, ReplaceMode replaceMode) { long[] matches = await DoFindBytes(matchBytes, mask); if (matches.Length < 1) { return(0); } int replaces = 0; switch (replaceMode) { case ReplaceMode.FirstMatch: await ReplaceBytes(newBytes, matches[0]); break; case ReplaceMode.LastMatch: await ReplaceBytes(newBytes, matches[matches.Length - 1]); break; case ReplaceMode.AllMatches: foreach (long index in matches) { await ReplaceBytes(newBytes, index); } replaces = matches.Length; break; } if (replaceMode == ReplaceMode.FirstMatch || replaceMode == ReplaceMode.LastMatch) { replaces = 1; } return(replaces); }
public ReplaceExecutedEventArgs(RoutedEvent routedEvent, string query, string replace, SearchOptions options, ReplaceMode mode) : base(routedEvent, query, options) { Replace = replace; Mode = mode; }
/// <summary> /// Mask wildcard is '?'. Ex.: "xxx??xx". /// Mask is matched with the raw bytes, not string characters. /// </summary> /// <param name="matchString"></param> /// <param name="newString"></param> /// <param name="mask"></param> /// <param name="encoding"></param> /// <param name="replaceMode"></param> /// <returns></returns> public async Task <int> ReplaceStrings(string matchString, string newString, string mask, Encoding encoding, ReplaceMode replaceMode) { long[] matches = await FindAllStrings(matchString, mask, encoding); if (matches.Length < 1) { return(0); } int replaces = 0; switch (replaceMode) { case ReplaceMode.FirstMatch: await ReplaceBytes(encoding.GetBytes(newString), matches[0]); break; case ReplaceMode.LastMatch: await ReplaceBytes(encoding.GetBytes(newString), matches[matches.Length - 1]); break; case ReplaceMode.AllMatches: foreach (long index in matches) { await ReplaceBytes(encoding.GetBytes(newString), index); } replaces = matches.Length; break; } if (replaceMode == ReplaceMode.FirstMatch || replaceMode == ReplaceMode.LastMatch) { replaces = 1; } return(replaces); }
/// <summary> /// Initializes a new instance of PronunciationRule /// </summary> /// <param name="word">The base word or phrase</param> /// <param name="pronunciation">The pronunciation string of the base word of phrase</param> /// <param name="replaceMode">The replacement mode for pronunciation rules</param> public PronunciationRule(string word, string pronunciation, ReplaceMode replaceMode) : this(word, pronunciation, replaceMode, 0) { }
/// <summary> /// Entry class for the SabreTools application /// </summary> /// <param name="args">String array representing command line parameters</param> public static void Main(string[] args) { // Perform initial setup and verification Globals.Logger = new Logger(true, "sabretools.log"); // Create a new Help object for this program _help = SabreTools.RetrieveHelp(); // Get the location of the script tag, if it exists int scriptLocation = (new List <string>(args)).IndexOf("--script"); // If output is being redirected or we are in script mode, don't allow clear screens if (!Console.IsOutputRedirected && scriptLocation == -1) { Console.Clear(); Build.PrepareConsole("SabreTools"); } // Now we remove the script tag because it messes things up if (scriptLocation > -1) { List <string> newargs = new List <string>(args); newargs.RemoveAt(scriptLocation); args = newargs.ToArray(); } // Credits take precidence over all if ((new List <string>(args)).Contains("--credits")) { _help.OutputCredits(); Globals.Logger.Close(); return; } // If there's no arguments, show help if (args.Length == 0) { _help.OutputGenericHelp(); Globals.Logger.Close(); return; } // User flags bool addBlankFiles = false, addFileDates = false, archivesAsFiles = false, basedat = false, chdsAsFiles = false, cleanGameNames = false, copyFiles = false, delete = false, depot = false, descAsName = false, hashOnly = false, individual = false, inplace = false, inverse = false, noAutomaticDate = false, nostore = false, onlySame = false, quickScan = false, removeUnicode = false, showBaddumpColumn = false, showNodumpColumn = false, shortname = false, skipFirstOutput = false, updateDat = false; Hash omitFromScan = Hash.DeepHashes;// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually OutputFormat outputFormat = OutputFormat.Folder; ReplaceMode replaceMode = ReplaceMode.None; SkipFileType skipFileType = SkipFileType.None; SplittingMode splittingMode = SplittingMode.None; SplitType splitType = SplitType.None; StatReportFormat statDatFormat = StatReportFormat.None; UpdateMode updateMode = UpdateMode.None; // User inputs int gz = 1, rar = 1, sevenzip = 1, zip = 1; long radix = 0; string outDir = null, tempDir = ""; DatHeader datHeader = new DatHeader(); Filter filter = new Filter(); List <string> basePaths = new List <string>(); List <string> datfiles = new List <string>(); List <string> exta = new List <string>(); List <string> extb = new List <string>(); List <string> inputs = new List <string>(); List <Field> updateFields = new List <Field>(); // Get the first argument as a feature flag string feature = args[0]; // Verify that the flag is valid if (!_help.TopLevelFlag(feature)) { Globals.Logger.User("'{0}' is not valid feature flag", feature); _help.OutputIndividualFeature(feature); Globals.Logger.Close(); return; } // Now get the proper name for the feature feature = _help.GetFeatureName(feature); // If we had the help feature first if (feature == "Help") { // If we had something else after help if (args.Length > 1) { _help.OutputIndividualFeature(args[1]); Globals.Logger.Close(); return; } // Otherwise, show generic help else { _help.OutputGenericHelp(); Globals.Logger.Close(); return; } } else if (feature == "Help (Detailed)") { // If we had something else after help if (args.Length > 1) { _help.OutputIndividualFeature(args[1], includeLongDescription: true); Globals.Logger.Close(); return; } // Otherwise, show generic help else { _help.OutputAllHelp(); Globals.Logger.Close(); return; } } // Now verify that all other flags are valid for (int i = 1; i < args.Length; i++) { // Verify that the current flag is proper for the feature if (!_help[feature].ValidateInput(args[i])) { Globals.Logger.Error("Invalid input detected: {0}", args[i]); _help.OutputIndividualFeature(feature); Globals.Logger.Close(); return; } // Special precautions for files and directories if (File.Exists(args[i]) || Directory.Exists(args[i])) { inputs.Add(args[i]); } } // Now loop through all inputs Dictionary <string, Feature> features = _help.GetEnabledFeatures(); foreach (KeyValuePair <string, Feature> feat in features) { // Check all of the flag names and translate to arguments switch (feat.Key) { #region User Flags case "add-blank-files": addBlankFiles = true; break; case "add-date": addFileDates = true; break; case "archives-as-files": archivesAsFiles = true; break; case "baddump-column": showBaddumpColumn = true; break; case "base": basedat = true; break; case "base-replace": updateMode |= UpdateMode.BaseReplace; break; case "chds-as-Files": chdsAsFiles = true; break; case "copy-files": copyFiles = true; break; case "clean": cleanGameNames = true; break; case "dat-device-non-merged": splitType = SplitType.DeviceNonMerged; break; case "dat-full-non-merged": splitType = SplitType.FullNonMerged; break; case "dat-merged": splitType = SplitType.Merged; break; case "dat-non-merged": splitType = SplitType.NonMerged; break; case "dat-split": splitType = SplitType.Split; break; case "dedup": datHeader.DedupeRoms = DedupeType.Full; break; case "delete": delete = true; break; case "depot": depot = true; break; case "depreciated": // Remove the Logiqx standard output if this is included if ((datHeader.DatFormat & DatFormat.Logiqx) != 0) { datHeader.DatFormat &= ~DatFormat.Logiqx; } datHeader.DatFormat |= DatFormat.LogiqxDepreciated; break; case "description-as-name": descAsName = true; break; case "diff-against": updateMode |= UpdateMode.DiffAgainst; break; case "diff-all": updateMode |= UpdateMode.AllDiffs; break; case "diff-cascade": updateMode |= UpdateMode.DiffCascade; break; case "diff-duplicates": updateMode |= UpdateMode.DiffDupesOnly; break; case "diff-individuals": updateMode |= UpdateMode.DiffIndividualsOnly; break; case "diff-no-duplicates": updateMode |= UpdateMode.DiffNoDupesOnly; break; case "diff-reverse-cascade": updateMode |= UpdateMode.DiffReverseCascade; break; case "exclude-of": Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); datHeader.ExcludeFields[(int)Field.CloneOf] = true; datHeader.ExcludeFields[(int)Field.MachineType] = true; datHeader.ExcludeFields[(int)Field.RomOf] = true; datHeader.ExcludeFields[(int)Field.Runnable] = true; datHeader.ExcludeFields[(int)Field.SampleOf] = true; break; case "extension": splittingMode |= SplittingMode.Extension; break; case "game-dedup": datHeader.DedupeRoms = DedupeType.Game; break; case "game-prefix": datHeader.GameName = true; break; case "hash": splittingMode |= SplittingMode.Hash; break; case "hash-only": hashOnly = true; break; case "individual": individual = true; break; case "inplace": inplace = true; break; case "inverse": inverse = true; break; case "keep-empty-games": datHeader.KeepEmptyGames = true; break; case "level": splittingMode |= SplittingMode.Level; break; case "match-of-tags": filter.IncludeOfInGame.Neutral = true; break; case "merge": updateMode |= UpdateMode.Merge; break; case "no-automatic-date": noAutomaticDate = true; break; case "nodump-column": showNodumpColumn = true; break; case "not-runnable": filter.Runnable.Neutral = false; break; case "no-store-header": nostore = true; break; case "one-rom-per-game": datHeader.OneRom = true; break; case "only-same": onlySame = true; break; case "quick": quickScan = true; break; case "quotes": datHeader.Quotes = true; break; case "remove-extensions": datHeader.RemoveExtension = true; break; case "remove-md5": Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); datHeader.ExcludeFields[(int)Field.MD5] = true; break; case "remove-sha1": Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); datHeader.ExcludeFields[(int)Field.SHA1] = true; break; case "remove-sha256": Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); datHeader.ExcludeFields[(int)Field.SHA256] = true; break; case "remove-sha384": Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); datHeader.ExcludeFields[(int)Field.SHA384] = true; break; case "remove-sha512": Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags)); datHeader.ExcludeFields[(int)Field.SHA512] = true; break; case "remove-unicode": removeUnicode = true; break; case "reverse-base-name": updateMode |= UpdateMode.ReverseBaseReplace; break; case "romba": datHeader.Romba = true; break; case "roms": datHeader.UseRomName = true; break; case "runnable": filter.Runnable.Neutral = true; break; case "scan-all": sevenzip = 0; gz = 0; rar = 0; zip = 0; break; case "scene-date-strip": datHeader.SceneDateStrip = true; break; case "short": shortname = true; break; case "size": splittingMode |= SplittingMode.Size; break; case "skip-archives": skipFileType = SkipFileType.Archive; break; case "skip-files": skipFileType = SkipFileType.File; break; case "skip-first-output": skipFirstOutput = true; break; case "skip-md5": omitFromScan |= Hash.MD5; break; case "skip-sha1": omitFromScan |= Hash.SHA1; break; case "skip-sha256": omitFromScan &= ~Hash.SHA256; // This needs to be inverted later break; case "skip-sha384": omitFromScan &= ~Hash.SHA384; // This needs to be inverted later break; case "skip-sha512": omitFromScan &= ~Hash.SHA512; // This needs to be inverted later break; case "single-set": filter.Single.Neutral = true; break; case "superdat": datHeader.Type = "SuperDAT"; break; case "tar": outputFormat = OutputFormat.TapeArchive; break; case "torrent-7zip": outputFormat = OutputFormat.Torrent7Zip; break; case "torrent-gzip": outputFormat = OutputFormat.TorrentGzip; break; case "torrent-lrzip": outputFormat = OutputFormat.TorrentLRZip; break; case "torrent-lz4": outputFormat = OutputFormat.TorrentLZ4; break; case "torrent-rar": outputFormat = OutputFormat.TorrentRar; break; case "torrent-xz": outputFormat = OutputFormat.TorrentXZ; break; case "torrent-zip": outputFormat = OutputFormat.TorrentZip; break; case "torrent-zpaq": outputFormat = OutputFormat.TorrentZPAQ; break; case "torrent-zstd": outputFormat = OutputFormat.TorrentZstd; break; case "trim": filter.Trim.Neutral = true; break; case "type": splittingMode |= SplittingMode.Type; break; case "update-dat": updateDat = true; break; case "update-description": replaceMode |= ReplaceMode.Description; break; case "update-game-type": replaceMode |= ReplaceMode.MachineType; break; case "update-hashes": replaceMode |= ReplaceMode.Hash; break; case "update-manufacturer": replaceMode |= ReplaceMode.Manufacturer; break; case "update-names": replaceMode |= ReplaceMode.ItemName; break; case "update-parents": replaceMode |= ReplaceMode.Parents; break; case "update-year": replaceMode |= ReplaceMode.Year; break; #endregion #region User Int32 Inputs case "7z": sevenzip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; break; case "gz": gz = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; break; case "rar": rar = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; break; case "threads": int val = (int)feat.Value.GetValue(); if (val != Int32.MinValue) { Globals.MaxThreads = val; } break; case "zip": zip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1; break; #endregion #region User Int64 Inputs case "radix": radix = (long)feat.Value.GetValue() == Int64.MinValue ? (long)feat.Value.GetValue() : 0; break; #endregion #region User List<string> Inputs case "base-dat": basePaths.AddRange((List <string>)feat.Value.GetValue()); break; case "crc": filter.CRC.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "dat": datfiles.AddRange((List <string>)feat.Value.GetValue()); break; case "exclude-field": // TODO: Use this foreach (string field in (List <string>)feat.Value.GetValue()) { datHeader.ExcludeFields[(int)Utilities.GetField(field)] = true; } break; case "exta": exta.AddRange((List <string>)feat.Value.GetValue()); break; case "extb": extb.AddRange((List <string>)feat.Value.GetValue()); break; case "game-description": filter.MachineDescription.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "game-name": filter.MachineName.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "game-type": foreach (string mach in (List <string>)feat.Value.GetValue()) { filter.MachineTypes.Positive |= Utilities.GetMachineType(mach); } break; case "item-name": filter.ItemName.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "item-type": filter.ItemTypes.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "md5": filter.MD5.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-crc": filter.CRC.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-game-description": filter.MachineDescription.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-game-name": filter.MachineName.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-game-type": foreach (string nmach in (List <string>)feat.Value.GetValue()) { filter.MachineTypes.Negative |= Utilities.GetMachineType(nmach); } break; case "not-item-name": filter.ItemName.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-item-type": filter.ItemTypes.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-md5": filter.MD5.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-sha1": filter.SHA1.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-sha256": filter.SHA256.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-sha384": filter.SHA384.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-sha512": filter.SHA512.NegativeSet.AddRange((List <string>)feat.Value.GetValue()); break; case "not-status": foreach (string nstat in (List <string>)feat.Value.GetValue()) { filter.ItemStatuses.Negative |= Utilities.GetItemStatus(nstat); } break; case "output-type": foreach (string ot in (List <string>)feat.Value.GetValue()) { DatFormat dftemp = Utilities.GetDatFormat(ot); if (dftemp != DatFormat.Logiqx || (dftemp == DatFormat.Logiqx && (datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0)) { datHeader.DatFormat |= dftemp; } } break; case "report-type": foreach (string rt in (List <string>)feat.Value.GetValue()) { statDatFormat |= Utilities.GetStatFormat(rt); } break; case "sha1": filter.SHA1.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "sha256": filter.SHA256.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "sha384": filter.SHA384.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "sha512": filter.SHA512.PositiveSet.AddRange((List <string>)feat.Value.GetValue()); break; case "status": foreach (string stat in (List <string>)feat.Value.GetValue()) { filter.ItemStatuses.Positive |= Utilities.GetItemStatus(stat); } break; case "update-field": // TODO: Use this foreach (string field in (List <string>)feat.Value.GetValue()) { updateFields.Add(Utilities.GetField(field)); } break; #endregion #region User String Inputs case "add-extension": datHeader.AddExtension = (string)feat.Value.GetValue(); break; case "author": datHeader.Author = (string)feat.Value.GetValue(); break; case "category": datHeader.Category = (string)feat.Value.GetValue(); break; case "comment": datHeader.Comment = (string)feat.Value.GetValue(); break; case "date": datHeader.Date = (string)feat.Value.GetValue(); break; case "description": datHeader.Description = (string)feat.Value.GetValue(); break; case "email": datHeader.Email = (string)feat.Value.GetValue(); break; case "equal": filter.Size.Neutral = Utilities.GetSizeFromString((string)feat.Value.GetValue()); break; case "filename": datHeader.FileName = (string)feat.Value.GetValue(); break; case "forcemerging": datHeader.ForceMerging = Utilities.GetForceMerging((string)feat.Value.GetValue()); break; case "forcenodump": datHeader.ForceNodump = Utilities.GetForceNodump((string)feat.Value.GetValue()); break; case "forcepacking": datHeader.ForcePacking = Utilities.GetForcePacking((string)feat.Value.GetValue()); break; case "greater": filter.Size.Positive = Utilities.GetSizeFromString((string)feat.Value.GetValue()); break; case "header": datHeader.Header = (string)feat.Value.GetValue(); break; case "homepage": datHeader.Homepage = (string)feat.Value.GetValue(); break; case "less": filter.Size.Negative = Utilities.GetSizeFromString((string)feat.Value.GetValue()); break; case "name": datHeader.Name = (string)feat.Value.GetValue(); break; case "output-dir": outDir = (string)feat.Value.GetValue(); break; case "postfix": datHeader.Postfix = (string)feat.Value.GetValue(); break; case "prefix": datHeader.Prefix = (string)feat.Value.GetValue(); break; case "replace-extension": datHeader.ReplaceExtension = (string)feat.Value.GetValue(); break; case "root": datHeader.RootDir = (string)feat.Value.GetValue(); break; case "root-dir": filter.Root.Neutral = (string)feat.Value.GetValue(); break; case "temp": tempDir = (string)feat.Value.GetValue(); break; case "url": datHeader.Url = (string)feat.Value.GetValue(); break; case "version": datHeader.Version = (string)feat.Value.GetValue(); break; #endregion } } // Now take care of each mode in succesion switch (feature) { case "Help": // No-op as this should be caught break; // Create a DAT from a directory or set of directories case "DATFromDir": VerifyInputs(inputs, feature); InitDatFromDir(inputs, datHeader, omitFromScan, noAutomaticDate, archivesAsFiles, chdsAsFiles, skipFileType, addBlankFiles, addFileDates, tempDir, outDir, copyFiles, filter); break; // If we're in header extract and remove mode case "Extract": VerifyInputs(inputs, feature); InitExtractRemoveHeader(inputs, outDir, nostore); break; // If we're in header restore mode case "Restore": VerifyInputs(inputs, feature); InitReplaceHeader(inputs, outDir); break; case "Script": // No-op as this should be caught break; // If we're using the sorter case "Sort": InitSort(datfiles, inputs, outDir, depot, quickScan, addFileDates, delete, inverse, outputFormat, datHeader.Romba, sevenzip, gz, rar, zip, updateDat, datHeader.Header, splitType, chdsAsFiles, individual); break; // Split a DAT by the split type case "Split": VerifyInputs(inputs, feature); InitSplit(inputs, outDir, inplace, datHeader.DatFormat, splittingMode, exta, extb, shortname, basedat, radix); break; // Get statistics on input files case "Stats": VerifyInputs(inputs, feature); InitStats(inputs, datHeader.FileName, outDir, individual, showBaddumpColumn, showNodumpColumn, statDatFormat); break; // Convert, update, merge, diff, and filter a DAT or folder of DATs case "Update": VerifyInputs(inputs, feature); InitUpdate(inputs, basePaths, datHeader, updateMode, inplace, skipFirstOutput, noAutomaticDate, filter, splitType, outDir, cleanGameNames, removeUnicode, descAsName, replaceMode, onlySame); break; // If we're using the verifier case "Verify": VerifyInputs(inputs, feature); InitVerify(datfiles, inputs, depot, hashOnly, quickScan, datHeader.Header, splitType, chdsAsFiles, individual, filter); break; // If nothing is set, show the help default: _help.OutputGenericHelp(); break; } Globals.Logger.Close(); return; }
protected void OnGUI() { EditorGUIUtility.labelWidth = 100f; GUILayout.BeginVertical(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.top); GUILayout.BeginHorizontal(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.left); GUILayout.BeginVertical(); GUI.changed = false; this.m_Instance = EditorGUILayout.ObjectField("Sprite Packer", this.m_Instance, typeof(SPInstance), false) as SPInstance; if (GUI.changed) { // Save the instance id EditorPrefs.SetInt(SPTools.Settings_SavedInstanceIDKey, (this.m_Instance == null) ? 0 : this.m_Instance.GetInstanceID()); } GUILayout.Space(6f); GUILayout.BeginVertical(GUI.skin.box); GUILayout.Space(6f); GUILayout.BeginHorizontal(); GUILayout.Space(6f); EditorGUILayout.LabelField("Replace mode", GUILayout.Width(130f)); this.m_ReplaceMode = (ReplaceMode)EditorGUILayout.EnumPopup(this.m_ReplaceMode); GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Replace references in", GUILayout.Width(130f)); this.m_TargetMode = (TargetMode)EditorGUILayout.EnumPopup(this.m_TargetMode); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(SPReferenceReplacerWindow.PrefsKey_TargetMode, (int)this.m_TargetMode); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(6f); GUI.changed = false; bool spriteRenderersOnly = GUILayout.Toggle(EditorPrefs.GetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly), " Replace references in Sprite Renderers only ?"); if (GUI.changed) { EditorPrefs.SetBool(SPReferenceReplacerWindow.PrefsKey_SpriteRenderersOnly, spriteRenderersOnly); } GUILayout.Space(6f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.EndVertical(); GUILayout.Space(6f); if (this.m_Instance == null) { EditorGUILayout.HelpBox("Please set the sprite packer instance reference in order to use this feature.", MessageType.Info); } else { if (GUILayout.Button("Replace")) { int replacedCount = 0; switch (this.m_TargetMode) { case TargetMode.CurrentScene: { replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); break; } case TargetMode.ProjectOnly: { replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); break; } case TargetMode.CurrentSceneAndProject: { replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); break; } case TargetMode.AllScenes: { replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, false); break; } case TargetMode.AllScenesAndProject: { replacedCount += SPTools.ReplaceReferencesInProject(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); replacedCount += SPTools.ReplaceReferencesInScene(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly); EditorApplication.SaveScene(); replacedCount += SPTools.ReplaceReferencesInAllScenes(this.m_Instance.copyOfSprites, this.m_ReplaceMode, spriteRenderersOnly, true); break; } } EditorUtility.DisplayDialog("Reference Replacer", "Replaced references count: " + replacedCount.ToString(), "Okay"); } } GUILayout.EndVertical(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.right); GUILayout.EndHorizontal(); GUILayout.Space((float)SPReferenceReplacerWindow.padding.bottom); GUILayout.EndVertical(); }
private void RaiseReplaceExecutedEvent(string query, string replace, SearchOptions options, ReplaceMode mode) { RaiseEvent(new ReplaceExecutedEventArgs(ReplaceExecutedEvent, query, replace, options, mode)); }