Ejemplo n.º 1
0
        /// <summary>
        /// Initialize new intance
        /// </summary>
        public TourPageViewModel(INavigationService navigationService, ISettingsService applicationService)
        {
            this.navigationService  = navigationService;
            this.applicationService = applicationService;

            this.LoginCommand = DelegateCommand.FromAsyncHandler(this.OnLoginCommand);
        }
Ejemplo n.º 2
0
 public LoginViewModel(INavigationService navigationService, IEventAggregator eventAggregator, IStoreManager storeManager, IToast toast, IFavoriteService favoriteService, ILoggerFacade logger, ILaunchTwitter twitter, ISSOClient ssoClient, IPushNotifications pushNotifications, IReminderService reminderService, IPageDialogService pageDialogService)
     : base(navigationService, eventAggregator, storeManager, toast, favoriteService, logger, twitter, ssoClient, pushNotifications, reminderService, pageDialogService)
 {
     if (!Settings.FirstRun)
     {
         Title = "My Account";
         var cancel = new ToolbarItem
         {
             Text    = "Cancel",
             Command = DelegateCommand.FromAsyncHandler(async() =>
             {
                 if (IsBusy)
                 {
                     return;
                 }
                 await Finish();
                 Settings.FirstRun = false;
             }).ObservesCanExecute((arg) => IsBusy)
         };
         if (Device.OS != TargetPlatform.iOS)
         {
             cancel.Icon = "toolbar_close.png";
         }
         ToolBarItems.Add(cancel);
     }
 }
Ejemplo n.º 3
0
        public void DelegateCommandFromAsyncHandlerCanExecuteShouldBeTrueByDefault()
        {
            var command    = DelegateCommand.FromAsyncHandler(async() => await Task.Run(() => { }));
            var canExecute = command.CanExecute();

            Assert.True(canExecute);
        }
Ejemplo n.º 4
0
        public LoginViewModel(LoginView loginView)
        {
            _loginView        = loginView;
            _netCheckService  = DependencyResolver.Current.GetService <INetCheckService>();
            _localDataManager = DependencyResolver.Current.GetService <ILocalDataManager>();
            _bmsService       = DependencyResolver.Current.GetService <IBms>();

            _meetingSdkAgent = DependencyResolver.Current.GetService <IMeetingSdkAgent>();
            _eventAggregator = DependencyResolver.Current.GetService <IEventAggregator>();
            _windowManager   = DependencyResolver.Current.GetService <IMeetingWindowManager>();

            LoginingCommand = DelegateCommand.FromAsyncHandler(LoginingAsync);

            //RegisterEvents();
            GlobalData.Instance.ModeList = new List <Mode>
            {
                new Mode {
                    Name = "自动", ReceiveCommand = true
                },
                new Mode {
                    Name = "键盘", ReceiveCommand = false
                }
            };
            GlobalData.Instance.CurrentMode = GlobalData.Instance.ModeList.FirstOrDefault();
        }
Ejemplo n.º 5
0
        public CustomerDetailUserControlViewModel()
        {
            this.MakeIMCommand = DelegateCommand <string> .FromAsyncHandler(async(emailId) =>
            {
                await Launcher.LaunchUriAsync(new Uri("skype:shoaibrafi?chat"));
            }, (emailId) => { return(!string.IsNullOrEmpty(emailId)); });

            this.MakeSkypeCallCommand = DelegateCommand <string> .FromAsyncHandler(async (number) =>
            {
                await Launcher.LaunchUriAsync(new Uri("audiocall-skype-com:" + number));
            }, (number) => { return(!string.IsNullOrEmpty(number)); });

            this.MailToCommand = DelegateCommand <string> .FromAsyncHandler(async (email) =>
            {
                await Launcher.LaunchUriAsync(new Uri("mailto:" + email));
            }, (email) => { return(!string.IsNullOrEmpty(email)); });

            this.LocateCommand = DelegateCommand <string> .FromAsyncHandler(async (address) =>
            {
                await Launcher.LaunchUriAsync(new Uri("bingmaps:?where=" + Regex.Replace(address, "\n", ",")));
            }, (address) =>
            {
                return(!string.IsNullOrEmpty(address));
            });
        }
