示例#1
0
        protected FilterViewModel(ICommandBus commandBus, Domain.Filters.Filter filter)
        {
            _filter     = filter;
            _commandBus = commandBus;

            _closeCommand = new DelegateCommand(Close);
        }
示例#2
0
 public static void RaiseCanExecuteChanged(this System.Windows.Input.ICommand command)
 {
     if (command is IRaiseCanExecuteChanged canExecuteChanged)
     {
         canExecuteChanged.RaiseCanExecuteChanged();
     }
 }
示例#3
0
        internal SettingViewModel(PeerCastApplication peca_app)
        {
            this.pecaApp                 = peca_app;
            this.peerCast                = peca_app.PeerCast;
            this.AddPortCommand          = new Command(() => AddPort());
            this.RemovePortCommand       = new Command(() => RemovePort(), () => SelectedPort != null);
            this.AddYellowPageCommand    = new Command(() => AddYellowPage());
            this.RemoveYellowPageCommand = new Command(() => RemoveYellowPage(), () => SelectedYellowPage != null);
            this.CheckBandwidth          = new CheckBandwidthCommand(this);
            channelCleanupMode           = ChannelCleaner.Mode;
            channelCleanupInactiveLimit  = ChannelCleaner.InactiveLimit / 60000;
            maxRelays                 = peerCast.AccessController.MaxRelays;
            maxRelaysPerChannel       = peerCast.AccessController.MaxRelaysPerChannel;
            maxPlays                  = peerCast.AccessController.MaxPlays;
            maxPlaysPerChannel        = peerCast.AccessController.MaxPlaysPerChannel;
            maxUpstreamRate           = peerCast.AccessController.MaxUpstreamRate;
            maxUpstreamRatePerChannel = peerCast.AccessController.MaxUpstreamRatePerChannel;
            isShowWindowOnStartup     = pecaApp.Settings.Get <WPFSettings>().ShowWindowOnStartup;
            ports = new ObservableCollection <OutputListenerViewModel>(
                peerCast.OutputListeners
                .Select(listener => new OutputListenerViewModel(this, listener))
                );
            yellowPages = new ObservableCollection <YellowPageClientViewModel>(
                peerCast.YellowPages
                .Select(yp => new YellowPageClientViewModel(this, yp))
                );
            var port_mapper = pecaApp.Plugins.GetPlugin <PeerCastStation.UI.PortMapper>();

            if (port_mapper != null)
            {
                portMapperEnabled = port_mapper.Enabled;
            }
        }
示例#4
0
        public LoadModuleBView2Command(LoadModuleBView2globalCommandProxy comandProxi)
        {
            this.comandProxi = comandProxi;
            this.LoadView2Command = new DelegateCommand(this.Ejecutar);
            this.comandProxi.Loadview2Comando.RegisterCommand(this.LoadView2Command); //publicamos globalmente el comanndo para poder acceder desde otros modulos

        }
示例#5
0
        public AudioSettingsViewModel(PropertyAudioViewModel property, TrackableViewModel parent) : base(property, parent)
        {
            AudioSources.AddRange(AudioHelper.GetAudioSources());


            UpdateAudioSourcesCommand = new Prism.Commands.DelegateCommand(UpdateSources);
        }
示例#6
0
 private void CreateCommands(INavigator navigator, ICommandDispatcher commandDispatcher, MessageBuilder messageBuilder)
 {
     setAsDefault       = new CurrencySetAsDefaultCommand(commandDispatcher, UniqueCode);
     addExchangeRate    = new NavigateCommand(navigator, new CurrencyAddExchangeRateParameter(UniqueCode));
     Delete             = new CurrencyDeleteCommand(navigator, commandDispatcher, messageBuilder, UniqueCode);
     DeleteExchangeRate = new CurrencyDeleteExchangeRateCommand(commandDispatcher, navigator, UniqueCode);
 }
        private void LinkUpdateAddLink(string title, string detail, System.Windows.Input.ICommand command)
        {
            var stack = new StackLayout();

            {
                stack.Padding = 10;
                stack.GestureRecognizers.Add(new TapGestureRecognizer()
                {
                    Command = command
                });
                stack.GestureRecognizers.Add(new ClickGestureRecognizer()
                {
                    Command = command
                });
            }
            {
                var label = new Label();
                label.Text = title;
                stack.Children.Add(label);
            }
            {
                var label = new Label();
                label.Text = detail;
                //label.VerticalTextAlignment = TextAlignment.End;
                //label.VerticalOptions = LayoutOptions.EndAndExpand;
                label.TextColor     = new Color(0, 0, 0, 0.5);
                label.LineBreakMode = LineBreakMode.TailTruncation;
                stack.Children.Add(label);
            }
            Links.Children.Add(stack);
        }
