public void TaskbarThumbButtonBindCommandWithParameter()
        {
            TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();

            Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
            EnqueueShowRealWindow();
            ButtonViewModel        viewModel         = new ButtonViewModel();
            ITaskbarButtonService  taskbarService    = taskbarServiceImpl;
            TaskbarThumbButtonInfo thumbButtonInfo_1 = new TaskbarThumbButtonInfo();

            BindingOperations.SetBinding(thumbButtonInfo_1, TaskbarThumbButtonInfo.CommandParameterProperty, new Binding("CommandParameter")
            {
                Source = viewModel, Mode = BindingMode.OneWay
            });
            BindingOperations.SetBinding(thumbButtonInfo_1, TaskbarThumbButtonInfo.CommandProperty, new Binding("Command")
            {
                Source = viewModel, Mode = BindingMode.OneWay
            });
            taskbarService.ThumbButtonInfos.Add(thumbButtonInfo_1);
            int?parameter = null;

            viewModel.Command          = new DelegateCommand <int?>(p => parameter = p);
            viewModel.CommandParameter = 13;
            RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].Command.Execute(RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].CommandParameter);
            Assert.AreEqual(13, parameter);
        }
예제 #2
0
        // GET: /Account/Opportunities/{id}
        public async Task <ActionResult> Opportunities(Guid id)
        {
            Response.AppendHeader("guid", id.ToString());

            using (var context = await GetCrmContext())
            {
                var query = GetQuery(context);
                var model = query.GetItem(id);

                var viewModel = new AccountReadViewModel
                {
                    Title        = model.Name,
                    Breadcrumb   = new Breadcrumb(),
                    DomainModel  = model,
                    CreateButton = ButtonViewModel.Create(
                        ButtonViewModel.New, "Opportunity",
                        Url.Action("Create", "Opportunity", new { id = model.Id })
                        ),
                    EditButton = ButtonViewModel.Create(
                        ButtonViewModel.Edit, "Account",
                        Url.Action("Edit", "Account", new { id = model.Id }))
                };

                return(View(viewModel));
            }
        }
예제 #3
0
 public static RenderFragment ToRenderFragment(this ButtonUI button, ButtonViewModel model)
 => builder =>
 {
     builder.OpenComponent(0, button.CustomType ?? typeof(DefaultButton));
     builder.AddAttribute(1, nameof(DefaultButton.Model), model);
     builder.CloseComponent();
 };
예제 #4
0
        // GET: Invoice/Details/{id}
        public async Task <ActionResult> Details(Guid id)
        {
            Response.AppendHeader("guid", id.ToString());

            using (var context = await GetCrmContext())
            {
                var query = new InvoiceQuery(context);
                var model = query.GetItem(id);

                var viewModel = new InvoiceReadViewModel
                {
                    Title      = model.Name,
                    Invoice    = model,
                    Breadcrumb = new Breadcrumb
                    {
                        Account     = new OpportunityQuery(context).GetParent(model.OpportunityId.Value),
                        Opportunity = new OpportunityQuery(context).GetItem(model.OpportunityId.Value)
                    },
                    Alerts     = CheckForAlerts(model),
                    OpenButton = ButtonViewModel.Create(ButtonViewModel.Open, "CRM", string.Format("https://trueclarity4.crm4.dynamics.com/main.aspx?etc={0}&id={{{1}}}&pagetype=entityrecord", InvoiceEntity.EntityTypeCode, model.Id)),
                    EditButton = ButtonViewModel.Create(ButtonViewModel.Edit, "Invoice", Url.Action("Edit", new { id = model.Id }))
                };

                return(View(viewModel));
            }
        }
예제 #5
0
        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();
        }
        public TimerPageModel(
            ITrackedPeriodService trackedPeriodService,
            IAccountService accountService,
            IImageService imageService,
            ILocationService locationService,
            IPhotoCapturingService photoCapturingService,
            INotificationService notificationService,
            ViewAllPageModel viewAllPageModel)
        {
            this.trackedPeriodService = trackedPeriodService;
            this.accountService       = accountService;
            this.imageService         = imageService;

            this.locationService       = locationService;
            this.photoCapturingService = photoCapturingService;
            this.notificationService   = notificationService;

            this.viewAllPageModel = viewAllPageModel;

            TimerButtonViewModel       = new ButtonViewModel("start timer", OnTimerButtonPressed);
            AttachPhotoButtonViewModel = new ButtonViewModel("attach photo", OnAttachPhotoButtonClicked, isEnabled: false);

            generalTimer = new Timer {
                Interval = 1000
            };
            generalTimer.Elapsed += (sender, args) => RunningTotal += TimeSpan.FromSeconds(1);

            notificationTimer = new Timer {
                Interval = TimeSpan.FromMinutes(1).TotalMilliseconds
            };
            notificationTimer.Elapsed += async(sender, args) => await OnNotificationTimerElapsed();
        }
