Inheritance: XmlSchemaObject
Exemple #1
0
        public DocUIList(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm, bool horizontal = true)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            _optlist = new List<ListItemComponent>();
            _parent = xmlNode;
            _listpanel = new StackPanel();
            _listpanel.Orientation = horizontal ? Orientation.Horizontal : Orientation.Vertical;
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null && seq.Items.Count == 1 && seq.Items[0] is XmlSchemaElement)
                {
                    _el = seq.Items[0] as XmlSchemaElement;
                    //get all elements from current node
                    foreach (XmlNode node in xmlNode.ChildNodes)
                    {
                        ListItemComponent lio = new ListItemComponent(node, _el, _listpanel, overlaypanel, _optlist, parentForm);
                        _optlist.Add(lio);
                    }
                }

                Button add = new Button();
                add.Content = "Add item";
                add.Click += AddItem;
                _listpanel.Children.Add(add);
                contentpanel.Children.Add(_listpanel);
            }
        }
Exemple #2
0
 public DocUITabbed(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
     : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
 {
     this.Sideways = true;
     _tabControl = new TabControl();
     this.Control = _tabControl;
     _optlist = new List<AbstractDocUIComponent>();
     XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
     if (schemaEl != null)
     {
         XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
         if (seq != null)
         {
             foreach (XmlSchemaElement el in seq.Items)
             {
                 TabItem ti = new TabItem();
                 ti.Header = XmlSchemaUtilities.tryGetDocumentation(el); ;
                 Grid newpanel = new Grid();
                 ColumnDefinition cdnew1 = new ColumnDefinition();
                 cdnew1.Width = new GridLength(1, GridUnitType.Auto);
                 ColumnDefinition cdnew2 = new ColumnDefinition();
                 newpanel.ColumnDefinitions.Add(cdnew1);
                 newpanel.ColumnDefinitions.Add(cdnew2);
                 Utilities.recursive(el, xmlNode.SelectSingleNode(el.Name), newpanel, overlaypanel, (comp) =>
                 {
                     _optlist.Add(comp);
                     comp.placeOption();
                 }, parentForm);
                 ti.Content = newpanel;
                 this._tabControl.Items.Add(ti);
             }
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Creates a new instance of the comboOption
        /// </summary>
        /// <param name="xmlNode">The xmlNode containing the data (selected value) of the comboOption</param>
        /// <param name="xsdNode">The corresponding xsdNode</param>
        /// <param name="panel">The panel on which the option should be placed</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUICombo(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                cb = new ComboBox() { Margin = new Thickness(5) };
                cb.SelectionChanged += (s, e) => { hasPendingChanges(); };
                cb.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;

                // get enumeration
                IEnumerable<XmlSchemaEnumerationFacet> enumFacets = XmlSchemaUtilities.tryGetEnumRestrictions(schemaEl.ElementSchemaType);

                if (enumFacets != null)
                {
                    foreach (var facet in enumFacets)
                    {
                        // fill the combobox
                        cb.Items.Add(facet.Value);
                    }
                    cb.SelectedIndex = 0;
                }
                else
                {
                    Log.Info("This combobox has no enumeration restriction. The Combobox will be empty.");
                }

                Control = cb;
                cb.Padding = new Thickness(10, 2, 10, 2);

                setup();
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates a new instance of MultiSelectOption
        /// </summary>
        /// <param name="xmlNode">The xmlNode that contains the data.</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel on which the option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIMultiSelect(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null && seq.Items.Count > 0)
                {
                    XmlSchemaElement el = seq.Items[0] as XmlSchemaElement;

                    IEnumerable<XmlSchemaEnumerationFacet> restrictions = XmlSchemaUtilities.tryGetEnumRestrictions(el.ElementSchemaType);
                    foreach (XmlSchemaEnumerationFacet e in restrictions)
                    {

                        AddOption(e.Value, FontWeights.Normal);
                    }
                }

                CheckBox all = AddOption("All", FontWeights.Bold);
                all.Checked += (s, e) => { SelectAll(); };
                all.Unchecked += (s, e) => { UnselectAll(); };

                _wrapPanel.Orientation = Orientation.Horizontal;
                Control = _wrapPanel;

                setup();
            }
        }
Exemple #5
0
        /// <summary>
        /// Creates a new instance of the TimeOption
        /// </summary>
        /// <param name="xmlNode">The xmlnode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdnode.</param>
        /// <param name="panel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUITime(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            Control = new TimePicker() { Format = TimeFormat.Custom, FormatString = "HH:mm:ss" };
            (Control as TimePicker).ValueChanged += (s, e) => { hasPendingChanges(); };

            setup();
        }
Exemple #6
0
        public DocUIBoolean(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            Control = new CheckBox();

            (Control as CheckBox).Click += (s, e) => { hasPendingChanges(); };

            setup();
        }
Exemple #7
0
        /// <summary>
        /// Creates a new instance of the SubSectionOption
        /// </summary>
        /// <param name="xmlNode">The xmlnode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUISubSection(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                optionlist = new List<AbstractDocUIComponent>();
                box = new GroupBox();
                DockPanel panel = new DockPanel();

                Grid g = new Grid() { Margin = new Thickness(5, 0, 0, 0) };
                g.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
                g.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });

                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null)
                {
                    foreach (XmlSchemaElement el in seq.Items)
                        Utilities.recursive(el, xmlNode.SelectSingleNode(el.Name), g, overlaypanel, (comp) =>
                        {
                            comp.placeOption();
                            optionlist.Add(comp);
                        }, parentForm);
                }

                if (xmlNode.Attributes["checked"] != null)
                {
                    check = new CheckBox() { Margin = new Thickness(5, 5, 0, 5) };
                    check.Checked += check_changed;
                    check.Checked += (s, e) => { hasPendingChanges(); };
                    check.Unchecked += check_changed;
                    check.Unchecked += (s, e) => { hasPendingChanges(); };
                    panel.Children.Add(check);
                }

                // if there is no label, there should be no groupbox.
                if (Label.Text != "")
                {
                    panel.Children.Add(Label);
                    box.Header = panel;
                    box.Content = g;
                    Control = box;
                }
                else
                {
                    panel.Children.Add(g);
                    //Control = g;
                    Control = panel;
                }

                setup();
            }
        }
