public WeatherForecastViewModel() { model = new WeatherForecast(); owms = new OpenWeatherMapService(); City = "Lugano"; WeatherCommand = new DelegateCommand(OnWeather); }
public MainViewModel() { Modules = new ObservableCollection <Module> { new Module() { Name = "Module 1", Description = "A description" }, new Module() { Name = "Module 2", Description = "A description" }, new Module() { Name = "Module 3", Description = "A description" }, new Module() { Name = "Module 4", Description = "A description" } }; SelectModuleCommand = new DelegateCommand(OnSelectModule); SelectModuleFromElementCommand = new DelegateCommand <Module>(OnSelectModule); SelectModuleFromItemClickCommand = new DelegateCommand <ItemClickEventArgs>(OnSelectModuleFromItemClick); }
public ViewModel() { RunTrigger = new DelegateCommand(() => OnSomeEvent(new Payload() { Value = 10 })); }
/// <summary> /// Constructor /// </summary> /// <param name="filename">Filename of the workflow to run</param> public ExecutionViewModel(string filename) { _filename = filename; Cancel = new DelegateCommand(OnCancel, () => IsRunning); CopyToClipboard = new DelegateCommand(OnCopyToClipboard); var log = new ObservableCollection <string>(); log.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var item in e.NewItems.Cast <string>()) { _logText.AppendLine(item); } } else { _logText.Clear(); foreach (var item in log) { _logText.AppendLine(item); } } RaisePropertyChanged(() => ReadOnlyLogText); }; Log = log; }
protected void RegisterCommands() { ShowInstalledCommand = new DelegateCommand(OnShowInstalled, CanShowInstalled); DeleteCommand = new DelegateCommand(OnDelete, CanDelete); SearchInstalledCommand = new DelegateCommand(OnSearchInstalled, CanSearchInstalled); GenerateCommand = new DelegateCommand(OnGenerate, CanGenerate); }
public DialogVM(string title, string message, Action <object> action) { Title = title; Message = message; this.action = new DelegateCommand(action); this.exit = new DelegateCommand(ExecuteExit); }
public MainViewModel(IPreferencesManager preferencesManager, IWindowFactory windowFactory, IDelegateCommand selectedPreferenceCommand, IDelegateCommand savePreferenceCommand, IDelegateCommand saveAllCommand, IDelegateCommand openFileCommand, IPreferenceTypeViewModel preferenceTypeViewModel) : base() { _PreferencesManager = preferencesManager; _WindowFactory = windowFactory; _PreferenceTypeViewModel = preferenceTypeViewModel; selectedPreferenceCommand.ExecuteAction = p => SetSelectedPreference(p); savePreferenceCommand.ExecuteAction = p => SavePreference(p); saveAllCommand.ExecuteAction = p => SaveAll(); openFileCommand.ExecuteAction = p => OpenFile(); SelectedPreferenceCommand = selectedPreferenceCommand; SavePreferenceCommand = savePreferenceCommand; SaveAllCommand = saveAllCommand; OpenFileCommand = openFileCommand; Preferences = new ObservableCollection<IPreferenceViewModel>(); }
public MainWindowViewModel() { _defaultPatientsFilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\Patients.xml")); _defaultDoctorsFilePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\Doctors.xml")); _patients = Load <Patient>(_defaultPatientsFilePath); _doctors = Load <Doctor>(_defaultDoctorsFilePath); #region InitializeCommands AddPatientCommand = new DelegateCommand(ExecuteAddPatient); RemovePatientCommand = new DelegateCommand(ExecuteRemovePatient, CanExecuteRemovePatient); EditPatientCommand = new DelegateCommand(ExecuteEditPatient, CanExecuteEditPatient); CompleteEditPatientCommand = new DelegateCommand(ExecuteComleteEditPatient, CanExecuteComleteEditPatient); RefreshPatient = new DelegateCommand(ExecuteRefreshPatient, CanExecuteRefreshPatient); FindPatients = new DelegateCommand(ExecuteFindPatients, CanExecuteFindPatients); AddAppointment = new DelegateCommand(ExecuteAddAppointment); RemoveAppointment = new DelegateCommand(ExecuteRemoveAppointment, CanExecuteRemoveAppointment); AddDoctorCommand = new DelegateCommand(ExecuteAddDoctor); RemoveDoctorCommand = new DelegateCommand(ExecuteRemoveDoctor, CanExecuteRemoveDoctor); EditDoctorCommand = new DelegateCommand(ExecuteEditDoctor, CanExecuteEditDoctor); CompleteEditDoctorCommand = new DelegateCommand(ExecuteComleteEditDoctor, CanExecuteComleteEditDoctor); RefreshDoctor = new DelegateCommand(ExecuteRefreshDoctor, CanExecuteRefreshDoctor); FindDoctors = new DelegateCommand(ExecuteFindDoctors, CanExecuteFindDoctors); #endregion }
public TabControlRegionViewModel(IViewResolver viewResolver, IRegionService regionService) { AddNewGammaViewCommand = DelegateCommand.Create() .OnExecute(x => { var view = viewResolver.GetView <GammaView>(); if (view != null) { regionService.GetKnownRegionManager <TabControlRegionView>() .GetRegion <ISwitchingElementsRegion>("MainTabRegion") .Add(view); } }); ActivateGammaViewCommand = DelegateCommand.Create() .OnExecute(x => { var region = regionService.GetKnownRegionManager <TabControlRegionView>() .GetRegion <ISwitchingElementsRegion>("MainTabRegion"); var elements = region.GetElements <DependencyObject>() .OfType <GammaView>() .Cast <DependencyObject>() .ToList(); if (elements.Count > 0) { var index = elements.IndexOf(region.ActiveContent); if (index >= 0) { DependencyObject viewToActivate = index + 1 < elements.Count ? elements[index + 1] : elements[0]; region.Activate(viewToActivate); } else { region.Activate(elements[0]); } } }); RemoveLastViewCommand = DelegateCommand.Create() .OnExecute(x => { var region = regionService.GetKnownRegionManager <TabControlRegionView>() .GetRegion <ISwitchingElementsRegion>("MainTabRegion"); var lastElement = region.GetElements <DependencyObject>().LastOrDefault(); if (lastElement != null) { region.Remove(lastElement); } }); }
public MainViewModel() { Color = "White"; ShowPrompt = new DelegateCommand(OnClickButton); MouseEnter = new AsyncDelegateCommand(OnGoForward, () => !_isChanging, () => _isChanging = false); MouseLeave = new AsyncDelegateCommand(OnGoBackward, () => !_isChanging, () => _isChanging = false); RunAction = new DelegateCommand(DoRunAction); }
/// <summary> /// Binds the specified command. /// </summary> /// <param name="command">The command.</param> /// <param name="component">The component.</param> /// <returns></returns> public CommandManager Bind(IDelegateCommand command, IComponent component) { if (!Commands.Contains(command)) Commands.Add(command); FindBinder(component).Bind(command, component); return this; }
public VisualizzaViewModel() { AppDbContext ctx = new AppDbContext(); repoQdc = new QdcDbDataRepository(ctx); MenuCommand = new DelegateCommand(OnMenuClick, CanMenuClick); VisualizzaQdc = new DelegateCommand(OnVisualizzaClick, CanVisualizzaClick); }
public static void Register(IDelegateCommand command) { if (commands.Contains(command)) { return; } commands.Add(command); }
public MainViewModel() { SettingPageCommand = new DelegateCommand(OnSettingPage, CanSettingPage); NugetPageCommand = new DelegateCommand(OnNugetPage, CanNugetPage); InstalledPageCommand = new DelegateCommand(OnInstalledPage, CanInstalledPage); AboutPageCommand = new DelegateCommand(OnAboutPage, CanAboutPage); CurrentViewModel = ViewModelLocator.Nuget; }
protected static void ExecuteCommand(IDelegateCommand cmd, object parameter) { if (cmd == null || !cmd.CanExecute(parameter)) { return; } cmd.Execute(parameter); }
protected void RegisterCommands() { SaveCommand = new DelegateCommand(OnSave, CanSave); SaveFastCommand = new DelegateCommand(OnSaveFast, CanSaveFast); ShowCommand = new DelegateCommand(OnShow, CanShow); SearchCommand = new DelegateCommand(OnSearch, CanSearch); SearchNewsCommand = new DelegateCommand(OnSearchNews, CanSearchNews); CheckDeletedCommand = new DelegateCommand(OnCheckDeleted, CanCheckDeleted); }
public IDelegateCommand RegisterCommand <TParam>(IDelegateCommand command, [CallerMemberName] string commandName = null) { if (!CommandList.ContainsKey(commandName)) { CommandList.Add(commandName, command); } command.Parent = ViewModel; command.Name = commandName; return(CommandList[commandName]); }
public TrayViewModel(IAuthorizationService authorizationService, IWindowFactory windowFactory, IApplicationService applicationService, IWindowService windowService) { _authorizationService = authorizationService; _windowFactory = windowFactory; _applicationService = applicationService; _windowService = windowService; TransitionToMainCommand = new DelegateCommandAsync(ExecuteTransitionToMainAsync); TransitionToAuthorizationCommand = new DelegateCommand.DelegateCommand(ExecuteTransitionToAuthorization); TransitionToExitCommand = new DelegateCommand.DelegateCommand(ExecuteTransitionToExit); }
public MainViewModel() { Carta.ChooseView = 0; NextPage = new DelegateCommand(OnNextPage, CanNextPage); CameraPageCommand = new DelegateCommand(OnCameraPage, CanCameraPage); GameIAPageCommand = new DelegateCommand(OnGameIAPage, CanGameIAPage); GameUserPageCommand = new DelegateCommand(OnGameUserPage, CanGameUserPage); SettingsPageCommand = new DelegateCommand(OnSettingsPage, CanSettingsPage); StartGamePageCommand = new DelegateCommand(OnStartGamePage, CanStartGamePage); CurrentViewModel = ViewModelLocator.Camera; }
public VideoPlaygroundViewModel(Compositor compositor, Grid videoContentGrid) { // Stash the dispatcher so that we can make calls off the UI thread (or rather, request // the UI thread to make calls on our behalf) that influence the UI. _dispatcher = videoContentGrid.Dispatcher; _compositor = compositor; // Set up our composition objects. EnsureComposition(videoContentGrid); EffectIndex = -1; _lights = new List <Light>(); EffectItems = new ObservableCollection <EffectItem>(); // No effect. EffectItems.Add(EffectItem.None); // Saturation effect with an adjustable Sturation property. EffectItems.Add(new EffectItem() { EffectName = "Saturation", AnimatablePropertyName = "Saturation", ValueMin = 0, ValueMax = 1, SmallChange = 0.1f, LargeChange = 0.3f, CreateEffectFactory = CreateSaturationEffectFactory }); // Blur effect with an adjustable BlurAmount property. EffectItems.Add(new EffectItem() { EffectName = "Blur", AnimatablePropertyName = "BlurAmount", ValueMin = 0, ValueMax = 20, SmallChange = 1.0f, LargeChange = 3.0f, CreateEffectFactory = CreateBlurEffectFactory }); // Invert effect with no adjustable properties. EffectItems.Add(new EffectItem() { EffectName = "Invert", AnimatablePropertyName = null, CreateEffectFactory = CreateInvertEffectFactory }); // HueRotation effect with an adjustable Angle property. EffectItems.Add(new EffectItem() { EffectName = "HueRotation", AnimatablePropertyName = "Angle", ValueMin = 0, ValueMax = (float)(2.0 * Math.PI), SmallChange = 0.1f, LargeChange = 1.0f, CreateEffectFactory = CreateHueRotationEffectFactory }); Durations = new ObservableCollection <double>(); // Setup our duration values, from 0.5 seconds to 5 seconds. for (int i = 1; i <= 10; i++) { Durations.Add(i * 0.5); } AddLightCommand = new DelegateCommand(AddLightButton); RemoveLightCommand = new DelegateCommand(RemoveLightButton); AnimateCommand = new DelegateCommand(Animate); OpenFileCommand = new DelegateCommand(OpenFile); OpenLinkDialogCommand = new DelegateCommand(OpenLinkDialog); OpenLinkCommand = new DelegateCommand(OpenLink); DurationIndex = 0; }
public SettingsViewModel( ISettingsStore settingsStore, IWebClient webClient, IErrorHandler errorHandler, IImagesProvider imagesProvider) { this.settingsStore = settingsStore; this.webClient = webClient; this.errorHandler = errorHandler; this.testServiceCommand = new BaseCommand(this.ExecuteTestCommand, this.CanExecuteTestCommand); this.Logo = imagesProvider.GetImage(ImageType.PluginIcon); }
internal void RegisterCommand(IDelegateCommand command) { if (command != null) { DelegateCommand delegateCommand = command as DelegateCommand;//this command does not have any parameter for CanExecute #if DEBUG if (delegateCommand != null) { //check if the command has been already registered foreach (var item in m_commandsWithoutParameter) { IDelegateCommand existingCommand; if (item.Command.TryGetTarget(out existingCommand)) { System.Diagnostics.Debug.Assert(existingCommand != command); } } } else { //check if the command has been already registered foreach (var item in m_commandsWithParameter) { IDelegateCommand existingCommand; if (item.TryGetTarget(out existingCommand)) { System.Diagnostics.Debug.Assert(existingCommand != command); } } } #endif if (delegateCommand != null) { m_commandsWithoutParameter.Add(new CommandItem() { Command = new WeakReference <IDelegateCommand>(command) }); } else { m_commandsWithParameter.Add(new WeakReference <IDelegateCommand>(command)); } if (!m_canExecuteTimer.IsEnabled) { m_canExecuteTimer.Start(); } } }
public EquationViewModel() { model = new Equation(); A = 1; B = 2; C = -8; Points = new ObservableCollection <Point2D>(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(SLEEPTIME); timer.Tick += Timer_Tick; DrawCommand = new DelegateCommand(OnDraw); }
public MainViewModel() { _title = "MVVM Test"; _color = "White"; Elements = new ObservableCollection <Element>(); _collectionObserver = new CollectionChangeUndoObserver(Elements, Resolve <IUndoService>()); ActivatedCommand = new DelegateCommand(() => IsActive = true); DeactivatedCommand = new DelegateCommand(() => IsActive = false); LoadedCommand = new DelegateCommand(OnLoaded); ClosingCommand = new DelegateCommand <CancelEventArgs>(OnClosing); ExitCommand = new DelegateCommand(RaiseCloseRequest); ShowColorDialogCommand = new DelegateCommand <Element>(ShowColorDialog); ShowPropertiesCommand = new DelegateCommand(ShowPropertyDialog); MouseEnterLeaveCommand = new DelegateCommand <RoutedEventArgs>(OnMouseEnterLeave); ChangeBackground = new DelegateCommand <string>(OnChangeBackground); }
internal void UnregisterCommand(IDelegateCommand command) { if (command != null) { DelegateCommand delegateCommand = command as DelegateCommand; IDelegateCommand existingCommand; if (delegateCommand != null) { m_commandsWithoutParameter.RemoveAll((item) => !item.Command.TryGetTarget(out existingCommand) || existingCommand == command); } else { m_commandsWithParameter.RemoveAll((item) => !item.TryGetTarget(out existingCommand) || existingCommand == command); } } }
/// <summary> /// Destroys the command. /// </summary> /// <param name="target">The target.</param> /// <param name="command">The command.</param> /// <returns></returns> public static IDelegateCommand DestroyCommand(this GameObject target, IDelegateCommand command) { var commands = target.GetComponents <DelegateCommand>(); if (commands == null) { return(null); } DelegateCommand res = null; foreach (var cmd in commands) { if (!cmd.Equals(command)) { continue; } res = cmd; break; } Object.Destroy(res); return(res); }
/// <summary> /// Monitors the specified properties. /// </summary> /// <typeparam name="TSource">The type of the source.</typeparam> /// <param name="command">The command.</param> /// <param name="source">The source.</param> /// <param name="properties">The properties to monitor.</param> /// <returns>The original command.</returns> public static IDelegateCommand Observe <TSource>(this IDelegateCommand command, TSource source, params Expression <Func <TSource, Object> >[] properties) where TSource : INotifyPropertyChanged { Ensure.That(properties).Named(() => properties).IsNotNull(); if (properties.Any()) { var observer = PropertyObserver.For(source); foreach (var prop in properties) { observer.Observe(prop); } command.AddMonitor(observer); } else { var observer = PropertyObserver.ForAllPropertiesOf(source); command.AddMonitor(observer); } return(command); }
protected override void SetInputBindings( DependencyObject target, ICommandSource source, IDelegateCommand command ) { //Not supported ? }
partial void OnSampleCommandChanging(ref IDelegateCommand newValue);
void Initialize(StreamingContext context) { SelectSpecificColor = new DelegateCommand <ItemClickEventArgs>(OnSelectColor); Colors = new ObservableCollection <ColorViewModel>( typeof(Colors).GetTypeInfo().DeclaredProperties.Select(pn => new ColorViewModel(pn.Name))); }
/// <summary> /// Metodo costruttore del ViewModel. /// </summary> public BenvenutoViewModel() { ImpostazioniBaseCommand = new DelegateCommand(OnImpostazioniBase, CanImpostazioniBase); EsercizioCommand = new DelegateCommand(OnEsercizio, CanEsercizio); ProvaCommand = new DelegateCommand(OnProva, CanProva); }
public MainWindowViewModel() { StartCommand = new DelegateCommand(StartCommandCallback); }
protected virtual void SetInputBindings( DependencyObject target, ICommandSource source, IDelegateCommand command ) { if ( source != null && command != null && command.InputBindings != null ) { var rootElement = this.GetRootElement( target as FrameworkElement ); foreach ( InputBinding ib in command.InputBindings ) { if ( ib.CommandParameter != source.CommandParameter ) { ib.CommandParameter = source.CommandParameter; } rootElement.InputBindings.Add( ib ); } } }
protected override void SetInputBindings(DependencyObject target, ICommandSource source, IDelegateCommand command) { //Not supported ? }
public KeypadViewModel() { AddCharacterCommand = new DelegateCommand(ExecuteAddCharacter); DeleteCharacterCommand = new DelegateCommand(ExecuteDeleteCharacter, CanExecuteDeleteCharacter); }
public VideoPlaygroundViewModel(Compositor compositor, Grid videoContentGrid) { // Stash the dispatcher so that we can make calls off the UI thread (or rather, request // the UI thread to make calls on our behalf) that influence the UI. _dispatcher = videoContentGrid.Dispatcher; _compositor = compositor; // Set up our composition objects. EnsureComposition(videoContentGrid); EffectIndex = -1; _lights = new List<Light>(); EffectItems = new ObservableCollection<EffectItem>(); // No effect. EffectItems.Add(EffectItem.None); // Saturation effect with an adjustable Sturation property. EffectItems.Add(new EffectItem() { EffectName = "Saturation", AnimatablePropertyName = "Saturation", ValueMin = 0, ValueMax = 1, SmallChange = 0.1f, LargeChange = 0.3f, CreateEffectFactory = CreateSaturationEffectFactory }); // Blur effect with an adjustable BlurAmount property. EffectItems.Add(new EffectItem() { EffectName = "Blur", AnimatablePropertyName = "BlurAmount", ValueMin = 0, ValueMax = 20, SmallChange = 1.0f, LargeChange = 3.0f, CreateEffectFactory = CreateBlurEffectFactory }); // Invert effect with no adjustable properties. EffectItems.Add(new EffectItem() { EffectName = "Invert", AnimatablePropertyName = null, CreateEffectFactory = CreateInvertEffectFactory }); // HueRotation effect with an adjustable Angle property. EffectItems.Add(new EffectItem() { EffectName = "HueRotation", AnimatablePropertyName = "Angle", ValueMin = 0, ValueMax = (float)(2.0 * Math.PI), SmallChange = 0.1f, LargeChange = 1.0f, CreateEffectFactory = CreateHueRotationEffectFactory }); Durations = new ObservableCollection<double>(); // Setup our duration values, from 0.5 seconds to 5 seconds. for (int i = 1; i <= 10; i++) { Durations.Add(i * 0.5); } AddLightCommand = new DelegateCommand(AddLightButton); RemoveLightCommand = new DelegateCommand(RemoveLightButton); AnimateCommand = new DelegateCommand(Animate); OpenFileCommand = new DelegateCommand(OpenFile); OpenLinkDialogCommand = new DelegateCommand(OpenLinkDialog); OpenLinkCommand = new DelegateCommand(OpenLink); DurationIndex = 0; }