示例#8
0
 private void SafelyExecute(System.Windows.Input.ICommand command)
 {
     if (command.CanExecute(null))
     {
         command.Execute(null);
     }
 }
示例#9
0
        public HelpMenuViewModel(ICommandBus commandBus)
        {
            _commandBus = commandBus;

            _viewHelpCommand  = new DelegateCommand(ViewHelp);
            _viewAboutCommand = new DelegateCommand(ViewAbout);
        }
示例#10
0
        //public System.Windows.Input.ICommand ComplexCommand { get; set; }

        public MainViewModel()
        {
            SelectedViewModel = new ReportViewModel();
            UpdateViewCommand = new Commands.UpdateViewCommand(this);
            FilterGridCommand = SelectedViewModel.FilterGridCommand;
            //ComplexCommand = new Commands.ComplexCommand(UpdateViewCommand, SelectedViewModel.FilterGridCommand);
        }
示例#11
0
        public Puzzle()
        {
            ForceOpen = new Command(() => {
                Debug($"{Name} clicked OPEN");

                var m = new BrainMessage()
                {
                    Order = messageKinds.forceSolve
                };
                if (ZCon != null)
                {
                    ZCon.Send(m.Serialize());
                }
                else
                {
                    Debug(null, "TCP Client is disconnected)");
                }
            });
            ForceReset = new Command(() => {
                Debug($"{Name} clicked RESET");
                var m = new BrainMessage()
                {
                    Order = messageKinds.reset
                };
                ZCon.Send(m.Serialize());
            });
        }
示例#12
0
        public bool OnEditorAction(TextView v, ImeAction actionId, KeyEvent e)
        {
            if (BaseElement.NextElement == null && (actionId == ImeAction.Done || actionId == ImeAction.Next))
            {
                UIHelper.CloseSoftKeyboard(Control);

                if (BaseElement.Command != null && BaseElement.Command.CanExecute(null))
                {
                    System.Windows.Input.ICommand cmd = BaseElement.Command;
                    cmd.Execute(null);
                }
                return(false);
            }

            if (actionId == ImeAction.Done || actionId == ImeAction.Next)
            {
                BaseElement.NextElement.Focus();
                UIHelper.OpenSoftKeyboard(Control);
                return(true);
            }



            return(false);
        }