Exemple #8
0
 public DocUIGUID(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
     base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
 {
     Label l = new Label();
     this.Control = l;
     //check if node contains default value
     if (xmlNode.InnerText == "")
     {
         xmlNode.InnerText = Guid.NewGuid().ToString();
         //save the key
         //parentForm.saveFile(this, null);
     }
     l.Content = xmlNode.InnerText;
 }
Exemple #9
0
        /// <summary>
        /// Creates a new incstance of the StringOption.
        /// </summary>
        /// <param name="xmlNode">The xmlnode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        /// <param name="metaname">Whether this option can be filled with metadata. And if so, whether it will get the name or the value of the metadata.</param>
        public DocUIString(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            string regex = XmlSchemaUtilities.tryGetPatternRestriction(xsdNode);

            if (regex == null) { regex = ""; }

            string watermark = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "watermark");
            string req = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "required");
            bool required = req == "true" ? true : false;

            Control = new ExtendedTextBox("", watermark, regex, required, parentForm);
            (Control as ExtendedTextBox).TextBlock.TextChanged += (s, e) => { hasPendingChanges(); };
            Setup();
        }
Exemple #10
0
        /// <summary>
        /// Creates a new instance of the TimeOption
        /// </summary>
        /// <param name="xmlNode">The xmlnode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdnode.</param>
        /// <param name="contentpanel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIDateTime(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            //Control = new DatePicker(); //{ Form Format = TimeFormat.Custom, FormatString = "HH:mm:ss" };
            //(Control as DatePicker).ValueChanged += (s, e) => { hasPendingChanges(); };

            stack = new StackPanel() { Orientation = Orientation.Horizontal };
            Control = stack;
            DateControl = new DatePicker();
            DateControl.SelectedDateChanged += (s, e) => { hasPendingChanges(); };
            TimeControl = new TimePicker() { Format = TimeFormat.Custom, FormatString = "HH:mm:ss" };
            TimeControl.ValueChanged += (s, e) => { hasPendingChanges(); };

            setup();
        }
        protected virtual void Visit(XmlSchemaAnnotated annotated)
        {
            XmlSchemaAnyAttribute anyAttribute;
            XmlSchemaAttribute attribute;
            XmlSchemaAttributeGroup attributeGroup;
            XmlSchemaAttributeGroupRef attributeGroupRef;
            XmlSchemaContent content;
            XmlSchemaContentModel contentModel;
            XmlSchemaFacet facet;
            XmlSchemaGroup group;
            XmlSchemaIdentityConstraint constraint;
            XmlSchemaNotation notation;
            XmlSchemaParticle particle;
            XmlSchemaSimpleTypeContent schemaSimpleTypeContent;
            XmlSchemaType type;
            XmlSchemaXPath xPath;

            if (Casting.TryCast(annotated, out anyAttribute))
                Visit(anyAttribute);
            else if (Casting.TryCast(annotated, out attribute))
                Visit(attribute);
            else if (Casting.TryCast(annotated, out attributeGroup))
                Visit(attributeGroup);
            else if (Casting.TryCast(annotated, out attributeGroupRef))
                Visit(attributeGroupRef);
            else if (Casting.TryCast(annotated, out content))
                Visit(content);
            else if (Casting.TryCast(annotated, out contentModel))
                Visit(contentModel);
            else if (Casting.TryCast(annotated, out facet))
                Visit(facet);
            else if (Casting.TryCast(annotated, out group))
                Visit(group);
            else if (Casting.TryCast(annotated, out constraint))
                Visit(constraint);
            else if (Casting.TryCast(annotated, out notation))
                Visit(notation);
            else if (Casting.TryCast(annotated, out particle))
                Visit(particle);
            else if (Casting.TryCast(annotated, out schemaSimpleTypeContent))
                Visit(schemaSimpleTypeContent);
            else if (Casting.TryCast(annotated, out type))
                Visit(type);
            else if (Casting.TryCast(annotated, out xPath))
                Visit(xPath);
            else
                throw ExceptionBuilder.UnexpectedSchemaObjectType(annotated);
        }