예제 #7
0
        public ActionResult Button()
        {
            var model = new ButtonViewModel();

            // Populate
            model.Claims = ExampleMapper.ToClaimWithButtonsViewModelList(UserService.Identity.Claims.AsEnumerable());//MappingEngine.Map<IEnumerable<ClaimWithButtonsViewModel>>(UserService.Identity.Claims.AsEnumerable());

            return(View(model));
        }
예제 #8
0
        public AboutViewModel()
        {
            ButtonUdpViewModel       = new ButtonViewModel(true, "UDP ", Color.IndianRed);
            ButtonTcpViewModel       = new ButtonViewModel(true, "TCP ", Color.IndianRed);
            ButtonWcfViewModel       = new ButtonViewModel(true, "WCF ", Color.IndianRed);
            ButtonStartStopViewModel = new ButtonViewModel(true, "Play/Pause ", Color.BlueViolet);
            LabelCurrentSongTitle    = new LabelViewModel(true, "Keine Daten empfangen", Color.BlueViolet);

            Title = "Am Server verbinden";
        }
예제 #9
0
 public void ShowButtonTest()
 {
     ((ShellViewModelClass)Model).ButtonDescription = "showButtonTest pressed.";
     ButtonNr = "1";
     if (_buttonViewModel == null)
     {
         _buttonViewModel = new ButtonViewModel();
     }
     ActiveItem = _buttonViewModel;
 }
예제 #10
0
 public static ButtonViewModel Create(ButtonViewModel template, string name, string url)
 {
     return(new ButtonViewModel
     {
         Name = name,
         Verb = template.Verb,
         Icon = template.Icon,
         Type = template.Type,
         Url = url
     });
 }
예제 #11
0
        public async Task <IViewComponentResult> InvokeAsync(string text, string glyphicon, string buttontype)
        {
            // Si può eseguire codice di accesso al db, configurazione o altre logiche business. Come un controller normale
            ButtonViewModel model = new ButtonViewModel
            {
                Glyphicon  = string.Concat("glyphicon-", glyphicon),
                ButtonType = buttontype,
                Text       = text
            };

            return(View(model));
        }
        public LoginPageModel(INavigationService navigationService,
                              IAccountService accountService)
        {
            this.accountService    = accountService;
            this.navigationService = navigationService;

            UsernameEntryViewModel = new LoginEntryViewModel("username", false);
            PasswordEntryViewModel = new LoginEntryViewModel("password", true);

            LogInButtonViewModel         = new ButtonViewModel("log in", OnLogin);
            CreateAccountButtonViewModel = new ButtonViewModel("create account", OnCreateAccount);
        }
예제 #13
0
        public void SetMenuButton(string key, ButtonViewModel button)
        {
            ButtonViewModel current;

            if (_lookup.TryGetValue(key, out current))
            {
                MenuButtons.Remove(current);
            }

            _lookup[key] = button;
            MenuButtons.Add(button);
        }
        public void ReturnsCorrectly()
        {
            string buttonText = "ButtonText";
            string value = "Value";

            var viewModel = new ButtonViewModel();
            var htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.SubmitButtonFor( x => x.SubmitButton, buttonText, value );

            string expectedResult = string.Format( "<button name=\"SubmitButton\" type=\"submit\" value=\"{0}\">{1}</button>", value, buttonText );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }
예제 #15
0
        public RestoPageViewModel(IRestoSource restoSource, INavigationService navigationService)
        {
            this.restoSource = restoSource;
            this.MapButton   = new NavigationButtonViewModel(navigationService)
            {
                IconSource  = "ms-appx:///Assets/Icons/Resto-MapIcon.png",
                DisplayName = "Kaart",
                PageToken   = PageTokens.RestoMapPage
            };

            this.RestoInfoList = new ObservableCollection <RestoMenu>();
            GetRestoMenus();
            GetRestoSandwichMenu();
        }
