示例#1
0
 public void XDocumentAddNull()
 {
     XElement xElem = new XElement("root", "text");
     EventsHelper elemHelper = new EventsHelper(xElem);
     xElem.FirstNode.AddBeforeSelf(null);
     elemHelper.Verify(0);
 }
示例#2
0
 public void XDocumentTypeDocTypeVariation()
 {
     XDocumentType toChange = new XDocumentType("root", "", "", "");
     XDocumentType original = new XDocumentType(toChange);
     using (EventsHelper eHelper = new EventsHelper(toChange))
     {
         toChange.Name = "newName";
         Assert.True(toChange.Name.Equals("newName"), "Name did not change");
         eHelper.Verify(XObjectChange.Name, toChange);
     }
 }
示例#3
0
 public void ExecuteXDocumentVariation(XNode toReplace, XNode newValue)
 {
     XDocument xDoc = new XDocument(toReplace);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             toReplace.ReplaceWith(newValue);
             docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
示例#4
0
 public void XProcessingInstructionPIVariation()
 {
     XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
     XProcessingInstruction original = new XProcessingInstruction(toChange);
     using (UndoManager undo = new UndoManager(toChange))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             toChange.Target = "newTarget";
             Assert.True(toChange.Target.Equals("newTarget"), "Name did not change");
             eHelper.Verify(XObjectChange.Name, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
     }
 }
示例#5
0
 public void ExecuteXDocumentVariation(XNode[] content, int index)
 {
     XDocument xDoc = new XDocument(content);
     XDocument xDocOriginal = new XDocument(xDoc);
     XNode toRemove = xDoc.Nodes().ElementAt(index);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             toRemove.Remove();
             docHelper.Verify(XObjectChange.Remove, toRemove);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
示例#6
0
 public void ExecuteXElementVariation(XElement toChange, XName newName)
 {
     XElement original = new XElement(toChange);
     using (UndoManager undo = new UndoManager(toChange))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             toChange.Name = newName;
             Assert.True(newName.Namespace == toChange.Name.Namespace, "Namespace did not change");
             Assert.True(newName.LocalName == toChange.Name.LocalName, "LocalName did not change");
             eHelper.Verify(XObjectChange.Name, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
     }
 }
示例#7
0
 public void ExecuteXElementVariation(XNode toReplace, XNode newValue)
 {
     XElement xElem = new XElement("root", toReplace);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             toReplace.ReplaceWith(newValue);
             xElem.Verify();
             eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#8
0
 public void ExecuteXElementVariation(XNode[] content, int index)
 {
     XElement xElem = new XElement("root", content);
     XNode toRemove = xElem.Nodes().ElementAt(index);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper elemHelper = new EventsHelper(xElem))
         {
             toRemove.Remove();
             xElem.Verify();
             elemHelper.Verify(XObjectChange.Remove, toRemove);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#9
0
 public void ExecuteXDocumentVariation(XNode[] toAdd, XNode contextNode)
 {
     IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
     XDocument xDoc = new XDocument(contextNode);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             using (EventsHelper nodeHelper = new EventsHelper(contextNode))
             {
                 contextNode.AddBeforeSelf(toAdd);
                 Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
                 nodeHelper.Verify(0);
             }
             docHelper.Verify(XObjectChange.Add, toAdd);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
示例#10
0
 public void ExecuteXElementVariation(XNode[] toAdd, XNode contextNode)
 {
     IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
     XElement xElem = new XElement("root", contextNode);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper elemHelper = new EventsHelper(xElem))
         {
             using (EventsHelper nodeHelper = new EventsHelper(contextNode))
             {
                 contextNode.AddBeforeSelf(toAdd);
                 Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
                 nodeHelper.Verify(0);
             }
             elemHelper.Verify(XObjectChange.Add, toAdd);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#11
0
 public void XCommentChangeValue()
 {
     XComment toChange = new XComment("Original Value");
     String newValue = "New Value";
     XElement xElem = new XElement("root", toChange);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             using (EventsHelper comHelper = new EventsHelper(toChange))
             {
                 toChange.Value = newValue;
                 Assert.True(toChange.Value.Equals(newValue), "Value did not change");
                 xElem.Verify();
                 comHelper.Verify(XObjectChange.Value, toChange);
             }
             eHelper.Verify(XObjectChange.Value, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
     }
 }
示例#12
0
 private void _treeCtrl_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     EventsHelper.Fire(_nodeMouseDoubleClicked, this, e);
 }
示例#13
0
 private void NotifyListChanged(ListChangedEventArgs args)
 {
     EventsHelper.Fire(_listChanged, this, args);
 }
示例#14
0
 public void XElementReplaceNodes()
 {
     XElement xElem = new XElement(InputSpace.GetElement(1000, 2));
     int count = xElem.Nodes().Count();
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             foreach (XElement x in xElem.Nodes())
             {
                 using (EventsHelper xHelper = new EventsHelper(x))
                 {
                     x.ReplaceNodes("text");
                     xHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Add });
                 }
                 eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Add });
             }
             undo.Undo();
             Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
         }
     }
 }