Exemple #12
0
        /// <summary>
        /// Creates a new instance of the passwordOption
        /// </summary>
        /// <param name="xmlNode">The xmlNode that contains the data.</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIPassword(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            PasswordBox pw = new PasswordBox() { PasswordChar = '*' };
            string req = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "required");
            required = req == "true" ? true : false;

            pw.PasswordChanged += (s, e) =>
            {
                pw.Background = required && pw.Password == "" ? ExtendedTextBox.IncorrectColor : ExtendedTextBox.CorrectColor;
                hasPendingChanges();
            };
            Control = pw;

            setup();
        }
Exemple #13
0
        /// <summary>
        /// Creates a new instance of the BigTextOption
        /// </summary>
        /// <param name="xmlNode">The node containing the data for the textbox</param>
        /// <param name="xsdNode">The corresponding xsdNode</param>
        /// <param name="panel">the panel on which this option should be placed</param>
        /// <param name="parentForm">the form of which this option is a part</param>
        public DocUIBigTextBox(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            ScrollViewer scroll = new ScrollViewer();

            string req = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "required");
            bool required = req == "true" ? true : false;

            box = new ExtendedTextBox("", "", "", required, parentForm);
            box.TextBlock.AcceptsReturn = true;
            box.TextBlock.TextWrapping = TextWrapping.Wrap;
            box.Height = 200;

            scroll.Content = box;
            Control = scroll;

            setup();
        }
Exemple #14
0
        /// <summary>
        /// Creates a new instance of the IntegerOption
        /// </summary>
        /// <param name="xmlNode">The node that contains the data for the integerOption</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel in which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIInteger(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            int maxIncl = XmlSchemaUtilities.tryGetMaxIncl(xsdNode);
            int minIncl = XmlSchemaUtilities.tryGetMinIncl(xsdNode);
            _defaultValue = minIncl;

            Control = new DoubleUpDown()
            {
                ShowButtonSpinner = true,
                AllowSpin = true,
                MouseWheelActiveTrigger = MouseWheelActiveTrigger.MouseOver,
                Increment = 1,
                ClipValueToMinMax = true,
                Minimum = minIncl,
                Maximum = maxIncl
            };
            (Control as DoubleUpDown).ValueChanged += (s, e) => { hasPendingChanges(); };

            setup();
        }
