Exemplo n.º 1
0
        void ParseElementDescr(elementDescr parentDescr)
        {
            var xmlLinkedNode = parentDescr.XmlElement as XmlLinkedNode;

            if (xmlLinkedNode != null)
            {
                xmlLinkedNode.ForEach(nodes => {
                    var element = nodes as XmlElement;
                    var text    = nodes as XmlText;

                    if (element != null)
                    {
                        elementDescr elDescr = new elementDescr()
                        {
                            Name = element.Name, XmlElement = element
                        };

                        ParseElementDescr(elDescr);

                        parentDescr.Childs.Add(elDescr);
                    }
                    if (text != null)
                    {
                        parentDescr.Value = text.Value;
                    }
                });
            }
            else
            {
                int i = 0;
            }
        }
Exemplo n.º 2
0
        elementDescr ParseXmlItem(ItemList.ElementItem elemItem)
        {
            var          element = elemItem.any;
            elementDescr elem    = new elementDescr()
            {
                Name = element.LocalName, XmlElement = element
            };

            ParseElementDescr(elem);

            return(elem);
        }
Exemplo n.º 3
0
        FrameworkElement GetXmlElementView(elementDescr element, string parentName)
        {
            FrameworkElement felement = null;

            if (element.HasChilds)
            {
                Expander grbox = new Expander();
                //grbox.Padding = new Thickness(20, 0, 0, 0);
                //if (parentName != "__Top") {
                //    //grbox.Margin = new Thickness(10, 0, 0, 0);
                //}

                grbox.Header = element.Name;

                StackPanel spanel = new StackPanel();
                spanel.Orientation = Orientation.Vertical;

                element.Childs.ForEach(child => {
                    spanel.Children.Add(GetXmlElementView(child, element.Name));
                });

                spanel.Margin = new Thickness(20, 0, 0, 0);

                grbox.Content = spanel;

                felement = grbox;
            }
            else
            {
                StackPanel spanel = new StackPanel();
                spanel.Orientation = Orientation.Horizontal;

                TextBlock tblock = new TextBlock();
                tblock.Margin            = new Thickness(3);
                tblock.Text              = element.Name;
                tblock.MinWidth          = 150;
                tblock.Foreground        = Brushes.DarkGray;
                tblock.FontWeight        = FontWeights.Bold;
                tblock.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                spanel.Children.Add(tblock);
                spanel.Children.Add(GetValueEditor(element));

                spanel.Margin = new Thickness(20, 0, 0, 0);

                felement = spanel;
            }
            return(felement);
        }
Exemplo n.º 4
0
        void PrepareChilds(elementDescr xmlElement, odm.ui.controls.SchemaParser.xsdElement schemaElement)
        {
            if (xmlElement.HasChilds)
            {
                xmlElement.Childs.ForEach(chld => {
                    var icomplex = schemaElement.Type as odm.ui.controls.SchemaParser.IComplexType;
                    var isimple  = schemaElement.Type as odm.ui.controls.SchemaParser.ISimpleType;
                    var ipure    = schemaElement.Type as odm.ui.controls.SchemaParser.IPureType;

                    if (icomplex != null)
                    {
                        var content = icomplex.Content.FirstOrDefault(schemel => schemel.Name == chld.Name);
                        if (content == null)
                        {
                            return;
                        }
                        if (content.Type.ContentType == SchemaParser.ContentTypes.pureType)
                        {
                            chld.QName = content.Type.QName;
                        }
                        else
                        {
                            PrepareChilds(chld, content);
                        }
                    }
                    else if (isimple != null)
                    {
                        chld.Defaults = isimple.SimpleValues;
                    }
                    else if (ipure != null)
                    {
                        int i = 0;
                    }
                });
            }
            else
            {
                var isimple = schemaElement.Type as odm.ui.controls.SchemaParser.ISimpleType;
                if (isimple != null)
                {
                    xmlElement.QName    = isimple.QName;
                    xmlElement.Defaults = isimple.SimpleValues;
                }
            }
        }
Exemplo n.º 5
0
 public void RemoveChild(elementDescr child)
 {
     childs.Remove(child);
     NotifyPropertyChanged("Childs");
 }
Exemplo n.º 6
0
 public void AddChild(elementDescr child)
 {
     childs.Add(child);
     NotifyPropertyChanged("Childs");
 }
