public byte[] GetFinalContent(byte[] sourceContent) { switch (ModificMode) { case ContentModificMode.NoChange: case ContentModificMode.EntireReplace: case ContentModificMode.KeyVauleReplace: case ContentModificMode.RegexReplace: case ContentModificMode.ReCode: throw new Exception("this implement of GetFinalContent is only for HexReplace"); case ContentModificMode.HexReplace: byte[] replaceContentBytes = AutoTest.MyBytes.HexStringToByte(ReplaceContent, AutoTest.HexDecimal.hex16); string searchKey = TargetKey.Remove(0, 5);//<hex> if (string.IsNullOrEmpty(searchKey)) { return(replaceContentBytes); } byte[] searchKeyBytes = AutoTest.MyBytes.HexStringToByte(searchKey, AutoTest.HexDecimal.hex16); return(AutoTest.MyBytes.ReplaceBytes(sourceContent, searchKeyBytes, replaceContentBytes)); default: throw new Exception("not support ContentModificMode"); } }
public void SerializeRelation() { FileStream Extractor = new FileStream(IndexerFile, FileMode.Open); foreach (int TargetKey in Cache.Keys) { byte[] buffer = Encoding.ASCII.GetBytes(TargetKey.ToString()); Extractor.Write(buffer, 0, buffer.Length); Extractor.WriteByte((byte)':'); buffer = Encoding.ASCII.GetBytes(Cache[TargetKey][0].ToString()); Extractor.Write(buffer, 0, buffer.Length); Extractor.WriteByte((byte)'\n'); if (RelationType == CARDINALITY.Signular) { continue; } for (int i = 1; i < Cache[TargetKey].Count; i++) { buffer = Encoding.ASCII.GetBytes(TargetKey.ToString()); Extractor.Write(buffer, 0, buffer.Length); Extractor.WriteByte((byte)':'); buffer = Encoding.ASCII.GetBytes(Cache[TargetKey][0].ToString()); Extractor.Write(buffer, 0, buffer.Length); Extractor.WriteByte((byte)'\n'); } } }
public override int GetHashCode() { unchecked { return(((TargetKey != null ? TargetKey.GetHashCode() : 0) * 397) ^ (SourceKey != null ? SourceKey.GetHashCode() : 0)); } }
public override bool Equals(object obj) { TargetKey other = obj as TargetKey; return(Object.ReferenceEquals(this, other) || !Object.ReferenceEquals(other, null) && Object.Equals(this.Target, other.Target) && Object.Equals(this.TargetProperty, other.TargetProperty)); }
private void treeView1_ItemDrag(object sender, ItemDragEventArgs e) { if (e.Button != MouseButtons.Left) { return; } //Ignore non-TreeNode objects being dragged if (!(e.Item is TreeNode)) { return; } //Get the dragged item from the event var SelectedNode = e.Item as TreeNode; Node Node = null; if ((string)SelectedNode.Tag == "Action") { var Action = DotaActionFactory.CreateNewAction(SelectedNode.Text); Node = new ActionNode(Action); } if ((string)SelectedNode.Tag == "Event") { var Event = DotaData.Events.FirstOrDefault(x => x.ClassName == SelectedNode.Text); Node = new EventNode(Event, Ability.ActionList.GetOrCreateCollection(Event)); } if ((string)SelectedNode.Tag == "Variable") { var Var = Ability.ActionList.Variables.First(x => x.Name == (string)SelectedNode.Text); Node = new VariableNode(Var); } if ((string)SelectedNode.Tag == "Target") { var Target = new TargetKey(); if (SelectedNode.Name == "line") { Target.Shape = TargetKey.ShapeE.LINE; } else if (SelectedNode.Name == "circle") { Target.Shape = TargetKey.ShapeE.CIRCLE; } Node = new CustomTargetNode(SelectedNode.Name, Target); } //The node can be null if an item with an unknown tag was drag-dropped if (Node != null) { Node.Location = new PointF(0, 0); this.DoDragDrop(Node, DragDropEffects.Copy); } }
public CustomTargetNode(string Name, TargetKey Target) : base(Name.ToTitleCase()) { this.Target = Target; OutputTarget = new TargetNodeItem("Target", Graph.NodeItemType.Output); OutputTarget.Target = Target; this.AddItem(OutputTarget); AddInputPins(); }
public static void Set(this KeyValue kv, TargetKey tc) { if (tc.IsPreset) { kv.Set(tc.Preset); } else { kv.ClearChildren(); kv.AddChildren(tc.KeyValue.Children); } }
/// <summary> /// Gets the set of tactical metadata types names given the tactical data target type. /// </summary> /// <param name="pTargetType">The tactical data target type.</param> /// <returns>The set of tactical metadata types names.</returns> public IEnumerable <string> this[TargetKey pTargetType] { get { Dictionary <string, MetadataSetType> lTypes; if (sTacticalMetadataTypes.TryGetValue(pTargetType, out lTypes)) { foreach (MetadataSetType lType in lTypes.Values) { yield return(lType.Id); } } yield break; } }
/// <summary> /// Parse the type path as string. /// </summary> /// <param name="pTypeAsString">The type as string.</param> /// <param name="pTarget">The parsed target.</param> /// <param name="pType">The parsed type.</param> /// <returns>True if parse succeeded.</returns> public bool ParseTypeAsString(string pTypeAsString, out TargetKey pTarget, out TypeKey pType) { pTarget = new TargetKey(); pType = new TypeKey(); string[] lTypeParts = pTypeAsString.Split(new string[] { TYPE_AS_STRING_SEP }, System.StringSplitOptions.RemoveEmptyEntries); if (lTypeParts.Length == 2) { pTarget = new TargetKey(lTypeParts[0]); pType = new TypeKey(lTypeParts[1]); return(true); } return(false); }
public byte[] GetRecodeContent(string sourceContent) { switch (ModificMode) { case ContentModificMode.NoChange: case ContentModificMode.EntireReplace: case ContentModificMode.KeyVauleReplace: case ContentModificMode.RegexReplace: case ContentModificMode.HexReplace: throw new Exception("this implement of GetRecodeContent is only for ReCode "); case ContentModificMode.ReCode: string searchKey = TargetKey.Remove(0, 8).Trim(' '); Encoding nowEncoding = Encoding.GetEncoding(searchKey); //shoud check the searchKey when we creat ContentModific return(nowEncoding.GetBytes(sourceContent)); default: throw new Exception("not support ContentModificMode"); } }
/// <summary> /// Retrieves the matadata type for the given tactical data type (e.g: Area2D, Area3D and so on..) /// </summary> /// <param name="pParentType">The parent metadata type.</param> /// <param name="pTarget">The target tactical data type.</param> /// <param name="pType">The user type.</param> /// <returns>The found type, null otherwise.</returns> public MetadataSetType GetType(MetadataSetType pParentType, TargetKey pTarget, TypeKey pType) { if (pParentType == null) { Dictionary <string, MetadataSetType> lTypes; if (sTacticalMetadataTypes.TryGetValue(pTarget, out lTypes)) { MetadataSetType lType; if (lTypes.TryGetValue(pType, out lType)) { return(lType); } } } if (pParentType != null) { return(pParentType.NestedTypes.FirstOrDefault(pNestedType => pNestedType.GetTypeAsString() == this.BuildTypeAsString(pTarget, pType)) as MetadataSetType); } return(null); }
private void GetAnimationClocksTargets(TimelineClock clock, FrameworkElement containingObject, INameScope nameScope, ref ListDictionary <TargetKey, AnimationTimelineClock> targets) { AnimationTimelineClock animationClock = clock as AnimationTimelineClock; if (animationClock != null) { TargetKey target = GetClockTarget(animationClock, containingObject, nameScope); if (target != null) { targets.Add(target, animationClock); } } TimelineGroupClock clockGroup = clock as TimelineGroupClock; if (clockGroup != null) { foreach (TimelineClock child in clockGroup.Children) { GetAnimationClocksTargets(child, containingObject, nameScope, ref targets); } } }
/// <summary> /// Builds a tactical metadata type string. /// </summary> /// <param name="pTarget">The target tactical data type.</param> /// <param name="pType">The user type.</param> /// <returns>The type as string.</returns> public string BuildTypeAsString(TargetKey pTarget, TypeKey pType) { return(string.Format("{0}" + TYPE_AS_STRING_SEP + "{1}", (string)pTarget, (string)pType)); }
public TargetNodeItem(TargetKey target) : base(NodeItemType.Output) { Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(target.Preset.ToLower()); Target = target; }
public string GetFinalContent(string sourceContent) { string finalContent = null; switch (ModificMode) { case ContentModificMode.NoChange: finalContent = sourceContent; break; case ContentModificMode.EntireReplace: finalContent = ReplaceContent; break; case ContentModificMode.KeyVauleReplace: finalContent = sourceContent.Replace(TargetKey, ReplaceContent); break; case ContentModificMode.RegexReplace: try { finalContent = System.Text.RegularExpressions.Regex.Replace(sourceContent, TargetKey.Remove(0, 8), ReplaceContent); } catch (Exception ex) { finalContent = string.Format("RegexReplace [{0}] GetFinalContent fail :{1}", TargetKey.Remove(0, 7), ex.Message); } break; case ContentModificMode.HexReplace: throw new Exception("your should implement HexReplace with anther GetFinalContent overload"); case ContentModificMode.ReCode: throw new Exception("your should implement Recode with GetRecodeContent"); default: throw new Exception("not support ContentModificMode"); } return(finalContent); }
public static TargetKey GetTargetKey(this KeyValue kv) { TargetKey tk = new TargetKey(kv); return(tk); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string Property = e.Link.LinkData as string; PropertyInfo info = action.GetType().GetProperty(Property); if (info == null) { MessageBox.Show("Property " + Property + " Does not exist for " + action.GetType().Name); return; } DialogResult result = DialogResult.Cancel; string valueResult = ""; if (info.PropertyType == typeof(NumberValue)) { VariableEditor editor = new VariableEditor(); if (Variables != null) { editor.SetVariable(Variables.Select(x => x.Name)); } else { editor.SetVariable(new string[] { }); } NumberValue val = info.GetMethod.Invoke(action, new object[] { }) as NumberValue; editor.SetDefault(val == null ? "" : val.ToString()); editor.Text = "Variable Editor - " + Property; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { new NumberValue(valueResult) }); } } if (info.PropertyType == typeof(TargetKey)) { TargetKeyEditor editor = new TargetKeyEditor(); editor.SetPresets(ActionContext); editor.VariableList = Variables; TargetKey t = info.GetMethod.Invoke(action, new object[] { }) as TargetKey; if (t == null) { t = new TargetKey(); } editor.Target = t; result = editor.ShowDialog(); if (result == DialogResult.OK) { TargetKey target = editor.Target; info.SetMethod.Invoke(action, new object[] { target }); } } //It's an Enum! if (typeof(Enum).IsAssignableFrom(info.PropertyType)) { Enum enumValue = info.GetMethod.Invoke(action, new object[] { }) as Enum; //Find out if it's a flag and open the flag editor if (info.PropertyType.GetCustomAttribute <FlagsAttribute>() != null) { FlagCheckBoxEditor editor = new FlagCheckBoxEditor(); editor.EnumValue = enumValue; result = editor.ShowDialog(); enumValue = editor.EnumValue; } else { EnumEditor editor = new EnumEditor(); editor.EnumValue = enumValue; result = editor.ShowDialog(); enumValue = editor.EnumValue; } if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { enumValue }); valueResult = enumValue.ToString(); } } if (typeof(bool) == info.PropertyType) { bool val = (bool)info.GetMethod.Invoke(action, new object[] { }); BoolEditor editor = new BoolEditor(); editor.Value = val; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.Value }); } } if (typeof(string) == info.PropertyType) { string val = (string)info.GetMethod.Invoke(action, new object[] { }); TextPrompt editor = new TextPrompt(); editor.Text = Property; editor.PromptText = val; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.PromptText }); } } if (typeof(ActionCollection) == info.PropertyType) { ActionCollection actions = info.GetMethod.Invoke(action, new object[] { }) as ActionCollection; ActionListEditor editor = new ActionListEditor(); if (actions == null) { actions = new ActionCollection(Property); } editor.ActionContext = ActionContext; editor.Variables = Variables; editor.Actions = actions; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.Actions }); } } if (result == DialogResult.OK) { UpdateLinkTexts(); } if (LinkClicked != null) { LinkClicked.Invoke(this, new LinkClickedEventArgs(e.Link.LinkData as string)); } }
public TargetKeyEditor(TargetKey target) { InitializeComponent(); Target = target; InitLinks(); }