Beispiel #1
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);
             }
         }
     }
 }
		public string GetDefaultHtml()
		{
			var defaultForm = new DynamicForm()
				{
					ActionUrl = _defaultPostUrl,
					IsAjaxForm = true,
					SaveFormToDatabase = true,
					SendEmailOnSubmit = false
				};

			using (var context = new DataContext())
			{
				context.DynamicForms.Add(defaultForm);
				context.SaveChanges();

				// Now we have an id to generat a label off of
				defaultForm.FormLabel = "Custom Form " + defaultForm.DynamicFormId;

				// Use the id for the generated id
				defaultForm.FormHtml = getDefaultFormHtml(defaultForm.DynamicFormId);

				context.SaveChanges();
			}

			return defaultForm.FormHtml;
		}
Beispiel #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();
            }
        }
Beispiel #4
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);
            }
        }
        private void createFeature_Click(object sender, EventArgs e)
        {
            if (elements.Items.Count == 0)
                MessageBox.Show("Must create elements.");
            else
            {
                DynamicForm f = new DynamicForm("Configure feature...", DynamicForm.CloseButtons.OkCancel);
                f.AddTextBox("Feature name:", null, 50, "name");
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string name = f.GetValue<string>("name").Trim();
                    if (name == "")
                        MessageBox.Show("Invalid name:  must not be blank.");
                    else
                    {
                        Shapefile shapefile = null;
                        try
                        {
                            shapefile = Shapefile.Create(name, (elements.Items[0] as Geometry).SRID, Shapefile.ShapefileType.Feature);
                            ShapefileGeometry.Create(shapefile, elements.Items.Cast<Geometry>().Select(g => new Tuple<Geometry, DateTime>(g, DateTime.MinValue)).ToList());
                            MessageBox.Show("Shapefile \"" + name + "\" created.");
                            elements.Items.Clear();
                            points.Items.Clear();
                        }
                        catch (Exception ex)
                        {
                            Console.Out.WriteLine("Failed to create shapefile:  " + ex.Message);

                            try { shapefile.Delete(); }
                            catch (Exception ex2) { Console.Out.WriteLine("Failed to delete failed shapefile:  " + ex2.Message); }
                        }
                    }
                }
            }
        }
Beispiel #6
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();
            }
        }
Beispiel #7
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();
        }
Beispiel #8
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();
        }
Beispiel #9
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();
            }
        }
Beispiel #10
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;
 }
Beispiel #11
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();
        }
Beispiel #12
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();
        }
Beispiel #13
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();
        }
Beispiel #14
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();
        }
Beispiel #15
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();
        }
Beispiel #16
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();
            }
        }
Beispiel #17
0
        public void DynamicGUI_Display(IZeusGuiControl gui, IZeusFunctionExecutioner executioner)
        {
            this.Cursor = Cursors.Default;

            try
            {
                DynamicForm  df     = new DynamicForm(gui as GuiController, executioner);
                DialogResult result = df.ShowDialog(this);

                if (result == DialogResult.Cancel)
                {
                    gui.IsCanceled = true;
                }
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
                //formError.SetControlsFromException();
                //formError.ShowDialog(this);
            }

            Cursor.Current = Cursors.Default;
        }