Ejemplo n.º 6
0
 public HistoryPageViewModel()
 {
     // ***
     // *** Set up the commands
     // ***
     this.RefreshCommand = DelegateCommand.FromAsyncHandler(this.OnRefresh, this.OnCanRefresh);
 }
        public CustomerDetailUserControlViewModel()
        {
            this.Location      = new Bing.Maps.Location();
            this.MakeIMCommand = DelegateCommand <string> .FromAsyncHandler(async (emailId) =>
            {
                await Launcher.LaunchUriAsync(new Uri("skype:shoaibrafi?chat"));
            }, (emailId) => { return(!string.IsNullOrEmpty(emailId)); });

            this.MakeSkypeCallCommand = DelegateCommand <string> .FromAsyncHandler(async (number) =>
            {
                await Launcher.LaunchUriAsync(new Uri("audiocall-skype-com:" + number));
            }, (number) => { return(!string.IsNullOrEmpty(number)); });

            this.MailToCommand = DelegateCommand <string> .FromAsyncHandler(async (email) =>
            {
                await Launcher.LaunchUriAsync(new Uri("mailto:" + email));
            }, (email) => { return(!string.IsNullOrEmpty(email)); });

            this.LocateCommand = DelegateCommand <string> .FromAsyncHandler(async (address) =>
            {
                //await this.GeocodeAddressAsync(Regex.Replace(address, "\n", ","));
                //var stringBuilder = new StringBuilder("bingmaps:?rtp=pos.");
                //stringBuilder.Append(Location.Latitude);
                //stringBuilder.Append("_");
                //stringBuilder.Append(Location.Longitude);
                var stringBuilder = new StringBuilder("bingmaps:?where=" + Regex.Replace(address, "\n", ","));
                await Launcher.LaunchUriAsync(new Uri(stringBuilder.ToString()));
            }, (address) =>
            {
                return(!string.IsNullOrEmpty(address));
            });
        }
Ejemplo n.º 8
0
 public void DelegateCommandFromAsyncHandlerWithNullCanExecuteFuncShouldThrow()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var command = DelegateCommand.FromAsyncHandler(async() => await Task.Run(() => { }), null);
     });
 }
Ejemplo n.º 9
0
        public InteractiveContentViewModel(InteractiveContentView interactiveContentView)
        {
            _interactiveContentView = interactiveContentView;

            _bmsService            = IoC.Get <IBms>();
            _sdkService            = IoC.Get <IMeeting>();
            _lessonInfo            = IoC.Get <LessonInfo>();
            _groupManager          = IoC.Get <IGroupManager>();
            _visualizeShellService = IoC.Get <IVisualizeShell>();
            _eventAggregator       = IoC.Get <IEventAggregator>();
            _regionManager         = IoC.Get <IRegionManager>();

            _eventAggregator.GetEvent <CommandReceivedEvent>()
            .Subscribe(ExecuteCommand, ThreadOption.PublisherThread, false,
                       command => command.Directive == GlobalCommands.Instance.GotoClassCommand.Directive);
            ParticipateOrWatchCommand = DelegateCommand.FromAsyncHandler(ParticipateOrWatchAsync);
            SelectionChangedCommand   = DelegateCommand <LessonInfo> .FromAsyncHandler(SelectionChangedAsync);

            LoadCommand           = DelegateCommand.FromAsyncHandler(LoadAsync);
            RefreshCommand        = DelegateCommand.FromAsyncHandler(RefreshAsync);
            CloseMainPointCommand = new DelegateCommand(() => { ShowMainPoint = false; });
            ShowMainPointCommand  = new DelegateCommand(() => { ShowMainPoint = true; });
            GotoSettingCommand    = new DelegateCommand(GotoSetting);

            Attendees = new ObservableCollection <UserInfo>();
            Lessons   = new ObservableCollection <LessonInfo>();
        }
