public static Quest Load(KmlNode Node) { Quest quest = new Quest(); quest.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; quest.Stage = Node.SelectSingleNode("index").Values[2].ValueAsInt; if(Node.ChildNodes.ContainsKey("linked")) { int linkedValue = Node.SelectSingleNode("linked").Values[1].ValueAsInt; if (linkedValue == 1) { quest.Linked = true; } else { quest.Linked = false; } } quest.Cases = new List<Case>(); //load cases foreach (KmlNode caseNode in Node.SelectNodes("case")) { quest.Cases.Add(LoadCase(caseNode)); } return quest; }
public void Deserialize(ConfigPropertyGroup Output, KmlNode Node) { Type obj = (Type)Activator.CreateInstance(Type); }
private void OnFeatureDoubleTapped(object sender, KmlNode feature) { var kmlvp = feature.Viewpoint; if (kmlvp != null) { Viewpoint vp = null; if (kmlvp.Type == KmlViewpointType.Camera) { vp = new Viewpoint(kmlvp.Location, new Camera(kmlvp.Location, kmlvp.Heading, kmlvp.Pitch, kmlvp.Roll)); } else { vp = new Viewpoint(kmlvp.Location, new Camera(kmlvp.Location, kmlvp.Range, kmlvp.Heading, kmlvp.Pitch, kmlvp.Roll)); } if (vm.Is3D) { sceneView.SetViewpointAsync(vp); sceneView.Focus(FocusState.Keyboard); } else { mapView.Focus(FocusState.Keyboard); mapView.SetViewpointAsync(vp); } if (highlightedFeature != null) { highlightedFeature.IsHighlighted = false; } feature.IsHighlighted = true; highlightedFeature = feature; } }
private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Clear any existing popups. MyMapView.DismissCallout(); try { // Perform identify on the KML layer and get the results. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_forecastLayer, e.Position, 2, false); // Return if there are no results that are KML placemarks. if (!identifyResult.GeoElements.OfType <KmlGeoElement>().Any()) { return; } // Get the first identified feature that is a KML placemark KmlNode firstIdentifiedPlacemark = identifyResult.GeoElements.OfType <KmlGeoElement>().First().KmlNode; // Show a page with the HTML content await Navigation.PushAsync(new KmlIdentifyResultDisplayPage(firstIdentifiedPlacemark.BalloonContent)); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void ExtendedMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { try { var kmlLayer = this.Map.OperationalLayers.FirstOrDefault(x => x.Id == "KML"); // Perform identify on the KML layer and get the results. IdentifyLayerResult identifyResult = await IdentifyLayerAsync(kmlLayer, e.Position, 2, false); // Return if there are no results that are KML placemarks. if (!identifyResult.GeoElements.OfType <KmlGeoElement>().Any()) { return; } // Get the first identified feature that is a KML placemark KmlNode firstIdentifiedPlacemark = identifyResult.GeoElements.OfType <KmlGeoElement>().First().KmlNode; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } var graphics = await this.IdentifyGraphicsOverlaysAsync(e.Position, tolerance : 10d, returnPopupsOnly : false); if (graphics?.SelectMany(x => x?.Graphics)?.Any() == true) { this.MapClickCommand?.Execute(graphics?.SelectMany(x => x.Graphics)?.FirstOrDefault()); } else { this.MapClickCommand?.Execute(null); } }
public void MixedAddWellOrdered() { KmlNode root = data.Root2; KmlAttrib attrib1 = KmlItem.CreateItem("attrib1 = value1") as KmlAttrib; root.Add(attrib1); KmlNode node1 = KmlItem.CreateItem("node1") as KmlNode; root.Add(node1); KmlAttrib attrib2 = KmlItem.CreateItem("attrib2 = value1") as KmlAttrib; root.Add(attrib2); KmlNode node2 = KmlItem.CreateItem("node2") as KmlNode; root.Add(node2); KmlAttrib attrib3 = KmlItem.CreateItem("attrib3 = value2") as KmlAttrib; root.Add(attrib3); Assert.AreEqual(3, root.Attribs.Count); Assert.AreEqual(2, root.Children.Count); Assert.AreEqual(5, root.AllItems.Count); Assert.AreEqual(attrib1, root.AllItems[0]); Assert.AreEqual(attrib2, root.AllItems[1]); Assert.AreEqual(attrib3, root.AllItems[2]); Assert.AreEqual(node1, root.AllItems[3]); Assert.AreEqual(node2, root.AllItems[4]); }
public void ToStringChangedEvent() { KmlNode root = data.Root2; root.ToStringChanged += TestEventHandler; //_testEventHandlerVisited = false; //root.Tag = "other"; //Assert.IsTrue(_testEventHandlerVisited); _testEventHandlerVisited = false; KmlAttrib attrib = KmlItem.CreateItem("name = rootname") as KmlAttrib; root.Add(attrib); Assert.IsTrue(_testEventHandlerVisited); _testEventHandlerVisited = false; attrib.Value = "other"; Assert.IsTrue(_testEventHandlerVisited); // attrib.CanBeDeleted will be false _testEventHandlerVisited = false; Assert.IsFalse(root.Delete(attrib)); Assert.IsFalse(_testEventHandlerVisited); }
public void ChildGetFrom() { Assert.AreEqual(data.Node2, KmlNode.GetChildNodeFrom(data.Root1, "Node2Tag")); Assert.IsNull(KmlNode.GetChildNodeFrom(data.Root1, "AnotherNodeTag")); KmlNode empty = null; Assert.IsNull(KmlNode.GetChildNodeFrom(empty, "Node2Tag")); List <KmlItem> list = new List <KmlItem>(); list.AddRange(data.Root1.Children); Assert.AreEqual(data.Node2, KmlNode.GetNodeFrom(list, "Node2Tag")); Assert.IsNull(KmlNode.GetNodeFrom(list, "AnotherNodeTag")); list.Clear(); list.Add(data.Root1); string[] tags1 = { "Root1", "Node2Tag" }; string[] tags2 = { "Root2", "Node2Tag" }; string[] tags3 = { "Root1", "AnotherNodeTag" }; Assert.AreEqual(data.Node2, KmlNode.GetNodeFromDeep(list, tags1)); Assert.IsNull(KmlNode.GetNodeFromDeep(list, tags2)); Assert.IsNull(KmlNode.GetNodeFromDeep(list, tags3)); }
public void MixedInsert() { KmlNode root = data.Root2; KmlNode node1 = KmlItem.CreateItem("node1") as KmlNode; root.Add(node1); KmlAttrib attrib1 = KmlItem.CreateItem("attrib1 = value1") as KmlAttrib; root.InsertBefore(node1, attrib1); // KmlItem constructor is only way to create a KmlItem (unknown) instead of KmlNode or KmlAttrib KmlItem unknown = new KmlItem("unknown"); root.InsertBefore(node1, unknown); KmlNode node2 = KmlItem.CreateItem("node2") as KmlNode; root.InsertBefore(node1, node2); KmlAttrib attrib2 = KmlItem.CreateItem("attrib2 = value2") as KmlAttrib; root.InsertBefore(attrib1, attrib2); Assert.AreEqual(2, root.Attribs.Count); Assert.AreEqual(2, root.Children.Count); Assert.AreEqual(1, root.Unknown.Count); Assert.AreEqual(5, root.AllItems.Count); Assert.AreEqual(attrib2, root.Attribs[0]); Assert.AreEqual(attrib1, root.Attribs[1]); Assert.AreEqual(unknown, root.Unknown[0]); Assert.AreEqual(node2, root.Children[0]); Assert.AreEqual(node1, root.Children[1]); }
public void PartIsDock() { Assert.IsFalse(KmlPartDock.PartIsDock(data.Vessel1Part1)); Assert.IsFalse(KmlPartDock.PartIsDock(data.Vessel1Part2)); KmlPart part = (KmlPart)KmlItem.CreateItem("PART"); Assert.IsFalse(KmlPartDock.PartIsDock(part)); KmlNode module = (KmlNode)KmlItem.CreateItem("WrongTag"); part.Add(module); Assert.IsFalse(KmlPartDock.PartIsDock(part)); module.Add(KmlItem.CreateItem("name = ModuleDockingNode")); Assert.IsFalse(KmlPartDock.PartIsDock(part)); module = (KmlNode)KmlItem.CreateItem("MODULE"); part.Add(module); Assert.IsFalse(KmlPartDock.PartIsDock(part)); KmlAttrib name = (KmlAttrib)KmlItem.CreateItem("name = ModuleDockingNode"); module.Add(name); Assert.IsTrue(KmlPartDock.PartIsDock(part)); name.Value = "WrongName"; Assert.IsFalse(KmlPartDock.PartIsDock(part)); name.Value = "ModuleDockingNodeNamed"; Assert.IsTrue(KmlPartDock.PartIsDock(part)); name.Value = "ModuleGrappleNode"; Assert.IsTrue(KmlPartDock.PartIsDock(part)); name.Value = "KASModuleStrut"; Assert.IsTrue(KmlPartDock.PartIsDock(part)); }
public void ChildGetName() { KmlNode root = data.Root2; KmlNode node1 = KmlItem.CreateItem("node") as KmlNode; node1.Add(KmlItem.CreateItem("name = name1")); root.Add(node1); KmlNode node2 = KmlItem.CreateItem("node") as KmlNode; node2.Add(KmlItem.CreateItem("name = name2")); root.Add(node2); KmlNode node3 = KmlItem.CreateItem("node") as KmlNode; node3.Add(KmlItem.CreateItem("name = name3")); root.Add(node3); KmlNode test = root.GetChildNode("node", "name2"); Assert.AreEqual(node2, test); KmlNode badname = root.GetChildNode("node", "badname"); Assert.IsNull(badname); KmlNode badtag = root.GetChildNode("badtag", "name2"); Assert.IsNull(badtag); KmlNode nonsense = root.GetChildNode("non", "sense"); Assert.IsNull(nonsense); }
public void CreateItem() { KmlPart part = (KmlPart)KmlItem.CreateItem("PART"); KmlNode module = (KmlNode)KmlItem.CreateItem("MODULE"); part.Add(module); KmlAttrib name = (KmlAttrib)KmlItem.CreateItem("name = ModuleDockingNode"); module.Add(name); Assert.IsTrue(KmlPartDock.PartIsDock(part)); // Need to parse memory roots, to call identify and have the KmlPart // replaced by a KmlPartDock List <KmlItem> list = new List <KmlItem>(); list.Add(part); list = KmlItem.ParseMemory(list); Assert.AreEqual(1, list.Count); Assert.AreNotEqual(part, list[0]); Assert.IsTrue(list[0] is KmlPartDock); KmlPartDock dock = (KmlPartDock)list[0]; Assert.AreEqual(KmlPartDock.DockTypes.Dock, dock.DockType); Assert.AreEqual("", dock.DockName); Assert.AreEqual("", dock.DockState); Assert.AreEqual("", dock.DockedVesselName); Assert.AreEqual("", dock.DockedVesselType); Assert.AreEqual("", dock.DockedVesselOtherName); Assert.AreEqual("", dock.DockedVesselOtherType); Assert.AreEqual("", dock.DockUid); Assert.IsNull(dock.DockedPart); Assert.IsFalse(dock.NeedsRepair); }
private void Count(KmlNode parent, KmlItem child) { if (parent == null) { RootCount++; } else { if (parent == Root1 && child is KmlAttrib) { Root1AttribCount++; } else if (parent == Root1 && child is KmlNode) { Root1ChildCount++; } else if (parent == Node1 && child is KmlAttrib) { Node1AttribCount++; } else if (parent == Node1 && child is KmlNode) { Node1ChildCount++; } else if (parent == Node2 && child is KmlAttrib) { Node2AttribCount++; } else if (parent == Node2 && child is KmlNode) { Node2ChildCount++; } } }
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Clear any existing popups. _myMapView.DismissCallout(); try { // Perform identify on the KML layer and get the results. IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_forecastLayer, e.Position, 2, false); // Return if there are no results that are KML placemarks. if (!identifyResult.GeoElements.OfType <KmlGeoElement>().Any()) { return; } // Get the first identified feature that is a KML placemark KmlNode firstIdentifiedPlacemark = identifyResult.GeoElements.OfType <KmlGeoElement>().First().KmlNode; // Display the string content as an HTML document. ShowResult(firstIdentifiedPlacemark.BalloonContent); } catch (Exception ex) { new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show(); } }
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Clear any existing popups. _myMapView.DismissCallout(); try { // Perform identify on the KML layer and get the results. IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_forecastLayer, e.Position, 2, false); // Return if there are no results that are KML placemarks. if (!identifyResult.GeoElements.OfType <KmlGeoElement>().Any()) { return; } // Get the first identified feature that is a KML placemark KmlNode firstIdentifiedPlacemark = identifyResult.GeoElements.OfType <KmlGeoElement>().First().KmlNode; // Show a preview with the HTML content. _webView.LoadHtmlString(new NSString(firstIdentifiedPlacemark.BalloonContent), new NSUrl("")); } catch (Exception ex) { new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Clear any existing popups. MyMapView.DismissCallout(); try { // Perform identify on the KML layer and get the results. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_forecastLayer, e.Position, 2, false); // Return if there are no results that are KML placemarks. if (!identifyResult.GeoElements.OfType <KmlGeoElement>().Any()) { return; } // Get the first identified feature that is a KML placemark KmlNode firstIdentifiedPlacemark = identifyResult.GeoElements.OfType <KmlGeoElement>().First().KmlNode; // Create a browser to show the feature popup HTML. WebView browser = new WebView { Width = 400, Height = 100 }; browser.NavigateToString(firstIdentifiedPlacemark.BalloonContent); // Create and show the callout. MyMapView.ShowCalloutAt(e.Location, browser); } catch (Exception ex) { await new MessageDialog(ex.ToString(), "Error").ShowAsync(); } }
public static Quest Load(KmlNode Node) { Quest quest = new Quest(); quest.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; quest.Stage = Node.SelectSingleNode("index").Values[2].ValueAsInt; if (Node.ChildNodes.ContainsKey("linked")) { int linkedValue = Node.SelectSingleNode("linked").Values[1].ValueAsInt; if (linkedValue == 1) { quest.Linked = true; } else { quest.Linked = false; } } quest.Cases = new List <Case>(); //load cases foreach (KmlNode caseNode in Node.SelectNodes("case")) { quest.Cases.Add(LoadCase(caseNode)); } return(quest); }
public void Create() { KmlNode root = new KmlNode("root"); Assert.IsNull(root.Parent); Assert.AreEqual("root", root.Tag); Assert.AreEqual("", root.Name); }
public static GenNpc Load(KmlNode Node) { GenNpc genNpc = new GenNpc(); genNpc.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; return genNpc; }
public void ChildGetTag() { KmlNode test = data.Root1.GetChildNode("Node2Tag"); Assert.AreEqual(data.Node2, test); KmlAttrib nonsense = data.Root1.GetAttrib("nonsense"); Assert.IsNull(nonsense); }
public static GenNpc Load(KmlNode Node) { GenNpc genNpc = new GenNpc(); genNpc.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; return(genNpc); }
public void ChildInsertAfterEmpty() { KmlNode child = KmlItem.CreateItem("child") as KmlNode; data.Node1.InsertAfter(null, child); Assert.AreEqual(data.Node1ChildCount + 1, data.Node1.Children.Count); Assert.AreEqual(data.Node1AttribCount + data.Node1ChildCount + 1, data.Node1.AllItems.Count); Assert.AreEqual(child, data.Node1.Children[data.Node1ChildCount]); }
private KmlNode NewNode(string tag, string name) { KmlNode node = KmlItem.CreateItem(tag) as KmlNode; if (name != null) { Add(node, NewAttrib("name", name)); } return(node); }
public void ChildInsertBeforeNotContained() { KmlNode child = KmlItem.CreateItem("child") as KmlNode; data.Node1.InsertBefore(data.Node2Child1, child); Assert.AreEqual(data.Node1ChildCount + 1, data.Node1.Children.Count); Assert.AreEqual(data.Node1AttribCount + data.Node1ChildCount + 1, data.Node1.AllItems.Count); Assert.AreEqual(child, data.Node1.Children[data.Node1ChildCount]); }
private Viewpoint ViewpointFromKmlViewpoint(KmlNode node, out bool needsAltitudeFix) { KmlViewpoint kvp = node.Viewpoint; // If KmlViewpoint is specified, use it. if (kvp != null) { // Altitude adjustment is needed for everything except Absolute altitude mode. needsAltitudeFix = (kvp.AltitudeMode != KmlAltitudeMode.Absolute); switch (kvp.Type) { case KmlViewpointType.LookAt: return(new Viewpoint(kvp.Location, new Camera(kvp.Location, kvp.Range, kvp.Heading, kvp.Pitch, kvp.Roll))); case KmlViewpointType.Camera: return(new Viewpoint(kvp.Location, new Camera(kvp.Location, kvp.Heading, kvp.Pitch, kvp.Roll))); default: throw new InvalidOperationException("Unexpected KmlViewPointType: " + kvp.Type); } } if (node.Extent != null && !node.Extent.IsEmpty) { // When no altitude specified, assume elevation should be taken into account. needsAltitudeFix = true; // Workaround: it's possible for "IsEmpty" to be true but for width/height to still be zero. if (node.Extent.Width == 0 && node.Extent.Height == 0) { // Defaults based on Google Earth. return(new Viewpoint(node.Extent, new Camera(node.Extent.GetCenter(), 1000, 0, 45, 0))); } else { Envelope tx = node.Extent; // Add padding on each side. double bufferDistance = Math.Max(node.Extent.Width, node.Extent.Height) / 20; Envelope bufferedExtent = new Envelope( tx.XMin - bufferDistance, tx.YMin - bufferDistance, tx.XMax + bufferDistance, tx.YMax + bufferDistance, tx.ZMin - bufferDistance, tx.ZMax + bufferDistance, SpatialReferences.Wgs84); return(new Viewpoint(bufferedExtent)); } } else { // Can't fly to. needsAltitudeFix = false; return(null); } }
public static Action CreateAction(KmlNode Node) { string type = Node.Values[0].Value; switch (type) { case "html": return new Html(Node); default: throw new Exception("No action defined for " + type); } }
private void UpdateShowChildren(KmlNode oldNode, KmlNode newNode) { if (oldNode != null) { oldNode.PropertyChanged -= KmlFeature_PropertyChanged; } if (newNode != null) { newNode.PropertyChanged += KmlFeature_PropertyChanged; } UpdateShowChildren(); }
public void PathToString() { KmlNode root = new KmlNode("root"); KmlNode node = new KmlNode("node"); KmlItem item = new KmlNode("item"); node.Add(item); root.Add(node); Assert.AreEqual("root", root.PathToString("-")); Assert.AreEqual("root-node", node.PathToString("-")); Assert.AreEqual("root/node/item", item.PathToString("/")); }
public void ChildInsertAfter() { KmlNode child3 = KmlItem.CreateItem("child3") as KmlNode; data.Node1.InsertAfter(data.Node1Child1, child3); Assert.AreEqual(data.Node1ChildCount + 1, data.Node1.Children.Count); Assert.AreEqual(data.Node1AttribCount + data.Node1ChildCount + 1, data.Node1.AllItems.Count); Assert.AreEqual(data.Node1Child1, data.Node1.Children[0]); Assert.AreEqual(child3, data.Node1.Children[1]); Assert.AreEqual(data.Node1Child2, data.Node1.Children[2]); }
public static Map Load(KmlNode Node) { Map map = new Map(); map.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; map.Kind = Node.SelectSingleNode("kind").Values[1].ValueAsInt; map.Location.X = Node.SelectSingleNode("xy").Values[1].ValueAsInt; map.Location.Y = Node.SelectSingleNode("xy").Values[2].ValueAsInt; map.FileName = Node.SelectSingleNode("filename").Values[1].Value; return map; }
public static Map Load(KmlNode Node) { Map map = new Map(); map.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; map.Kind = Node.SelectSingleNode("kind").Values[1].ValueAsInt; map.Location.X = Node.SelectSingleNode("xy").Values[1].ValueAsInt; map.Location.Y = Node.SelectSingleNode("xy").Values[2].ValueAsInt; map.FileName = Node.SelectSingleNode("filename").Values[1].Value; return(map); }
public void ChildrenChangedEvent() { data.Root1.ChildrenChanged += TestEventHandler; _testEventHandlerVisited = false; KmlNode child = KmlItem.CreateItem("child") as KmlNode; data.Root1.Add(child); Assert.IsTrue(_testEventHandlerVisited); _testEventHandlerVisited = false; data.Root1.Delete(child); Assert.IsTrue(_testEventHandlerVisited); }
private void Add(KmlNode parent, KmlItem child) { if (parent == null) { Roots.Add(child); } else { parent.Add(child); } Count(parent, child); }
public static Action CreateAction(KmlNode Node) { string type = Node.Values[0].Value; switch (type) { case "html": return(new Html(Node)); default: throw new Exception("No action defined for " + type); } }
public void ChildAddToEnd() { KmlNode node1 = KmlItem.CreateItem("node1") as KmlNode; data.Root2.Add(node1); KmlNode node2 = KmlItem.CreateItem("node2") as KmlNode; data.Root2.Add(node2); Assert.AreEqual(2, data.Root2.Children.Count); Assert.AreEqual(2, data.Root2.AllItems.Count); Assert.AreEqual(node1, data.Root2.Children[0]); Assert.AreEqual(node2, data.Root2.Children[1]); }
public static Case LoadCase(KmlNode CaseNode) { Case newCase = new Case(); newCase.Actions = new List<Quests.Action>(); newCase.Conditions = new List<Condition>(); //load conditions //KmlNode conditions = CaseNode.SelectSingleNode("if"); //foreach (KmlNode conditionNode in conditions.ChildNodes) //{ // newCase.Conditions.Add(LoadCondition(conditionNode)); //} //load actions KmlNode actions = CaseNode.SelectSingleNode("then"); foreach (KmlNode actionNode in actions.ChildNodes) { newCase.Actions.Add(LoadAction(actionNode)); } return newCase; }
public static GenMonster Load(KmlNode Node) { GenMonster genMonster = new GenMonster(); genMonster.Index = Node.SelectSingleNode("index").Values[1].ValueAsInt; genMonster.Cycle = Node.SelectSingleNode("cycle").Values[1].ValueAsInt; genMonster.Area = Node.SelectSingleNode("area").Values[1].ValueAsInt; genMonster.Map = Node.SelectSingleNode("map").Values[1].ValueAsInt; genMonster.Max = Node.SelectSingleNode("max").Values[1].ValueAsInt; //rect int X1 = Node.SelectSingleNode("rect").Values[1].ValueAsInt; int Y1 = Node.SelectSingleNode("rect").Values[2].ValueAsInt; int X2 = Node.SelectSingleNode("rect").Values[3].ValueAsInt; int Y2 = Node.SelectSingleNode("rect").Values[4].ValueAsInt; genMonster.Rect = new GenMonsterRect(X1,Y1,X2,Y2); genMonster.Max = Node.SelectSingleNode("max").Values[1].ValueAsInt; return genMonster; }
public Html(KmlNode Node) { this.HtmlID = Node.Values[1].ValueAsInt; }
public KmlNode Serialize(string RootName, ConfigPropertyGroup Group) { //create node KmlNode parent = new KmlNode(); //add rootname to values parent.Values.Add(new KmlValue(RootName)); //get fields FieldInfo[] fields = Group.GetType().GetFields(); //cycle each field foreach (FieldInfo fi in fields) { object value = fi.GetValue(Group); Type type = fi.FieldType; Type baseType = fi.FieldType.BaseType; //check if its a config property if (baseType.Equals(typeof(ConfigProperty)) && value != null) { //add field name KmlNode kNode = new KmlNode(parent); kNode.Values.Add(new KmlValue(fi.Name)); //Console.WriteLine(fi.Name); //get values from inside field FieldInfo[] fields2 = type.GetFields(); foreach(FieldInfo fi2 in fields2) { object value2 = fi2.GetValue(value); Type type2 = fi2.FieldType; Type baseType2 = fi2.FieldType.BaseType; // Console.WriteLine("type: " + type2); //enum if (baseType2.Equals(typeof(Enum))) { //Console.WriteLine("-e" + (int)value2); kNode.Values.Add(new KmlValue((int)value2)); } //string else if(type2.Equals(typeof(System.String))) { //Console.WriteLine("-s" + value2); kNode.Values.Add(new KmlValue(value2.ToString(), true)); } //bool else if (type2.Equals(typeof(System.Boolean))) { //Console.WriteLine("-b" + value2); bool bval = (bool)value2; if (bval) { kNode.Values.Add(new KmlValue(1)); } else { kNode.Values.Add(new KmlValue(0)); } } else { //Console.WriteLine("--" + value2); kNode.Values.Add(new KmlValue(value2)); } } } //check if its a group if (fi.FieldType.BaseType.Equals(typeof(ConfigPropertyGroup))) { //serialize the group and add it to parent parent.ChildNodes.Add(Serialize(fi.Name, (ConfigPropertyGroup)fi.GetValue(Group))); } } return parent; }
public Guide(KmlNode Node) { this.GuideID = Node.Values[1].ValueAsInt; }
//public Condition LoadCondition(KmlNode ConditionNode) // { // Condition condition = new Condition(); // // return condition; // } public static Action LoadAction(KmlNode ActionNode) { Action action = ActionManager.CreateAction(ActionNode); return action; }