Beispiel #18
0
        public async Task PopulateFormModelFromDbAsync(DynamicForm formModel, string formSubmissionId, string sectionUrlSlug, CancellationToken cancellationToken = default(CancellationToken))
        {
            FormSectionSubmissionDto sectionSubmission = null;

            if (!string.IsNullOrEmpty(formSubmissionId) && !string.IsNullOrEmpty(sectionUrlSlug))
            {
                var formSubmissionGuid = new Guid(formSubmissionId);
                sectionSubmission = await _dynamicFormsApplicationServices.FormSectionSubmissionApplicationService.GetOneAsync(cancellationToken, fss => fss.FormSubmissionId == formSubmissionGuid && fss.UrlSlug == sectionUrlSlug, true);
            }

            if (sectionSubmission != null)
            {
                var properties = formModel.GetProperties();

                foreach (var propertyName in formModel.GetDynamicMemberNames())
                {
                    var persistedValue = sectionSubmission.QuestionAnswers.Where(qa => qa.FieldName == propertyName).FirstOrDefault();
                    if (persistedValue != null)
                    {
                        bool isCollection = formModel.IsCollectionProperty(propertyName);
                        var  property     = properties.Find(propertyName, true);

                        if (isCollection)
                        {
                            var genericCollectionType = typeof(List <>).MakeGenericType(property.PropertyType.GetGenericArguments()[0]);
                            var newCollection         = Activator.CreateInstance(genericCollectionType);

                            formModel[propertyName] = newCollection;

                            var addMethod = genericCollectionType.GetMethod("Add");

                            foreach (var csvSplit in persistedValue.Answer.Split(','))
                            {
                                var convertedValue = Convert.ChangeType(csvSplit.Trim(), property.PropertyType.GetGenericArguments()[0]);
                                addMethod.Invoke(newCollection, new object[] { convertedValue });
                            }
                        }
                        else if (property.PropertyType == typeof(DateTime))
                        {
                            if (!String.IsNullOrWhiteSpace(persistedValue.Answer))
                            {
                                //ISO 8601
                                var parsedValue = DateTime.Parse(persistedValue.Answer, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
                                formModel[propertyName] = parsedValue;
                            }
                            else
                            {
                                formModel[propertyName] = new DateTime();
                            }
                        }
                        else if (property.PropertyType == typeof(bool))
                        {
                            formModel[propertyName] = BoolParser.GetValue(persistedValue.Answer);
                        }
                        else if (property.PropertyType == typeof(decimal))
                        {
                            var convertedValue = decimal.Parse(persistedValue.Answer, NumberStyles.Currency);
                            formModel[propertyName] = convertedValue;
                        }
                        else
                        {
                            var convertedValue = Convert.ChangeType(persistedValue.Answer, property.PropertyType);
                            formModel[propertyName] = convertedValue;
                        }
                    }
                }
            }
        }
			if (zout != null)
			{
				SimpleOutputForm frm = new SimpleOutputForm();
				frm.OutText = zout.text;
				frm.ShowDialog(this);
Beispiel #20
0
        public DocUISplitPanel(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {

        }
Beispiel #21
0
 private void buttonConfig_Click(object sender, EventArgs e)
 {
     DynamicForm f = new DynamicForm();
     f.Text = ai.Name;
     f.Width = 640;
     f.Height = 480;
     f.Controls.Add(new ModuleConfiguration(ai.Adapter) { Dock = DockStyle.Fill });
     f.Show();
 }
Beispiel #22
0
 public DocUITabbedTop(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
     : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
 {
     this.Sideways = false;
 }
 public FormResourceContext(DynamicForm form, string basePath)
 {
     Form     = form;
     BasePath = basePath;
 }
 public FormResourceContext(DynamicForm form)
     : this(form, null)
 {
 }
        /// <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;
            }
        }
Beispiel #26
0
 public void UpdateWindow(DynamicForm form)
 {
     form.Text = "Title";
     UpdateListView(form.ControlList);
Beispiel #27
0
        public void DynamicGUI_Display(GuiController gui, IScriptExecutioner executioner)
        {
            DynamicForm df = new DynamicForm(gui, executioner);

            df.ShowDialog(this);
        }
 private void setPointDrawingDiameterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DynamicForm f = new DynamicForm("Set point drawing diameter...", DynamicForm.CloseButtons.OkCancel);
     f.AddNumericUpdown("Diameter (pixels):", _pointDrawingDiameter, 0, 1, decimal.MaxValue, 1, "d");
     if (f.ShowDialog() == DialogResult.OK)
     {
         int value = Convert.ToInt32(f.GetValue<decimal>("d"));
         if (value != _pointDrawingDiameter)
         {
             _pointDrawingDiameter = value;
             GetThreatSurfaces(new Rectangle(0, 0, CurrentThreatSurface.Width, CurrentThreatSurface.Height), false);
         }
     }
 }
        private DynamicForm SetupForm()
        {
            //1. Setup Form definition
            DynamicForm model = new DynamicForm();

            model.Add("Text", "David");
            model.Add("Email", "");
            model.Add("Website", "");
            model.Add("PhoneNumber", "");
            model.Add("TextArea", "");
            model.Add("Number", 0);
            model.Add("Slider", 50);

            decimal currency = 0;

            model.Add("Currency", currency);
            model.Add("Date", new DateTime());
            model.Add("DateTime", new DateTime());
            model.Add("Dropdown", "");
            model.Add("DropdownMany", new List <string>());
            model.Add("RadioList", "");
            model.Add("RadioListButtons", "");
            model.Add("CheckboxList", new List <string>());
            model.Add("CheckboxListButtons", new List <string>());
            model.Add("Checkbox", false);
            model.Add("YesButton", false);

            model.Add("YesNo", "");
            model.Add("YesNoButtons", "");

            model.Add("YesNoButtonsBoolean", false);

            model.Add("TrueFalse", "");
            model.Add("TrueFalseButtons", "");
            model.Add("TrueFalseButtonsBoolean", false);

            FormFile formFile = new FormFile(null, 0, 0, "", "");

            model.Add("File", formFile);
            model.Add("MultipleFiles", new List <FormFile>()
            {
            });
            model.Add("MultipleMediaFiles", new List <FormFile>()
            {
            });

            //2. Add Display and Validation
            model.AddAttribute("Text", new DisplayAttribute()
            {
                Name = "What is your Name?"
            });
            model.AddAttribute("Email", new DataTypeAttribute(DataType.EmailAddress));
            model.AddAttribute("Email", new HelpTextAttribute("Your personal email please"));
            model.AddAttribute("PhoneNumber", new DataTypeAttribute(DataType.PhoneNumber));
            model.AddAttribute("Website", new DataTypeAttribute(DataType.Url));
            model.AddAttribute("TextArea", new MultilineTextAttribute(5));

            model.AddAttribute("Number", new NumberValidatorAttribute());

            model.AddAttribute("Slider", new SliderAttribute(0, 100));

            //text-success
            model.Add("SectionHeading", "");
            model.AddAttribute("SectionHeading", new HeadingAttributeH3("text-danger"));

            //  model.AddAttribute("Dropdown", new DropdownAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));
            // model.AddAttribute("DropdownMany", new DropdownAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));

            // model.AddAttribute("RadioList", new CheckboxOrRadioAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));
            model.AddAttribute("RadioListButtons", new CheckboxOrRadioButtonsAttribute(new List <string>()
            {
                "Option 1", "Option 2", "Option 3", "Option 4"
            }));

            //  model.AddAttribute("CheckboxList", new CheckboxOrRadioAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));
            //wrapper.AddAttribute("CheckboxList", new CheckboxOrRadioInlineAttribute());
            model.AddAttribute("CheckboxList", new LimitCountAttribute(3, 5));

            model.AddAttribute("CheckboxListButtons", new CheckboxOrRadioButtonsAttribute(new List <string>()
            {
                "Option 1", "Option 2", "Option 3", "Option 4"
            }));

            model.AddAttribute("Currency", new DataTypeAttribute(DataType.Currency));

            model.AddAttribute("Date", new DataTypeAttribute(DataType.Date));
            model.AddAttribute("Date", new AgeValidatorAttribute(18));

            model.AddAttribute("DateTime", new DataTypeAttribute(DataType.DateTime));

            model.AddAttribute("YesButton", new BooleanYesButtonAttribute());

            model.AddAttribute("YesNo", new YesNoCheckboxOrRadioAttribute());
            model.AddAttribute("YesNo", new CheckboxOrRadioInlineAttribute());

            model.AddAttribute("YesNoButtons", new YesNoCheckboxOrRadioButtonsAttribute());

            model.AddAttribute("YesNoButtonsBoolean", new BooleanYesNoButtonsAttribute());

            model.AddAttribute("TrueFalse", new TrueFalseCheckboxOrRadioAttribute());
            model.AddAttribute("TrueFalse", new CheckboxOrRadioInlineAttribute());

            model.AddAttribute("TrueFalseButtons", new TrueFalseCheckboxOrRadioButtonsAttribute());

            model.AddAttribute("TrueFalseButtonsBoolean", new BooleanTrueFalseButtonsAttribute());

            model.AddAttribute("MultipleMediaFiles", new FileImageAudioVideoAcceptAttribute());

            model.Add("Submit", "");
            model.AddAttribute("Submit", new NoLabelAttribute());
            model.AddAttribute("Submit", new SubmitButtonAttribute("btn btn-block btn-success"));

            return(model);
        }
Beispiel #30
0
        public async Task SaveFormModelToDbAsync(DynamicForm formModel, string formSubmissionId, string formUrlSlug, string sectionUrlSlug, bool isValid, CancellationToken cancellationToken = default(CancellationToken))
        {
            var formDisplayValues = GetFormDisplayValues(formModel);

            var formSubmissionGuid       = new Guid(formSubmissionId);
            FormSubmissionDto submission = await _dynamicFormsApplicationServices.FormSubmissionApplicationService.GetByIdAsync(formSubmissionGuid, cancellationToken);

            bool newSubmission = true;

            if (submission != null)
            {
                newSubmission = false;
            }

            FormSectionSubmissionDto sectionSubmission = null;

            if (!string.IsNullOrEmpty(formSubmissionId) && !string.IsNullOrEmpty(sectionUrlSlug))
            {
                sectionSubmission = await _dynamicFormsApplicationServices.FormSectionSubmissionApplicationService.GetOneAsync(cancellationToken, fss => fss.FormSubmissionId == formSubmissionGuid && fss.UrlSlug == sectionUrlSlug, true);
            }

            bool newSectionSubmission = false;

            if (sectionSubmission == null)
            {
                newSectionSubmission = true;
                sectionSubmission    = new FormSectionSubmissionDto()
                {
                    FormSubmissionId = formSubmissionGuid, UrlSlug = sectionUrlSlug
                };
            }

            sectionSubmission.Valid = isValid;

            var form = await GetFormByUrlSlugAsync(formUrlSlug, cancellationToken);

            var section = await GetSectionByUrlSlugsAsync(formUrlSlug, sectionUrlSlug);

            foreach (var sectionQuestion in section.Questions)
            {
                var question = sectionQuestion.Question;

                var answer = "";
                if (formDisplayValues.ContainsKey(question.FieldName))
                {
                    answer = formDisplayValues[question.FieldName];
                }

                var questionAnswer = sectionSubmission.QuestionAnswers.FirstOrDefault(qa => qa.FieldName == question.FieldName);
                if (questionAnswer == null)
                {
                    questionAnswer = new FormSectionSubmissionQuestionAnswerDto()
                    {
                        FieldName = question.FieldName, FormSectionSubmissionId = sectionSubmission.Id
                    };
                    sectionSubmission.QuestionAnswers.Add(questionAnswer);
                }

                questionAnswer.Question = question.QuestionText;
                questionAnswer.Answer   = answer;
            }

            if (newSubmission)
            {
                var newFormSubmission = new FormSubmissionDto()
                {
                    Id = formSubmissionGuid, FormId = form.Id
                };
                newFormSubmission.Sections.Add(sectionSubmission);
                await _dynamicFormsApplicationServices.FormSubmissionApplicationService.CreateAsync(newFormSubmission, "", cancellationToken);
            }
            else
            {
                if (newSectionSubmission)
                {
                    await _dynamicFormsApplicationServices.FormSectionSubmissionApplicationService.CreateAsync(sectionSubmission, "", cancellationToken);
                }
                else
                {
                    await _dynamicFormsApplicationServices.FormSectionSubmissionApplicationService.UpdateGraphAsync(sectionSubmission.Id, sectionSubmission, "", cancellationToken);
                }
            }
        }
Beispiel #31
0
        private void AddQuestionToForm(DynamicForm formModel, QuestionDto question)
        {
            IEnumerable <string> options;

            var questionFieldName = question.FieldName;

            switch (question.QuestionType)
            {
            case QuestionType.Text:
                formModel.Add(questionFieldName, string.Empty);
                break;

            case QuestionType.TextArea:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new MultilineTextAttribute(5));
                break;

            case QuestionType.Number:
                formModel.Add(questionFieldName, default(int));
                break;

            case QuestionType.Slider:
                formModel.Add(questionFieldName, default(int));
                formModel.AddAttribute(questionFieldName, new SliderAttribute());
                break;

            case QuestionType.Currency:
                formModel.Add(questionFieldName, default(decimal));
                formModel.AddAttribute(questionFieldName, new DataTypeAttribute(DataType.Currency));
                break;

            case QuestionType.Date:
                formModel.Add(questionFieldName, default(DateTime));
                formModel.AddAttribute(questionFieldName, new DataTypeAttribute(DataType.Date));
                break;

            case QuestionType.DateTime:
                formModel.Add(questionFieldName, default(DateTime));
                formModel.AddAttribute(questionFieldName, new DataTypeAttribute(DataType.DateTime));
                break;

            case QuestionType.PhoneNumber:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new DataTypeAttribute(DataType.PhoneNumber));
                break;

            case QuestionType.Email:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new DataTypeAttribute(DataType.EmailAddress));
                break;

            case QuestionType.Website:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new DataTypeAttribute(DataType.Url));
                break;

            case QuestionType.Checkbox:
                formModel.Add(questionFieldName, false);
                question.DefaultAnswer = BoolParser.IsTrue(question.DefaultAnswer) ? "true" : "";
                break;

            case QuestionType.YesButton:
                formModel.Add(questionFieldName, false);
                formModel.AddAttribute(questionFieldName, new BooleanYesButtonAttribute());
                question.DefaultAnswer = BoolParser.IsTrue(question.DefaultAnswer) ? "true" : "";
                break;

            case QuestionType.Dropdown:
                formModel.Add(questionFieldName, string.Empty);
                options = question.LookupTable != null?question.LookupTable.LookupTableItems.Select(lti => lti.Text) : new List <string>();

                formModel.AddAttribute(questionFieldName, new DropdownAttribute(options));
                break;

            case QuestionType.DropdownMany:
                formModel.Add(questionFieldName, new List <string>());
                options = question.LookupTable != null?question.LookupTable.LookupTableItems.Select(lti => lti.Text) : new List <string>();

                formModel.AddAttribute(questionFieldName, new DropdownAttribute(options));
                break;

            case QuestionType.RadioListTrueFalse:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new TrueFalseCheckboxOrRadioAttribute());
                break;

            case QuestionType.RadioListYesNo:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new YesNoCheckboxOrRadioAttribute());
                break;

            case QuestionType.RadioList:
                formModel.Add(questionFieldName, string.Empty);
                options = question.LookupTable != null?question.LookupTable.LookupTableItems.Select(lti => lti.Text) : new List <string>();

                formModel.AddAttribute(questionFieldName, new CheckboxOrRadioAttribute(options));
                break;

            case QuestionType.RadioListButtons:
                formModel.Add(questionFieldName, string.Empty);
                options = question.LookupTable != null?question.LookupTable.LookupTableItems.Select(lti => lti.Text) : new List <string>();

                formModel.AddAttribute(questionFieldName, new CheckboxOrRadioButtonsAttribute(options));
                break;

            case QuestionType.RadioListButtonsYesNo:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new YesNoCheckboxOrRadioButtonsAttribute());
                break;

            case QuestionType.RadioListButtonsTrueFalse:
                formModel.Add(questionFieldName, string.Empty);
                formModel.AddAttribute(questionFieldName, new TrueFalseCheckboxOrRadioButtonsAttribute());
                break;

            case QuestionType.CheckboxList:
                formModel.Add(questionFieldName, new List <string>());
                options = question.LookupTable != null?question.LookupTable.LookupTableItems.Select(lti => lti.Text) : new List <string>();

                formModel.AddAttribute(questionFieldName, new CheckboxOrRadioAttribute(options));
                break;

            case QuestionType.CheckboxListButtons:
                formModel.Add(questionFieldName, new List <string>());
                options = question.LookupTable != null?question.LookupTable.LookupTableItems.Select(lti => lti.Text) : new List <string>();

                formModel.AddAttribute(questionFieldName, new CheckboxOrRadioButtonsAttribute(options));
                break;

            case QuestionType.File:
                formModel.Add(questionFieldName, new FormFile(null, 0, 0, "", ""));
                break;

            case QuestionType.FileImage:
                formModel.Add(questionFieldName, new FormFile(null, 0, 0, "", ""));
                formModel.AddAttribute(questionFieldName, new FileImageAcceptAttribute());
                break;

            case QuestionType.FileVideo:
                formModel.Add(questionFieldName, new FormFile(null, 0, 0, "", ""));
                formModel.AddAttribute(questionFieldName, new FileVideoAcceptAttribute());
                break;

            case QuestionType.FileAudio:
                formModel.Add(questionFieldName, new FormFile(null, 0, 0, "", ""));
                formModel.AddAttribute(questionFieldName, new FileAudioAcceptAttribute());
                break;

            case QuestionType.FileImageVideo:
                formModel.Add(questionFieldName, new FormFile(null, 0, 0, "", ""));
                formModel.AddAttribute(questionFieldName, new FileImageVideoAcceptAttribute());
                break;

            case QuestionType.MultipleFiles:
                formModel.Add(questionFieldName, new List <FormFile>());
                break;

            case QuestionType.MultipleFilesImage:
                formModel.Add(questionFieldName, new List <FormFile>());
                formModel.AddAttribute(questionFieldName, new FileImageAcceptAttribute());
                break;

            case QuestionType.MultipleFilesVideo:
                formModel.Add(questionFieldName, new List <FormFile>());
                formModel.AddAttribute(questionFieldName, new FileVideoAcceptAttribute());
                break;

            case QuestionType.MultipleFilesAudio:
                formModel.Add(questionFieldName, new List <FormFile>());
                formModel.AddAttribute(questionFieldName, new FileAudioAcceptAttribute());
                break;

            case QuestionType.MultipleFilesImageVideo:
                formModel.Add(questionFieldName, new List <FormFile>());
                formModel.AddAttribute(questionFieldName, new FileImageVideoAcceptAttribute());
                break;

            default:
                throw new Exception("QuestionType not Mapped");
            }

            //Add Default Values
            if (!string.IsNullOrEmpty(question.DefaultAnswer))
            {
                foreach (var defaultValue in question.DefaultAnswer.Split(','))
                {
                    formModel[questionFieldName] = defaultValue;
                }
            }

            //Add Question Text
            //Add Placeholder
            formModel.AddAttribute(questionFieldName, new DisplayAttribute()
            {
                Name = question.QuestionText, Prompt = question.Placeholder
            });

            //Add Help Text
            if (!string.IsNullOrEmpty(question.HelpText))
            {
                formModel.AddAttribute(questionFieldName, new HelpTextAttribute(question.HelpText));
            }

            //Add Validation
            foreach (var questionValidation in question.Validations)
            {
                switch (questionValidation.ValidationType)
                {
                case QuestionValidationType.Required:
                    var validation = new RequiredAttribute();

                    if (!string.IsNullOrWhiteSpace(questionValidation.CustomValidationMessage))
                    {
                        validation.ErrorMessage = questionValidation.CustomValidationMessage;
                    }
                    formModel.AddAttribute(questionFieldName, validation);
                    break;

                default:
                    throw new Exception("ValidationType not Mapped");
                }
            }

            //Add Conditional Questions
            //foreach (var questionQuestion in question.Questions)
            //{
            //    var logicQuestion = questionQuestion.LogicQuestion;
            //    await AddQuestionToFormAsync(formModel, logicQuestion, cancellationToken);
            //}
        }