예제 #16
0
        public static MvcHtmlString CreateButtonIfNeeded(this HtmlHelper html, ButtonViewModel bvm)
        {
            StringBuilder result = new StringBuilder();

            if (bvm.NeedToShowButton)
            {
                TagBuilder tagForm = new TagBuilder("form");
                tagForm.Attributes["action"] = string.Format("/{0}/{1}", bvm.Controller, bvm.Method);
                tagForm.Attributes["method"] = "post";
                if (bvm.HiddenParams != null && bvm.HiddenParams.ContainsKey("ajax"))
                {
                    tagForm.Attributes["data-ajax-update"] = bvm.HiddenParams["ajax"];
                    tagForm.Attributes["data-ajax-mode"]   = "replace";
                    tagForm.Attributes["data-ajax"]        = "true";
                    tagForm.Attributes["id"] = "form1";
                }


                var inner = new StringBuilder();
                if (bvm.HiddenParams != null)
                {
                    foreach (var hiddenParam in bvm.HiddenParams)
                    {
                        if (hiddenParam.Key == "ajax")
                        {
                            continue;
                        }
                        var tag = new TagBuilder("input");
                        tag.Attributes["type"]  = "hidden";
                        tag.Attributes["id"]    = tag.Attributes["name"] = hiddenParam.Key;
                        tag.Attributes["value"] = hiddenParam.Value;
                        inner.Append(tag.ToString());
                    }
                }
                TagBuilder tagBut = new TagBuilder("input");
                tagBut.Attributes["type"]  = "submit";
                tagBut.Attributes["value"] = bvm.TextButton;
                inner.Append(tagBut);
                tagForm.InnerHtml = inner.ToString();
                result.Append(tagForm.ToString());
            }
            else
            {
                TagBuilder div = new TagBuilder("div");
                div.InnerHtml = bvm.TextIfNotNeeded;
                result.Append(div.ToString());
            }
            return(MvcHtmlString.Create(result.ToString()));
        }
        public void WithAttributeExpressionReturnsCorrectly()
        {
            string buttonText = "ButtonText";
            string value = "Value";
            string attributeName = "AttributeName";
            string attributeValue = "AttributeValue";

            var viewModel = new ButtonViewModel();
            var htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.SubmitButtonFor( x => x.SubmitButton, buttonText, value, x => x.Attribute( attributeName, attributeValue ) );

            string expectedResult = string.Format( "<button {0}=\"{1}\" name=\"SubmitButton\" type=\"submit\" value=\"{2}\">{3}</button>", attributeName, attributeValue, value, buttonText );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }
예제 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class
        /// </summary>
        /// <param name="dbBridge">The database bridge</param>
        /// <param name="externalFilterProvider">The external filter provider</param>
        public MainViewModel(IDatabaseBridge dbBridge, IExternalFilterProvider externalFilterProvider)
        {
            if (dbBridge == null)
            {
                throw new ArgumentNullException(nameof(dbBridge));
            }
            if (externalFilterProvider == null)
            {
                throw new ArgumentNullException(nameof(externalFilterProvider));
            }

            _dbBridge = dbBridge;
            DataSetDescriptorBuilder.FilterProvider = externalFilterProvider;

            ViewLoadVm = new ButtonViewModel
            {
                Command = new AsyncRelayCommand(
                    o => DoLoadView(),
                    o => !IsBusy,
                    o => IsBusy = true,
                    o => IsBusy = false)
            };

            SaveCubeVm = new ButtonViewModel
            {
                Command = new AsyncRelayCommand(
                    o => DoSaveCube((TOLAPAnalysis)o),
                    o => !IsBusy && _isCubeLoaded && _currentCubeConfig != null,
                    o => IsBusy = true,
                    o => IsBusy = false)
            };
            SaveCubeAsVm = new ButtonViewModel
            {
                Command = new AsyncRelayCommand(
                    o => DoSaveCubeAs((TOLAPAnalysis)o),
                    o => !IsBusy && _isCubeLoaded && _currentDataSetConfig != null,
                    o => IsBusy = true,
                    o => IsBusy = false)
            };
            DeleteCubeVm = new ButtonViewModel
            {
                Command = new AsyncRelayCommand(
                    o => DoDeleteCube((TOLAPAnalysis)o),
                    o => !IsBusy && _isCubeLoaded && _currentCubeConfig != null,
                    o => IsBusy = true,
                    o => IsBusy = false)
            };
        }