Ejemplo n.º 10
0
        public AddCustomerPageViewModel(IEventAggregator eventAggregator)
        {
            this.Model              = new AlternateContactPerson();
            this._eventAggregator   = eventAggregator;
            this.AddCustomerCommand = DelegateCommand.FromAsyncHandler(async() =>
            {
                if (this.CDUserInfo == null)
                {
                    this.CDUserInfo = JsonConvert.DeserializeObject <CDUserInfo>(ApplicationData.Current.RoamingSettings.Values[Constants.UserInfo].ToString());
                }
                this.Model.UserId = this.CDUserInfo.UserId;
                var alternateData = await SqliteHelper.Storage.LoadTableAsync <AlternateContactPerson>();
                if (alternateData != null && alternateData.Any(a => a.FirstName == this.Model.FirstName && a.Surname == this.Model.Surname))
                {
                    //await SqliteHelper.Storage.UpdateSingleRecordAsync<AlternateContactPerson>(this.Model);
                }
                else
                {
                    await SqliteHelper.Storage.InsertSingleRecordAsync <AlternateContactPerson>(this.Model);
                }

                this._eventAggregator.GetEvent <AlternateContactPersonEvent>().Publish(this.Model);
            });

            this.ClearCustomerCommand = new DelegateCommand(() =>
            {
                this.Model = new AlternateContactPerson();
                this._eventAggregator.GetEvent <AlternateContactPersonEvent>().Publish(this.Model);
            });
        }
Ejemplo n.º 11
0
        public VideoSettingModel(VideoSettingView view)
        {
            _view             = view;
            _cameraDeviceList = new List <VideoDeviceModel>();
            _docDeviceList    = new List <VideoDeviceModel>();
            _s = new InputSimulator();

            _configManager    = new ConfigManager();
            _meetingSdkAgent  = DependencyResolver.Current.GetService <IMeetingSdkAgent>();
            _localDataManager = DependencyResolver.Current.GetService <ILocalDataManager>();

            _deviceNameAccessor = DependencyResolver.Current.GetService <IDeviceNameAccessor>();
            _deviceConfigLoader = DependencyResolver.Current.GetService <IDeviceConfigLoader>();

            CameraDeviceList = new ObservableCollection <string>();
            DocDeviceList    = new ObservableCollection <string>();

            CameraColorSpaces = new ObservableCollection <VideoFormatModel>();
            DocColorSpaces    = new ObservableCollection <VideoFormatModel>();

            VedioParameterVgaList    = new ObservableCollection <string>();
            DocParameterVgaList      = new ObservableCollection <string>();
            VedioParameterRatesList  = new ObservableCollection <int>();
            LoadCommand              = new DelegateCommand(Loading);
            WindowKeyDownCommand     = new DelegateCommand <object>(WindowKeyDownHandler);
            CheckCameraDeviceCommand = DelegateCommand.FromAsyncHandler(CheckCameraDeviceAsync);
            CheckDocDeviceCommand    = DelegateCommand.FromAsyncHandler(CheckDocDeviceAsync);

            //CheckCameraColorSpaceCommand = new DelegateCommand(CheckCameraColorSpace);
            //CheckDocColorSpaceCommand = new DelegateCommand(CheckDocColorSpace);

            GoBackCommand = new DelegateCommand(GoBack);
        }
Ejemplo n.º 12
0
 public MainViewModel()
 {
     Channel = new NotifyTaskCompletion <PushNotificationChannel>(loadChannelUri());
     DoIt    = DelegateCommand.FromAsyncHandler(OnDoItClicked);
     Context = new Dictionary <string, string>();
     Folder  = new FolderVM(false);
 }
        private void LoadedAsync()
        {
            var openedViews = _viewLayoutService.ViewFrameList.Where(v => v.IsOpened);

            var attendees = from openedView in openedViews
                            select new AttendeeItem()
            {
                Text          = openedView.ViewName,
                Id            = openedView.PhoneId,
                Hwnd          = openedView.Hwnd,
                ButtonCommand = DelegateCommand <AttendeeItem> .FromAsyncHandler(async (attendeeItem) =>
                {
                    var specialView =
                        _viewLayoutService.ViewFrameList.FirstOrDefault(
                            v => v.PhoneId == attendeeItem.Id && v.Hwnd == attendeeItem.Hwnd);

                    if (!CheckIsUserSpeaking(specialView, true))
                    {
                        return;
                    }

                    _viewLayoutService.SetSpecialView(specialView, _targetSpecialViewType);
                    await _viewLayoutService.LaunchLayout();
                    _selectAttendeeListView.Close();
                })
            };

            attendees.ToList().ForEach(attendee =>
            {
                AttendeeItems.Add(attendee);
            });

            InputSimulatorManager.Instance.Simulator.Keyboard.KeyPress(VirtualKeyCode.TAB);
            //InputSimulatorManager.Instance.Simulator.Keyboard.KeyPress(VirtualKeyCode.TAB);
        }