示例#13
0
        public DataPiece()
        {
            visible     = new ReactiveProperty <Visibility>(Visibility.Hidden).AddTo(Disposable);
            page        = new ReactiveProperty <string>().AddTo(Disposable);
            InsertRight = new ReactiveProperty <Visibility>(Visibility.Hidden).AddTo(Disposable);
            InsertLeft  = new ReactiveProperty <Visibility>(Visibility.Hidden).AddTo(Disposable);

            RemoveCommand = new DelegateCommand <MainWindow>(x =>
            {
                if (x.lview.SelectedItems.Count == 0)
                {
                    return;
                }

                var dp       = ((Conv)x.DataContext).DataPieces;
                var delItems = new List <DataPiece>();

                foreach (DataPiece item in x.lview.SelectedItems)
                {
                    delItems.Add(item);
                }

                delItems.ForEach(d => dp.Remove(d));

                ReloadPage(dp);
            });
        }
 public VistoriasNovasViewModel()
 {
     _vistoriasService  = DependencyService.Get <IVistoriasService>();
     VistoriasList      = new ObservableCollection <VistoriaDTO>();
     VerVistoriaCommand = new Command <VistoriaDTO>(verVistoria);
     LoadVistorias();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialogButtonData"/> struct.
 /// </summary>
 /// <param name="id">The id value for the button.</param>
 /// <param name="text">The text label.</param>
 /// <param name="command">The command to associate.</param>
 /// <param name="isDefault">Whether the button should be the default.</param>
 /// <param name="isCancel">Whether the button should be a cancel.</param>
 public TaskDialogButtonData(int id, string text, System.Windows.Input.ICommand command = null, bool isDefault = false, bool isCancel = false)
 {
     ID        = id;
     Text      = text;
     Command   = command;
     IsDefault = isDefault;
     IsCancel  = isCancel;
 }
示例#16
0
 static public void AddKeyBinding(this Control item, System.Windows.Input.ICommand command, KeyGesture gesture)
 {
     item.KeyBindings.Add(new KeyBinding()
     {
         Command = command,
         Gesture = gesture
     });
 }
示例#17
0
 public static IDisposable Execute <T>(this IObservable <T> observable, System.Windows.Input.ICommand command)
 {
     return(observable.Do(t => { if (command.CanExecute(t))
                                 {
                                     command.Execute(t);
                                 }
                          }).Subscribe());
 }
        public MainWindowViewModel()
        {
            Client      = new Services.ChuckNorrisJokeClient();
            _categories = Client.Categories();

            NextJoke = new DelegateCommand(_ => SetRandomJoke());

            SetRandomJoke();
        }
示例#19
0
文件: MenuView.cs 项目: zjdgx/CodeHub
 public PinnedRepoElement(PinnedRepository pinnedRepo, System.Windows.Input.ICommand command)
     : base(pinnedRepo.Name,
            () => command.Execute(new RepositoryIdentifier { Owner = pinnedRepo.Owner, Name = pinnedRepo.Name }),
            Images.Repo,
            GetActualImage(pinnedRepo))
 {
     PinnedRepo = pinnedRepo;
     TintImage  = false;
 }
 public ParameterWrapperCommand(System.Windows.Input.ICommand wrappedCommand, object parameter)
 {
     if (wrappedCommand == null)
     {
         throw new ArgumentNullException(nameof(wrappedCommand));
     }
     WrappedCommand = wrappedCommand;
     Parameter      = parameter;
 }
 /// <summary>
 /// Initializes the commands for the view
 /// </summary>
 protected override void InitializeCommands()
 {
     base.InitializeCommands();
     this.CheckItemCommand   = new RelayCommand <FilteredItemContainer>(CheckSelectedItem, CanCheckSelectedItem);
     this.SelectAllCommand   = new RelayCommand(this.SelectAllItems);
     this.DeselectAllCommand = new RelayCommand(this.DeselectAllItems);
     this.ExpandAllCommand   = new RelayCommand(this.ExpandAllItems);
     this.CollapseAllCommand = new RelayCommand(this.CollapseAllItems);
 }
 /// <summary>
 /// Initializes the commands for the view
 /// </summary>
 protected override void InitializeCommands()
 {
     base.InitializeCommands();
     this.CheckItemCommand = new RelayCommand<FilteredItemContainer>(CheckSelectedItem, CanCheckSelectedItem);
     this.SelectAllCommand = new RelayCommand(this.SelectAllItems);
     this.DeselectAllCommand = new RelayCommand(this.DeselectAllItems);
     this.ExpandAllCommand = new RelayCommand(this.ExpandAllItems);
     this.CollapseAllCommand = new RelayCommand(this.CollapseAllItems);
 }
示例#23
0
 public PinnedRepoElement(PinnedRepository pinnedRepo, System.Windows.Input.ICommand command)
     : base(pinnedRepo.Name,
            () => command.Execute(new RepositoryIdentifier(pinnedRepo.Owner, pinnedRepo.Name)),
            Octicon.Repo.ToImage(),
            GetActualImage(pinnedRepo))
 {
     PinnedRepo = pinnedRepo;
     TintImage  = pinnedRepo.ImageUri == null;
 }
示例#24
0
 private void Init()
 {
     connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left));
     connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right));
     imageUrl            = dicImageUrl[this.GetType()];
     editorService       = ApplicationServicesProvider.Instance.Provider.EditorService;
     ShowEditorCommand   = new SimpleCommand(ExecuteShowEditorCommand);
     this.ShowConnectors = false;
 }
        public ProductViewModel(ShoppingCartViewModel shoppingCartViewModel,
                                IShoppingCartRepository shoppingCartRepository,
                                IProductRepository productRepository,
                                Product product,
                                int quantity = 0)
        {
            Product  = product;
            Quantity = quantity;

            var addToCartCommand =
                new AddToCartCommand(shoppingCartRepository, productRepository, product);

            var increaseQuantityCommand =
                new ChangeQuantityCommand(ChangeQuantityCommand.Operation.Increase,
                                          shoppingCartRepository,
                                          productRepository,
                                          product);

            var decreaseQuantityCommand =
                new ChangeQuantityCommand(ChangeQuantityCommand.Operation.Decrease,
                                          shoppingCartRepository,
                                          productRepository,
                                          product);

            var removeFromCartCommand =
                new RemoveFromCartCommand(shoppingCartRepository,
                                          productRepository,
                                          product);

            AddToCartCommand = new RelayCommand(
                execute: () => {
                addToCartCommand.Execute();
                shoppingCartViewModel.Refresh();
            },
                canExecute: () => addToCartCommand.CanExecute());

            IncreaseQuantityCommand = new RelayCommand(
                execute: () => {
                increaseQuantityCommand.Execute();
                shoppingCartViewModel.Refresh();
            },
                canExecute: () => increaseQuantityCommand.CanExecute());

            DecreaseQuantityCommand = new RelayCommand(
                execute: () => {
                decreaseQuantityCommand.Execute();
                shoppingCartViewModel.Refresh();
            },
                canExecute: () => decreaseQuantityCommand.CanExecute());

            RemoveFromCartCommand = new RelayCommand(
                execute: () => {
                removeFromCartCommand.Execute();
                shoppingCartViewModel.Refresh();
            },
                canExecute: () => removeFromCartCommand.CanExecute());
        }