예제 #19
0
        public void WithHtmlAttributesDictionaryReturnsCorrectly()
        {
            string buttonText = "ButtonText";
            string value = "Value";
            string attributeName = "AttributeName";
            string attributeValue = "AttributeValue";

            var htmlAttributes = new Dictionary<string, object>();
            htmlAttributes.Add( attributeName, attributeValue );

            var viewModel = new ButtonViewModel();
            var htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.ButtonFor( x => x.Button, buttonText, value, htmlAttributes );

            string expectedResult = string.Format( "<button {0}=\"{1}\" name=\"Button\" type=\"button\" value=\"{2}\">{3}</button>", attributeName, attributeValue, value, buttonText );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }
 public MainViewModel()
 {
     ResetCommand = new DelegateCommand(_Reset);
     for (int i = 0; i < Settings.Default.Colors.Count; i++)
     {
         ButtonViewModel buttonModel = new ButtonViewModel(i)
         {
             Color = Settings.Default.Colors[i]
         };
         Buttons.Add(buttonModel);
         buttonModel.PropertyChanged += (s, e) =>
         {
             ButtonViewModel model = (ButtonViewModel)s;
             Settings.Default.Colors[model.ButtonIndex] = model.Color;
             Settings.Default.Save();
         };
     }
 }
        public ProfilePageModel(
            IAccountService accountService,
            ITrackedPeriodService trackedPeriodService,
            INavigationService navigationService,
            ViewAllPageModel viewAllPageModel,
            TimerPageModel timerPageModel)
        {
            this.accountService       = accountService;
            this.trackedPeriodService = trackedPeriodService;
            this.navigationService    = navigationService;
            this.viewAllPageModel     = viewAllPageModel;
            this.timerPageModel       = timerPageModel;

            UsernameEntryViewModel = new LoginEntryViewModel("username", isPassword: false);
            PasswordEntryViewModel = new LoginEntryViewModel("password", isPassword: true);

            UpdatePasswordButtonViewModel = new ButtonViewModel("update password", OnUpdatePasswordButtonPressed);
            ClearUserDataButtonViewModel  = new ButtonViewModel("clear data", OnClearDataButtonPressed);
            LogOutButtonViewModel         = new ButtonViewModel("log out", OnLogOutButtonPressed);
        }
예제 #22
0
        public PartialViewResult SubmitButton(ButtonViewModel bvm)
        {
            if (bvm == null)
            {
                bvm = new ButtonViewModel()
                {
                    NeedToShowButton = false, TextIfNotNeeded = "Произошла ошибка."
                }
            }
            ;
            var week     = weekProvider.GetCurrentWeek();
            var userName = userProvider.GetUserName(this);

            if (bvm.NeedToShowButton)
            {
                bvm.NeedToShowButton = !userProvider.IsAuthentificated(this) ||
                                       !voteRepository.Votes.Any(v => v.User == userName && v.Week == week);
            }
            return(PartialView(bvm));
        }
    }
        public List <ButtonViewModel> GetButtonListByUserIdAndMenuId(int userId, string url, PositionEnum position)
        {
            List <ButtonViewModel> buttonViewModels = new List <ButtonViewModel>();
            var sysActionButtons = dao.GetList(x => true).ToList();
            var menu             = SysActionMenuDao.GetList(x => x.Url == url).FirstOrDefault();

            if (menu == null)
            {
                return(buttonViewModels);
            }
            var sysActionList = SysActionService.GetPermissionByType(userId, ActionTypeEnum.Button)
                                .Where(x => x.ParentId == menu.Id && x.SysActionButton.Location == position).OrderBy(x => x.SortCode).ToList();

            foreach (var item in sysActionList)
            {
                ButtonViewModel buttonViewModel = new ButtonViewModel();
                buttonViewModel.FullName   = item.Name;
                buttonViewModel.ButtonCode = item.SysActionButton.ButtonCode;
                buttonViewModel.ClassName  = item.SysActionButton.ButtonClass;
                buttonViewModel.Icon       = item.SysActionButton.ButtonIcon;
                buttonViewModels.Add(buttonViewModel);
            }
            return(buttonViewModels);
        }
 public static IHtmlContent GovUkButton(
     this IHtmlHelper htmlHelper,
     ButtonViewModel buttonViewModel)
 {
     return(htmlHelper.Partial("/GovUkDesignSystemComponents/Button.cshtml", buttonViewModel));
 }