Ejemplo n.º 14
0
 public void GenericDelegateCommandFromAsyncHandlerWithNullExecuteFuncShouldThrow()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var command = DelegateCommand <object> .FromAsyncHandler(null);
     });
 }
Ejemplo n.º 15
0
        public void DelegateCommandFromAsyncHandlerCanExecuteShouldInvokeCanExecuteFunc()
        {
            var command    = DelegateCommand.FromAsyncHandler(async() => await Task.Run(() => { }), () => true);
            var canExecute = command.CanExecute();

            Assert.True(canExecute);
        }
Ejemplo n.º 16
0
        public MainView(IRegionManager regionManager, IModuleManager moduleManager)
        {
            InitializeComponent();

            DataContext = this;

            _regionManager   = regionManager;
            _groupManager    = IoC.Get <IGroupManager>();
            _eventAggregator = IoC.Get <IEventAggregator>();
            _eventAggregator.GetEvent <CommandReceivedEvent>().Subscribe(ExecuteCommand);

            Application.Current.Deactivated += Current_Deactivated;
            Application.Current.Activated   += Current_Activated;

            moduleManager.LoadModuleCompleted +=
                (s, e) =>
            {
                if (e.ModuleInfo.ModuleName == FirstModuleName)
                {
                    ExecuteGotoPage(GlobalResources.CollaborativeInfoNavView);
                }
            };

            TopMostTriggerCommand = new DelegateCommand(TriggerTopMost);
            ShowLogCommand        = DelegateCommand.FromAsyncHandler(ShowLogAsync);
            ShowHelpCommand       = new DelegateCommand(ShowHelp);
            OpenDrawingBorad      = new DelegateCommand(() =>
            {
                DrawingBoardView drawingBoardView = new DrawingBoardView();
                drawingBoardView.Show();
            });
            LoadCommand = new DelegateCommand(() =>
            {
                GlobalData.Instance.CurWindowHwnd = new WindowInteropHelper(this).Handle;

                ListBoxItem listBoxItem2 =
                    ListBoxMenu.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem;
                if (listBoxItem2 != null)
                {
                    listBoxItem2.IsSelected = true;
                    listBoxItem2.Focus();
                }

                //var commandServer = IoC.Get<ICommandServer>();
                //commandServer.RunServer();

                if (GlobalData.Instance.RunMode == RunMode.Development)
                {
                    Topmost              = false;
                    Width                = 1200;
                    Height               = 650;
                    WindowState          = WindowState.Normal;
                    IsWindowDraggable    = true;
                    ResizeMode           = ResizeMode.CanResize;
                    ShowMinButton        = true;
                    ShowMaxRestoreButton = true;
                }
            });
        }
        public MainPageViewModel(AppContext model, INavigationService navigationService)
        {
            this.model             = model;
            this.navigationService = navigationService;

            this.LoadPeopleCommand       = DelegateCommand.FromAsyncHandler(this.LoadPeopleAsync);
            this.NavigateEditPageCommand = new DelegateCommand <Person>(this.NavigateEditPage);
        }
Ejemplo n.º 18
0
        protected BaseViewModel(IAppService appService)
        {
            AppService = appService;

            NavigateCommand = DelegateCommand <string> .FromAsyncHandler(NavigateAsync);

            OpenUrlCommand = new DelegateCommand <string>(OpenUrlAsync);
        }
