示例#1
0
        public ActionResult Index()
        {
            var variants = new List <SelectListItem>();

            for (int i = 1; i < 26; i++)
            {
                variants.Add(new SelectListItem
                {
                    Text  = EnumValuesParser.GetVariantModel(i).Caption,
                    Value = i.ToString()
                });
            }

            ViewBag.Variants = variants;

            var model = new InputViewModel
            {
                Variant     = 1,
                InputType   = true,
                ManualInput = new InputModel(),
                OutputSize  = 190
            };

            return(View(model));
        }
示例#2
0
        public string ShowWorkspaceNameWindow(string currentName, Func <string, bool> validationRule)
        {
            if (string.IsNullOrEmpty(currentName))
            {
                currentName = "Default workspace";
            }

            var input = new ValueInput
            {
                Title          = "Barcodes - Workspace",
                ContentHeader  = "Enter workspace's name",
                Label          = "Name:",
                InputValue     = currentName,
                ValidationRule = validationRule
            };

            var dataContext = new InputViewModel(input);
            var window      = new InputWindow(dataContext)
            {
                Owner = MainWindow
            };

            window.ShowDialog();
            return(dataContext.Result);
        }
示例#3
0
        public void TestInput_ShouldRenderCorrectViewWithModel()
        {
            // Arrange
            var model = new InputViewModel();

            var mockedFactory = new Mock <IViewModelFactory>();

            mockedFactory.Setup(f => f.CreateInputViewModel(It.IsAny <DateTime>())).Returns(model);

            var date = new DateTime();

            var mockedDateTimeProvider = new Mock <IDateTimeProvider>();

            mockedDateTimeProvider.Setup(p => p.GetCurrentTime()).Returns(date);

            var mockedNutritionService = new Mock <INutritionService>();

            var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>();

            var controller = new NutritionController(mockedFactory.Object, mockedDateTimeProvider.Object,
                                                     mockedNutritionService.Object, mockedAuthenticationProvider.Object);

            // Act, Assert
            controller
            .WithCallTo(c => c.Input())
            .ShouldRenderDefaultView()
            .WithModel <InputViewModel>(m => Assert.AreSame(model, m));
        }