예제 #25
0
 /// <summary>
 /// for tests only!!!
 /// </summary>
 public DefaultDialogOperationViewModel(ButtonViewModel buttonViewModel)
 {
     this.AgreeSelectionField        = buttonViewModel;
     this.DisagreeSelectionField     = buttonViewModel;
     this.NewDirectorySelectionField = buttonViewModel;
 }
예제 #26
0
 private void ClickButton(TemporaryDispatcherThread thread, ButtonBarViewModel viewModel, ButtonViewModel button, object parameter = null)
 {
     Assert.True(button.Command.CanExecute(parameter), "The button should be enabled.");
     Assert.True(viewModel.ActionButtons.Contains(button), "The button should be visible.");
     thread.Invoke(() => { button.Command.Execute(parameter); });
     viewModel.NuGetViewModel.WaitUntilComplete();
 }
 private DefaultDialogOperationViewModel CreateTestDialogOperationVM(ButtonViewModel fakeButtonViewModel = null)
 {
     fakeButtonViewModel = fakeButtonViewModel ?? Substitute.For <ButtonViewModel>();
     return(new DefaultDialogOperationViewModel(fakeButtonViewModel));
 }
예제 #28
0
        // GET: MyButton/MyButton

        public ViewResult MyButton()
        {
            var model = new ButtonViewModel(GetDataSourceItem <ButtonScModel>(), GetRenderingParameters <ButtonRP>());

            return(View("~/Areas/MyButton/Views/MyButton/MyButton.cshtml", model));
        }
예제 #29
0
 private void ClickButton(TemporaryDispatcherThread thread, ButtonBarViewModel viewModel, ButtonViewModel button, object parameter = null)
 {
     Assert.True(button.Command.CanExecute(parameter), "The button should be enabled.");
     Assert.True(viewModel.ActionButtons.Contains(button), "The button should be visible.");
     thread.Invoke(() => { button.Command.Execute(parameter); });
     viewModel.NuGetViewModel.WaitUntilComplete();
 }
예제 #30
0
 public ActionResult Button(ButtonViewModel model)
 {
     return(View(model));
 }
 public void TaskbarThumbButtonBindCommandWithParameter() {
     TaskbarButtonService taskbarServiceImpl = new TaskbarButtonService();
     Interaction.GetBehaviors(RealWindow).Add(taskbarServiceImpl);
     EnqueueShowRealWindow();
     ButtonViewModel viewModel = new ButtonViewModel();
     ITaskbarButtonService taskbarService = taskbarServiceImpl;
     TaskbarThumbButtonInfo thumbButtonInfo_1 = new TaskbarThumbButtonInfo();
     BindingOperations.SetBinding(thumbButtonInfo_1, TaskbarThumbButtonInfo.CommandParameterProperty, new Binding("CommandParameter") { Source = viewModel, Mode = BindingMode.OneWay });
     BindingOperations.SetBinding(thumbButtonInfo_1, TaskbarThumbButtonInfo.CommandProperty, new Binding("Command") { Source = viewModel, Mode = BindingMode.OneWay });
     taskbarService.ThumbButtonInfos.Add(thumbButtonInfo_1);
     int? parameter = null;
     viewModel.Command = new DelegateCommand<int?>(p => parameter = p);
     viewModel.CommandParameter = 13;
     RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].Command.Execute(RealWindow.TaskbarItemInfo.ThumbButtonInfos[0].CommandParameter);
     Assert.AreEqual(13, parameter);
 }
예제 #32
0
 public ButtonPage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);
     BindingContext = _viewModel = new ButtonViewModel();
 }
예제 #33
0
 public async Task <IViewComponentResult> InvokeAsync(ButtonViewModel model)
 {
     return(View(model));
 }
예제 #34
0
 public ButtonPage()
 {
     InitializeComponent();
     BindingContext = new ButtonViewModel("This is a label text");
 }
예제 #35
0
 public static IHtmlContent GovUkButton(
     this IHtmlHelper htmlHelper,
     ButtonViewModel buttonViewModel)
 {
     return(htmlHelper.Partial("~/Partials/Button.cshtml", buttonViewModel));
 }