public ActionResult CreateFormGroup(FormGroupModel formGroupModel)
        {
            // Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path
            string accountId   = RequestItemsService.Session.AccountId;                     // Represents your {ACCOUNT_ID}

            try
            {
                // Call the Rooms API to create form group
                FormGroup formGroup = CreateFormGroups.CreateGroup(basePath, accessToken, accountId, formGroupModel.Name);

                ViewBag.h1          = "The form group was successfully created";
                ViewBag.message     = $"The form group was successfully created, FormGroupId: '{formGroup.FormGroupId}'";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(formGroup, Formatting.Indented);

                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
        private async Task ViewStart(int delay = 350)
        {
            FormGroup.Opacity = 0;
            await Task.Delay(delay);

            await FormGroup.FadeTo(1, 850, Easing.CubicIn);
        }
Example #3
0
 public virtual void Visit(FormGroup formGroup)
 {
     foreach (var c in formGroup.Contents.Where(c => !c.IsHidden))
     {
         Visit(c);
     }
 }
        private void AddElementConfigurationRows(FormGroup group, FormElementViewModel formElement)
        {
            switch (formElement)
            {
            case ButtonElementViewModel buttonElement:
                AddButtonConfigurationRows(group, buttonElement);
                break;

            case HtmlElementViewModel htmlElement:
                AddHtmlConfigurationRows(group, htmlElement);
                break;

            case CheckBoxFieldViewModel checkBox:
                AddCheckBoxConfigurationRows(group, checkBox);
                break;

            case TextFieldViewModel textField:
                AddTextConfigurationRows(group, textField);
                break;

            case ComboBoxFieldViewModel comboBox:
                AddComboBoxConfigurationRows(group, comboBox);
                break;
            }
        }
        public static FormGroup <MvcBootstrapHelper <TModel> > FormGroup <TModel, TValue>(this IFormGroupCreator <MvcBootstrapHelper <TModel> > creator, Expression <Func <TModel, TValue> > labelExpression)
        {
            FormGroup <MvcBootstrapHelper <TModel> > formGroup = new FormGroup <MvcBootstrapHelper <TModel> >(creator);

            formGroup.ControlLabel = formGroup.GetWrapper().ControlLabel(labelExpression);
            return(formGroup);
        }
        private void AddCheckBoxConfigurationRows(FormGroup group, CheckBoxFieldViewModel element)
        {
            var textField = new TextField("defaultItem", LabelPosition.AboveElement, "Default Item",
                                          new ValidationRule <TextField>[]
            {
            }, element.Content);

            var checkedField = new CheckBoxField("checkbox", LabelPosition.AboveElement, "Default Value",
                                                 new ValidationRule <CheckBoxField>[]
            {
            }, element.Content, element.DefaultIsChecked);

            textField.OnFormEvent += (s, e) =>
            {
                if (e is TextFieldChangedEventArgs eventArgs)
                {
                    element.Content = eventArgs.NewContent;
                }
            };

            checkedField.OnFormEvent += (s, e) =>
            {
                if (e is CheckBoxFieldChangedEventArgs eventArgs)
                {
                    element.DefaultIsChecked = eventArgs.NewValue;
                }
            };

            group.Rows.Add(new FormRow(1, new[]
            {
                new FormColumn(1, textField),
                new FormColumn(1, checkedField)
            }));
        }
Example #7
0
 public virtual void Visit(FormGroup formGroup)
 {
     foreach (var i in formGroup.Contents)
     {
         Visit(i);
     }
 }
        private void AddComboBoxConfigurationRows(FormGroup group, ComboBoxFieldViewModel element)
        {
            var optionsField = new TextField("options", LabelPosition.AboveElement, "Options",
                                             new ValidationRule <TextField>[]
            {
            }, string.Join(",", element.Items));

            optionsField.OnFormEvent += (s, e) =>
            {
                if (e is TextFieldChangedEventArgs eventArgs)
                {
                    element.Items.Clear();
                    element.Items.AddRange(eventArgs.NewContent.Split(',').ToList());
                }
            };

            var textField = new TextField("defaultItem", LabelPosition.AboveElement, "Default Item",
                                          new ValidationRule <TextField>[]
            {
            }, element.DefaultSelectedItem);

            textField.OnFormEvent += (s, e) =>
            {
                if (e is TextFieldChangedEventArgs eventArgs)
                {
                    element.DefaultSelectedItem = eventArgs.NewContent;
                }
            };

            group.Rows.Add(new FormRow(1, new[]
            {
                new FormColumn(1, optionsField),
                new FormColumn(1, textField)
            }));
        }
Example #9
0
        protected void OpenGroup(string name)
        {
            FormGroup formGroup = new FormGroup(name);

            if (formGroups.Count == 0)
            {
                this.formGroup = formGroup;

                this.formGroup.RequiredMessage = "!";

                this.formGroup.RequiredMark          = "*";
                this.formGroup.RequiredInLabel       = true;
                this.formGroup.RequiredInPlaceholder = false;

                this.formGroup.OptionalMark          = "...";
                this.formGroup.OptionalInLabel       = false;
                this.formGroup.OptionalInPlaceholder = false;

                this.formGroup.OrderElements = OrderElements.InputLabelMark;
            }
            else
            {
                formGroups.Peek().Add(formGroup);
            }

            formGroups.Push(formGroup);
        }
Example #10
0
 public FormModel()
 {
     formGroup  = null;
     formGroups = new Stack <FormGroup>();
     rules      = new List <FormRule>();
     submitted  = true;
 }
Example #11
0
        //修改组
        private void ModifyGroup(object sender, RoutedEventArgs e)
        {
            SHHOPCGroup node = tree.SelectedItem as SHHOPCGroup;
            FormGroup   form = new FormGroup();

            //载入参数
            form.tbx_Name.Text              = node.Name;
            form.tbx_UpdateRate.Text        = node.UpdateRate.ToString();
            form.tbx_DeadBend.Text          = node.DeadBend.ToString();
            form.tbx_TimeBias.Text          = node.TimeBias.ToString();
            form.cbx_IsActive.IsChecked     = node.IsActive;
            form.cbx_IsSubscribed.IsChecked = node.IsSubscribed;

            form.Owner = this;
            if ((bool)form.ShowDialog())
            {
                //确定修改
                node.Name         = form.Name;
                node.UpdateRate   = form.UpdateRate;
                node.DeadBend     = form.DeadBend;
                node.TimeBias     = form.TimeBias;
                node.IsActive     = form.IsActive;
                node.IsSubscribed = form.IsSubscribed;


                OPCManager.ModifyGroup(node);
            }
        }
 public FormGroupViewModel(FormGroup group)
 {
     Rows  = new ObservableCollection <FormRowViewModel>();
     Group = group;
     LoadRows();
     Label = group.Label;
 }
Example #13
0
        public FormUpdateVisitor(FormGroup formGroup, NameValueCollection values, FormItem source, string argument)
        {
            this.values   = values;
            this.source   = source;
            this.argument = argument;

            Visit(formGroup);
        }
 public TextBox(FormGroup formGroup, string id, string value) : base("input", null, true)
 {
     _id             = id;
     Attrs["type"]   = "text";
     Attrs["id"]     = id;
     Attrs["value"]  = value;
     Attrs["class"] += "form-control";
 }
 private async Task ViewDone()
 {
     await Task.WhenAll(
         _topGroupBehaviour.SwitchStateToSuccess(),
         FormGroup.FadeTo(0, 400, Easing.SinIn),
         FormGroup.TranslateTo(0, 1000, 600, Easing.SinIn)
         );
 }
        public FormIconVisitor(FormGroup formGroup, HtmlContainer htmlContainer, bool prepend)
        {
            this.prepend = prepend;

            if (!formGroup.IsHidden)
            {
                Visit(formGroup, htmlContainer);
            }
        }
Example #17
0
 public TextBox(FormGroup formGroup, string id, string value)
     : base("input", null, true)
 {
     _id = id;
     Attrs["type"] = "text";
     Attrs["id"] = id;
     Attrs["value"] = value;
     Attrs["class"] += "form-control";
 }
Example #18
0
        public ActionResult Edit(int Id)
        {
            List <string> UsersId          = new List <string>();
            string        NotificationTime = string.Empty;
            string        UserId           = User.Identity.GetUserId();
            string        Message          = string.Empty;

            Notification notification = null;

            FormGroup formGroup = db.FormGroups.Find(Id);

            if (formGroup == null)
            {
                return(RedirectToAction("HttpNotFoundError", "ErrorController"));
            }

            int Form_Id = formGroup.FormId;

            formGroup.Updatedat = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss");
            if (formGroup.Is_Active == true)
            {
                formGroup.Is_Active = false;
                Message             = "تم الغاء تفعيل النموذج في المجموعة :" + db.Groups.Find(formGroup.GroupId).Name;
            }
            else
            {
                formGroup.Is_Active = true;
                Message             = "تم  تفعيل النموذج في المجموعة :" + db.Groups.Find(formGroup.GroupId).Name;
            }

            formGroup.UpdatedById     = this.User.Identity.GetUserId();
            db.Entry(formGroup).State = EntityState.Modified;
            db.SaveChanges();

            NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss");


            List <ApplicationUser> Users = db.UsersGroups.Where(a => a.GroupId == formGroup.GroupId).Include(a => a.User).Select(a => a.User).ToList();

            foreach (ApplicationUser user in Users)
            {
                notification = new Notification()
                {
                    CreatedAt           = NotificationTime,
                    Active              = false,
                    UserId              = user.Id,
                    Message             = Message + "، النموذج :" + db.Forms.Find(Form_Id).Name,
                    NotificationOwnerId = UserId
                };
                db.Notifications.Add(notification);
            }


            db.SaveChanges();
            return(RedirectToAction("Index", new { @id = Form_Id, @msg = "EditSuccess" }));
        }
Example #19
0
        //添加组
        private void AddGroup(object sender, RoutedEventArgs e)
        {
            FormGroup form = new FormGroup();

            form.Owner = this;
            if ((bool)form.ShowDialog())
            {
                OPCManager.AddGroup((SHHOPCServer)tree.SelectedItem, new SHHOPCGroup(Guid.NewGuid(), form.Name, form.UpdateRate, form.DeadBend, form.TimeBias, form.IsActive, form.IsSubscribed));
            }
        }
Example #20
0
        protected override void OnNewButtonClick()
        {
            FormGroup form = new FormGroup();

            form.FormClosed += (s, e) =>
            {
                BindList(_schoolID, _trainPlaceID, false);
            };
            form.Show();
        }
Example #21
0
        public void Add(FormGroup group)
        {
            if (group == null || Form.Groups.Contains(group))
            {
                return;
            }

            Form.Groups.Add(group);
            LoadGroups();
        }
        public void Add()
        {
            FormGroup g = new FormGroup("");
            FormLabel l = new FormLabel("");

            g.Add(l);

            Assert.AreSame(l.Container, g);
            Assert.IsTrue(g.Contents.Any(c => ReferenceEquals(c, l)));
            Assert.AreEqual(g.Contents.Count, 1);
        }
        private void DoEdit(string formURI)
        {
            form = Form.Find(formURI);
            formBindingSource.DataSource  = form;
            groupBindingSource.DataSource = FormGroup.FindAll();
            Text = form.Name;
            statusComboBox.Items.AddRange(Enum.GetValues(typeof(FormStatus)).Cast <object>().ToArray());
            statusComboBox.SelectedItem = form.Status;

            ShowDialog(Program.MainForm);
        }
Example #24
0
        public ActionResult Create(int FormIdValue, List <int> Groups)
        {
            ViewBag.Current = "Forms";

            if (Groups == null)
            {
                return(RedirectToAction("Index", new { @id = FormIdValue, @msg = "CreateError" }));
            }
            if (ModelState.IsValid)
            {
                List <string> UsersId          = new List <string>();
                string        NotificationTime = string.Empty;
                string        UserId           = User.Identity.GetUserId();
                string        GroupName        = string.Empty;

                Notification notification = null;
                FormGroup    formgroup    = null;
                foreach (int i in Groups)
                {
                    NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss");

                    formgroup = new FormGroup()
                    {
                        GroupId     = i,
                        FormId      = FormIdValue,
                        Is_Active   = true,
                        CreatedAt   = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"),
                        CreatedById = this.User.Identity.GetUserId()
                    };
                    db.FormGroups.Add(formgroup);

                    GroupName = db.Groups.Find(formgroup.GroupId).Name;
                    List <ApplicationUser> Users = db.UsersGroups.Where(a => a.GroupId == i).Include(a => a.User).Select(a => a.User).ToList();
                    foreach (ApplicationUser user in Users)
                    {
                        notification = new Notification()
                        {
                            CreatedAt           = NotificationTime,
                            Active              = false,
                            UserId              = user.Id,
                            Message             = "تم إضافة نموذج جديد للمجموعة :" + GroupName + "، النموذج: " + db.Forms.Find(FormIdValue).Name,
                            NotificationOwnerId = UserId
                        };
                        db.Notifications.Add(notification);
                    }
                }
                db.SaveChanges();
                return(RedirectToAction("Index", new { @id = FormIdValue, @msg = "CreateSuccess" }));
            }



            return(RedirectToAction("Index"));
        }
        public Layout GenerateLayoutForSelectedFormGroup(FormGroup fg, string formData, string assessmentTrackingNumber)
        {
            var FormModelLayout = new StackLayout();

            FormModelLayout.Orientation = StackOrientation.Vertical;

            var formGroupLayout = new StackLayout();

            formGroupLayout.Orientation = StackOrientation.Horizontal;

            var formComponentLayout = new StackLayout();

            formComponentLayout.Orientation = StackOrientation.Vertical;

            //get groups
            //foreach (FormGroup fg in formModel.formgroups)
            //{
            //    FormGroupBoxView boxView = new FormGroupBoxView(fg.text);
            //    formGroupLayout.Children.Add(boxView);

            //Component Selector. Need to be more robust
            foreach (Component c in fg.components)
            {
                if (c.type.Equals(ComponentTypes.YesNoSwitchView))
                {
                    YesNoSwitchView yesNo = new YesNoSwitchView(c, formData);
                    formComponentLayout.Children.Add(yesNo);
                }
                else if (c.type.Equals(ComponentTypes.LabelEditorView))
                {
                    LabelEditorView labelEditorView = new LabelEditorView(c, formData);
                    formComponentLayout.Children.Add(labelEditorView);
                }
                else if (c.type.Equals(ComponentTypes.CameraView))
                {
                    CameraView cameraView = new CameraView(c, formData, assessmentTrackingNumber);
                    formComponentLayout.Children.Add(cameraView);
                }
                else if (c.type.Equals(ComponentTypes.AudioRecorderView))
                {
                    //AudioRecorderView audioRecorderView = new AudioRecorderView();//CameraView(c, formData);
                    VoiceMemoView audioRecorderView = new VoiceMemoView(c, formData, assessmentTrackingNumber);
                    formComponentLayout.Children.Add(audioRecorderView);
                }
            }
            //}

            //FormModelLayout.Children.Add(formTitle);
            FormModelLayout.Children.Add(formGroupLayout);
            FormModelLayout.Children.Add(formComponentLayout);


            return(FormModelLayout);
        }
        // FormGroup

        public static FormGroup <THelper> FormGroup <THelper>(this IFormGroupCreator <THelper> creator, string label = null, string labelFor = null)
            where THelper : BootstrapHelper <THelper>
        {
            FormGroup <THelper> formGroup = new FormGroup <THelper>(creator);

            if (label != null)
            {
                formGroup.ControlLabel = formGroup.GetWrapper().ControlLabel(label, labelFor);
            }
            return(formGroup);
        }
        public virtual void Visit(FormGroup formGroup, HtmlContainer htmlContainer)
        {
            for (int i = 0; i < formGroup.Contents.Count; i++)
            {
                if (formGroup.Contents[i].IsHidden)
                {
                    continue;
                }

                Visit(formGroup.Contents[i], (HtmlContainer)htmlContainer.Contents[i]);
            }
        }
        protected override void OnInitialized()
        {
            if (FormGroup != null)
            {
                _inputNumber = FormGroup.InputComponentCount;
                Id           = FormGroup.Id + "-input-" + _inputNumber;

                FormGroup.AddInputComponent(this);

                if (AutoLabel && String.IsNullOrEmpty(FormGroup.Label))
                {
                    try
                    {
                        var fieldProperty = this.FieldIdentifier.Model.GetType().GetProperty(this.FieldIdentifier.FieldName);

                        var displayAttribute     = fieldProperty.GetCustomAttribute <DisplayAttribute>();
                        var displayNameAttribute = fieldProperty.GetCustomAttribute <System.ComponentModel.DisplayNameAttribute>();

                        if (displayAttribute != null)
                        {
                            FormGroup.SetLabel(displayAttribute.GetName());
                        }
                        else if (displayNameAttribute != null)
                        {
                            FormGroup.SetLabel(displayNameAttribute.DisplayName);
                        }
                        else
                        {
                            FormGroup.SetLabel(this.FieldIdentifier.FieldName);
                        }
                    }
                    catch { }
                }

                if (AutoRequired)
                {
                    try
                    {
                        var fieldProperty = this.FieldIdentifier.Model.GetType().GetProperty(this.FieldIdentifier.FieldName);

                        var requiredAttribute = fieldProperty.GetCustomAttribute <RequiredAttribute>();

                        if (requiredAttribute != null)
                        {
                            FormGroup.SetRequired(true);
                        }
                    }
                    catch { }
                }
            }

            base.OnInitialized();
        }
Example #29
0
        private void LoadFirstQuestionByDefault(FormGroup fg)
        {
            //Select the color of first button
            View   firstButton = questionNavigationButtonBarLayout.Children.FirstOrDefault <View>();
            Button frstbtn     = (Button)firstButton;

            frstbtn.BackgroundColor = Color.FromHex("#3693FF");
            frstbtn.TextColor       = Color.White;
            //firstButton.SetBinding(Button.TextColorProperty, "#FFFFFF");


            LoadQuestions(fg);
        }
        public void Remove()
        {
            FormGroup g = new FormGroup("");

            FormLabel l = new FormLabel("");

            g.Add(l);
            g.Remove(l);

            Assert.IsNull(l.Container);
            Assert.IsFalse(g.Contents.Any(c => ReferenceEquals(c, l)));
            Assert.AreEqual(g.Contents.Count, 0);
        }
Example #31
0
        public AssessmentButtonPage(string selectedItem)
        {
            _friendlyName = selectedItem;

            CreateToolBar();
            CreateErrorLabel();


            _formService = new FormService();

            //Get Form Instance
            _formInstance     = _formService.GetFormInstance(AppDataWallet.SelectedAssessmentMetadata.AssessmentTrackingNumber.ToString(), selectedItem);
            _validationSchema = _formInstance.ValidationSchema;
            //generate Layout Dynamically

            //Set the bar naviagtion
            _pageLayout = new StackLayout();
            StackLayout questionNavigationButtonBarLayout = new StackLayout();

            questionNavigationButtonBarLayout.Orientation = StackOrientation.Horizontal;
            _pageLayout.Children.Add(questionNavigationButtonBarLayout);

            //Create Button list for Navigation
            Button questionButton;

            foreach (FormGroup formGroup in _formInstance.FormModelView.formgroups)
            {
                questionButton                  = new Button();
                questionButton.Text             = formGroup.text;
                questionButton.Clicked         += QuestionButton_Clicked;
                questionButton.CommandParameter = formGroup;
                questionNavigationButtonBarLayout.Children.Add(questionButton);
            }

            //Add Error Message
            _pageLayout.Children.Add(lblErrorMessage);

            //Load First Question
            _formGroup = _formInstance.FormModelView.formgroups[0];
            LoadFirstQuestionByDefault(_formGroup);

            //Final Page Content
            //Content = _pageLayout;
            //scrollView = new ScrollView();
            Content = _pageLayout;

            /*Content = new ScrollView
             * {
             *  Content = _pageLayout
             * };*/
        }
Example #32
0
 public Label(FormGroup formGroup, string text, string id = null)
     : base("label", text, false)
 {
     _id = id ?? text;
     Attrs["for"] = _id;
 }