示例#4
0
 public InputModel(Person person, InputViewModel inputViewModel)
 {
     _person         = person;
     _inputViewModel = inputViewModel;
     _periodFrom     = new DateTime(DateTime.Now.Year - 135, DateTime.Now.Month, DateTime.Now.Day,
                                    DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
 }
示例#5
0
 public BoardViewModel()
 {
     _elements = new ObservableRangeCollection <ElementViewModel>();
     _session  = new SessionViewModel();
     _sync     = SynchronizationContext.Current;
     _input    = new InputViewModel();
 }
示例#6
0
        public IActionResult ResolveDependencies([FromBody] InputViewModel input)
        {
            var dependencies = _dependencyResolverService.ParseRawInput(input.Input);

            _dependencyResolverService.ResolveDependencies(dependencies);
            return(Ok(dependencies.Select(x => x.ToString())));
        }
示例#7
0
        public void OnGet()
        {
            List <Product> Products = new List <Product>();

            Products.Add(new Product
            {
                Name        = "T-Shirt",
                Description = "Blue, XL",
                SKU         = "SKU01",
                UnitPrice   = 55.99M,
                Quantity    = 1
            });
            Products.Add(new Product
            {
                Name        = "Shoes",
                Description = "Running Shoes, Size 9.5",
                SKU         = "SKU01",
                UnitPrice   = 101.99M,
                Quantity    = 1
            });

            Input = new InputViewModel
            {
                Products     = Products,
                ShippingCost = 12.5M,
                HandlingCost = 7.8M,
                TaxRate      = 0.085M
            };
        }
示例#8
0
        private void InitializeInputDevices()
        {
            // Clear the list before we add new items
            _inputViewModels.Clear();

            for (int i = 0; i < FtInterfaceInstanceProvider.Instance.GetInputCount(); i++)
            {
                // Create a new instance and add it to the list
                var inputViewModel = new InputViewModel
                {
                    Context       = Activity,
                    InputIndex    = i,
                    InputValue    = 0,
                    InputMaxValue = 1
                };

                _inputViewModels.Add(inputViewModel);
            }

            // When we are already connected we load the configuration
            if (FtInterfaceInstanceProvider.Instance != null)
            {
                if (FtInterfaceInstanceProvider.Instance.Connection == ConnectionStatus.Online)
                {
                    ConfigureInputPorts();
                }
            }

            // Update the list on the ui thread
            Activity?.RunOnUiThread(() =>
            {
                _listAdapter?.NotifyDataSetChanged();
            });
        }
示例#9
0
        public async Task <IActionResult> Details(string Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            var Input = await _db.Inputs.FindAsync(Id);

            if (Input == null)
            {
                return(NotFound());
            }
            else
            {
                InputVM = new InputViewModel()
                {
                    Input      = Input,
                    inputInfos = _db.InputInfos
                                 .Include(d => d.Product)
                                 .Include(d => d.Supplier)
                                 .Where(d => d.InputId == Id).ToList()
                };
            }
            return(View(InputVM));
        }
示例#10
0
        public IActionResult Format(InputViewModel inputViewModel)
        {
            HtmlParserOptions htmlParserOptions = new HtmlParserOptions();
            var parser = new HtmlParser(htmlParserOptions);

            var document = parser.ParseDocument(inputViewModel.tbInput);

            var sw = new StringWriter();
            PrettyMarkupFormatter prettyMarkupFormatter = new PrettyMarkupFormatter();

            document.ToHtml(sw, prettyMarkupFormatter);

            var formattedHtml = sw.ToString();

            string guid = Guid.NewGuid().ToString();


            var result = new OutputViewModel()
            {
                RawHtml       = inputViewModel.tbInput,
                FormattedHtml = formattedHtml,
                Guid          = guid,
            };

            memoryCache.Set(guid, formattedHtml);

            return(Json(result));
        }
        public async Task <JsonResult> SubmitAsync(InputViewModel model)
        {
            var response = new ResponseViewModel();

            if (!ModelState.IsValid)
            {
                response.Status = (int)Status.UserError;

                return(Json(response));
            }

            try
            {
                var result = await _userService.SubmitAsync(ParseToUserDataModel(model));

                response.Status = (int)result;

                return(Json(response));
            }
            catch
            {
                response.Status = (int)Status.Errored;

                return(Json(response));
            }
        }
示例#12
0
 public MainWindowViewModel()
 {
     CompositeDisposable.Add(_backstageViewModel  = new BackstageViewModel());
     CompositeDisposable.Add(this._inputViewModel = new InputViewModel());
     CompositeDisposable.Add(_mainAreaViewModel   = new MainAreaViewModel());
     CompositeDisposable.Add(_globalAccountSelectionFlipViewModel = new AccountSelectionFlipViewModel());
     CompositeDisposable.Add(_settingFlipViewModel          = new SettingFlipViewModel(this));
     CompositeDisposable.Add(_tabConfigurationFlipViewModel = new TabConfigurationFlipViewModel());
     CompositeDisposable.Add(_searchFlipViewModel           = new SearchFlipViewModel());
     CompositeDisposable.Add(Observable
                             .FromEvent <FocusRequest>(
                                 h => MainWindowModel.FocusRequested += h,
                                 h => MainWindowModel.FocusRequested -= h)
                             .Subscribe(SetFocus));
     CompositeDisposable.Add(Observable
                             .FromEvent <bool>(
                                 h => MainWindowModel.BackstageTransitionRequested += h,
                                 h => MainWindowModel.BackstageTransitionRequested -= h)
                             .Subscribe(this.TransitionBackstage));
     CompositeDisposable.Add(Setting.BackgroundImagePath.ListenValueChanged(
                                 _ =>
     {
         RaisePropertyChanged(() => BackgroundImageUri);
         RaisePropertyChanged(() => BackgroundImage);
     }));
     CompositeDisposable.Add(Setting.BackgroundImageTransparency.ListenValueChanged(
                                 _ => RaisePropertyChanged(() => BackgroundImageOpacity)));
     CompositeDisposable.Add(Setting.RotateWindowContent.ListenValueChanged(
                                 _ => RaisePropertyChanged(() => RotateWindowContent)));
     this._backstageViewModel.Initialize();
 }
示例#13
0
 public ActionResult CheckAction(InputViewModel viewModel)
 {
     try
     {
         FileSecurity sec = System.IO.File.GetAccessControl(@"d:\new");
         AuthorizationRuleCollection rules = sec.GetAccessRules(true, true,
                                                                typeof(NTAccount));
         foreach (FileSystemAccessRule rule in rules)
         {
             InputViewModel.ErrorMessage = rule.AccessControlType.ToString();       // Allow or Deny
             InputViewModel.ErrorMessage = rule.FileSystemRights.ToString();        // e.g., FullControl
             InputViewModel.ErrorMessage = rule.IdentityReference.Value.ToString(); // e.g., MyDomain/Joe
         }
         var    sid                   = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
         string usersAccount          = sid.Translate(typeof(NTAccount)).ToString();
         FileSystemAccessRule newRule = new FileSystemAccessRule
                                            (usersAccount, FileSystemRights.ExecuteFile, AccessControlType.Allow);
         sec.AddAccessRule(newRule);
         System.IO.File.SetAccessControl(@"d:\new", sec);
     }
     catch (Exception e)
     {
         InputViewModel.ErrorMessage  = "Another Error occur while playing ";
         InputViewModel.ErrorMessage += e.Message;
     }
     return(View("Notify", viewModel));
 }
示例#14
0
        /// <summary>
        /// Calculate meeting time
        /// </summary>
        public void CalcMeetingTimes()
        {
            if (Context.CurrentCommand is DefaultCommand)
            {
                var command = (DefaultCommand)Context.CurrentCommand;
                if (command != null && command.Parameters != null)
                {
                    var meetingTimes = _teamLeaderService.ApplyforMeeting(InputViewModel.ConvertToMeetingModel(command.Parameters));

                    if (meetingTimes.Count() > 0)
                    {
                        ShowTips(string.Format("If you are looking for {2} Person having a meeting.{0}{1}", ConstantTips.CompleteTip,
                                               string.Join(",", meetingTimes),
                                               command.Parameters.Number));
                    }
                    else
                    {
                        ShowTips(ConstantTips.NotenoughTip);
                    }
                }
                else
                {
                    ShowTips(ConstantTips.InputErrTip);
                }

                ShowTips($"{ConstantTips.InputTip}{ConstantTips.ExitTip}");
            }
            else
            {
                ShowTips(ConstantTips.InputErrTip);
            }
        }
示例#15
0
        private void YouTubeComments(InputViewModel viewModel, string youTubeUrl, string videoId)
        {
            using (var client = new HttpClient())
            {
                var commentList = new List <CommentViewModel>();
                client.BaseAddress = new Uri("https://www.googleapis.com");
                var responseTask = client.GetAsync(youTubeUrl);
                responseTask.Wait();
                var result      = responseTask.Result;
                var stringAsync = result.Content.ReadAsStringAsync().Result;

                //var convertToJson = JsonConvert.DeserializeObject(stringAsync);
                var convertToJson = JObject.Parse(stringAsync);
                var items         = convertToJson["items"];

                if (!result.IsSuccessStatusCode || !items.Any())
                {
                    viewModel.CommentLength = 0;
                }
                else
                {
                    ProcessMoreYouTubeComments(viewModel, items, commentList, convertToJson, videoId, client);
                }
            }
        }
示例#16
0
        private void AddingItems_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            bool shiftPressed = CoreWindow.GetForCurrentThread()
                                .GetKeyState(VirtualKey.Shift) == CoreVirtualKeyStates.Down;

            if (e.Key == VirtualKey.Tab &&
                shiftPressed)
            {
                if (InputViewModel.SelectedIndex == 0)
                {
                    e.Handled = true;
                    InputViewModel.AddFront();
                }
            }
            else
            {
                if (e.Key == VirtualKey.Tab)
                {
                    if (InputViewModel.SelectedIndex == InputViewModel.LastIndex)
                    {
                        e.Handled = true;
                        InputViewModel.AddBack();
                    }
                }
            }
        }