示例#15
0
 public void ExecuteXAttributeVariation(XAttribute[] content)
 {
     XElement xElem = new XElement("root", content);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceAttributes(new XAttribute("a", "aa"));
             Assert.True(XObject.ReferenceEquals(xElem.FirstAttribute, xElem.LastAttribute), "Did not replace attributes correctly");
             xElem.Verify();
             eHelper.Verify(content.Length + 1);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#16
0
 /// <summary>
 /// Called when the region of interest changes, thereby changing the data and invalidating any existing, computed statistics.
 /// </summary>
 protected virtual void OnRoiChanged()
 {
     EventsHelper.Fire(_roiChanged, this, EventArgs.Empty);
 }
示例#17
0
 public void XElementWorkOnTextNodes1()
 {
     XElement elem = new XElement("A", "text2");
     XNode n = elem.FirstNode;
     using (UndoManager undo = new UndoManager(elem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(elem))
         {
             n.AddBeforeSelf("text0");
             Assert.Equal("text0text2", elem.Value);
             n.AddBeforeSelf("text1");
             Assert.Equal("text0text1text2", elem.Value);
             eHelper.Verify(new XObjectChange[] { XObjectChange.Add, XObjectChange.Value });
         }
         undo.Undo();
         Assert.Equal("text2", elem.Value);
     }
 }
 private void NotifyDocumentInformationChanged()
 {
     EventsHelper.Fire(_documentInformationChanged, this, new EventArgs());
 }
 private void HandleEntryPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     EventsHelper.Fire(_collectionChanged, this, new EventArgs());
 }
示例#20
0
 public void Forward()
 {
     EventsHelper.Fire(_forwardInvokedEvent, this, EventArgs.Empty);
 }
        /// <summary>
        /// Override of <see cref="ApplicationComponent.Stop"/>
        /// </summary>
        /// <remarks>
        /// For internal Framework use only.
        /// </remarks>
        public override void Stop()
        {
            EventsHelper.Fire(_closingEvent, this, EventArgs.Empty);

            base.Stop();
        }
示例#22
0
 public void Back()
 {
     EventsHelper.Fire(_backInvokedEvent, this, EventArgs.Empty);
 }
示例#23
0
 public void Go()
 {
     EventsHelper.Fire(_goInvokedEvent, this, EventArgs.Empty);
 }
 public void Fire()
 {
     EventsHelper.Fire(RealEvent, null, EventArgs.Empty);
 }