示例#26
0
        public static void RaiseCanExecuteChanged(this System.Windows.Input.ICommand command)
        {
            var canExecuteChanged = command as IRaiseCanExecuteChanged;

            if (canExecuteChanged != null)
            {
                canExecuteChanged.RaiseCanExecuteChanged();
            }
        }
示例#27
0
        public CategoryListViewModel(ICommandDispatcher commandDispatcher, INavigator navigator)
        {
            Ensure.NotNull(commandDispatcher, "commandDispatcher");
            Ensure.NotNull(navigator, "navigator");
            this.commandDispatcher = commandDispatcher;
            this.navigator         = navigator;

            Items = new ObservableCollection <CategoryEditViewModel>();
            New   = new NavigateCommand(navigator, new CategoryCreateParameter());
        }
示例#28
0
 public BaseContactViewModel()
 {
     checkedAll              = false;
     SelectableRow           = new List <BaseDataRow>();
     MouseDoubleClickCommand = new DelegateCommand <object>(new Action <object>(OnMouseDoubleClick));
     EditCommand             = new DelegateCommand <object>(new Action <object>(OnEdit));
     DeleteCommand           = new DelegateCommand <object>(new Action <object>(OnDelete));
     CheckedHeaderCommand    = new DelegateCommand <object>(new Action <object>(OnCheckedHeader));
     CheckedRowCommand       = new DelegateCommand <object>(new Action <object>(OnCheckedRow));
 }
