public static Composite CreateShamanEnhancementHeal() { Composite healBT = new Decorator( ret => !Group.Healers.Any(h => h.IsAlive && h.Distance < 40), Spell.Heal("Healing Surge", ret => StyxWoW.Me, ret => StyxWoW.Me.GetPredictedHealthPercent() <= 60) ); // group healing logic ONLY if we are configured for it and in an Instance if (SingularRoutine.CurrentWoWContext == WoWContext.Instances && SingularSettings.Instance.Shaman.EnhancementHeal) { healBT =new Decorator( ret => !StyxWoW.Me.GroupInfo.IsInRaid, new PrioritySelector( // Off Heal the party in dungeons if the healer is dead new Decorator( ret => StyxWoW.Me.CurrentMap.IsDungeon && !Group.Healers.Any(h => h.IsAlive), Restoration.CreateRestoShamanHealingOnlyBehavior()), healBT ) ); } return healBT; }
static DecoratorTests() { QUnit.module("Decorator tests"); QUnit.test("Set Decorator.Child succeeds with null", delegate { Decorator d = new Decorator(); d.Child = null; }); QUnit.test("Set Decorator.Child succeeds with Control", delegate { Decorator d = new Decorator(); UiElement c = new UiElement(); d.Child = c; QUnit.ok(d.Child == c, "child should be the control"); QUnit.ok(c.Parent == d, "parent should be the decorator"); }); QUnit.test("Reset Decorator.Child clears child's parent", delegate { Decorator d = new Decorator(); UiElement c = new UiElement(); d.Child = c; d.Child = null; QUnit.ok(d.Child == null, "child should be null"); QUnit.ok(c.Parent == null, "parent should be null"); }); }
/// <summary> /// Constructor for the <c>ElementLabel</c> object. This is /// used to create a label that can convert a XML node into a /// composite object or a primitive type from an XML element. /// </summary> /// <param name="contact"> /// this is the field that this label represents /// </param> /// <param name="label"> /// this is the annotation for the contact /// </param> public ElementLabel(Contact contact, Element label) { this.detail = new Signature(contact, this); this.decorator = new Qualifier(contact); this.type = contact.Type; this.name = label.name(); this.label = label; }
public static Composite CreateShamanElementalHeal() { Composite healBT = new Decorator( ret => !StyxWoW.Me.Combat || (Group.Healers.Any() && !Group.Healers.Any(h => h.IsAlive)), Common.CreateShamanNonHealBehavior() ); // only include group healing logic if we are configured for group heal and in an Instance if (SingularRoutine.CurrentWoWContext == WoWContext.Instances && SingularSettings.Instance.Shaman.ElementalHeal ) { healBT =new Decorator( ret => !StyxWoW.Me.GroupInfo.IsInRaid, new PrioritySelector( // Heal the party in dungeons if the healer is dead new Decorator( ret => StyxWoW.Me.CurrentMap.IsDungeon && Group.Healers.Count(h => h.IsAlive) == 0, Restoration.CreateRestoShamanHealingOnlyBehavior()), healBT ) ); } return healBT; }
static RegionTests() { QUnit.module("Region tests"); QUnit.test("Region.GetRegion succeeds with null", delegate { QUnit.equals(Region.GetRegion(null), null, "should return null"); }); QUnit.test("Region.GetRegion succeeds with unparented control", delegate { UiElement c = new UiElement(); QUnit.equals(Region.GetRegion(c), null, "should return null"); }); QUnit.test("Region.GetRegion succeeds with parented control", delegate { Region r = new Region(); UiElement c = new UiElement(); r.Child = c; QUnit.ok(Region.GetRegion(c) == r, "should return the region"); }); QUnit.test("Region.GetRegion succeeds with parented control chain", delegate { Region r = new Region(); Decorator d = new Decorator(); UiElement c = new UiElement(); d.Child = c; r.Child = d; QUnit.ok(Region.GetRegion(c) == r, "should return the region"); }); }
public void Content_Control_Should_Appear_In_LogicalChildren() { var decorator = new Decorator(); var child = new Control(); decorator.Child = child; Assert.Equal(new[] { child }, ((ILogical)decorator).LogicalChildren.ToList()); }
public RuntimeDecorator(Node parent, Decorator decorator, int oaType, float tick, bool inversed, bool activeSelf) { this.parent = parent; this.decorator = decorator; this.observerAbortsType = oaType; this.tick = tick; this.inversed = inversed; this.activeSelf = activeSelf; }
public void LogicalParent_Should_Be_Set_To_Parent() { var parent = new Decorator(); var target = new TestControl(); parent.Child = target; Assert.Equal(parent, target.InheritanceParent); }
public void DrawBehaviorTree(BehaviorTree behaviorTree) { if(behaviorTree == null || BehaviorTreeEditor.BTEditorWindow == null) { return; } if(behaviorTree != _behaviorTree) { BehaviorTreeEditorHelper.GenerateQueue(_drawingQueue, behaviorTree); BehaviorTreeEditor.BTEditorWindow.Repaint(); } _behaviorTree = behaviorTree; if (_behaviorTree.Child == null) { int i = EditorGUI.Popup(_addRootRect, "Add root: ", 0, _addChildOptions, BehaviorTreeEditorSettings.Instance.AddButtonStyle); switch (i) { case 1: Sequence newSequence = new Sequence(); behaviorTree.AddChild(newSequence); break; case 2: Selector newSelector = new Selector(); behaviorTree.AddChild(newSelector); break; case 3: Decorator newDecorator = new Decorator(); behaviorTree.AddChild(newDecorator); break; case 4: Task t = new Task(); behaviorTree.AddChild(t); break; default: break; } BehaviorTreeEditorHelper.GenerateQueue(_drawingQueue, _behaviorTree); } _scrollPos = GUI.BeginScrollView(new Rect(0, 100, BehaviorTreeEditor.BTEditorWindow.position.width - BehaviorTreeEditorSettings.Instance.SideMenuRect.width - 10, BehaviorTreeEditor.BTEditorWindow.position.height - _addRootRect.height - 100), _scrollPos, new Rect(0, 100, BehaviorTreeEditorHelper.GetWidth() * (BehaviorTreeEditorSettings.Instance.ElementWidth + BehaviorTreeEditorSettings.Instance.HorizontalSpaceBetweenElements) + 110 + _infoRect.x, BehaviorTreeEditorHelper.GetDepth(_drawingQueue) * (BehaviorTreeEditorSettings.Instance.ElementHeight + BehaviorTreeEditorSettings.Instance.VerticalSpaceBetweenElements) + 100)); BehaviorTreeEditor.BTEditorWindow.BeginWindows(); GUILayout.Window(-1, _infoRect, DrawInfo, "Behavior Tree Info"); DrawStack(); BehaviorTreeEditor.BTEditorWindow.EndWindows(); GUI.EndScrollView(); }
public void Setting_Content_Should_Set_Child_Controls_Parent() { var decorator = new Decorator(); var child = new Control(); decorator.Child = child; Assert.Equal(child.Parent, decorator); Assert.Equal(((ILogical)child).LogicalParent, decorator); }
public void LogicalParent_Should_Be_Cleared_When_Removed_From_Parent() { var parent = new Decorator(); var target = new TestControl(); parent.Child = target; parent.Child = null; Assert.Null(target.InheritanceParent); }
public void Materialize_Should_Create_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null); var result = containers.OfType<TextBlock>().Select(x => x.Text).ToList(); Assert.Equal(items, result); }
public void Clearing_Content_Should_Remove_From_LogicalChildren() { var decorator = new Decorator(); var child = new Control(); decorator.Child = child; decorator.Child = null; Assert.Equal(new ILogical[0], ((ILogical)decorator).LogicalChildren.ToList()); }
public void Setting_Parent_Should_Also_Set_InheritanceParent() { var parent = new Decorator(); var target = new TestControl(); parent.Child = target; Assert.Equal(parent, target.Parent); Assert.Equal(parent, target.InheritanceParent); }
public void ContainerFromIndex_Should_Return_Materialized_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = Materialize(target, 0, items); Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0)); Assert.Equal(containers[1].ContainerControl, target.ContainerFromIndex(1)); Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(2)); }
public void IndexFromContainer_Should_Return_Index() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); Assert.Equal(0, target.IndexFromContainer(containers[0])); Assert.Equal(1, target.IndexFromContainer(containers[1])); Assert.Equal(2, target.IndexFromContainer(containers[2])); }
public void Clearing_Content_Should_Clear_Child_Controls_Parent() { var decorator = new Decorator(); var child = new Control(); decorator.Child = child; decorator.Child = null; Assert.Null(child.Parent); Assert.Null(((ILogical)child).LogicalParent); }
public void Dematerialize_Should_Return_Removed_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = Materialize(target, 0, items); var expected = target.Containers.Take(2).ToList(); var result = target.Dematerialize(0, 2); Assert.Equal(expected, result); }
public void ContainerFromIndex_Should_Return_Materialized_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); Assert.Equal(containers[0], target.ContainerFromIndex(0)); Assert.Equal(containers[1], target.ContainerFromIndex(1)); Assert.Equal(containers[2], target.ContainerFromIndex(2)); }
public void IndexFromContainer_Should_Return_Index() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = Materialize(target, 0, items); Assert.Equal(0, target.IndexFromContainer(containers[0].ContainerControl)); Assert.Equal(1, target.IndexFromContainer(containers[1].ContainerControl)); Assert.Equal(2, target.IndexFromContainer(containers[2].ContainerControl)); }
public void Setting_Parent_Should_Not_Set_InheritanceParent_If_Already_Set() { var parent = new Decorator(); var inheritanceParent = new Decorator(); var target = new TestControl(); ((ISetInheritanceParent)target).SetParent(inheritanceParent); parent.Child = target; Assert.Equal(parent, target.Parent); Assert.Equal(inheritanceParent, target.InheritanceParent); }
public void InheritanceParent_Should_Be_Cleared_When_Removed_From_Parent_When_Has_Different_InheritanceParent() { var parent = new Decorator(); var inheritanceParent = new Decorator(); var target = new TestControl(); ((ISetInheritanceParent)target).SetParent(inheritanceParent); parent.Child = target; parent.Child = null; Assert.Null(target.InheritanceParent); }
public void RemoveRange_Should_Alter_Successive_Container_Indexes() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); var removed = target.RemoveRange(1, 1).Single(); Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0)); Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(1)); Assert.Equal(containers[1], removed); }
public void Setting_Content_Should_Fire_LogicalChildren_CollectionChanged() { var decorator = new Decorator(); var child = new Control(); var called = false; ((ILogical)decorator).LogicalChildren.CollectionChanged += (s, e) => called = e.Action == NotifyCollectionChangedAction.Add; decorator.Child = child; Assert.True(called); }
public void Dematerialize_Should_Remove_Container() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = Materialize(target, 0, items); target.Dematerialize(1, 1); Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0)); Assert.Equal(null, target.ContainerFromIndex(1)); Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(2)); }
protected override Composite CreateBehavior() { var children=new Composite[2]; var compositeArray=new Composite[2]; compositeArray[0]=new Action(new ActionSucceedDelegate(FlagTagAsCompleted)); children[0]=new Decorator(CheckDistanceWithinPathPrecision, new Sequence(compositeArray)); ActionDelegate actionDelegateMove=GilesMoveToLocation; var sequenceblank=new Sequence( new Action(actionDelegateMove) ); children[1]=sequenceblank; return new PrioritySelector(children); }
public void Materialize_Should_Create_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator<ListBoxItem>(owner, ListBoxItem.ContentProperty); var containers = target.Materialize(0, items, null); var result = containers .Select(x => x.ContainerControl) .OfType<ListBoxItem>() .Select(x => x.Content) .ToList(); Assert.Equal(items, result); }
public void Materialize_Should_Create_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = Materialize(target, 0, items); var result = containers .Select(x => x.ContainerControl) .OfType<ContentPresenter>() .Select(x => x.Content) .ToList(); Assert.Equal(items, result); }
public void Changing_Content_Should_Fire_LogicalChildren_CollectionChanged() { var decorator = new Decorator(); var child1 = new Control(); var child2 = new Control(); var called = false; decorator.Child = child1; ((ILogical)decorator).LogicalChildren.CollectionChanged += (s, e) => called = true; decorator.Child = child2; Assert.True(called); }
private void Initialize() { // Popup root has a decorator used for // applying the transforms _transformDecorator = new Decorator(); AddVisualChild(_transformDecorator); // Clip so animations do not extend beyond its bounds _transformDecorator.ClipToBounds = true; // Under the transfrom decorator is an Adorner // decorator that handles rendering adorners // and the animated popup translations _adornerDecorator = new NonLogicalAdornerDecorator(); _transformDecorator.Child = _adornerDecorator; }
public void VisualBrush_SourceRect_DestinationRect_Percent() { Decorator target = new Decorator { Padding = new Thickness(8), Width = 200, Height = 200, Child = new Rectangle { Fill = new VisualBrush { SourceRect = new RelativeRect(0.22, 0.22, 0.56, 0.56, OriginUnit.Percent), DestinationRect = new RelativeRect(0.5, 0.5, 0.5, 0.5, OriginUnit.Percent), Visual = new Border { Width = 180, Height = 180, Background = Brushes.Red, BorderBrush = Brushes.Black, BorderThickness = 2, Child = new Ellipse { Width = 100, Height = 100, Fill = Brushes.Yellow, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, } } } } }; RenderToFile(target); CompareImages(); }
public void Does_Not_Call_Converter_ConvertBack_On_OneWay_Binding() { var control = new Decorator { Name = "foo" }; var style = Mock.Of <IStyle>(); var binding = new Binding("Name", BindingMode.OneWay) { Converter = new TestConverter(), RelativeSource = new RelativeSource(RelativeSourceMode.Self), }; var setter = new Setter(Decorator.TagProperty, binding); var instance = setter.Instance(control); instance.Start(true); instance.Activate(); Assert.Equal("foobar", control.Tag); // Issue #1218 caused TestConverter.ConvertBack to throw here. instance.Deactivate(); Assert.Null(control.Tag); }
public static T FindVisualChild <T> (DependencyObject obj) where T : DependencyObject { if (VisualTreeHelper.GetChildrenCount(obj) > 0) { Decorator border = VisualTreeHelper.GetChild(obj, 0) as Decorator; if (border != null) { Decorator borderChild = border.Child as Decorator; if (borderChild != null) { ScrollViewer scroll = borderChild.Child as ScrollViewer; if (scroll != null) { scroll.ScrollChanged += new ScrollChangedEventHandler(Flags.CurrentSqlViewer.Scroll_ScrollChanged); } } } } for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is T) { return((T)child); } else { T childOfChild = FindVisualChild <T> (child); if (childOfChild != null) { return(childOfChild); } } } return(null); }
public void DataContext_Binding_Should_Produce_Correct_Results() { var viewModel = new { Foo = "bar" }; var root = new Decorator { DataContext = viewModel, }; var child = new Control(); var values = new List <object>(); child.GetObservable(Control.DataContextProperty).Subscribe(x => values.Add(x)); child.Bind(Control.DataContextProperty, new Binding("Foo")); // When binding to DataContext and the target isn't found, the binding should produce // null rather than UnsetValue in order to not propagate incorrect DataContexts from // parent controls while things are being set up. This logic is implemented in // `Avalonia.Markup.Data.Binding.Initiate`. Assert.True(child.IsSet(Control.DataContextProperty)); root.Child = child; Assert.Equal(new[] { null, "bar" }, values); }
public async Task VisualBrush_NoStretch_NoTile_Alignment_BottomRight() { Decorator target = new Decorator { Padding = new Thickness(8), Width = 200, Height = 200, Child = new Rectangle { Fill = new VisualBrush { Stretch = Stretch.None, TileMode = TileMode.None, AlignmentX = AlignmentX.Right, AlignmentY = AlignmentY.Bottom, Visual = Visual, } } }; await RenderToFile(target); CompareImages(); }
public bool CreateAndStartTreeFromLoadedProfile() { if (Settings.LoadedProfile == null) { return(false); } if (Settings.LoadedProfile.Composite == null) { LogMessage(Name + ": Profile " + Settings.LoadedProfile.Name + " was loaded, but it had no composite.", 5); return(true); } if (TreeCoroutine != null) { TreeCoroutine.Done(true); } var extensionParameter = new ExtensionParameter(this); Tree = new ProfileTreeBuilder(ExtensionCache, extensionParameter).BuildTreeFromTriggerComposite(Settings.LoadedProfile.Composite); // Append the cache action to the built tree Tree = new Decorator(x => TreeHelper.CanTick(), new Sequence( new TreeSharp.Action(x => ExtensionCache.LoadedExtensions.ForEach(ext => ext.UpdateCache(extensionParameter, ExtensionCache.Cache))), Tree)); // Add this as a coroutine for this plugin TreeCoroutine = new Coroutine(() => TickTree(Tree), new WaitTime(1000 / Settings.TicksPerSecond), this, "BuildYourOwnRoutine Tree"); Core.ParallelRunner.Run(TreeCoroutine); LogMessage(Name + ": Profile " + Settings.LoadedProfile.Name + " was loaded successfully!", 5); return(true); }
public static T AddDecorator <T>(Node parent, BehaviorTree bt) { if (parent == null) { Debug.LogWarning("Can't add a decorator to the behavior trees, because the behavior trees are null."); return(default(T)); } Decorator decorator = ScriptableObject.CreateInstance(typeof(T)) as Decorator; decorator.hideFlags = HideFlags.HideInHierarchy; decorator.Name = BehaviorTreeEditorUtility.GenerateName <T>(); decorator.comment = decorator.Name; decorator.parent = parent; parent.decorators = ArrayUtility.Add <Decorator>(parent.decorators, decorator); if (EditorUtility.IsPersistent(bt)) { AssetDatabase.AddObjectToAsset(decorator, bt); } AssetDatabase.SaveAssets(); return((T)(object)decorator); }
public ResourceBenchmarks() { _searchStart = new Button(); _app = CreateApp(); Decorator root = new TestRoot(true, null) { Renderer = new NullRenderer() }; var current = root; for (int i = 0; i < 10; i++) { var child = new Decorator(); current.Child = child; current = child; } current.Child = _searchStart; }
public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this Decorator This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h)); }
// ReadDeck parses the XML file passed to it into CardDefinitions public void ReadDeck(string deckXMLText) { xmlr = new PT_XMLReader(); // Create a new PT_XMLReader xmlr.Parse(deckXMLText); // Use that PT_XMLReader to parse DeckXML // The following prints a test line to show you how xmlr can be used. // For more information read about XML in the Useful Concepts Appendix string s = "xml[0] decorator[0] "; s += "type=" + xmlr.xml["xml"][0]["decorator"][0].att("type"); s += " x=" + xmlr.xml["xml"][0]["decorator"][0].att("x"); s += " y=" + xmlr.xml["xml"][0]["decorator"][0].att("y"); s += " scale=" + xmlr.xml["xml"][0]["decorator"][0].att("scale"); //print(s); // Comment out this line, since we're done with the test // Read decorators for all Cards decorators = new List <Decorator>(); // Init the List of Decorators // Grab an PT_XMLHashList of all <decorator>s in the XML file PT_XMLHashList xDecos = xmlr.xml["xml"][0]["decorator"]; Decorator deco; for (int i = 0; i < xDecos.Count; i++) { // For each <decorator> in the XML deco = new Decorator(); // Make a new Decorator // Copy the attributes of the <decorator> to the Decorator deco.type = xDecos[i].att("type"); // bool deco.flip is true if the text of the flip attribute is "1" deco.flip = (xDecos[i].att("flip") == "1"); // a // floats need to be parsed from the attribute strings deco.scale = float.Parse(xDecos[i].att("scale")); // Vector3 loc initializes to [0,0,0], so we just need to modify it deco.loc.x = float.Parse(xDecos[i].att("x")); deco.loc.y = float.Parse(xDecos[i].att("y")); deco.loc.z = float.Parse(xDecos[i].att("z")); // Add the temporary deco to the List decorators decorators.Add(deco); } // Read pip locations for each card number cardDefs = new List <CardDefinition>(); // Init the List of Cards // Grab an PT_XMLHashList of all the <card>s in the XML file PT_XMLHashList xCardDefs = xmlr.xml["xml"][0]["card"]; for (int i = 0; i < xCardDefs.Count; i++) { // For each of the <card>s // Create a new CardDefinition CardDefinition cDef = new CardDefinition(); // Parse the attribute values and add them to cDef cDef.rank = int.Parse(xCardDefs[i].att("rank")); // Grab an PT_XMLHashList of all the <pip>s on this <card> PT_XMLHashList xPips = xCardDefs[i]["pip"]; if (xPips != null) { for (int j = 0; j < xPips.Count; j++) { // Iterate through all the <pip>s deco = new Decorator(); // <pip>s on the <card> are handled via the Decorator Class deco.type = "pip"; deco.flip = (xPips[j].att("flip") == "1"); deco.loc.x = float.Parse(xPips[j].att("x")); deco.loc.y = float.Parse(xPips[j].att("y")); deco.loc.z = float.Parse(xPips[j].att("z")); if (xPips[j].HasAtt("scale")) { deco.scale = float.Parse(xPips[j].att("scale")); } cDef.pips.Add(deco); } } // Face cards (Jack, Queen, & King) have a face attribute if (xCardDefs[i].HasAtt("face")) { cDef.face = xCardDefs[i].att("face"); // b } cardDefs.Add(cDef); } }
// Readdeck parses the XML file passed to it into CardDefinitions public void ReadDeck(string deckXMLText) { xmlr = new PT_XMLReader(); // Create a new PT_XMLReader xmlr.Parse(deckXMLText); // Use that PT_XMLReader to parse DeckXML //This prints a test line to show you how xmlr can be used. string s = "xml[0] decorator[0] "; s += "type=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("type"); s += " x=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("x"); s += " y=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("y"); s += " scale" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("scale"); // print (s); // Commented out as this is just for testing //Read decorators for all Cards decorators = new List <Decorator> (); //Init the List of Decorators //Grab a PT_XMLHashList of all <decorator>s in the XML file PT_XMLHashList xDecos = xmlr.xml ["xml"] [0] ["decorator"]; Decorator deco; for (int i = 0; i < xDecos.Count; i++) { // For each <decorator> in the XML deco = new Decorator(); // Make a new Decorator //Copy the attributes of the <decorator> to the Decorator deco.type = xDecos [i].att("type"); // Set the bool flip based on whetherthe text of the attribute is "1" or something else. // This is an atrypical but perfectly fine use of the == comparison operator. // It will return a true or false, which will be assigned to deco.flip deco.flip = (xDecos [i].att("flip") == "1"); // floats need to be parsed from the attribute strings deco.scale = float.Parse(xDecos [i].att("scale")); // Vector3 loc initializes to [0,0,0], so we just need to modify it deco.loc.x = float.Parse(xDecos [i].att("x")); deco.loc.y = float.Parse(xDecos [i].att("y")); deco.loc.z = float.Parse(xDecos [i].att("z")); // Add the temporary deco to the List decorators decorators.Add(deco); } // Read pip locations for each card number cardDefs = new List <CardDefinition> (); // Init the List of Cards // Grab a PT_XMLHashList of all the <card>s in the XML file PT_XMLHashList xCardDefs = xmlr.xml ["xml"] [0] ["card"]; for (int i = 0; i < xCardDefs.Count; i++) { // For each of the <card>s // Create a new CardDefinition CardDefinition cDef = new CardDefinition(); // Parse the attribute values and add them to cDef cDef.rank = int.Parse(xCardDefs [i].att("rank")); // Grab a PT_XMLHastlist of all the <pip>s on this <card> PT_XMLHashList xPips = xCardDefs [i] ["pip"]; if (xPips != null) { for (int j = 0; j < xPips.Count; j++) { //Iterate through all the <pip>s deco = new Decorator(); // <pip>s on the <card> are handled via the Decorator Class deco.type = "pip"; deco.flip = (xPips [j].att("flip") == "1"); deco.loc.x = float.Parse(xPips [j].att("x")); deco.loc.y = float.Parse(xPips [j].att("y")); deco.loc.z = float.Parse(xPips [j].att("z")); if (xPips [j].HasAtt("scale")) { deco.scale = float.Parse(xPips [j].att("scale")); } cDef.pips.Add(deco); } } // Face cards (Jack, Queen, & King) have a face attribute // cDef.face is the base name of the face card Sprite // e.g., FaceCard_11 is the base name for the Jack face Sprites // the Jack of CLubs is FaceCard_11C, hearts is FaceCard_11H, etc. if (xCardDefs [i].HasAtt("face")) { cDef.face = xCardDefs [i].att("face"); } cardDefs.Add(cDef); } }
public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this Decorator This) { return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h)); }
// ReadDeck parses the XML file passed to it into Card Definitions public void ReadDeck(string deckXMLText) { xmlr = new PT_XMLReader(); xmlr.Parse(deckXMLText); // print a test line string s = "xml[0] decorator [0] "; s += "type=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("type"); s += " x=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("x"); s += " y=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("y"); s += " scale=" + xmlr.xml ["xml"] [0] ["decorator"] [0].att("scale"); print(s); //Read decorators for all cards // these are the small numbers/suits in the corners decorators = new List <Decorator>(); // grab all decorators from the XML file PT_XMLHashList xDecos = xmlr.xml["xml"][0]["decorator"]; Decorator deco; for (int i = 0; i < xDecos.Count; i++) { // for each decorator in the XML, copy attributes and set up location and flip if needed deco = new Decorator(); deco.type = xDecos[i].att("type"); deco.flip = (xDecos[i].att("flip") == "1"); // too cute by half - if it's 1, set to 1, else set to 0 deco.scale = float.Parse(xDecos[i].att("scale")); deco.loc.x = float.Parse(xDecos[i].att("x")); deco.loc.y = float.Parse(xDecos[i].att("y")); deco.loc.z = float.Parse(xDecos[i].att("z")); decorators.Add(deco); } // read pip locations for each card rank // read the card definitions, parse attribute values for pips cardDefs = new List <CardDefinition>(); PT_XMLHashList xCardDefs = xmlr.xml["xml"][0]["card"]; for (int i = 0; i < xCardDefs.Count; i++) { // for each carddef in the XML, copy attributes and set up in cDef CardDefinition cDef = new CardDefinition(); cDef.rank = int.Parse(xCardDefs[i].att("rank")); PT_XMLHashList xPips = xCardDefs[i]["pip"]; if (xPips != null) { for (int j = 0; j < xPips.Count; j++) { deco = new Decorator(); deco.type = "pip"; deco.flip = (xPips[j].att("flip") == "1"); // too cute by half - if it's 1, set to 1, else set to 0 deco.loc.x = float.Parse(xPips[j].att("x")); deco.loc.y = float.Parse(xPips[j].att("y")); deco.loc.z = float.Parse(xPips[j].att("z")); if (xPips[j].HasAtt("scale")) { deco.scale = float.Parse(xPips[j].att("scale")); } cDef.pips.Add(deco); } // for j } // if xPips // if it's a face card, map the proper sprite // foramt is ##A, where ## in 11, 12, 13 and A is letter indicating suit if (xCardDefs[i].HasAtt("face")) { cDef.face = xCardDefs[i].att("face"); } cardDefs.Add(cDef); } // for i < xCardDefs.Count } // ReadDeck
private static bool IsGetterDecorator(Decorator decoration) { return(decoration.className.segs.Count == 1 && decoration.className.segs[0].Name == "property"); }
private void DoInitialization(TelemetryConfiguration configuration) { this.TelemetryClient = new TelemetryClient(configuration); if (string.IsNullOrEmpty(this.RootOperationIdHeaderName)) { this.RootOperationIdHeaderName = CorrelationHeaders.HttpStandardRootIdHeader; } if (string.IsNullOrEmpty(this.ParentOperationIdHeaderName)) { this.ParentOperationIdHeaderName = CorrelationHeaders.HttpStandardParentIdHeader; } if (this.SoapHeaderNamespace == null) { this.SoapHeaderNamespace = CorrelationHeaders.SoapStandardNamespace; } if (string.IsNullOrEmpty(this.SoapParentOperationIdHeaderName)) { this.SoapParentOperationIdHeaderName = CorrelationHeaders.SoapStandardParentIdHeader; } if (string.IsNullOrEmpty(this.SoapRootOperationIdHeaderName)) { this.SoapRootOperationIdHeaderName = CorrelationHeaders.SoapStandardRootIdHeader; } if (Decorator.IsHostEnabled()) { WcfClientEventSource.Log.ClientDependencyTrackingInfo("Profiler is attached"); WcfClientEventSource.Log.ClientDependencyTrackingInfo("Agent version: " + Decorator.GetAgentVersion()); if (!this.DisableRuntimeInstrumentation) { this.wcfClientProcessing = new ProfilerWcfClientProcessing(this); this.DecorateProfilerForWcfClientProcessing(); } else { WcfClientEventSource.Log.ClientDependencyTrackingInfo("Runtime Instrumentation is disabled."); } } }
public ContentManager(TabControl tabControl, Decorator border) { _tabControl = tabControl; _border = border; _tabControl.SelectionChanged += (sender, args) => { UpdateSelectedTab(); }; }
public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this Decorator This) { return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseUpObserver(this Decorator This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseUp += h, h => This.PreviewMouseUp -= h)); }
public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this Decorator This) { return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h)); }
public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this Decorator This) { return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h)); }
public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this Decorator This) { return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h)); }
public static void DeleteDecorator(Decorator decorator) { decorator.parent.decorators = ArrayUtility.Remove <Decorator>(decorator.parent.decorators, decorator); BehaviorTreesEditorUtility.DestroyImmediate(decorator); }
public static IObservable <EventPattern <EventArgs> > LayoutUpdatedObserver(this Decorator This) { return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.LayoutUpdated += h, h => This.LayoutUpdated -= h)); }
//把xml文件编译后传递到CarDefinitions中 public void ReadDeck(string deckXMLText) { xmlr = new PT_XMLReader(); xmlr.Parse(deckXMLText); //用PT_XMLReader脚本的Parse方法读xml string s = "xml[0] decorator[0] "; s += "type=" + xmlr.xml["xml"][0]["decorator"][0].att("type"); s += " x=" + xmlr.xml["xml"][0]["decorator"][0].att("x"); s += " y=" + xmlr.xml["xml"][0]["decorator"][0].att("y"); s += " scale=" + xmlr.xml["xml"][0]["decorator"][0].att("scale"); // print(s); //read decorators for all Cards decorators = new List <Decorator>(); PT_XMLHashList xDecos = xmlr.xml["xml"][0]["decorator"]; //得到全部“decorator”下的信息 Decorator deco; //声明其中一个<decorator> //对于xml中的每个<decorator>, 这个项目中为Count=4 for (int i = 0; i < xDecos.Count; i++) { deco = new Decorator(); //deco储存每一个decorator中的信息 deco.type = xDecos[i].att("type"); deco.flip = (xDecos[i].att("flip") == "1"); //true if flip att is "1" deco.scale = float.Parse(xDecos[i].att("scale")); deco.loc.x = float.Parse(xDecos[i].att("x")); deco.loc.y = float.Parse(xDecos[i].att("y")); deco.loc.z = float.Parse(xDecos[i].att("z")); decorators.Add(deco); } //read图案排列图形,xml文件中的所有<card> cardDefs = new List <CardDefinition>(); PT_XMLHashList xCardDefs = xmlr.xml["xml"][0]["card"]; //得到全部<card>下的信息 for (int i = 0; i < xCardDefs.Count; i++) { CardDefinition cDef = new CardDefinition(); cDef.rank = int.Parse(xCardDefs[i].att("rank")); PT_XMLHashList xPips = xCardDefs[i]["pip"]; //"pip"不是xml中的att if (xPips != null) //针对1-10 { for (int j = 0; j < xPips.Count; j++) { deco = new Decorator(); deco.type = "pip"; deco.flip = (xPips[j].att("flip") == "1"); deco.loc.x = float.Parse(xPips[j].att("x")); deco.loc.y = float.Parse(xPips[j].att("y")); deco.loc.z = float.Parse(xPips[j].att("z")); if (xPips[j].HasAtt("scale")) //针对1 { deco.scale = float.Parse(xPips[j].att("scale")); } cDef.pips.Add(deco); } } if (xCardDefs[i].HasAtt("face")) //针对JQK,“face”是此xml中的att { cDef.face = xCardDefs[i].att("face"); } cardDefs.Add(cDef); } }
private BTNode KaI_BossFightBehaviour() { long _guidForCtm = 0; GameObject ick = null; var prep = new LeafAction(() => { tank.ExecLua("print('KaI bhv ON!')"); ick = tank.ObjectManager.FirstOrDefault(obj => obj.EntryID == IckId); return(ick != null ? BTStatus.Success : BTStatus.Running); }); var bossDeadCheck = new Decorator((() => { return(ick.Health == 0); }), new LeafAction(() => { return(BTStatus.Success); })); var nova = new Decorator((() => { /* act when Ick casting Poison Nova */ return(ick.CastingSpellId == 68989); }), new LeafAction(() => { var targetCoords = ick.Coordinates; var desiredDistance = 20; foreach (var client in mbox.clients) { var playerCoords = client.Player.Coordinates; var diff = (targetCoords - playerCoords); var distance = diff.Length(); if (distance < desiredDistance) { var adjusted = ((diff * desiredDistance) / distance); var finalTargetCoords = targetCoords - adjusted; client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); } } return(BTStatus.Failed); })); var mines = new Decorator((() => { return(true); }), new LeafAction(() => { return(BTStatus.Failed); })); var pursuit = new Decorator((() => { /* act when Ick casting Pursuit */ return(ick.CastingSpellId == 68987); }), new LeafAction(() => { var targetCoords = ick.Coordinates; var desiredDistance = 20; foreach (var client in mbox.clients) { var playerCoords = client.Player.Coordinates; var diff = (targetCoords - playerCoords); var distance = diff.Length(); if (distance < desiredDistance) { var adjusted = ((diff * desiredDistance) / distance); var finalTargetCoords = targetCoords - adjusted; client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); } } return(BTStatus.Failed); })); var basic = new Decorator((() => { return(true); }), new LeafAction(() => { mbox.GroupTargetGuids[0] = ick.GUID; // step out of puddles (if not tank) foreach (var client in mbox.clients.Where(cli => cli != tank)) { if (client.Player.Auras.Select(aura => aura.auraID).Any(auraId => ToxicWasteIds.Contains(auraId))) { var playerCoords = client.Player.Coordinates; var finalTargetCoords = playerCoords + new Vector3(2.5f, 0f, 0f); client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); } } return(BTStatus.Failed); })); var stratSelector = new Selector(bossDeadCheck, nova, mines, pursuit, basic); return(new Sequence(false, prep, stratSelector)); }
void OnQuickAccessClick(object sender, MouseButtonEventArgs e) { ToggleButton button = (ToggleButton)sender; if ((!IsOpen) && (!IsSnapped)) { if (popup == null) { // Trying to load control RibbonTabItem item = Parent as RibbonTabItem; if (item != null) { RibbonTabControl tabControl = item.Parent as RibbonTabControl; if (tabControl != null) { RibbonTabItem selectedItem = tabControl.SelectedItem as RibbonTabItem; tabControl.SelectedItem = item; tabControl.UpdateLayout(); tabControl.SelectedItem = selectedItem; } } } IsSnapped = true; savedState = this.State; this.State = RibbonGroupBoxState.Collapsed; if (!IsVisible) { UIElement element = popup.Child; popup.Child = null; if (element != null) { Decorator parent = VisualTreeHelper.GetParent(element) as Decorator; if (parent != null) parent.Child = null; } quickAccessPopup = new RibbonPopup(); quickAccessPopup.AllowsTransparency = popup.AllowsTransparency; quickAccessPopup.Child = element; } else quickAccessPopup = popup as RibbonPopup; quickAccessPopup.Closed += OnMenuClosed; popupPlacementTarget = popup.PlacementTarget; quickAccessPopup.PlacementTarget = button; quickAccessPopup.Tag = button; if (IsVisible) { Width = ActualWidth; Height = ActualHeight; } savedScale = Scale; Scale = -100; quickAccessPopup.IsOpen = true; RaiseEvent(new RoutedEventArgs(RibbonControl.ClickEvent, this)); /* if (quickAccessPopup.Child != null) { Decorator parent = VisualTreeHelper.GetParent(quickAccessPopup.Child) as Decorator; if (parent != null) parent.UpdateLayout(); } */ if (quickAccessPopup.Child != null) quickAccessPopup.Child.InvalidateMeasure(); button.IsChecked = true; e.Handled = true; } }
internal virtual bool IsProfilerAvailable() { return(Decorator.IsHostEnabled()); }
public void Should_Update_When_Control_Moved_Causing_Layout_Change() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { Decorator moveFrom; Decorator moveTo; Canvas moveMe; var tree = new TestRoot { Width = 100, Height = 100, Child = new DockPanel { Children = { (moveFrom = new Decorator { Child = moveMe = new Canvas { Width = 100, Height = 100, }, }), (moveTo = new Decorator()), } } }; tree.Measure(Size.Infinity); tree.Arrange(new Rect(tree.DesiredSize)); var scene = new Scene(tree); var sceneBuilder = new SceneBuilder(); sceneBuilder.UpdateAll(scene); var moveFromNode = (VisualNode)scene.FindNode(moveFrom); var moveToNode = (VisualNode)scene.FindNode(moveTo); Assert.Equal(1, moveFromNode.Children.Count); Assert.Same(moveMe, moveFromNode.Children[0].Visual); Assert.Empty(moveToNode.Children); moveFrom.Child = null; moveTo.Child = moveMe; tree.LayoutManager.ExecuteLayoutPass(); scene = scene.CloneScene(); moveFromNode = (VisualNode)scene.FindNode(moveFrom); moveToNode = (VisualNode)scene.FindNode(moveTo); moveFromNode.SortChildren(scene); moveToNode.SortChildren(scene); sceneBuilder.Update(scene, moveFrom); sceneBuilder.Update(scene, moveTo); sceneBuilder.Update(scene, moveMe); Assert.Empty(moveFromNode.Children); Assert.Equal(1, moveToNode.Children.Count); Assert.Same(moveMe, moveToNode.Children[0].Visual); } }
public static IObservable <EventPattern <MouseButtonEventArgs> > MouseLeftButtonDownObserver(this Decorator This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseLeftButtonDown += h, h => This.MouseLeftButtonDown -= h)); }
public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this Decorator This) { return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h)); }