示例#25
0
 public void AddAndRemoveEventListnersXElementAddRemoveEventListners()
 {
     XDocument xDoc = new XDocument(InputSpace.GetElement(10, 10));
     EventsHelper docHelper = new EventsHelper(xDoc);
     EventsHelper eHelper = new EventsHelper(xDoc.Root);
     xDoc.Root.Add(new XElement("Add", "Me"));
     docHelper.Verify(XObjectChange.Add);
     eHelper.Verify(XObjectChange.Add);
     eHelper.RemoveListners();
     xDoc.Root.Add(new XComment("Comment"));
     eHelper.Verify(0);
     docHelper.Verify(XObjectChange.Add);
 }
 protected virtual void NotifyPropertyChanged(string propertyName)
 {
     EventsHelper.Fire(PropertyChanged, this, new PropertyChangedEventArgs(propertyName));
 }
示例#27
0
 protected virtual void OnCheckedChanged()
 {
     UpdateVisibility();
     EventsHelper.Fire(_checkedChanged, this, new EventArgs());
 }
示例#28
0
 public void XElementWorkOnTextNodes2()
 {
     XElement elem = new XElement("A", "text2");
     XElement xElemOriginal = new XElement(elem);
     using (UndoManager undo = new UndoManager(elem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(elem))
         {
             elem.Add("text0", "text1");
             Assert.Equal("text2text0text1", elem.Value);
             eHelper.Verify(new XObjectChange[] { XObjectChange.Value, XObjectChange.Value });
         }
         undo.Undo();
         Assert.Equal("text2", elem.Value);
     }
 }
示例#29
0
 public void Refresh()
 {
     EventsHelper.Fire(_refreshInvokedEvent, this, EventArgs.Empty);
 }
示例#30
0
 protected virtual void OnItemDrag(GalleryItemDragEventArgs e)
 {
     EventsHelper.Fire(ItemDrag, this, e);
 }
示例#31
0
 public void Cancel()
 {
     EventsHelper.Fire(_cancelInvokedEvent, this, EventArgs.Empty);
 }
        /// <summary>
        /// XDocument:
        ///  - with content, empty
        ///  - adding valid nodes
        ///  - adding invalid nodes
        ///  - XDecl + XDocType (correct/incorrect order)
        /// </summary>
        public void AddFirstIntoDocument()
        {
            _runWithEvents = (bool)Params[0];
            var    xml               = Variation.Params[0] as string;
            var    variationLength   = (int)Variation.Params[1];
            var    hasRoot           = (bool)Variation.Params[2]; // for source document creation
            var    isConnected       = (bool)Variation.Params[3]; // to force cloning
            string stringOnlyContent = Variation.Params.Length > 4 ? Variation.Params[4] as string : null;

            var rs = new XmlReaderSettings
            {
                ConformanceLevel = ConformanceLevel.Fragment,
                IgnoreWhitespace = false,
                DtdProcessing    = DtdProcessing.Ignore,
            };

            object[] nodes = { new XDocumentType("Q", null, null, "<!ENTITY e SYSTEM 'e.ent'!>"), new XDocumentType("Q", null, null, "<!ENTITY e SYSTEM 'e.ent'!>"), new XElement("B", new XElement("C"), new XAttribute("a", "aa")), new XElement("B", new XElement("C"), new XAttribute("a", "aa")), new XProcessingInstruction("PI", "data"), new XProcessingInstruction("PI2", ""), new XComment("comment"), new XComment(""), new XText(""), new XText(" "), new XText("data"), // invalid
                               "data",                                                                                                                                                                                                                                                                                                                                                                                                                                               // invalid
                               new XCData(""),                                                                                                                                                                                                                                                                                                                                                                                                                                       // invalid
                               "\n",                  "\t", " ",  "",                             null };

            if (isConnected)
            {
                foreach (XNode n in nodes.OfType <XNode>())
                {
                    if (n is XDocumentType)
                    {
                        new XDocument(n);
                        continue;
                    }
                    new XDocument(new XElement("dummy", n));
                }
            }

            foreach (var toInsert in nodes.NonRecursiveVariations(variationLength))
            {
                bool shouldFail = false;

                XDocument doc = null;
                if (hasRoot)
                {
                    doc = XDocument.Parse(xml, LoadOptions.PreserveWhitespace);
                }
                else
                {
                    doc = new XDocument();
                    using (XmlReader r = XmlReader.Create(new StringReader(xml), rs))
                    {
                        while (r.Read())
                        {
                            doc.Add(XNode.ReadFrom(r));
                        }
                    }
                }

                string stringOnlyContentCopy       = stringOnlyContent == null ? null : new string(stringOnlyContent.ToCharArray());
                List <ExpectedValue> expectedNodes = CalculateExpectedValuesAddFirst(doc, toInsert, stringOnlyContentCopy).ProcessNodes().ToList();
                shouldFail = expectedNodes.IsXDocValid();

                try
                {
                    if (_runWithEvents)
                    {
                        _eHelper = new EventsHelper(doc);
                    }
                    doc.AddFirst(toInsert);
                    // Difficult to verifty the way this variation is setup
                    //if (runWithEvents) eHelper.Verify(XObjectChange.Add, toInsert);
                    TestLog.Compare(!shouldFail, "exception was expected here");
                    TestLog.Compare(expectedNodes.EqualAll(doc.Nodes(), XNode.EqualityComparer), "AddFirst");
                }
                catch (InvalidOperationException)
                {
                    TestLog.Compare(shouldFail, "exception was NOT expected here");
                }
                catch (ArgumentException)
                {
                    TestLog.Compare(shouldFail, "exception was NOT expected here");
                }
                finally
                {
                    doc.RemoveNodes();
                }
            }
        }