Ejemplo n.º 19
0
        public void NonGenericDelegateCommandShouldInvokeExplicitExecuteFunc()
        {
            bool     executed = false;
            ICommand command  = DelegateCommand.FromAsyncHandler(async() => await Task.Run(() => { executed = true; }));

            command.Execute(null);
            Assert.IsTrue(executed);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DomainModelResolveViewModel"/> class.
 /// </summary>
 /// <param name="log">The log.</param>
 public DomainModelResolveViewModel(Action <string, Category, Prism.Logging.Priority> log)
 {
     ClearUserInterface();
     LookupDNSCommand    = DelegateCommand.FromAsyncHandler(DomainDiscoveryAsync);
     InformationModelURI = new Uri(Properties.Settings.Default.DefaultInformationModelUri);
     m_Logger            = log;
     m_LoggerAction      = (x, y, z) => { LogList.Add(x); m_Logger(x, y, z); };
 }
Ejemplo n.º 21
0
 public IWanUClientViewModel()
 {
     AddGroupCommand          = new DelegateCommand(AddGroup);
     ChooseFriendAsyncCommand = DelegateCommand.FromAsyncHandler(ChooseFriendAsync, () => CanChooseFriend);
     SendMessageAsyncCommand  = DelegateCommand.FromAsyncHandler(SendMessageAsync, () => CanSendMessage);
     SignInAsyncCommand       = DelegateCommand.FromAsyncHandler(SignInAsync, () => CanSignIn);
     SignOutAsyncCommand      = DelegateCommand.FromAsyncHandler(SignOutAsync, () => CanSignOut);
 }
 public SettingsPageViewModel()
 {
     // ***
     // *** Set up the commands
     // ***
     this.AutoAlertModeCommand   = DelegateCommand.FromAsyncHandler(this.OnAutoAlertModeCommand, this.OnCanAutoAlertModeCommand);
     this.ManualAlertModeCommand = DelegateCommand.FromAsyncHandler(this.OnManualAlertModeCommand, this.OnCanManualAlertModeCommand);
 }
Ejemplo n.º 23
0
        public LoginDialogViewModel(StartService startService)
        {
            this.startService        = startService;
            this.userMessage         = string.Empty;
            this.windowLoadedCommand = DelegateCommand <object> .FromAsyncHandler(OnWindowLoaded);

            this.cancelCommand = new DelegateCommand <object>(OnCancel);
        }
 public RunUserControlViewModel(IAlertMessageService alertService)
 {
     _service      = new QueryFileService();
     _alertService = alertService;
     Params        = new ObservableCollection <SqlParamView>();
     SaveCommand   = DelegateCommand.FromAsyncHandler(SaveSync, CanSave);
     DeleteCommand = DelegateCommand.FromAsyncHandler(DeleteAsync, CanDelete);
 }
Ejemplo n.º 25
0
        public void GenericDelegateCommandFromAsyncHandlerCanExecuteShouldBeTrueByDefault()
        {
            var command = DelegateCommand <object> .FromAsyncHandler(async (o) => await Task.Run(() => { }));

            var canExecute = command.CanExecute(null);

            Assert.True(canExecute);
        }
        public ProfileContentViewModel(ProfileContentView profileContentView, IContainer container)
        {
            _profileContentView = profileContentView;
            _userInfo           = container.Resolve <UserInfo>();

            LoadCommand   = DelegateCommand.FromAsyncHandler(LoadAsync);
            LogoutCommand = new DelegateCommand(LogoutAsync);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Constructir
        /// </summary>
        public TopPage()
        {
            this.ViewModel = new TopPageViewModel();
            this.ViewModel.RefreshCommand = DelegateCommand.FromAsyncHandler(this.Refresh);
            this.newsFeed  = ((App)App.Current).Container.Resolve <INewsFeedService>();
            this.translate = ((App)App.Current).Container.Resolve <ITranslateService>();

            this.InitializeComponent();
        }
Ejemplo n.º 28
0
        public async Task DelegateCommandFromAsyncHandlerExecuteShouldInvokeExecuteFunc()
        {
            bool executed = false;

            var command = DelegateCommand.FromAsyncHandler(async() => await Task.Run(() => executed = true));
            await command.Execute();

            Assert.True(executed);
        }
Ejemplo n.º 29
0
        public InviteAttendeeViewModel()
        {
            _bmsService         = DependencyResolver.Current.GetService <IBms>();
            _meetingService     = DependencyResolver.Current.GetService <IMeetingSdkAgent>();
            SendInvitationItems = new ObservableCollection <TextWithButtonItem>();

            GetInviteesCommand    = DelegateCommand.FromAsyncHandler(GetInviteesAsync);
            SendInvitationCommand = DelegateCommand <TextWithButtonItem> .FromAsyncHandler(SendInvitationAsync);
        }
        public LookupUserControlViewModel(IAlertMessageService alertService)
        {
            _alertService     = alertService;
            _queryFileService = new QueryFileService();
            _tokenSource      = new CancellationTokenSource();
            Results           = new ObservableCollection <SearchQueryFile>();

            SearchCommand = DelegateCommand.FromAsyncHandler(SearchAsync);
        }