Beispiel #32
0
 public MvcField(DynamicForm dynamicForm, DynamicFormField field)
 {
     _dynamicForm = dynamicForm;
     _field       = field;
 }
        private DynamicForm SetupForm(bool summary)
        {
            string containerDiv = "#dynamicForm";

            //1. Setup Form definition
            dynamic model = new DynamicForm();

            model.Add("Text", "");
            model.Add("Email", "");
            model.Add("Website", "");
            model.Add("PhoneNumber", "");
            model.Add("TextArea", "");
            model.Add("Number", 0);
            model.Add("Slider", 50);

            if (summary)
            {
                model.Add("IconButton", "");
            }

            var section2Link = Html.ActionLink("Section 2", "Edit", "DynamicForms", new { sectionId = "section2", formId = "insurance" }, new { @class = "text-danger", data_ajax = "true", data_ajax_method = "GET", data_ajax_mode = "replace", data_ajax_update = containerDiv }).Render();

            model.Add("SectionHeading", section2Link);

            decimal currency = 0;

            model.Add("Currency", currency);
            model.Add("Date", new DateTime());
            model.Add("DateTime", new DateTime());
            model.Add("Dropdown", "");
            model.Add("DropdownMany", new List <string>());
            model.Add("RadioList", "");
            model.Add("RadioListButtons", "");
            model.Add("CheckboxList", new List <string>());
            model.Add("CheckboxListButtons", new List <string>());
            model.Add("Checkbox", false);
            model.Add("YesButton", false);

            model.Add("YesNo", "");
            model.Add("YesNoButtons", "");



            model.Add("YesNoButtonsBoolean", false);

            model.Add("TrueFalse", "");
            model.Add("TrueFalseButtons", "");
            model.Add("TrueFalseButtonsBoolean", false);

            FormFile formFile = new FormFile(null, 0, 0, "", "");

            model.Add("File", formFile);
            model.Add("MultipleFiles", new List <FormFile>()
            {
            });
            model.Add("MultipleMediaFiles", new List <FormFile>()
            {
            });

            if (summary)
            {
                model.Add("Submit", "Submit");
            }
            else
            {
                model.Add("Submit", "Continue");
            }

            //2. Add Display and Validation
            model.AddAttribute("Text", new DisplayAttribute()
            {
                Name = "What is your Name?"
            });
            model.AddAttribute("Email", new DataTypeAttribute(DataType.EmailAddress));
            model.AddAttribute("Email", new HelpTextAttribute("Your personal email please"));
            model.AddAttribute("PhoneNumber", new DataTypeAttribute(DataType.PhoneNumber));
            model.AddAttribute("Website", new DataTypeAttribute(DataType.Url));
            model.AddAttribute("TextArea", new MultilineTextAttribute(5));

            model.AddAttribute("Number", new NumberValidatorAttribute());

            model.AddAttribute("Slider", new SliderAttribute(0, 100));

            if (summary)
            {
                model.AddAttribute("IconButton", new OffsetRightAttribute(1));
                model.AddAttribute("IconButton", new EditLinkAttribute("Edit", "DynamicForms", containerDiv));
                model.AddAttribute("IconButton", new LinkRouteValueAttribute("formId", "insurance"));
                model.AddAttribute("IconButton", new LinkRouteValueAttribute("sectionId", "section2"));
            }
            //text-success
            model.AddAttribute("SectionHeading", new HeadingAttributeH3("text-danger"));

            model.AddAttribute("Dropdown", new DropdownAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));
            model.AddAttribute("DropdownMany", new DropdownAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));

            model.AddAttribute("RadioList", new CheckboxOrRadioAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));
            model.AddAttribute("RadioListButtons", new CheckboxOrRadioButtonsAttribute(new List <string>()
            {
                "Option 1", "Option 2", "Option 3", "Option 4"
            }));

            model.AddAttribute("CheckboxList", new CheckboxOrRadioAttribute(Type.GetType("DND.Domain.Blog.Tags.Tag, DND.Domain.Blog"), "Name", "Name"));
            //wrapper.AddAttribute("CheckboxList", new CheckboxOrRadioInlineAttribute());
            model.AddAttribute("CheckboxList", new LimitCountAttribute(3, 5));

            model.AddAttribute("CheckboxListButtons", new CheckboxOrRadioButtonsAttribute(new List <string>()
            {
                "Option 1", "Option 2", "Option 3", "Option 4"
            }));

            model.AddAttribute("Currency", new DataTypeAttribute(DataType.Currency));

            model.AddAttribute("Date", new DataTypeAttribute(DataType.Date));
            model.AddAttribute("Date", new AgeValidatorAttribute(18));

            model.AddAttribute("DateTime", new DataTypeAttribute(DataType.DateTime));

            model.AddAttribute("YesButton", new BooleanYesButtonAttribute());

            model.AddAttribute("YesNo", new YesNoCheckboxOrRadioAttribute());
            model.AddAttribute("YesNo", new CheckboxOrRadioInlineAttribute());

            model.AddAttribute("YesNoButtons", new YesNoCheckboxOrRadioButtonsAttribute());

            model.AddAttribute("YesNoButtonsBoolean", new BooleanYesNoButtonsAttribute());

            model.AddAttribute("TrueFalse", new TrueFalseCheckboxOrRadioAttribute());
            model.AddAttribute("TrueFalse", new CheckboxOrRadioInlineAttribute());

            model.AddAttribute("TrueFalseButtons", new TrueFalseCheckboxOrRadioButtonsAttribute());

            model.AddAttribute("TrueFalseButtonsBoolean", new BooleanTrueFalseButtonsAttribute());

            model.AddAttribute("MultipleMediaFiles", new FileImageAudioVideoAcceptAttribute());

            model.AddAttribute("Submit", new NoLabelAttribute());
            model.AddAttribute("Submit", new SubmitButtonAttribute("btn btn-block btn-success"));

            return(model);
        }
 /// <summary>
 /// Builds the module Help window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonHelp_Click(object sender, EventArgs e)
 {
     try
     {
         DynamicForm f = new DynamicForm();
         f.Size = new System.Drawing.Size(640, 480);
         f.Text = "Help";
         Help uc = new Help(checkedListBoxModules.SelectedItem);
         uc.Dock = DockStyle.Fill;
         f.Controls.Add(uc);
         f.Show();
         f.ThemeChanged();
     }
     catch (Exception ne)
     {
         LogCenter.Instance.LogException(ne);
     }
 }
 private void buttonOpenConfiguration_Click(object sender, EventArgs e)
 {
     try
     {
         DynamicUserControl uc = na.Modules.GetModule(checkedListBoxModules.SelectedIndex).GetUserInterface();
         if (uc != null)
         {
             DynamicForm f = new DynamicForm();
             f.Size = new System.Drawing.Size(640, 480);
             f.Text = na.GetAdapterInformation().Name + ": " + na.Modules.GetModule(checkedListBoxModules.SelectedIndex).MetaData.GetMeta().Name + " - " + na.Modules.GetModule(checkedListBoxModules.SelectedIndex).MetaData.GetMeta().Version;
             f.Controls.Add(uc);
             f.Show();
             f.ThemeChanged();
         }
     }
     catch (Exception ne)
     {
         LogCenter.Instance.LogException(ne);
     }
 }