示例#33
0
 public void XElementXElementAddAtDeepLevel()
 {
     XDocument xDoc = new XDocument(InputSpace.GetElement(100, 10));
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             using (EventsHelper eHelper = new EventsHelper(xDoc.Root))
             {
                 foreach (XElement x in xDoc.Root.Descendants())
                 {
                     x.Add(new XText("Add Me"));
                     eHelper.Verify(XObjectChange.Add);
                 }
                 docHelper.Verify(XObjectChange.Add, xDoc.Root.Descendants().Count());
             }
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
示例#34
0
 private void OnPropertyChanged(string propertyName)
 {
     EventsHelper.PropertyChanged(PropertyChanged, this, propertyName);
 }
示例#35
0
 public void XElementWorkTextNodes()
 {
     XElement elem = new XElement("A", "text2");
     XElement xElemOriginal = new XElement(elem);
     using (UndoManager undo = new UndoManager(elem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(elem))
         {
             XNode x = elem.LastNode;
             eHelper.Verify(0);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(elem, xElemOriginal), "Undo did not work!");
     }
 }
示例#36
0
 private void GuiLogMessage(string message, NotificationLevel logLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
 }
示例#37
0
 private void OnPropertyChanged(string name)
 {
     EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(name));
 }
示例#38
0
 private void ProgressChanged(double value, double max)
 {
     EventsHelper.ProgressChanged(OnPluginProgressChanged, this, new PluginProgressEventArgs(value, max));
 }
示例#39
0
 public void ExecuteXElementVariation(XNode toReplace)
 {
     XNode newValue = new XText("text");
     XElement xElem = new XElement("root", InputSpace.GetAttributeElement(10, 1000).Elements().Attributes(), toReplace);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceNodes(newValue);
             Assert.True(xElem.Nodes().Count() == 1, "Did not replace correctly");
             Assert.True(Object.ReferenceEquals(xElem.FirstNode, newValue), "Did not replace correctly");
             Assert.True(xElem.HasAttributes, "ReplaceNodes removed attributes");
             xElem.Verify();
             eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#40
0
 private void StatusChanged(int imageIndex)
 {
     EventsHelper.StatusChanged(OnPluginStatusChanged, this, new StatusEventArgs(StatusChangedMode.ImageUpdate, imageIndex));
 }
示例#41
0
 public void XElementReplaceWithIEnumerable()
 {
     XElement xElem = new XElement("root");
     IEnumerable<XNode> newValue = InputSpace.GetElement(1000, 2).DescendantNodes();
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceNodes(newValue);
             eHelper.Verify(XObjectChange.Add, newValue.ToArray());
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
     }
 }
