Inheritance: TextBoxViewModelTextOriented, ITextBoxModel
        public void should_use_the_correct_name_based_on_the_property_name_for_shallow_properties()
        {
            var viewModel = new TextBoxViewModel();

            new TextBoxExpression<TextBoxViewModel>(viewModel, c => c.Site, "")
                .ToString().ShouldEqual("<input type=\"text\" name=\"Site\" value=\"\" />");
        }
        public ActionResult MasterFormcreates(string formName, string FormWorkFlow_1, FormCollection form)
        {
            var appSettings = form.AllKeys.Where(k => k.StartsWith("AppSettings.")).ToDictionary(k => k, k => form[k]);
            Dictionary <string, object> forma = new Dictionary <string, object>(); form.CopyTo(forma);

            TextBoxList textList = new TextBoxList();

            foreach (String key in form.AllKeys)
            {
                if (key != "FormWorkFlow_1")
                {
                    TextBoxViewModel textBoxList1 = new TextBoxViewModel();
                    textBoxList1.FieldId = key;
                    textBoxList1.Value   = form[key];
                    textList.Add(textBoxList1);
                }
            }
            RelianceController.FormFieldController formFieldController = new RelianceController.FormFieldController();
            TextBoxViewModel textBoxList      = formFieldController.InsertMetada(formName, "", textList);
            MasterDocumentDo masterDocumentDo = new MasterDocumentDo();

            masterDocumentDo.Formid = Convert.ToInt32(TempData["Dataid"]);
            if (FormWorkFlow_1 != "0")
            {
                masterDocumentDo.docid    = textBoxList.IdentityId;
                masterDocumentDo.Formid   = Convert.ToInt32(TempData["Dataid"]);
                masterDocumentDo.UserId   = Convert.ToInt32(Session["LOGGED_UserId"]);
                masterDocumentDo.RoleId   = Convert.ToInt32(Session["LOGGED_ROLE"]);
                masterDocumentDo.FormName = formName;
                MasterDocumentController masterDocumentController = new MasterDocumentController();
                masterDocumentController.AddMasterDocument(masterDocumentDo);
            }
            return(RedirectToAction("MasterFormcreate", "FormMaster", new { LinKType = masterDocumentDo.Formid }));
        }
        public void should_use_the_correct_value_based_on_the_property_value()
        {
            var viewModel = new TextBoxViewModel {Value = "Star Wars"};

            new TextBoxExpression<TextBoxViewModel>(viewModel, c => c.Value, "")
                .ToString().ShouldEqual("<input type=\"text\" name=\"Value\" value=\"Star Wars\" />");
        }
        public void should_render_the_type_as_password_when_password_option_is_enabled()
        {
            var viewModel = new TextBoxViewModel {Value = "Star Wars"};

            new TextBoxExpression<TextBoxViewModel>(viewModel, c => c.Value, "").PasswordMode()
                .ToString().ShouldEqual("<input type=\"password\" name=\"Value\" value=\"Star Wars\" />");
        }
        public void should_use_prefix_for_name()
        {
            var viewModel = new TextBoxViewModel();

            new TextBoxExpression<TextBoxViewModel>(viewModel, c => c.Site.Notes, "prefix")
                .ToString().ShouldEqual("<input type=\"text\" name=\"prefixSiteNotes\" value=\"\" />");
        }
        public TextBoxView(TextBoxViewModel vm)
        {
            ViewModel   = vm;
            DataContext = vm;

            InitializeComponent();
        }
        public void should_render_a_textarea_when_multiline_option_is_enabled()
        {
            var viewModel = new TextBoxViewModel {Value = "Star Wars"};

            new TextBoxExpression<TextBoxViewModel>(viewModel, c => c.Value, "").MultilineMode()
                .ToString().ShouldEqual("<textarea name=\"Value\" >Star Wars</textarea>");
        }
        private void OnShowDialogButtonClicked(object sender, RoutedEventArgs e)
        {
            var username = new TextBoxViewModel();
            var password = new TextBoxViewModel();

            var okButton = new ButtonViewModel {
                Content = new TextBlockViewModel("YYY")
            };

            var buttonPanel = new StackPanelViewModel();

            buttonPanel.Children.Add(okButton);

            var contentPanel = new StackPanelViewModel();

            contentPanel.Children.Add(username);
            contentPanel.Children.Add(password);
            contentPanel.Children.Add(buttonPanel);

            var window          = DependencyResolver.Instance.Get <IModalWindow <WindowViewModel> >();
            var windowViewModel = new WindowViewModel {
                Content = contentPanel
            };

            window.SetViewModel(windowViewModel);

            window.ShowDialog();
        }