示例#29
0
        public ZustandsErfassungsmodusChooserViewModel(
            ZustandsabschnittGISDTO zustandsabschnittGisDto,
            StrassenabschnittGISDTO strassenabschnittGisdto,
            IDTOService dtoService,
            IWindowService windowService,
            ISchadenMetadatenService schadenMetadatenService,
            IMessageBoxService messageBoxService,
            bool isNew)
        {
            this.zustandsabschnittGisDto = zustandsabschnittGisDto;
            this.strassenabschnittGisdto = strassenabschnittGisdto;
            this.dtoService              = dtoService;
            this.windowService           = windowService;
            this.schadenMetadatenService = schadenMetadatenService;
            this.messageBoxService       = messageBoxService;
            this.isNew = isNew;

            OpenZustandsFahrbahnWindowCommand = new DelegateCommand(OpenZustandsFahrbahnWindow);

            RegisterValidation(m => m.Zustandsindex, () => IsValidDecimalWithDecimalPlaces(Zustandsindex, 2), string.Format(MobileLocalization.InvalidDecimalPlacesValidationError, 2));
            RegisterValidation(m => m.Zustandsindex, () => RangeValidator(Zustandsindex, 0, 5), RangeValidationMessage(0, 5));
            RegisterValidation(m => m.Zustandsindex, IsZustandsindexValid, RangeValidationMessage(0, 5));
            RegisterValidation(m => m.IsGrobInitializiert, () => ZustandsErfassungsmodus != ZustandsErfassungsmodus.Grob || IsGrobInitializiert, MobileLocalization.GrobFormIsNotinitialized);
            RegisterValidation(m => m.IsDetailInitializiert, () => ZustandsErfassungsmodus != ZustandsErfassungsmodus.Detail || IsDetailInitializiert, MobileLocalization.DetailFormIsNotinitialized);

            ReCreateZustabdFahrbahnWindowViewModel();

            Load(zustandsabschnittGisDto, isNew);

            PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == ExpressionHelper.GetPropertyName(() => Zustandsindex))
                {
                    HasNoChanges = false;
                }
            };

            DelegateEvent(() => IsValid, () => HasError);
            DelegateEvent(() => Zustandsindex, () => ZustandsindexCalculated);

            PropertyChanged += (sender, args) =>
            {
                if (
                    args.PropertyName == ExpressionHelper.GetPropertyName(() => Zustandsindex) ||
                    args.PropertyName == ExpressionHelper.GetPropertyName(() => IsGrobInitializiert) ||
                    args.PropertyName == ExpressionHelper.GetPropertyName(() => IsDetailInitializiert) ||
                    args.PropertyName == ExpressionHelper.GetPropertyName(() => Massnahmenvorschlag) ||
                    args.PropertyName == ExpressionHelper.GetPropertyName(() => ZustandsErfassungsmodus) ||
                    args.PropertyName == ExpressionHelper.GetPropertyName(() => Dringlichkeit)
                    )
                {
                    OnChanged();
                }
            };
        }
 public TicketDetailViewModel(MerchandisingTicket ticket = null)
 {
     Title         = "Ticket Details";
     Ticket        = ticket;
     TimerText     = string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
     Comment       = Ticket.comment;
     SubmitCommand = new Xamarin.Forms.Command(OnSubmit);
     TimerStart    = new Xamarin.Forms.Command(TimeStart);
     TimerStop     = new Xamarin.Forms.Command(TimeStop);
     TimerComplete = new Xamarin.Forms.Command(TimeComplete);
 }
示例#31
0
    protected override void ExecuteCommandOnItem(System.Windows.Input.ICommand command, int position)
    {
        var item = Adapter.GetRawItem(position) as Station;

        if (item.Name == "New Station")
        {
            Parent.ShowSearch();
            return;
        }
        base.ExecuteCommandOnItem(command, position);
    }
 public FeatureExtractionUIViewModel(IUnityContainer container)
     : base(container)
 {
     this.View              = this.UnityContainer.Resolve <IFeatureExtractionUIView>();
     this.View.Model        = this;
     this.ExperimentContext = this.UnityContainer.Resolve <IExperimentContext>();
     this.SubscribeEvents();
     this.InitializeCommands();
     SelectPositiveIonsCommand = new DelegateCommand <object>(SelectPositiveIonsCommandExecuted);
     SelectNegativeIonsCommand = new DelegateCommand <object>(SelectNegativeIonsCommandExecuted);
     SelectNeutralIonsCommand  = new DelegateCommand <object>(SelectNeutralIonsCommandExecuted);
 }
        private void InitializeCommands()
        {
            this.ExpandAllCommand = new RelayCommand(
                () => this.ChangeIsExpanded(true),
                () => this.currentWorkflow != null && this.currentWorkflow.Nodes.Any());

            this.CollapseAllCommand = new RelayCommand(
                () => this.ChangeIsExpanded(false),
                () => this.currentWorkflow != null && this.currentWorkflow.Nodes.Any());

            this.RefreshGraphCommand = new RelayCommand(
                () => this.currentWorkflow.RefreshGraphStates(),
                () => this.currentWorkflow != null && this.currentWorkflow.Nodes.Any());

            this.GoToFocusedCommand = new RelayCommand(
                () => this.currentWorkflow.GoToFocusedAction(),
                () => this.currentWorkflow != null && this.currentWorkflow.Model.FocusedAction != null);
        }