示例#42
0
        // ShowParameters
        private void ShowParameters()
        {
            const int size = 115;

            GUILayout.BeginVertical("Box");
            GUILayout.Label("Parameters", StyleHelper.LabelStyle());
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Anchor", GUILayout.Width(size));
            myTarget.myData.Anchor = ( ControllerAnchor )EditorGUILayout.EnumPopup(myTarget.myData.Anchor);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Sensitivity", GUILayout.Width(size));
            myTarget.sensitivity = EditorGUILayout.Slider(myTarget.sensitivity, 1f, 10f);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            float minOffsetX = 0f;
            float minOffsetY = 0f;

            if (myTarget.myData.Anchor == ControllerAnchor.LowerCenter || myTarget.myData.Anchor == ControllerAnchor.UpperCenter)
            {
                minOffsetX = -50f;
            }
            else if (myTarget.myData.Anchor == ControllerAnchor.MiddleCenter)
            {
                minOffsetX = -50f;
                minOffsetY = -50f;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Offset X", GUILayout.Width(size));
            myTarget.myData.OffsetX = EditorGUILayout.Slider(myTarget.myData.OffsetX, minOffsetX, 50f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Offset Y", GUILayout.Width(size));
            myTarget.myData.OffsetY = EditorGUILayout.Slider(myTarget.myData.OffsetY, minOffsetY, 50f);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Max Steering Angle", GUILayout.Width(size));
            myTarget.maxSteeringAngle = EditorGUILayout.Slider(myTarget.maxSteeringAngle, 36f, 360f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Released Speed", GUILayout.Width(size));
            myTarget.releasedSpeed = EditorGUILayout.Slider(myTarget.releasedSpeed, 25f, 150f);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Wheel Name", GUILayout.Width(size));
            myTarget.MyName = EditorGUILayout.TextField(myTarget.MyName);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Steering Wheel", GUILayout.Width(size));
            myTarget.myData.touchzoneSprite.sprite = EditorGUILayout.ObjectField(myTarget.myData.touchzoneSprite.sprite, typeof(Sprite), false) as Sprite;
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
            GUILayout.EndVertical();

            GUILayout.Space(5);
            AxesHelper.ShowAxes(size, true);
            GUILayout.Space(5);
            EventsHelper.ShowEvents(size);
        }
示例#43
0
 public void ExecuteXElementVariation(XObject[] toReplace)
 {
     XNode newValue = new XText("text");
     XElement xElem = new XElement("root", toReplace);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceAll(newValue);
             Assert.True(xElem.Nodes().Count() == 1, "Did not replace correctly");
             Assert.True(Object.ReferenceEquals(xElem.FirstNode, newValue), "Did not replace correctly");
             Assert.True(!xElem.HasAttributes, "ReplaceAll did not remove attributes");
             xElem.Verify();
             eHelper.Verify(toReplace.Length + 1);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#44
0
 protected virtual void OnUnloaded()
 {
     EventsHelper.Fire(_volumeUnloaded, this, EventArgs.Empty);
 }
示例#45
0
        public void ElementWithAttributes()
        {
            XElement toReplace = new XElement("Automobile",
                new XAttribute("axles", 2),
                new XElement("Make", "Ford"),
                new XElement("Model", "Mustang"),
                new XElement("Year", "2004"));
            XElement xElemOriginal = new XElement(toReplace);

            using (UndoManager undo = new UndoManager(toReplace))
            {
                undo.Group();
                using (EventsHelper eHelper = new EventsHelper(toReplace))
                {
                    toReplace.ReplaceAll(new XAttribute("axles", 2),
                        new XElement("Make", "Chevrolet"),
                        new XElement("Model", "Impala"),
                        new XElement("Year", "2006"));
                    toReplace.Verify();
                }
                undo.Undo();
                Assert.True(toReplace.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
                Assert.True(toReplace.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
            }
        }
示例#46
0
 /// <summary>
 /// Fires the <see cref="Drawing"/> event.  Should be called by an <see cref="IRenderer"/>
 /// for each object just before it is drawn/rendered, hence the reason it is public.
 /// </summary>
 public virtual void OnDrawing()
 {
     EventsHelper.Fire(_drawing, this, EventArgs.Empty);
 }
示例#47
0
 public void ExecuteXDocumentVariation(XNode toReplace)
 {
     XNode newValue = new XText(" ");
     XDocument xDoc = new XDocument(toReplace);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             xDoc.ReplaceNodes(newValue);
             Assert.True(xDoc.Nodes().Count() == 1, "Not all content were removed");
             Assert.True(Object.ReferenceEquals(xDoc.FirstNode, newValue), "Did not replace correctly");
             docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
示例#48
0
 public void ExecuteXElementVariation(XElement toChange, object newValue)
 {
     int count = toChange.Nodes().Count();
     XElement xElemOriginal = new XElement(toChange);
     using (UndoManager undo = new UndoManager(toChange))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             toChange.SetValue(newValue);
             Assert.True(newValue.Equals(toChange.Value), "Value change was not correct");
             toChange.Verify();
             eHelper.Verify(count + 1);
         }
         undo.Undo();
         Assert.True(toChange.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(toChange.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#49
0
        public void AttachListnersAtEachLevelNestedElementsXElementAttachAtEachLevel()
        {
            XDocument xDoc = new XDocument(XElement.Parse(@"<a>a<b>b<c>c<d>c<e>e<f>f</f></e></d></c></b></a>"));
            EventsHelper[] listeners = new EventsHelper[xDoc.Descendants().Count()];

            int i = 0;
            foreach (XElement x in xDoc.Descendants())
                listeners[i++] = new EventsHelper(x);
            // f element
            XElement toChange = xDoc.Descendants().ElementAt(5);
            // Add element
            toChange.Add(new XElement("Add", "Me"));
            foreach (EventsHelper e in listeners)
                e.Verify(XObjectChange.Add);
            // Add xattribute
            toChange.Add(new XAttribute("at", "value"));
            foreach (EventsHelper e in listeners)
                e.Verify(XObjectChange.Add);
        }
示例#50
0
 public void ExecuteRemoveVariation(XElement content)
 {
     XElement xElem = new XElement("root", content);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.SetElementValue(content.Name, null);
             xElem.Verify();
             eHelper.Verify(XObjectChange.Remove, content);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#51
0
 protected override void OnGraphicCancelled()
 {
     EventsHelper.Fire(_graphicFinalCancelled, this, new GraphicEventArgs(this.Graphic));
     base.OnGraphicCancelled();
 }
示例#52
0
 /// <summary>
 /// Fires the <see cref="VisualStateChanged"/> event.
 /// </summary>
 /// <param name="propertyName">The name of the property whose value changed.</param>
 protected void NotifyVisualStateChanged(string propertyName)
 {
     this.OnVisualStateChanged(propertyName);
     EventsHelper.Fire(_visualStateChanged, this, new VisualStateChangedEventArgs(this, propertyName));
 }
示例#53
0
 public void XDocumentTypeChangeInternalSubset()
 {
     XDocumentType toChange = new XDocumentType("root", "", "", "");
     XDocument xDoc = new XDocument(toChange);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (EventsHelper docHelper = new EventsHelper(xDoc))
     {
         using (EventsHelper typeHelper = new EventsHelper(toChange))
         {
             toChange.InternalSubset = "newValue";
             Assert.True(toChange.InternalSubset.Equals("newValue"), "Internal Subset did not change");
             typeHelper.Verify(XObjectChange.Value, toChange);
         }
         docHelper.Verify(XObjectChange.Value, toChange);
     }
 }
示例#54
0
 protected void NotifyTextChanged()
 {
     EventsHelper.Fire(_textChanged, this, EventArgs.Empty);
 }
示例#55
0
 public void ExecuteXAttributeVariation(XAttribute toChange, object newValue)
 {
     XElement xElem = new XElement("root", toChange);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(toChange))
         {
             xElem.SetAttributeValue(toChange.Name, newValue);
             Assert.True(newValue.Equals(toChange.Value), "Value did not change");
             xElem.Verify();
             eHelper.Verify(XObjectChange.Value, toChange);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#56
0
 protected void NotifyIconChanged()
 {
     EventsHelper.Fire(_iconChanged, this, EventArgs.Empty);
 }
示例#57
0
 public void ExecuteValueVariation(XElement content, object newValue)
 {
     int count = content.Nodes().Count();
     XElement xElem = new XElement("root", content);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.SetElementValue(content.Name, newValue);
             // First all contents are removed and then new element with the value is added.
             xElem.Verify();
             eHelper.Verify(count + 1);
         }
         undo.Undo();
         Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
         Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
     }
 }
示例#58
0
 protected void NotifyItemsTableChanged()
 {
     EventsHelper.Fire(_itemsTableChanged, this, EventArgs.Empty);
 }
示例#59
0
 public void XProcessingInstructionChangeValue()
 {
     XProcessingInstruction toChange = new XProcessingInstruction("target", "Original Value");
     String newValue = "New Value";
     XElement xElem = new XElement("root", toChange);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             using (EventsHelper piHelper = new EventsHelper(toChange))
             {
                 toChange.Data = newValue;
                 Assert.True(toChange.Data.Equals(newValue), "Value did not change");
                 xElem.Verify();
                 piHelper.Verify(XObjectChange.Value, toChange);
             }
             eHelper.Verify(XObjectChange.Value, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
     }
 }
示例#60
0
        private void PreResetConfirmDialog_Confirmed(object data)
        {
            Hide();

            var key = data as ServerEntityKey;

            if (key != null)
            {
                var             adaptor = new WorkQueueAdaptor();
                Model.WorkQueue item    = adaptor.Get(key);
                if (item == null)
                {
                    String errorMessage = SR.WorkQueueNotAvailable;
                    EventsHelper.Fire(Error, this, new WorkQueueItemResetErrorEventArgs(errorMessage, null));
                }
                else
                {
                    var      controller    = new WorkQueueController();
                    DateTime scheduledTime = item.ScheduledTime;
                    if (scheduledTime < Platform.Time)
                    {
                        scheduledTime = Platform.Time.AddSeconds(WorkQueueSettings.Default.WorkQueueProcessDelaySeconds);
                    }

                    DateTime expirationTime = item.ExpirationTime;
                    if (expirationTime < scheduledTime)
                    {
                        expirationTime = scheduledTime.AddSeconds(WorkQueueSettings.Default.WorkQueueExpireDelaySeconds);
                    }

                    try
                    {
                        var items = new List <Model.WorkQueue>();
                        items.Add(item);

                        controller.ResetWorkQueueItems(items, scheduledTime, expirationTime);

                        Platform.Log(LogLevel.Info, "{0} Work Queue item reset:  Key={1}.", item.WorkQueueTypeEnum,
                                     item.GetKey());
                        if (WorkQueueItemReseted != null)
                        {
                            WorkQueueItemReseted(item);
                        }

                        if (OnHide != null)
                        {
                            OnHide();
                        }
                    }
                    catch (Exception e)
                    {
                        Platform.Log(LogLevel.Error, e, "Unable to reset {0} work queue item. Key={1}.",
                                     item.WorkQueueTypeEnum, item.GetKey());

                        String errorMessage = String.Format(SR.WorkQueueResetFailed, e.Message);

                        EventsHelper.Fire(Error, this, new WorkQueueItemResetErrorEventArgs(errorMessage, e));
                    }
                }
            }
        }