Exemple #15
0
        /// <summary>
        /// Creates a new instance of the RadioSelector
        /// </summary>
        /// <param name="xmlNode">The xmlNode containing the data.</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIRadioSelect(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                g.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
                g.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
                g.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });

                g.HorizontalAlignment = HorizontalAlignment.Stretch;

                Control = g;

                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null)
                    foreach (XmlSchemaElement el in seq.Items)
                        Utilities.recursive(el, xmlNode.SelectSingleNode(el.Name), contentpanel, overlaypanel, addOption, parentForm);
                else
                    Log.Info("this comboselector does not contain any options.");

                setup();
            }
        }
 private void CopyPosition(XmlSchemaAnnotated to, XmlSchemaAnnotated from, bool copyParent) {
     to.SourceUri = from.SourceUri;
     to.LinePosition = from.LinePosition;
     to.LineNumber = from.LineNumber;
     to.SetUnhandledAttributes(from.UnhandledAttributes);
     if (copyParent) {
        to.Parent = from.Parent;
     }
 }
 private bool CheckUnhandledAttributes(XmlSchemaAnnotated annotated)
 {
     if (annotated.UnhandledAttributes != null)
     {
         foreach (XmlAttribute att in annotated.UnhandledAttributes)
         {
             if (att.LocalName == "root" && att.NamespaceURI == Constants.TypedXLinqNs)
             {
                 return true;
             }
         }
     }
     return false;
 }
		// common process for element and attribute
		private void ImportColumnMetaInfo (XmlSchemaAnnotated obj, XmlQualifiedName name, DataColumn col)
		{
			int ordinal = -1;
			if (obj.UnhandledAttributes != null) {
				foreach (XmlAttribute attr in obj.UnhandledAttributes) {
					if (attr.NamespaceURI != XmlConstants.MsdataNamespace)
						continue;
					switch (attr.LocalName) {
					case XmlConstants.Caption:
						col.Caption = attr.Value;
						break;
					case XmlConstants.DataType:
						col.DataType = Type.GetType (attr.Value);
						break;
					case XmlConstants.AutoIncrement:
						col.AutoIncrement = bool.Parse (attr.Value);
						break;
					case XmlConstants.AutoIncrementSeed:
						col.AutoIncrementSeed = int.Parse (attr.Value);
						break;
					case XmlConstants.AutoIncrementStep:
						col.AutoIncrementStep = int.Parse (attr.Value);
						break;
					case XmlConstants.ReadOnly:
						col.ReadOnly = XmlConvert.ToBoolean (attr.Value);
						break;
					case XmlConstants.Ordinal:
						ordinal = int.Parse (attr.Value);
						break;
					}
				}
			}
		}
Exemple #19
0
 public static XmlSchemaDocumentation GetDocumentation(XmlSchemaAnnotated a, string language)
 {
     XmlSchemaAnnotation ann = a.Annotation;
     if (ann == null) return null;
     foreach (XmlSchemaObject o in ann.Items) {
         // search for xs:documentation nodes
         XmlSchemaDocumentation doc = o as XmlSchemaDocumentation;
         if (doc != null)
         {
             if (string.IsNullOrEmpty(language) || doc.Language == language)
             {
                 return doc;
             }
         }
     }
     return null;
 }
Exemple #20
0
 public static string GetAnnotation(XmlSchemaAnnotated a, AnnotationNode node, string language)
 {
     XmlSchemaAnnotation ann = a.Annotation;
     if (ann == null) return null;
     string filter = node.ToString().ToLowerInvariant();
     if (filter == "default") filter = "";
     string result = GetMarkup(ann, filter, language);
     if (!string.IsNullOrEmpty(result)) return result;
     return GetMarkup(ann, null, language);
 }