示例#34
0
 public MaterialType()
 {
     AddCommand = new DelegateCommand<MaterialType>(new Action<MaterialType>(OnAdd));
     UpdateCommand = new DelegateCommand<MaterialType>(new Action<MaterialType>(OnUpdate));
     Quality = ObjectPool.Instance.Resolve<List<QualityType>>();
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="TaskDialogButtonData"/> struct.
		/// </summary>
		/// <param name="id">The id value for the button.</param>
		/// <param name="text">The text label.</param>
		/// <param name="command">The command to associate.</param>
		/// <param name="isDefault">Whether the button should be the default.</param>
		/// <param name="isCancel">Whether the button should be a cancel.</param>
		public TaskDialogButtonData(int id, string text, System.Windows.Input.ICommand command = null, bool isDefault = false, bool isCancel = false)
		{
			ID = id;
			Text = text;
			Command = command;
			IsDefault = isDefault;
			IsCancel = isCancel;
		}
 private void InitializeCommands()
 {
     this.SelectToolkitCommand = new RelayCommand<IDialogWindow>(dialog => this.CloseDialog(dialog), dialog => this.IsValid);
     this.HomePageCommand = new RelayCommand(this.NavigateToHomePage, () => true);
     this.ToggleAllPatternsCommand = new RelayCommand<bool>(x => this.ToggleAllPatterns(x), x => true);
 }
示例#37
0
			public WpfCommandWrapper(System.Windows.Input.ICommand wpfCommand)
			{
				this.wpfCommand = wpfCommand;
			}
示例#38
0
 public ContactMessageBar()
 {
     ComposeCommand = new DelegateCommand<object>(new Action<object>(OnCompose));
 }
 private void InitializeCommands()
 {
     this.SelectAutomationExtensionCommand = new RelayCommand<IDialogWindow>(dialog => CloseDialog(dialog), dialog => CanCloseDialog());
 }
 internal SettingViewModel(PeerCastApplication peca_app)
 {
   this.pecaApp = peca_app;
   this.peerCast = peca_app.PeerCast;
   this.AddPortCommand = new Command(() => AddPort());
   this.RemovePortCommand = new Command(() => RemovePort(), () => SelectedPort!=null);
   this.AddYellowPageCommand = new Command(() => AddYellowPage());
   this.RemoveYellowPageCommand = new Command(() => RemoveYellowPage(), () => SelectedYellowPage!=null);
   this.CheckBandwidth = new CheckBandwidthCommand(this);
   channelCleanupMode = ChannelCleaner.Mode;
   channelCleanupInactiveLimit = ChannelCleaner.InactiveLimit/60000;
   maxRelays           = peerCast.AccessController.MaxRelays;
   maxRelaysPerChannel = peerCast.AccessController.MaxRelaysPerChannel;
   maxPlays            = peerCast.AccessController.MaxPlays;
   maxPlaysPerChannel  = peerCast.AccessController.MaxPlaysPerChannel;
   maxUpstreamRate           = peerCast.AccessController.MaxUpstreamRate;
   maxUpstreamRatePerChannel = peerCast.AccessController.MaxUpstreamRatePerChannel;
   isShowWindowOnStartup = pecaApp.Settings.Get<WPFSettings>().ShowWindowOnStartup;
   ports = new ObservableCollection<OutputListenerViewModel>(
     peerCast.OutputListeners
     .Select(listener => new OutputListenerViewModel(this, listener))
   );
   yellowPages = new ObservableCollection<YellowPageClientViewModel>(
     peerCast.YellowPages
     .Select(yp => new YellowPageClientViewModel(this, yp))
   );
   var port_mapper = pecaApp.Plugins.GetPlugin<PeerCastStation.UI.PortMapper>();
   if (port_mapper!=null) portMapperEnabled = port_mapper.Enabled;
 }
 /// <summary>
 /// Initializes the commands for the view
 /// </summary>
 protected override void InitializeCommands()
 {
     base.InitializeCommands();
     this.ExpandAllCommand = new RelayCommand(ExpandAllItems);
     this.CollapseAllCommand = new RelayCommand(CollapseAllItems);
 }
        /// <summary>
        /// Constructor, called just once per invocation of the app.
        /// </summary>
        /// <param name="mobileServiceClientIn"></param>
        public GameProcessor(TicTacToeMobileServiceClient mobileServiceClientIn)
        {
            mobileServiceClient = mobileServiceClientIn;

            m_cells = new ObservableCollection<Cell>();
            isGameInProgress = false;
            playerOptions = new ObservableCollection<String>();
            defaultButtonForegroundBrush = new SolidColorBrush(Colors.White);
            winningPathButtonForegroundBrush = new SolidColorBrush(Colors.Red);
        
            for (int i = 0; i < 9; i++)
            {
                m_cells.Add(new Cell(i, defaultButtonForegroundBrush, this));
            }

            foreach (Cell cell in m_cells)
            {
                cell.CellSelected += new CellSelectedHandler(this.CellSelected);
            }

            m_newGameCommand = new DelegateCommand(new ExecuteDelegate(this.CreateNewGame), new CanExecuteDelegate(this.CanSelectNewGame));
            signInCommand = new DelegateCommand(new ExecuteDelegate(this.RegisterOrSignInOrOut), new CanExecuteDelegate(this.CanRegisterOrSignInOrOut));
            searchCommand = new DelegateCommand(new ExecuteDelegate(this.SearchUsers), new CanExecuteDelegate(this.CanSearch));
            addFriendCommand = new DelegateCommand(new ExecuteDelegate(this.AddFriend), new CanExecuteDelegate(this.CanAddFriend));
            submitMoveCommand = new DelegateCommand(new ExecuteDelegate(this.SubmitMove), new CanExecuteDelegate(this.CanSubmitMoveCommand));
            // This sections helps the user log in if they have logged in previously by attempting to
            // retrieve credentials from the Password Vault.
            // If no cached credentials exist in the Password Vault, provide a Register button.

            //Task<bool> checkRegistration = mobileServiceClient.IsKnownUser();
            //checkRegistration.Wait();
            //isRegistered = checkRegistration.Result;
            //UserNameText = mobileServiceClient.GetUserName();

            // How do we set "isRegistered" ?
            // How do we set "isSignedIn" ?

            /*Task task = FinalizeRegistration();
            task.Wait();

            if (CanRegisterOrSignInOrOut(null))
            {
                RegisterOrSignInOrOut(null);
            }
            */

            FinalizeSignIn();
        }
示例#43
0
 internal SettingViewModel(PeerCastApplication peca_app)
 {
   this.pecaApp = peca_app;
   this.peerCast = peca_app.PeerCast;
   this.AddPortCommand = new Command(() => AddPort());
   this.RemovePortCommand = new Command(() => RemovePort(), () => SelectedPort!=null);
   this.AddYellowPageCommand = new Command(() => AddYellowPage());
   this.RemoveYellowPageCommand = new Command(() => RemoveYellowPage(), () => SelectedYellowPage!=null);
   this.CheckBandwidth = new CheckBandwidthCommand(this);
   channelCleanupMode = ChannelCleaner.Mode;
   channelCleanupInactiveLimit = ChannelCleaner.InactiveLimit/60000;
   maxRelays           = peerCast.AccessController.MaxRelays;
   maxRelaysPerChannel = peerCast.AccessController.MaxRelaysPerChannel;
   maxPlays            = peerCast.AccessController.MaxPlays;
   maxPlaysPerChannel  = peerCast.AccessController.MaxPlaysPerChannel;
   maxUpstreamRate           = peerCast.AccessController.MaxUpstreamRate;
   maxUpstreamRatePerChannel = peerCast.AccessController.MaxUpstreamRatePerChannel;
   isShowWindowOnStartup = pecaApp.Settings.Get<WPFSettings>().ShowWindowOnStartup;
   ports = new ObservableCollection<OutputListenerViewModel>(
     peerCast.OutputListeners
     .Select(listener => new OutputListenerViewModel(this, listener))
   );
   yellowPages = new ObservableCollection<YellowPageClientViewModel>(
     peerCast.YellowPages
     .Select(yp => new YellowPageClientViewModel(this, yp))
   );
   var port_mapper = pecaApp.Plugins.GetPlugin<PeerCastStation.UI.PortMapperPlugin>();
   if (port_mapper!=null) {
     portMapperEnabled = port_mapper.Enabled;
     port_mapper.DiscoverAsync()
       .ContinueWith(prev => OnPropertyChanged("PortMapperExternalAddresses"));
   }
   PortCheckStatus = PortCheckStatus.Checking;
   CheckPortAsync().ContinueWith(prev => {
     if (prev.IsCanceled || prev.IsFaulted) {
       PortCheckStatus = PortCheckStatus.Failed;
     }
     else {
       PortCheckStatus = prev.Result;
     }
   });
 }