Exemplo n.º 7
0
        FrameworkElement GetValueEditor(elementDescr element)
        {
            FrameworkElement felem = null;

            switch (element.QName.Name)
            {
            case "int":
                IntegerUpDown numUp = new IntegerUpDown();
                numUp.Margin            = new Thickness(3);
                numUp.Increment         = 1;
                numUp.VerticalAlignment = VerticalAlignment.Center;
                numUp.MinWidth          = 50;
                numUp.CreateBinding(IntegerUpDown.ValueProperty, element, x => {
                    int val = 0;
                    int.TryParse(element.Value, out val);
                    return(val);
                }, (o, v) => {
                    o.Value = v.ToString();
                });
                felem = numUp;
                break;

            case "float":
                DoubleUpDown doubleUp = new DoubleUpDown();
                doubleUp.CultureInfo       = System.Globalization.CultureInfo.InvariantCulture;
                doubleUp.Margin            = new Thickness(3);
                doubleUp.Increment         = 0.01f;
                doubleUp.FormatString      = "F3";
                doubleUp.VerticalAlignment = VerticalAlignment.Center;
                doubleUp.MinWidth          = 50;
                doubleUp.CreateBinding(DoubleUpDown.ValueProperty, element, x => {
                    float val = 0;
                    //float.TryParse(element.Value, out val);
                    try {
                        val = XmlConvert.ToSingle(element.Value);
                    }catch (Exception err) {
                        dbg.Error(err);
                    }
                    return(val);
                }, (o, v) => {
                    o.Value = XmlConvert.ToString(v);
                });
                felem = doubleUp;
                break;

            case "boolean":
                CheckBox chBox = new CheckBox();
                chBox.Margin = new Thickness(3);
                chBox.CreateBinding(CheckBox.IsCheckedProperty, element, x => {
                    bool val = false;
                    bool.TryParse(element.Value, out val);
                    return(val);
                }, (o, v) => {
                    o.Value = v.ToString();
                });
                felem = chBox;
                break;

            default:
                TextBox tbox = new TextBox();
                tbox.Margin = new Thickness(3);
                tbox.CreateBinding(TextBox.TextProperty, element, x => x.Value, (o, v) => {
                    o.Value = v;
                });
                tbox.MinWidth          = 50;
                tbox.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                felem = tbox;
                break;
            }
            return(felem);
        }
		public void AddChild(elementDescr child) {
			childs.Add(child);
			NotifyPropertyChanged("Childs");
		}
		public void RemoveChild(elementDescr child) {
			childs.Remove(child);
			NotifyPropertyChanged("Childs");
		}
Exemplo n.º 10
0
		void ParseElementDescr(elementDescr parentDescr) {
			var xmlLinkedNode = parentDescr.XmlElement as XmlLinkedNode;
			if (xmlLinkedNode != null) {
				xmlLinkedNode.ForEach(nodes => {
					var element = nodes as XmlElement;
					var text = nodes as XmlText;

					if (element != null) {
						elementDescr elDescr = new elementDescr() { Name = element.Name, XmlElement = element };

						ParseElementDescr(elDescr);

						parentDescr.Childs.Add(elDescr);
					}
					if (text != null) {
						parentDescr.Value = text.Value;
					}

				});
			} else {
				int i = 0;
			}
		}
Exemplo n.º 11
0
		elementDescr ParseXmlItem(ItemList.ElementItem elemItem) {
			var element = elemItem.any;
			elementDescr elem = new elementDescr() { Name = element.LocalName, XmlElement = element };

			ParseElementDescr(elem);
			
			return elem;
		}
Exemplo n.º 12
0
		void PrepareChilds(elementDescr xmlElement, odm.ui.controls.SchemaParser.xsdElement schemaElement) {
			if (xmlElement.HasChilds) {
				xmlElement.Childs.ForEach(chld => {
					var icomplex = schemaElement.Type as odm.ui.controls.SchemaParser.IComplexType;
					var isimple = schemaElement.Type as odm.ui.controls.SchemaParser.ISimpleType;
					var ipure = schemaElement.Type as odm.ui.controls.SchemaParser.IPureType;

					if(icomplex != null){
						var content =  icomplex.Content.FirstOrDefault(schemel => schemel.Name == chld.Name);
						if (content == null)
							return;
						if (content.Type.ContentType == SchemaParser.ContentTypes.pureType) {
							chld.QName = content.Type.QName;
						} else {
							PrepareChilds(chld, content);
						}
					} else if (isimple != null) {
						chld.Defaults = isimple.SimpleValues;
					} else if (ipure != null) {
						int i = 0;
					}
				});
			} else {
				var isimple = schemaElement.Type as odm.ui.controls.SchemaParser.ISimpleType;
				if (isimple != null) {
					xmlElement.QName = isimple.QName;
					xmlElement.Defaults = isimple.SimpleValues;
				}
			}
		}