Beispiel #36
0
        /// <summary>
        /// Creates a new instance of a comboSelector.
        /// </summary>
        /// <param name="xmlNode">The xmlNode that contains the data of the comboSelector</param>
        /// <param name="xsdNode">The corresponding xsdNode</param>
        /// <param name="contentpanel">the panel on which the option should be placed.</param>
        /// <param name="overlaypanel"></param>
        /// <param name="parentForm"></param>
        public DocUIComboSubSection(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();
                _cb.Margin = new Thickness(5);

                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null && schemaEl.ElementSchemaType is XmlSchemaComplexType)
                {
                    XmlSchemaAttribute att = XmlSchemaUtilities.tryGetAttribute(schemaEl.ElementSchemaType as XmlSchemaComplexType, "selected");
                    if (att != null)
                    {
                        IEnumerable<XmlSchemaEnumerationFacet> enumFacets = XmlSchemaUtilities.tryGetEnumRestrictions(att.AttributeSchemaType);

                        if (enumFacets != null)
                        {
                            foreach (var facet in enumFacets)
                            {
                                // fill the combobox
                                _cb.Items.Add(facet.Value);
                            }
                        }

                        int i = 0;
                        foreach (XmlSchemaElement el in seq.Items)
                        {
                            DocUISubSection comp = new DocUISubSection(xmlNode.SelectSingleNode(el.Name), el, contentpanel, overlaypanel, parentForm);
                            object e = _cb.Items[i++];
                            string s = e.ToString();
                            _subsections.Add(s, comp);
                        }
                        if (_cb.Items.Count > 0)
                        {
                            _cb.SelectionChanged += combo_Selectionchanged;
                            _cb.SelectionChanged += (s, e) => { hasPendingChanges(); };
                        }

                        DockPanel dock = new DockPanel();

                        DockPanel.SetDock(_cb, Dock.Top);
                        dock.Children.Add(_cb);


                        _currentSubsection = new StackPanel();
                        dock.Children.Add(_currentSubsection);

                        Control = dock;


                        if (Label.Text != "")
                        {
                            GroupBox gb = new GroupBox();
                            gb.Header = Label.Text;
                            gb.Content = dock;
                            gb.Margin = new Thickness(5);
                            this.Control = gb;
                        }

                        setup();
                    }
                    else
                    {
                        Log.Info("this comboselector does not contain any options.");
                    }
                }
                else
                {
                    Log.Info("the xsdnode does not have the right structure for a combosubsection.");
                }
            }
        }
