private void GoToFormProvider(object o) { formProvider = new FormProvider(o); formProvider.AddProviderClicked += formProvider_AddProviderClicked; Content.Content = formProvider; NotificationsButton.Content = productBusiness.GetList().Count(x => x.Quantity < 10); }
public IEnumerable <FieldResponse> GetAllForForm(string id) { var result = new List <FieldResponse>(); foreach (var field in FieldProvider.GetAllFor(id)) { if (!field.AutoGenerate) { continue; } var control = ControlMatcher.GetFor(field.Type, field.UIHints); var embeddedFormId = FormProvider.GetAll().FirstOrDefault(f => f.Type == field.Type); if (control == null && embeddedFormId == null) { continue; } result.Add(new FieldResponse { Id = field.Id, Label = field.Label ?? Humanizer.Humanize(field.Id), CamelCaseId = CamelCaseNamingStrategy.GetPropertyName(field.Id, false), Control = control, EmbeddedFormId = embeddedFormId?.Id, IsSortable = field.IsSortable, Group = field.Group, }); } return(result); }
public void Initialize(object instance, FormDescriptor form) { foreach (var field in FieldProvider.GetAllFor(form.Id)) { if (field.IsSortable) { PropertySetter.SetProperty(form.Type, instance, field.Id, Activator.CreateInstance(typeof(List <>).MakeGenericType(field.Type))); continue; } var nestedForm = FormProvider.Get(field.Type); if (nestedForm == null) { continue; } var value = Activator.CreateInstance(field.Type); Initialize(value, nestedForm); PropertySetter.SetProperty(form.Type, instance, field.Id, value); } }
public WrapperForm() { //this.FormBorderStyle = FormBorderStyle.None; this.HScroll = false; this.VScroll = false; this.StartPosition = FormStartPosition.CenterScreen; this.ShowIcon = false; InitializeComponent(); this.Text = "FaceTan UI"; this.MinimumSize = new Size(1200, 800); CefInstance CefContext = new CefInstance(); chromium = new ChromiumWebBrowser(onLoadURL) { Name = Guid.NewGuid().ToString(), Dock = DockStyle.Fill, MenuHandler = new MenuHandler(), Top = 0 }; this.Controls.Add(chromium); var formHandler = new FormProvider(this); //Register DataSet Object to boundDataSet Javascript Object DataSet dataSet = new DataSet("capstone-dataset", "AKIAJJKYA2TLOIPHNNVA", "BBN6C1W3Lx0bo+mOgmD7xjlfstoA3qKA8ppIr38A", 0); chromium.JavascriptObjectRepository.Register("boundDataSet", dataSet, true); chromium.JavascriptObjectRepository.Register("boundTestRunner", new TestRunner(dataSet), true); IntializeEventHandlers(); }
public IEnumerable <FormResponseItem> GetOptions(IEnumerable <string> types) { var result = new List <FormResponseItem>(); foreach (var form in FormProvider.GetAll()) { if (ContentTypeProvider.Get(form.Type) != null) { continue; } if (!types.Contains(form.Id)) { continue; } result.Add(new FormResponseItem { Type = form.Id, Name = form.Type.GetCustomAttribute <DisplayAttribute>()?.Name ?? Humanizer.Humanize(form.Type.Name), }); } return(result.OrderBy(f => f.Name).ToList().AsReadOnly()); }
public ActionResult Index() { var form = FormProvider.GetForm(); // layout templates form.Template = string.Format(@"<fieldset><legend>Basic Info</legend><table>{0}</table>{1}{2}</fieldset>", PlaceHolders.Fields, PlaceHolders.SerializedForm, PlaceHolders.DataScript); form.SetFieldTemplates( string.Format(@"<tr><th valign=""top"">{0}</th><td valign=""top"">{1}{2}{3}</td></tr>", PlaceHolders.Prompt, PlaceHolders.Error, PlaceHolders.Input, PlaceHolders.Literal), form.Fields.ToArray()); form.SetFieldTemplates( string.Format(@"<tr><th /><td valign=""top"" class=""chkCell"">{0}{1}{2}</td></tr>", PlaceHolders.Error, PlaceHolders.Input, PlaceHolders.Prompt), form.Fields.Where(x => x is CheckBox).ToArray()); form.Fields.Single(x => x.Key == "description").Template = "</table><p>" + PlaceHolders.Literal + "</p><table>"; form.Serialize = true; return(this.View(form)); }
public void Should_ignore_incorrect_codeRRContext() { var context = new ErrorReporterContext(this, new Exception()); var sut = new FormProvider(); var result = sut.Collect(context); result.Should().BeNull(); }
public void Should_not_return_an_empty_collection_when_the_form_collection_is_empty() { var httpContext = Substitute.For <HttpContextBase>(); var context = new AspNetContext(this, new Exception(), httpContext); var sut = new FormProvider(); var result = sut.Collect(context); result.Should().BeNull(); }
/* * First off, these Demos do the exact same thing from the end user's perspective. * The difference is in how the Form object is persisted across requests. * * Most often, you'll need to keep the original Form and Field objects around for as long * as your user is working on completing the form. This is because, when InputField * objects are constructed, they are keyed with a new Guid. See Demos 1 & 2 for examples. * * You can key your InputFields manually by setting the InputField.Key property. * If you do this and can guarantee that the Fields and their Keys will not change after * a complete reconstruction of all objects, then you don't have to persist the objects across * requests. See Demo 3. * * In Demo 1, the Form object graph is serialized to a string and stored in a hidden field * in the page's HTML. * * In Demo 2, the Form object graph is simply stored in TempData (short lived session state). * * In Demo 3, the Form object graph is not persisted across requests. It is reconstructed * on each request and the InputField's keys are set manually. * * The serialization approach (demo 1) results in more concise code in the controller. * Serializing the Form is also more reliable, in my opinion. * * However, response time increases because of serialized data * and the (de)serialization process takes time, as well. * * The approach you take depends on your needs. */ public ActionResult Demo1() { var form = FormProvider.GetForm(); // we are going to store the form and // the field objects on the page across requests form.Serialize = true; return(this.View("Demo", form)); }
public ActionResult Demo2() { var form = FormProvider.GetForm(); // we are going to store the form // in server memory across requests this.TempData["form"] = form; return(this.View("Demo", form)); }
public IEnumerable <FieldResponse> GetAllForForm(string id) { var result = new List <FieldResponse>(); foreach (var field in FieldProvider.GetAllFor(id)) { if (!field.AutoGenerate) { continue; } var control = ControlMatcher.GetFor(field.Type, field.UIHints); var embeddedFormId = FormProvider.GetAll().FirstOrDefault(f => f.Type == field.Type); if (control == null && embeddedFormId == null) { Logger.LogInformation($"Could not find control for {id} {field.Id}"); continue; } var label = field.Label; if (label == null) { label = field.Id; label = Humanizer.Humanize(field.Id); if (label.EndsWith(" ids")) { label = label.Substring(0, label.Length - " ids".Length); label = Pluralizer.Pluralize(label); } else if (label.EndsWith(" id")) { label = label.Substring(0, label.Length - " id".Length); } } var singularLabel = Singularizer.Singularize(label); result.Add(new FieldResponse { Id = field.Id, Label = label, SingularLabel = singularLabel, CamelCaseId = CamelCaseNamingStrategy.GetPropertyName(field.Id, false), Control = control, EmbeddedFormId = embeddedFormId?.Id, IsSortable = field.IsSortable, Group = field.Group, }); } return(result); }
private void GetFormsByContentTypeId(HttpRequest request, HttpResponse response) { int contentTypeId = ValidationHelper.GetInteger(request.QueryString["id"], 0); using (FormProvider formProvider = new FormProvider()) { List<FormInfo> formInfos = formProvider.SelectAllByContentTypeId(contentTypeId, new ErrorInfoList()); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<FormInfo>)); serializer.WriteObject(response.OutputStream, formInfos); response.OutputStream.Close(); } }
protected override IRawElementProviderSimple GetProvider() { ContextMenu menu = new ContextMenu(); menu.MenuItems.Add("item1"); Form.ContextMenu = menu; System.Windows.Point winPoint = (System.Windows.Point) FormProvider.GetPropertyValue(AEIds.ClickablePointProperty.Id); menu.Show(Form, new System.Drawing.Point((int)winPoint.X, (int)winPoint.Y)); return(ProviderFactory.FindProvider(menu)); }
public ActionResult Index( string formStatus, DateTime?utcCreationDate1 = null, DateTime?utcCreationDate2 = null, DateTime?utcCompletedDate1 = null, DateTime?utcCompletedDate2 = null, DateTime?utcClosedDate1 = null, DateTime?utcClosedDate2 = null, string patientFirstName = "", string patientLastName = "", bool?FormLayoutActive = null, int page = 1, int itemsPerPage = 10, string patientId = "", bool onlyProfileForms = false) { var betweenOperador = "between"; var viewModel = new GenericModel <FormModel>(); utcCreationDate1 = utcCreationDate1 ?? DateTime.MinValue; utcCreationDate2 = utcCreationDate2 ?? DateTime.MaxValue; viewModel.Criteria.Add("UtcCreationDate1", utcCreationDate1.ToString()); viewModel.Criteria.Add("UtcCreationDate2", utcCreationDate2.ToString()); viewModel.Criteria.Add("FormStatus", formStatus); viewModel.Criteria.Add("PatientId", patientId); try { viewModel.SearchResults = FormProvider.Search(Helpers.GetAuthenticator(), formStatus, betweenOperador, utcCreationDate1, utcCreationDate2, betweenOperador, utcCompletedDate1, utcCompletedDate2, betweenOperador, utcClosedDate1, utcClosedDate2, patientFirstName, patientLastName, FormLayoutActive, patientId); viewModel.Header = Resources.ResultsHeader; viewModel.ListEmptyMessage = viewModel.SearchResults != null && viewModel.SearchResults.Rows.Count() > 0 ? string.Empty : Resources.ListEmptyMessage; } catch (Exception ex) { viewModel.ErrorMessage = ex.GetBaseException().Message; } return(View("Index", viewModel)); }
public ActionResult Demo3() { // recreate the form and set the keys var form = FormProvider.GetForm(); this.Demo3SetKeys(form); // set user input on recreated form this.UpdateModel(form); if (this.Request.HttpMethod == "POST" && form.Validate()) // input is valid { return(this.View("Responses", form)); } // input is not valid return(this.View("Demo", form)); }
public void Should_include_form_items() { var httpContext = Substitute.For <HttpContextBase>(); var context = new AspNetContext(this, new Exception(), httpContext); var items = new NameValueCollection { { "MyKey", "MyValue" }, { "AnotherKey", "AnotherLevel" }, { "MyKey", "SecondValue" } }; httpContext.Request.Form.Returns(items); var sut = new FormProvider(); var result = sut.Collect(context); result.Properties["MyKey"].Should().Be("MyValue,SecondValue"); result.Properties["AnotherKey"].Should().Be("AnotherLevel"); }
public virtual async void OpenItemEditor(TItem item) { EditingItem = item; if (FormProvider == null) { return; } UsedForm = FormProvider.GetUIElement(); Cache.Set(EdiTItemCacheKey, EditingItem.DeepClone()); // cache item state so it can be restored later bool result = false; try { result = (bool)await DialogService.Show(UsedForm, (sender, args) => { OnItemEditorOpening(sender, new ItemEditorOpeningDialogEventArgs <TItem>(item)); if (args.ShouldClose) { args.Close(); } }, (sender, args) => { ItemEditorClosingDialogEventArgs <TItem> extArgs = new ItemEditorClosingDialogEventArgs <TItem>(args.Result, item); OnFormClosing(extArgs); if (extArgs.IsCancelled) { args.Cancel(); } }).ConfigureAwait(true); } catch (Exception ex) { Log.Error(ex, "Couldn't open form"); OnOpenFormFailed(item); return; } OnItemEdited(new ItemEditedEventArgs <TItem>(result, (TItem)Cache.Get(EdiTItemCacheKey), item)); Cache.Remove(EdiTItemCacheKey); }
protected override IRawElementProviderSimple GetProvider() { SWF.Label label1 = new SWF.Label(); label1.Text = "hola"; label1.Size = new System.Drawing.Size(30, 30); label1.Location = new System.Drawing.Point(1, 1); Form.Controls.Add(label1); SWF.Label label2 = new SWF.Label(); label2.Text = "mundo"; label2.Size = new System.Drawing.Size(30, 30); label2.Location = new System.Drawing.Point(1, 32); Form.Controls.Add(label2); SWF.ErrorProvider errorProvider = new SWF.ErrorProvider(); errorProvider.SetError(label1, "Error: hola"); errorProvider.SetError(label2, "Error: mundo"); IRawElementProviderSimple provider = null; IRawElementProviderFragment child = (IRawElementProviderFragment)FormProvider.Navigate(NavigateDirection.FirstChild); while (child != null) { if ((int)child.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) != ControlType.Text.Id) { provider = child; } child = child.Navigate(NavigateDirection.NextSibling); } Assert.IsNotNull(provider, "We should have a provider different than Text"); return(provider); }
public edit() : base("", null) { _contentTypeProvider = new ContentTypeProvider(); _formProvider = new FormProvider(); }
public FormAutomationFocusChangedEvent (FormProvider provider) : base (provider) { }
public void ShowHideTest() { ContextMenu formMenu = new ContextMenu(); formMenu.MenuItems.Add("form item 1"); Form.ContextMenu = formMenu; Label label = new Label(); label.Text = "I have my own context menu"; ContextMenu labelMenu = new ContextMenu(); labelMenu.MenuItems.Add("label item 1"); label.ContextMenu = labelMenu; Form.Controls.Add(label); label.Show(); var labelProvider = ProviderFactory.FindProvider(label); Assert.IsNotNull(labelProvider, "Form's label should have a provider"); // No menu providers unless shown IRawElementProviderFragment formMenuProvider = ProviderFactory.FindProvider(formMenu); Assert.IsNull(formMenuProvider, "Form menu provider not expected until shown"); IRawElementProviderFragment labelMenuProvider = ProviderFactory.FindProvider(labelMenu); Assert.IsNull(labelMenuProvider, "Label menu provider not expected until shown"); bridge.ResetEventLists(); // Test showing Form menu System.Windows.Point winPoint = (System.Windows.Point) FormProvider.GetPropertyValue(AEIds.ClickablePointProperty.Id); formMenu.Show(Form, new System.Drawing.Point((int)winPoint.X, (int)winPoint.Y)); formMenuProvider = ProviderFactory.FindProvider(formMenu); Assert.IsNotNull(formMenuProvider, "Form menu provider expected once menu is shown"); labelMenuProvider = ProviderFactory.FindProvider(labelMenu); Assert.IsNull(labelMenuProvider, "Label menu provider not expected until shown"); Assert.AreEqual(FormProvider, formMenuProvider.Navigate(NavigateDirection.Parent), "Form menu parent should be Form"); Assert.IsTrue(ProviderContainsChild(FormProvider, formMenuProvider), "Form menu should be Form's child"); var tuple = bridge.GetAutomationEventFrom(formMenuProvider, AEIds.MenuOpenedEvent.Id); Assert.IsNotNull(tuple, "MenuOpenedEvent expected"); bridge.ResetEventLists(); // Test closing Form menu formMenu.Dispose(); tuple = bridge.GetAutomationEventFrom(formMenuProvider, AEIds.MenuClosedEvent.Id); Assert.IsNotNull(tuple, "MenuClosedEvent expected"); formMenuProvider = ProviderFactory.FindProvider(formMenu); Assert.IsNull(formMenuProvider, "Form menu provider should be gone after menu closed"); Assert.IsFalse(ProviderContainsChildOfType(FormProvider, ControlType.Menu), "Form should have no menu child after menu closed"); bridge.ResetEventLists(); // Test showing Label menu winPoint = (System.Windows.Point) labelProvider.GetPropertyValue(AEIds.ClickablePointProperty.Id); labelMenu.Show(label, new System.Drawing.Point((int)winPoint.X, (int)winPoint.Y)); formMenuProvider = ProviderFactory.FindProvider(formMenu); Assert.IsNull(formMenuProvider, "Form menu provider not expected while closed"); labelMenuProvider = ProviderFactory.FindProvider(labelMenu); Assert.IsNotNull(labelMenuProvider, "Label menu provider expected once menu is shown"); Assert.AreEqual(labelProvider, labelMenuProvider.Navigate(NavigateDirection.Parent), "Label menu parent should be Label"); Assert.IsTrue(ProviderContainsChild(labelProvider, labelMenuProvider), "Label menu should be Label's child"); tuple = bridge.GetAutomationEventFrom(labelMenuProvider, AEIds.MenuOpenedEvent.Id); Assert.IsNotNull(tuple, "MenuOpenedEvent expected"); bridge.ResetEventLists(); // Test closing Label menu labelMenu.Dispose(); tuple = bridge.GetAutomationEventFrom(labelMenuProvider, AEIds.MenuClosedEvent.Id); Assert.IsNotNull(tuple, "MenuClosedEvent expected"); labelMenuProvider = ProviderFactory.FindProvider(labelMenu); Assert.IsNull(labelMenuProvider, "Label menu provider should be gone after menu closed"); Assert.IsFalse(ProviderContainsChildOfType(labelProvider, ControlType.Menu), "Label should have no menu child after menu closed"); }
public WindowProviderBehavior(FormProvider provider) : base(provider) { form = (SWF.Form)provider.Control; closing = false; }
public TransformProviderBehavior(FormProvider provider) : base(provider) { form = (SWF.Form)provider.Control; }
public TransformProviderBehavior (FormProvider provider) : base (provider) { form = (SWF.Form) provider.Control; }
public WindowProviderBehavior (FormProvider provider) : base (provider) { form = (SWF.Form) provider.Control; closing = false; }
public void BasicPropertiesTest() { //Lets use 2 dummy Labels SWF.Label label1 = new SWF.Label(); label1.Text = "hola"; label1.Size = new System.Drawing.Size(30, 30); label1.Location = new System.Drawing.Point(1, 1); Form.Controls.Add(label1); SWF.Label label2 = new SWF.Label(); label2.Text = "mundo"; label2.Size = new System.Drawing.Size(30, 30); label2.Location = new System.Drawing.Point(1, 32); Form.Controls.Add(label2); //We already have 2 controls (label1 y label2) in the form, //lets navigate to look for ErrorProvider, we *shouldn't* find any Assert.IsNotNull(FormProvider, "Form provider shouldn't be null"); //Lets verify we have two labels *only* IRawElementProviderFragment child = (IRawElementProviderFragment)FormProvider.Navigate(NavigateDirection.FirstChild); Assert.IsNotNull(child, "child provider shouldn't be null"); int count = 1; while (child != null) { child = child.Navigate(NavigateDirection.NextSibling); if (child != null) { count++; } } Assert.AreEqual(2, count, "We should only have 2 children"); //Lets show the error message. We should have *only* 3 children SWF.ErrorProvider errorProvider = new SWF.ErrorProvider(); errorProvider.SetError(label1, "Error: hola"); errorProvider.SetError(label2, "Error: mundo"); child = (IRawElementProviderFragment)FormProvider.Navigate(NavigateDirection.FirstChild); Assert.IsNotNull(child, "child provider shouldn't be null"); count = 1; IRawElementProviderSimple provider = null; while (child != null) { if ((int)child.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) != ControlType.Text.Id) { provider = child; } child = child.Navigate(NavigateDirection.NextSibling); if (child != null) { count++; } } Assert.AreEqual(3, count, "We should only have 3 children"); Assert.IsNotNull(provider, "We should have a provider different than Text"); TestProperty(provider, AutomationElementIdentifiers.ControlTypeProperty, ControlType.Pane.Id); TestProperty(provider, AutomationElementIdentifiers.LocalizedControlTypeProperty, "pane"); TestProperty(provider, AutomationElementIdentifiers.IsKeyboardFocusableProperty, false); //Test patterns: TestProperty(provider, AutomationElementIdentifiers.IsTransformPatternAvailableProperty, false); TestProperty(provider, AutomationElementIdentifiers.IsWindowPatternAvailableProperty, false); TestProperty(provider, AutomationElementIdentifiers.IsDockPatternAvailableProperty, false); //Test Navigation Assert.IsNull(((IRawElementProviderFragment)provider).Navigate(NavigateDirection.FirstChild), "child provider should be null"); }
public WindowDeactivatedEvent (FormProvider provider) : base (provider, AutomationElementIdentifiers.WindowDeactivatedEvent) { }
public WindowDeactivatedEvent(FormProvider provider) : base(provider, AutomationElementIdentifiers.WindowDeactivatedEvent) { }
public FormAutomationFocusChangedEvent(FormProvider provider) : base(provider) { }
public edit(string properties, ErrorInfoList errorInfoList) : base(properties, errorInfoList) { _contentTypeProvider = new ContentTypeProvider(); _formProvider = new FormProvider(); }
protected override void Init() { base.Init(); if (_contentTypeProvider == null) _contentTypeProvider = new ContentTypeProvider(); if (_formProvider == null) _formProvider = new FormProvider(); if (IsEdit) { Title = "Edit Form | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "Edit Form"; } else { Title = "New Form | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "New Form"; } }