Exemplo n.º 13
0
		FrameworkElement GetValueEditor(elementDescr element) {
			FrameworkElement felem = null;

			switch (element.QName.Name) { 
				case "int":
					IntegerUpDown numUp = new IntegerUpDown();
					numUp.Margin = new Thickness(3);
					numUp.Increment = 1;
					numUp.VerticalAlignment = VerticalAlignment.Center;
					numUp.MinWidth = 50;
					numUp.CreateBinding(IntegerUpDown.ValueProperty, element, x => {
						int val = 0;
						int.TryParse(element.Value, out val);
						return val;
					}, (o, v) => {
						o.Value = v.ToString();
					});
					felem = numUp;
					break;
				case "float":
					DoubleUpDown doubleUp = new DoubleUpDown();
					doubleUp.CultureInfo = System.Globalization.CultureInfo.InvariantCulture;
					doubleUp.Margin = new Thickness(3);
					doubleUp.Increment = 0.01f;
					doubleUp.FormatString = "F3";
					doubleUp.VerticalAlignment = VerticalAlignment.Center;
					doubleUp.MinWidth = 50;
					doubleUp.CreateBinding(DoubleUpDown.ValueProperty, element, x => {
						float val = 0;
						//float.TryParse(element.Value, out val);
						try {
							val = XmlConvert.ToSingle(element.Value);
						}catch(Exception err){
							dbg.Error(err);
						}
						return val;
					}, (o, v) => {
						o.Value = XmlConvert.ToString(v);
					});
					felem = doubleUp;
					break;
				case "boolean":
					CheckBox chBox = new CheckBox();
					chBox.Margin = new Thickness(3);
					chBox.CreateBinding(CheckBox.IsCheckedProperty, element, x => {
						bool val = false;
						bool.TryParse(element.Value, out val);
						return val;
					}, (o, v) => {
						o.Value = v.ToString();
					});
					felem = chBox;
					break;
				default:
					TextBox tbox = new TextBox();
					tbox.Margin = new Thickness(3);
					tbox.CreateBinding(TextBox.TextProperty, element, x => x.Value, (o, v) => {
						o.Value = v;
					});
					tbox.MinWidth = 50;
					tbox.VerticalAlignment = System.Windows.VerticalAlignment.Center;
					felem = tbox;
					break;
			}
			return felem;
		}
Exemplo n.º 14
0
		FrameworkElement GetXmlElementView(elementDescr element, string parentName) {
			FrameworkElement felement = null;
			if (element.HasChilds) {
				Expander grbox = new Expander();
				//grbox.Padding = new Thickness(20, 0, 0, 0);
				//if (parentName != "__Top") {
				//    //grbox.Margin = new Thickness(10, 0, 0, 0);
				//}
				
				grbox.Header = element.Name;

				StackPanel spanel = new StackPanel();
				spanel.Orientation = Orientation.Vertical;

				element.Childs.ForEach(child => {
					spanel.Children.Add(GetXmlElementView(child, element.Name));
				});
				
				spanel.Margin = new Thickness(20, 0, 0, 0);

				grbox.Content = spanel;

				felement = grbox;
			} else{
				StackPanel spanel = new StackPanel();
				spanel.Orientation = Orientation.Horizontal;

				TextBlock tblock = new TextBlock();
				tblock.Margin = new Thickness(3);
				tblock.Text = element.Name;
				tblock.MinWidth = 150;
				tblock.Foreground = Brushes.DarkGray;
				tblock.FontWeight = FontWeights.Bold;
				tblock.VerticalAlignment = System.Windows.VerticalAlignment.Center;

				spanel.Children.Add(tblock);
				spanel.Children.Add(GetValueEditor(element));

				spanel.Margin = new Thickness(20, 0, 0, 0);

				felement = spanel;
			}
			return felement;
		}