Exemple #9
0
        private void OnClickCreateItem(MouseButtonEventArgs e)
        {
            ItemViewModel item     = null;
            var           position = e.MouseDevice.GetPosition(e.Source as IInputElement);

            if (IsAddingClassPressed)
            {
                item = new ClassViewModel()
                {
                    X = position.X, Y = position.Y
                };
                IsAddingClassPressed = false;
            }
            else if (IsAddingTextBoxPressed)
            {
                item = new TextBoxViewModel()
                {
                    X = position.X, Y = position.Y
                };
                IsAddingTextBoxPressed = false;
            }
            if (item != null)
            {
                commandController.AddAndExecute(new AddItemCommand(Items, item));
                StatusBarMsg = item.Type + " have been added on postions {" + position.X + ";" + position.Y + "}";
            }
        }
Exemple #10
0
        public IObjectViewModel Add(ObjectType objectType)
        {
            ErrorMessage = string.Empty;

            var id   = MakeId();
            var name = $"Объект {id}";

            IObjectViewModel viewModel;
            IVariableWrapper variable;

            switch (objectType)
            {
            case ObjectType.Label:
                viewModel = new LabelViewModel(id, name, _dataProvider);
                break;

            case ObjectType.TextBox:
                variable  = CreateVariable(VariableType.String);
                viewModel = new TextBoxViewModel(id, name, variable, _dataProvider);
                break;

            case ObjectType.CheckBox:
                variable  = CreateVariable(VariableType.Bool);
                viewModel = new CheckBoxViewModel(id, name, variable, _dataProvider);
                break;

            case ObjectType.RadioButton:
                variable  = CreateVariable(VariableType.Bool);
                viewModel = new RadioViewModel(id, name, variable, _dataProvider)
                {
                    GroupName = GetRadioGroupName()
                };
                break;

            case ObjectType.DatePicker:
                variable  = CreateVariable(VariableType.Date);
                viewModel = new DatePickerViewModel(id, name, variable, _dataProvider);
                break;

            case ObjectType.TimePicker:
                variable  = CreateVariable(VariableType.Time);
                viewModel = new TimePickerViewModel(id, name, variable, _dataProvider);
                break;

            default:
                ErrorMessage = "Неизвестный тип объекта.";
                return(null);
            }

            viewModel.Properties.TabId        = _dataProvider.TabsRepository.SelectedTabIndex;
            viewModel.Properties.Left         = 20;
            viewModel.Properties.Top          = 20;
            viewModel.Properties.FontSettings = new FontSettings();
            ViewModels.Add(viewModel);
            Select(viewModel);
            ObjectModified?.Invoke(viewModel.Properties.Id);

            return(viewModel);
        }
        public ActionResult TextBox()
        {
            string message = "Type Here!";

            var viewModel = new TextBoxViewModel(message);

            return(View(viewModel));
        }
        public ActionResult TextBox(string input)
        {
            string message = "Success, it posted!";  // update

            var viewModel = new TextBoxViewModel(message);

            return(View(viewModel));
        }
Exemple #13
0
        public void ProperlySetPanelChildrenModel()
        {
            var textBoxViewModel    = new TextBoxViewModel();
            var stackPanelViewModel = new StackPanelViewModel();

            stackPanelViewModel.Children.Add(textBoxViewModel);

            VerifyPanelChildrenCollection(textBoxViewModel.GetModel(), stackPanelViewModel);
        }
Exemple #14
0
        public TextBoxUserControl()
        {
            EnsureApplicationResources();
            InitializeComponent();
            vm = new TextBoxViewModel();
            base.DataContext = vm;

            vm.LockEvent += Vm_LockEvent;
        }
        public IActionResult TextBox(TextBoxViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                return(this.View("TextBoxResult", model));
            }

            return(this.View(model));
        }
        public void should_add_specified_custom_html_attributes()
        {
            var viewModel = new TextBoxViewModel {Value = "Star Wars"};

            var expr = new TextBoxExpression<TextBoxViewModel>(viewModel, c => c.Value, "");
            expr.HtmlAttributes.Add("disabled", "disabled");

            expr.ToString().ShouldEqual(
                "<input type=\"text\" name=\"Value\" value=\"Star Wars\" disabled=\"disabled\" />");
        }
        public ActionResult TextBoxControl(string formName, FormCollection form)
        {
            TextBoxList textList = new TextBoxList();

            foreach (String key in form.AllKeys)
            {
                TextBoxViewModel textBoxList1 = new TextBoxViewModel();
                textBoxList1.FieldId = key;
                textBoxList1.Value   = form[key];

                textList.Add(textBoxList1);
            }
            RelianceController.FormFieldController formFieldController = new FormFieldController();
            formFieldController.InsertMetada(formName, "", textList);
            // TextList.Add(textBoxList1);
            return(View());
            // return Json(new { OnSuccess = "success" }, JsonRequestBehavior.AllowGet);
        }