Beispiel #37
0
 private void listBox1_DoubleClick(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         LogEvent le = (LogEvent)listBox1.SelectedItem;
         if (le.Module != null)
         {
             if (le.Module.GetUserInterface() != null)
             {
                 try
                 {
                     DynamicUserControl uc = le.Module.GetUserInterface();
                     if (uc != null)
                     {
                         DynamicForm f = new DynamicForm();
                         f.Size = new System.Drawing.Size(640, 480);
                         f.Text = le.Module.Adapter.GetAdapterInformation().Name + " - " + le.Module.MetaData.GetMeta().Name + " " + le.Module.MetaData.GetMeta().Version;
                         f.Controls.Add(uc);
                         f.Show();
                         f.ThemeChanged();
                     }
                 }
                 catch (Exception ne)
                 {
                     LogCenter.Instance.LogException(ne);
                 }
             }
         }
     }
 }
Beispiel #38
0
        public DocUIDataGrid(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                _dgrid = new MyDataGrid() { Margin = new Thickness(5), CanUserReorderColumns = false };
                _dgrid.CellEditEnding += (s, e) => { hasPendingChanges(); };
                _dgrid.SelectionUnit = DataGridSelectionUnit.Cell;

                this.xmlNode = xmlNode;
                XmlSchemaSequence seq1 = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);

                XmlDataProvider provider = new XmlDataProvider();
                provider.Document = xmlNode.OwnerDocument;

                Binding myNewBindDef = new Binding();
                myNewBindDef.Source = provider;
                myNewBindDef.XPath = "//" + xmlNode.Name + "/*";
                _dgrid.SetBinding(DataGrid.ItemsSourceProperty, myNewBindDef);
                _dgrid.AutoGenerateColumns = false;
                if (seq1 != null && seq1.Items.Count > 0)
                {
                    _el = seq1.Items[0] as XmlSchemaElement;
                    XmlSchemaSequence seq2 = XmlSchemaUtilities.tryGetSequence((seq1.Items[0] as XmlSchemaElement).ElementSchemaType);
                    if (seq2 != null)
                    {
                        foreach (XmlSchemaElement child in seq2.Items)
                        {
                            XmlSchemaType type = child.ElementSchemaType;
                            string result1;
                            GetColumn result2;
                            DataGridColumn col;
                            if (DynamicForm.Components.TryGetValue(type.QualifiedName.Name, out result1)
                                && ColDict.TryGetValue(result1, out result2))
                            {

                                var b = new Binding
                                   {
                                       XPath = child.Name
                                   };
                                col = result2(b);

                                if (result1 == "combobox")
                                {
                                    DataGridTemplateColumn col2 = col as DataGridTemplateColumn;
                                    FrameworkElementFactory fact = col2.CellTemplate.VisualTree;
                                    List<string> list = new List<string>();
                                    IEnumerable<XmlSchemaEnumerationFacet> enumFacets = XmlSchemaUtilities.tryGetEnumRestrictions(child.ElementSchemaType);
                                    foreach (var facet in enumFacets)
                                    {
                                        list.Add(facet.Value);
                                    }
                                    fact.SetValue(ComboBox.ItemsSourceProperty, list);
                                    string widthstr = XmlSchemaUtilities.tryGetUnhandledAttribute(child, "width");
                                    int width = 0;
                                    if (widthstr != "")
                                        width = Int32.Parse(widthstr);
                                    else
                                        width = 50;
                                    col2.Width = width;
                                }
                            }
                            else
                            {
                                col = new DataGridTextColumn();
                                DataGridTextColumn textcol = col as DataGridTextColumn;
                                var b = new Binding
                                {
                                    XPath = child.Name
                                };
                                textcol.Binding = b;
                                textcol.Width = new DataGridLength(1, DataGridLengthUnitType.Star);

                            }
                            col.Header = child.Name;
                            _dgrid.Columns.Add(col);
                        }

                        DataTemplate dt = new DataTemplate();

                        FrameworkElementFactory templatebutton = new FrameworkElementFactory(typeof(Button));
                        FrameworkElementFactory img = new FrameworkElementFactory(typeof(Image));


                        Binding bind = new Binding
                        {
                            XPath = ".",
                            Mode = BindingMode.TwoWay
                        };

                        BitmapImage bi3 = EmbeddedResourceTools.GetImage("Com.Xploreplus.DocUI.Resources.Images.component.delete.png");

                        img.SetValue(Image.SourceProperty, bi3);

                        templatebutton.AddHandler(Button.ClickEvent, new RoutedEventHandler(click_Delete));
                        templatebutton.AppendChild(img);
                        templatebutton.SetBinding(Button.TagProperty, bind);
                        dt.VisualTree = templatebutton;

                        DataGridTemplateColumn buttoncol = new DataGridTemplateColumn();
                        buttoncol.CanUserResize = false;
                        buttoncol.CellTemplate = dt;
                        _dgrid.Columns.Add(buttoncol);
                        _dgrid.RowHeight = 25;
                        _dgrid.CanUserResizeRows = false;

                        _dgrid.GotFocus += gotFocus;
                        _dgrid.PreparingCellForEdit += checkEmptyRow;

                        _dgrid.PreparingCellForEdit += (s, e) => { this._isEditing = true; };
                        _dgrid.CellEditEnding += (s, e) => { this._isEditing = false; };
                    }
                }
            }
        }
 public DocUIVerticalSplitPanel(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
     : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
 {
     this.Horizontal = false;
 }