Exemple #21
0
        /// <summary>
        /// Creates a new instance of the ListSelectOption.
        /// </summary>
        /// <param name="xmlNode">The xmlNode that contains the data for the list</param>
        /// <param name="xsdNode">The corresponding xsdNode</param>
        /// <param name="p">The panel on which the option should be placed</param>
        /// <param name="ordered">Whether the list should be ordered or not.</param>
        public DocUIFileList(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicProjectForm parentForm)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            //init variables
            this.parentForm = parentForm;
            this.projectpath = parentForm.ProjectSystem.WorkingDirectory.FullName;
            ext = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "ext");
            folder = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "folder");
            string tmprel = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "relative");
            relative = tmprel == "true" ? true : false;

            DockPanel dock = new DockPanel();

            // init the grid
            Grid g = new Grid();
            g.ColumnDefinitions.Add(new ColumnDefinition());
            g.ColumnDefinitions.Add(new ColumnDefinition());
            g.RowDefinitions.Add(new RowDefinition());
            g.RowDefinitions.Add(new RowDefinition());

            // init the Components
            menu = new ContextMenu();
            MenuItem OpenMenu = new MenuItem();
            OpenMenu.Icon = ModernImageLibrary.GetImage((int)ModernImageLibrary.FileIcons.Open, 16);
            OpenMenu.Click += OpenMenu_Click;
            OpenMenu.Header = "Add";
            menu.Items.Add(OpenMenu);

            if (folder != "")
            {
                MenuItem EditMenu = new MenuItem();
                EditMenu.Click += EditMenu_Click;
                EditMenu.Icon = ModernImageLibrary.GetImage((int)ModernImageLibrary.FileIcons.Edit, 16);
                EditMenu.Header = "Edit";
                menu.Items.Add(EditMenu);
            }

            MenuItem RemoveMenu = new MenuItem();
            RemoveMenu.Click += RemoveMenu_Click;
            RemoveMenu.Icon = ModernImageLibrary.GetImage((int)ModernImageLibrary.FileIcons.Close, 16);
            RemoveMenu.Header = "Remove";
            menu.Items.Add(RemoveMenu);

            Image DropMenuImage = ModernImageLibrary.GetImage((int)ModernImageLibrary.FileIcons.Shortcut, 16);
            DropMenuImage.ContextMenu = menu;
            DropMenuImage.MouseEnter += DropMenuImage_MouseEnter;

            StackPanel stack = new StackPanel();
            stack.Children.Add(DropMenuImage);
            DockPanel.SetDock(stack, Dock.Right);
            dock.Children.Add(stack);

            View = new ListView() { ItemsSource = ViewCollection };
            View.Height = 50;
            ((INotifyCollectionChanged)ViewCollection).CollectionChanged += (s, e) => { hasPendingChanges(); };
            dock.Children.Add(View);

            //init drag en drop extras
            this.View.DragEnter += DropList_Drag;
            this.View.Drop += DropList_Drop;
            this.View.DragOver += DropList_Drag;
            this.View.AllowDrop = true;

            // set the Control
            this.Control = dock;

            // make the list ordered
            if (ordered)
                new ListViewDragDropManager<string>(View);

            setup();
        }
        private List<XmlNode> GetAnnotation(XmlSchemaAnnotated annotated)
        {
            List<XmlNode> nodes = new List<XmlNode>();
            XmlSchemaAnnotation annotation = annotated.Annotation;
            if (annotation != null)
            {
                // find the first <xs:appinfo> element
                foreach (XmlSchemaObject schemaObj in annotation.Items)
                {
                    XmlSchemaAppInfo appInfo = schemaObj as XmlSchemaAppInfo;
                    if (appInfo != null)
                    {
                        // copy annotation, removing comments
                        foreach (XmlNode node in appInfo.Markup)
                            if (node.NodeType != XmlNodeType.Comment)
                                nodes.Add(node);
                    }
                }
            }

            return nodes;
        }
 internal static String GetMsdataAttribute(XmlSchemaAnnotated node, String ln) {
     XmlAttribute[]   nodeAttributes = node.UnhandledAttributes;
     if (nodeAttributes!=null)
         for(int i=0; i<nodeAttributes.Length;i++)
             if (nodeAttributes[i].LocalName == ln && nodeAttributes[i].NamespaceURI == Keywords.MSDNS)
                 return nodeAttributes[i].Value;
     return null;
 }
        internal XmlSchemaAnnotated FindTypeNode(XmlSchemaAnnotated node) {
            // this function is returning null
            // if the typeNode for node is in the XSD namespace.
            
            XmlSchemaAttribute attr = node as XmlSchemaAttribute;
            XmlSchemaElement el = node as XmlSchemaElement;
            bool isAttr = false;
            if (attr != null) {
                isAttr = true;
            }

            String _type = isAttr ? attr.SchemaTypeName.Name :  el.SchemaTypeName.Name;
            String _typeNs = isAttr ? attr.SchemaTypeName.Namespace :  el.SchemaTypeName.Namespace;
            if (_typeNs == Keywords.XSDNS)
                return null;
            XmlSchemaAnnotated typeNode;
            if (_type == null || _type.Length == 0) {
                _type = isAttr ? attr.RefName.Name :  el.RefName.Name;
                if (_type == null || _type.Length == 0) 
                    typeNode = (XmlSchemaAnnotated) (isAttr ? attr.SchemaType :  el.SchemaType);
                else 
                    typeNode = isAttr ? FindTypeNode((XmlSchemaAnnotated)attributes[attr.RefName]) :FindTypeNode((XmlSchemaAnnotated)elementsTable[el.RefName]);
            }
            else
                typeNode = (XmlSchemaAnnotated)schemaTypes[isAttr ? ((XmlSchemaAttribute)node).SchemaTypeName :  ((XmlSchemaElement)node).SchemaTypeName];
            return typeNode;
        }
        internal string GetInstanceName(XmlSchemaAnnotated node) {
            string  instanceName = null;

            Debug.Assert( (node is XmlSchemaElement) || (node is XmlSchemaAttribute), "GetInstanceName should only be called on attribute or elements");

            if (node is XmlSchemaElement) {
                XmlSchemaElement el = (XmlSchemaElement) node;
                instanceName = el.Name != null ? el.Name : el.RefName.Name;
            }
            else if (node is XmlSchemaAttribute) {
                XmlSchemaAttribute el = (XmlSchemaAttribute) node;
                instanceName = el.Name != null ? el.Name : el.RefName.Name;
            }

            Debug.Assert((instanceName != null) && (instanceName.Length != 0), "instanceName cannot be null or empty. There's an error in the XSD compiler");

            return instanceName;
        }