示例#17
0
        public void ModelChangedHandlerTest()
        {
            var input = new InputViewModel <int, string>(Converters.IntStringWithExeption);

            input.Model = 1;

            var newValue = -1;
            var oldValue = -1;
            var count    = 0;

            input.HandleModelChanged = (nwv, old) =>
            {
                newValue = nwv;
                oldValue = old;
                count++;
            };

            input.Model = 2;

            Assert.AreEqual(2, newValue);
            Assert.AreEqual(1, oldValue);
            Assert.AreEqual(1, count);

            input.EditValueAndUpdateModel(3.ToString());

            Assert.AreEqual(3, newValue);
            Assert.AreEqual(2, oldValue);
            Assert.AreEqual(2, count);
        }
示例#18
0
        public void EditWithReverterTest()
        {
            var msg           = "test validation error";
            var defValue      = -1;
            var preValue      = -1;
            var revertedValue = 10;

            var validator = new TestValidator <int, string>(msg);
            var reverter  = new TestReverter <int, string>((def, prev) => {
                defValue = def;
                preValue = prev;

                return(revertedValue);
            });

            var input = new InputViewModel <int, string>(Converters.IntStringWithExeption, validator, reverter);

            validator.SetIsValid(true);
            input.Model        = 1;
            input.DefaultModel = 11;
            validator.SetIsValid(false);
            input.EditValueAndUpdateModel(2.ToString());

            Assert.AreEqual(revertedValue, input.Model);
            Assert.AreEqual(11, defValue);
            Assert.AreEqual(1, preValue);

            Assert.AreEqual(revertedValue.ToString(), input.View);
            Assert.IsFalse(input.IsValid);
            Assert.AreEqual(msg, input.ErrorMessage);
        }