Exemple #18
0
        /// <summary>
        /// Добавление десериализуемого объекта
        /// </summary>
        public void Add(IFormObject formObject)
        {
            IObjectViewModel viewModel = null;

            if (formObject is CheckBoxObject)
            {
                viewModel = new CheckBoxViewModel((CheckBoxObject)formObject, _dataProvider);
            }
            else if (formObject is LabelObject)
            {
                viewModel = new LabelViewModel((LabelObject)formObject, _dataProvider);
            }
            else if (formObject is TextBoxObject)
            {
                viewModel = new TextBoxViewModel((TextBoxObject)formObject, _dataProvider);
            }
            else if (formObject is RadioButtonObject)
            {
                viewModel = new RadioViewModel((RadioButtonObject)formObject, _dataProvider);
            }
            else if (formObject is DateBoxObject)
            {
                viewModel = new DatePickerViewModel((DateBoxObject)formObject, _dataProvider);
            }
            else if (formObject is TimePickerObject)
            {
                viewModel = new TimePickerViewModel((TimePickerObject)formObject, _dataProvider);
            }

            if (viewModel == null)
            {
                return;
            }

            viewModel.Properties.Left       = formObject.Left;
            viewModel.Properties.Top        = formObject.Top;
            viewModel.Properties.IsSelected = false;
            viewModel.Properties.SetVisibility(formObject.IsVisible);
            viewModel.Properties.TabId = formObject.TabId;
            ViewModels.Add(viewModel);
            ObjectModified?.Invoke(viewModel.Properties.Id);
        }
        public ActionResult UpdateFields(string formName, string id, FormCollection form)
        {
            TextBoxList textList = new TextBoxList();

            foreach (String key in form.AllKeys)
            {
                TextBoxViewModel textBoxList1 = new TextBoxViewModel();
                textBoxList1.FieldId = key;
                textBoxList1.Value   = form[key];
                if (key == "id")
                {
                    // textList.Add(textBoxList1);
                }
                else
                {
                    textList.Add(textBoxList1);
                }
            }
            RelianceController.FormFieldController formFieldController = new RelianceController.FormFieldController();
            formFieldController.UpdateMasterField(formName, id, "", textList);
            return(RedirectToAction("MasterFormcreate", "FormMaster", new { LinKType = Convert.ToInt32(TempData["Dataid"]) }));
        }
Exemple #20
0
        public static MvcHtmlString RPTextBoxFor <TModel, TProperty>(
            this HtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, TProperty> > expression,
            DataTypeUI dataType       = DataTypeUI.Undefined,
            string labelMessage       = null,
            string placeholderMessage = null,
            string cssClass           = null)
        {
            var metadata       = htmlHelper.GetModelMetadata(expression, labelMessage, placeholderMessage);
            var viewModel      = new TextBoxViewModel(metadata, dataType);
            var htmlAttributes = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(viewModel.PlaceholderMessage))
            {
                htmlAttributes.Add("placeholder", viewModel.PlaceholderMessage);
            }

            htmlAttributes.Add("type", viewModel.DataType.GetMetadata().Value);
            htmlAttributes.Add("class", $"form-control input-val {cssClass}");
            viewModel.Input = htmlHelper.TextBoxFor(expression, htmlAttributes);

            return(htmlHelper.Partial(Mvc.View.UI.TextBox, viewModel));
        }
Exemple #21
0
        public static MvcHtmlString RPTextAreaFor <TModel, TProperty>(
            this HtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, TProperty> > expression,
            int rows                  = 10,
            string labelMessage       = null,
            string placeholderMessage = null)
        {
            var metadata       = htmlHelper.GetModelMetadata(expression, labelMessage, placeholderMessage);
            var viewModel      = new TextBoxViewModel(metadata);
            var htmlAttributes = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(viewModel.PlaceholderMessage))
            {
                htmlAttributes.Add("placeholder", viewModel.PlaceholderMessage);
            }

            htmlAttributes.Add("type", viewModel.DataType.GetMetadata().Value);
            htmlAttributes.Add("class", "form-control input-val");
            htmlAttributes.Add("style", "resize:none;");
            htmlAttributes.Add("rows", rows);
            viewModel.Input = htmlHelper.TextAreaFor(expression, htmlAttributes);

            return(htmlHelper.Partial(Mvc.View.UI.TextArea, viewModel));
        }