Exemple #26
0
		string GetDocumentation (XmlSchemaAnnotated elem)
		{
			string res = "";
			XmlSchemaAnnotation anot = elem.Annotation;
			if (anot == null || anot.Items == null) return null;
			
			foreach (object ob in anot.Items)
			{
				XmlSchemaDocumentation doc = ob as XmlSchemaDocumentation;
				if (doc != null && doc.Markup != null && doc.Markup.Length > 0) {
					if (res != string.Empty) res += "\n";
					foreach (XmlNode node in doc.Markup)
						res += node.Value;
				}
			}
			return res;
		}
        /// <summary>
        /// Creates a new AbstractOption. This, of course, is impossible, due to the fact that AbstractOption is an abstract class.
        /// </summary>
        /// <param name="xmlNode">The xml node containing the data that will be manipulated.</param>
        /// <param name="xsdNode">The corresponding xsdnode of this xmlnode.</param>
        /// <param name="contentpanel">The panel on which this option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        /// <param name="ismdname">Whether this option allows metadata and if so, whether it needs the name or the value of the metadata.</param>
        public AbstractDocUIComponent(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel = null, Panel overlaypanel = null, DynamicForm parentForm = null)
        {
            Log = LogManager.GetCurrentClassLogger();

            Label = new TextBlock() { Margin = new Thickness(5) };
            this.xmlNode = xmlNode;
            this.xsdNode = xsdNode;
            this.Contentpanel = contentpanel;
            this.ParentForm = parentForm;
            this.Overlaypanel = overlaypanel;
            Description = XmlSchemaUtilities.tryGetDocumentation(xsdNode);
            Visible = XmlSchemaUtilities.tryGetUnhandledAttribute(xsdNode, "visible") == "false" ? false : true;
            if (Description == null)
            {
                Description = xmlNode.LocalName;
            }
        }
 internal bool GetBooleanAttribute(XmlSchemaAnnotated element, String attrName, bool defVal) {
     string value = GetMsdataAttribute(element, attrName);
     if (value == null || value.Length == 0) {
         return defVal;
     }
     if ((value == Keywords.TRUE) || (value == Keywords.ONE_DIGIT)){
         return true;
     }
     if ((value == Keywords.FALSE) || (value == Keywords.ZERO_DIGIT)){
         return false;
     }            
     // Error processing:
     throw ExceptionBuilder.InvalidAttributeValue(attrName, value);
 }
 /// <summary>
 /// Gets the documentation associated with the given XML element.
 /// </summary>
 /// <param name="p_xsaAnnotatedElement">The element for which to retrieve the documentations.</param>
 /// <returns>The documentation associated with the given XML element, or <lang cref="null"/>
 /// if there is no documentation in the schema.</returns>
 private string GetDocumentation(XmlSchemaAnnotated p_xsaAnnotatedElement)
 {
     XmlSchemaAnnotation xsaAnnotation = p_xsaAnnotatedElement.Annotation;
     if (xsaAnnotation != null)
     {
         StringBuilder stbDescriptions = new StringBuilder();
         foreach (XmlSchemaObject xmoObject in xsaAnnotation.Items)
         {
             if (xmoObject is XmlSchemaDocumentation)
             {
                 XmlSchemaDocumentation xsdDocumentation = (XmlSchemaDocumentation)xmoObject;
                 foreach (XmlNode xndNode in xsdDocumentation.Markup)
                     stbDescriptions.AppendLine(xndNode.Value);
             }
         }
         return stbDescriptions.ToString();
     }
     return null;
 }
 internal String GetStringAttribute(XmlSchemaAnnotated element, String attrName, String defVal) {
     string value = GetMsdataAttribute(element, attrName);
     if (value == null || value.Length == 0) {
         return defVal;
     }
     return value;
 }