示例#19
0
        public void ViewSetTest()
        {
            var input = new InputViewModel <int, string>(Converters.IntStringWithExeption);

            input.DefaultModel = 1;

            using (var subscriber = new PropertyChangedSubscriber(input))
            {
                input.EditValue(10.ToString());

                Assert.AreEqual(10.ToString(), input.View);
                Assert.AreEqual(1, input.Model);
                Assert.AreEqual(1, input.DefaultModel);

                input.EndEditing();

                Assert.AreEqual(10.ToString(), input.View);
                Assert.AreEqual(10, input.Model);
                Assert.AreEqual(1, input.DefaultModel);

                CollectionAssert.AreEquivalent(
                    new[] { nameof(input.View), nameof(input.Model) },
                    subscriber.Sequence
                    );
            }
        }
示例#20
0
        private void RemoveCommandExecute(object o)
        {
            HierarchicalResultViewModel vm = Hierarchical.Selected;

            if (vm == null)
            {
                return;
            }

            ICardCollection sourceCollection = _magicDatabase.GetAllCollections().First(cc => cc.Name == Hierarchical.Name);

            InputViewModel questionViewModel = InputViewModelFactory.Instance.CreateQuestionViewModel("Remove", string.Format("Remove selected from {0}?", sourceCollection.Name));

            OnInputRequested(questionViewModel);

            if (questionViewModel.Result == true)
            {
                using (_magicDatabaseForCardInCollection.BatchMode())
                {
                    foreach (ICardInCollectionCount cicc in GetCardInCollectionInSelected(vm, sourceCollection))
                    {
                        ICardCount cardCount = new CardCount();
                        foreach (KeyValuePair <ICardCountKey, int> kv in cicc.GetCardCount())
                        {
                            cardCount.Add(kv.Key, -kv.Value);
                        }

                        _magicDatabaseForCardInCollection.InsertOrUpdateCardInCollection(sourceCollection.Id, cicc.IdGatherer, cicc.IdLanguage, cardCount);
                    }
                }

                LoadCardsHierarchy();
            }
        }
示例#21
0
        public ActionResult XmlToJson()
        {
            InputViewModel model = new InputViewModel();

            ViewBag.Input = "<Root><FirstName>santosh</FirstName><LastName>Singh</LastName></Root>";
            return(View(model));
        }
示例#22
0
        public InputAreaView()
        {
            InitializeComponent();
            var viewModel = new InputViewModel();

            this.DataContext = viewModel;
        }
 public InputPage()
 {
     InitializeComponent();
     BindingContext = new InputViewModel
     {
         Page = this
     };
 }
示例#24
0
 public void Setup()
 {
     mExecutor             = Substitute.For <IWpfCalculationExecutor>();
     mArguments            = Substitute.For <IApplicationArguments>();
     mAggregator           = Substitute.For <IEventAggregator>();
     mInputStringValidator = Substitute.For <InputStringValidator>();
     mUnderTest            = new InputViewModel(mExecutor, mArguments, mAggregator, mInputStringValidator);
 }
示例#25
0
        public void Setup()
        {
            var    size = 10;
            string id   = "Circle";

            inputViewModel = new InputViewModel();
            inputViewModel.Circle_Create(size);
        }
示例#26
0
        public ActionResult SHA(string id)
        {
            InputViewModel model = new InputViewModel();
            var            desc  = HashInfo.GetHashInfo(id);

            model.Description = desc;
            return(View(model));
        }
示例#27
0
        public IActionResult GcpInput()
        {
            var viewModel = new InputViewModel
            {
                RequestUrl = @"/Ocr/GcpAnalyze"
            };

            return(View("Input", viewModel));
        }
示例#28
0
        public ActionResult UTFToAsci(InputViewModel model)
        {
            InputViewModel inputViewModel = new InputViewModel();

            inputViewModel.Input  = model.Input;
            inputViewModel.Output = model.Input.EncodeNonAsciiCharacters();
            this.ModelState.Clear();
            return((ActionResult)this.View((object)inputViewModel));
        }
示例#29
0
        private void OnOpenFileDialog(InputViewModel vm)
        {
            var e = OpenFileDialog;

            if (e != null)
            {
                e(this, new EventArgs <InputViewModel>(vm));
            }
        }
示例#30
0
        public InputView()
        {
            InputViewModel inputViewModel = new InputViewModel();

            InitializeComponent();

            this.DataContext = inputViewModel;
            this.InputInnerFrame.Navigated += inputViewModel.ClearFrameCache;
        }