Exemple #22
0
 public TextBoxModel(Point p, TextBoxViewModel tbvm)
 {
     PositionLeft     = p.X;
     PositionTop      = p.Y;
     TextBoxViewModel = tbvm;
 }
Exemple #23
0
 public void Build(IIocContainer ctx)
 {
     ClientName  = ctx.Resolve <TextBoxViewModel>();
     ClientEmail = ctx.Resolve <TextBoxViewModel>();
 }
Exemple #24
0
        public void ProperlyAssemblyMvvmStructure()
        {
            var expectedTextBoxViewModel = new TextBoxViewModel();
            var expectedTextBoxModel     = expectedTextBoxViewModel.GetModel();

            var expectedStackPanelViewModel = new StackPanelViewModel();
            var expectedStackPanelModel     = expectedStackPanelViewModel.GetModel();

            expectedStackPanelViewModel.Children.Add(expectedTextBoxViewModel);

            var expectedWindowViewModel = new WindowViewModel {
                Content = expectedStackPanelViewModel
            };
            var window = DependencyResolver.Instance.Get <IModalWindow <WindowViewModel> >();

            Assert.AreSame(expectedStackPanelModel, expectedWindowViewModel.GetModel().Content);
            VerifyPanelChildrenCollection(expectedTextBoxModel, expectedStackPanelViewModel);

            window.SetViewModel(expectedWindowViewModel);
            VerifyPanelChildrenCollection(expectedTextBoxModel, expectedStackPanelViewModel);

            var actualWindowViewModel = window.GetViewModel();

            // Model structure.
            var actualStackPanelModel = (StackPanelModel)actualWindowViewModel.GetModel().Content;

            Assert.AreSame(expectedStackPanelModel, actualStackPanelModel);

            var actualStackPanelChildren = actualStackPanelModel.Children;

            Assert.IsNotNull(actualStackPanelChildren);
            Assert.AreEqual(1, actualStackPanelChildren.Count);

            var actualTextBoxModel = actualStackPanelChildren[0];

            Assert.AreSame(expectedTextBoxModel, actualTextBoxModel);


            // ViewModel structure
            Assert.AreSame(expectedWindowViewModel, actualWindowViewModel);

            var actualStackPanelViewModel = (StackPanelViewModel)actualWindowViewModel.Content;

            Assert.AreSame(expectedStackPanelViewModel, actualStackPanelViewModel);

            var actualChildren = actualStackPanelViewModel.Children.ViewModelCollection;

            Assert.AreEqual(1, actualChildren.Count);

            var actualTextBoxViewModel = actualChildren[0];

            Assert.AreSame(expectedTextBoxViewModel, actualTextBoxViewModel);



            // View structure.

            var actualStackPanelView = ((WindowView)window).Content;

            Assert.IsNotNull(actualStackPanelView);
            Assert.AreSame(expectedStackPanelViewModel, actualStackPanelView.GetViewModel <StackPanelViewModel>());


            //var actualChildren = actualStackPanelViewModel.Children;

            //var actualTextBoxViewModel = actualChildren.ViewModelCollection[0];
            //Assert.AreSame(expectedTextBoxViewModel, actualTextBoxViewModel);



            //var actualStackPanelView = (StackPanelView)((WindowView)window).Content;
            //Assert.AreSame(expectedStackPanelViewModel, actualStackPanelView.GetViewModel<StackPanelViewModel>());

            //var actualStackPanelChildrenCollection = actualStackPanelView.Children;
            //Assert.AreEqual(1, actualStackPanelChildrenCollection.Count);

            //var actualTextBoxView = (TextBoxView)actualStackPanelChildrenCollection[0];
            //Assert.AreSame(expectedTextBoxViewModel, actualTextBoxView.GetViewModel<TextBoxViewModel>());

            //Assert.AreEqual(1, expectedStackPanelViewModel.GetModel().Children.Count);
            //Assert.AreSame(expectedTextBoxViewModel.Model, expectedStackPanelViewModel.GetModel().Children[0]);

            //// ViewModel structure
            //Assert.AreSame(window.GetViewModel(), expectedWindowViewModel);
            //Assert.AreSame(expectedWindowViewModel.Content, expectedStackPanelViewModel);
            //Assert.AreEqual(1, expectedStackPanelViewModel.Children.ViewModelCollection.Count);
            //Assert.AreSame(expectedTextBoxViewModel, expectedStackPanelViewModel.Children.ViewModelCollection[0]);

            //// View structure, verifying through the ViewModels.
            //Assert.AreSame(expectedStackPanelViewModel, window.GetViewModel().Content);
        }