/// <summary> /// Initializes a new instance of the <see cref="ViewModelBlade{TEntity}"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="automaticValidation"></param> protected ViewModelBlade( IContext context, IBaseCommonServices commonServices, ILogger logger, bool automaticValidation = false) : base(context, commonServices, logger, automaticValidation) { Validator = new Action <IObservableClass>(arg => { if (arg is ViewModelBlade <TEntity> vm && vm.SelectedItem is IObservableClass selectedItem) { if (!selectedItem.Validate()) { foreach (var error in selectedItem.Errors) { vm.Properties[nameof(vm.SelectedItem)].Errors.Add(error); } } } }); SelectedItem = TypeActivator.CreateInstance <TEntity>(); IsNew = true; Submit_Command = new Command(async() => await SubmitAsync(SelectedItem)); }
/// <summary> /// Initializes a new instance of the <see cref="ConvertersViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> public ConvertersViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger) : base(context, commonServices, logger) { SelectedSoftwareEnvironment = (int)SoftwareEnvironments.Production; }
public NoteViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger, string note) : base(context, commonServices, logger) { SelectedItem = note; }
/// <summary> /// Default constructor /// </summary> /// <param name="context"></param> /// <param name="commonServices"></param> /// <param name="logger"></param> protected BaseBootstrapper( IContext context, IBaseCommonServices commonServices, ILogger logger) { _context = context; _commonServices = commonServices; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="NoteViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="note">The note.</param> /// <param name="targetProperty">The target property.</param> public NoteViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger, string note, string targetProperty) : this(context, commonServices, logger, note) { _targetProperty = targetProperty; }
/// <summary> /// Initializes a new instance of the <see cref="InfoViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> public InfoViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger) : base(context, commonServices, logger) { CompanyName = commonServices.InfoService.CompanyName; ProductName = commonServices.InfoService.ProductName; Version = commonServices.InfoService.ProductVersion; Copyrights = commonServices.InfoService.Copyrights; }
/// <summary> /// Initializes a new instance of the <see cref="ViewModelBladeWizard{TEntity}"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="automaticValidation"></param> protected ViewModelBladeWizard( IContext context, IBaseCommonServices commonServices, ILogger logger, bool automaticValidation = false) : base(context, commonServices, logger, automaticValidation) { Back_Command = new Command(PerformBackAction); Next_Command = new Command(PerformNextAction); Page = 1; }
/// <summary> /// Initializes a new instance of the <see cref="MapsViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="name">The name.</param> /// <param name="address">The address.</param> public MapsViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger, string name, string address) : base(context, commonServices, logger) { Locations = new ObservableCollection <object>(); Title = address; Address = address; Name = name; }
/// <summary> /// Initializes a new instance of the <see cref="InfoViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> public InfoViewModel( IContext context, IBaseCommonServices commonServices, ILogger <InfoViewModel> logger) : base(context, commonServices, logger) { SelectedItem = new InfoModel() { CompanyName = commonServices.InfoService.CompanyName, ProductName = commonServices.InfoService.ProductName, Version = commonServices.InfoService.ProductVersion, Copyrights = commonServices.InfoService.Copyrights }; }
/// <summary> /// Initializes a new instance of the <see cref="LanguageViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="appSettingsService">The settings services.</param> /// <param name="localizationFunctions">The localization functions.</param> /// <param name="logger">The logger factory.</param> public LanguageViewModel( IContext context, IBaseCommonServices commonServices, IBaseApplicationSettingsService appSettingsService, LocalizationFunctions localizationFunctions, ILogger logger) : base(context, commonServices, logger) { _localizationFunctions = localizationFunctions; _appSettingsService = appSettingsService; SetLanguage_Command = new Command <string>((e) => SelectedItem = e); SelectedItem = _appSettingsService.Settings.Culture; }
/// <summary> /// Initializes a new instance of the <see cref="SelectionTestViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> public SelectionTestViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger) : base(context, commonServices, logger) { SelectSingle_Command = new Command(async() => await SelectSingleAsync()); SelectMultiple_Command = new Command(async() => await SelectMultipleAsync()); ShowDialogYesNo = new Command(async() => await ShowDialogAsync(MessageBoxButton.YesNo)); ShowDialogYesNoCancel = new Command(async() => await ShowDialogAsync(MessageBoxButton.YesNoCancel)); ShowDialogOk = new Command(async() => await ShowDialogAsync(MessageBoxButton.OK)); ShowDialogOkCancel = new Command(async() => await ShowDialogAsync(MessageBoxButton.OKCancel)); }
/// <summary> /// Initializes a new instance of the <see cref="ViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="automaticValidation">The validation.</param> protected ViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger, bool automaticValidation = false) : base(automaticValidation) { Context = context; BaseCommonServices = commonServices; Logger = logger; PropertyChanged += OnPropertyChanged; IsInitialized = false; Close_Command = new Command(async() => await CloseAsync()); }
/// <summary> /// Initializes a new instance of the <see cref="EditableComboViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="loggerFactory">The logger factory.</param> public EditableComboViewModel( IContext context, IBaseCommonServices commonServices, ILogger <EditableComboViewModel> loggerFactory) : base(context, commonServices, loggerFactory) { MaskExpression = "9999aa"; RegexExpression = "0000>LL"; //1111Ab 0000Xx this.Validator = new Action <IObservableClass>(_ => { var regex = RegexUtility.MaskToRegexConverter(RegexExpression); if (string.IsNullOrEmpty(RegexSample) || !regex.IsMatch(RegexSample)) { Properties[nameof(RegexSample)].Errors.Add("TextSample is fout."); } }); }
/// <summary> /// Initializes a new instance of the <see cref="SelectionViewModel{TEntity}"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="items">The items.</param> /// <param name="selectedItems">The selected items.</param> /// <param name="selectionMode">The selection mode.</param> /// <param name="automaticValidation"></param> public SelectionViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger, IEnumerable <TEntity> items, IEnumerable <object> selectedItems, SelectionModes selectionMode = SelectionModes.Single, bool automaticValidation = false) : base(context, commonServices, logger, automaticValidation) { if (items is null) { items = items.EnsureNotNull(); } if (selectedItems is null) { selectedItems = selectedItems.EnsureNotNull(); } SelectionMode = selectionMode; Validator = new Action <IObservableClass>(arg => { if (SelectionMode == SelectionModes.Single && SelectedItem.Count != 1) { Properties[nameof(SelectedItem)].Errors.Add(commonServices.LanguageService.GetString("WarningSelectItem")); } if (SelectionMode == SelectionModes.Multiple && SelectedItem.Count < 1) { Properties[nameof(SelectedItem)].Errors.Add(commonServices.LanguageService.GetString("WarningSelectItem")); } }); Search_Command = new Command <string>(async(e) => await QueryItemsAsync(e)); RawItems = items; Items = new ObservableCollection <TEntity>(items); SelectedItem = new List <object>(selectedItems); IsInitialized = true; }
/// <summary> /// Initializes a new instance of the <see cref="SlideShowViewModel"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> public SlideShowViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger) : base(context, commonServices, logger) { UpdateSourceTimer = new Timer(TimeSpan.FromMinutes(30).TotalMilliseconds); UpdateSourceTimer.Elapsed += UpdateSourceTimer_Tick; UpdateSourceTimer.AutoReset = true; UpdateSourceTimer.Start(); // Get initial images from source. Items = new ObservableCollection <MediaItem>() { new MediaItem { Index = 0, ImageUri = "http://3.bp.blogspot.com/-gxIdD54Xngg/UHcjjul0xHI/AAAAAAAAAA8/CkdJsPJ9qlQ/s1600/Microsoft-Windows-7-wallpaper-HD+(6).jpg" }, new MediaItem { Index = 1, ImageUri = "http://3.bp.blogspot.com/-mo_E98lebOM/UHcjgEm5vdI/AAAAAAAAAA0/zLbJOvWRa8M/s1600/Microsoft-Windows-7-wallpaper-HD+(5).jpg" }, new MediaItem { Index = 2, ImageUri = "https://wallpapercave.com/wp/W4ab0vD.jpg" }, new MediaItem { Index = 3, ImageUri = "http://getwallpapers.com/wallpaper/full/c/6/8/100549.jpg" } }; // Set timer if images count is at least 1. if (Items.Count > 0) { SlideshowTimer = new Timer(TimeSpan.FromSeconds(5).TotalMilliseconds); SlideshowTimer.Elapsed += SlideshowTimer_Tick; UpdateSourceTimer.AutoReset = true; SlideshowTimer.Start(); } }
/// <summary> /// Default constructor. /// </summary> /// <param name="context"></param> /// <param name="commonServices"></param> /// <param name="logger"></param> public ValidationViewModel( IContext context, IBaseCommonServices commonServices, ILogger <ValidationViewModel> logger) : base(context, commonServices, logger) { IsRegexCheck = true; Regex = @"\d\d\d\d[A-Z]"; Description = commonServices.LanguageService.GetString("ValidationDescription"); this.Validator = new Action <IObservableClass>(_ => { if (string.IsNullOrEmpty(Test)) { Properties[nameof(Test)].Errors.Add($"Value of [{nameof(Test)}] cannot be null or empty."); } if (IsLengthCheck && !string.IsNullOrEmpty(Test) && Test.Length < 4) { Properties[nameof(Test)].Errors.Add($"Value of [{nameof(Test)}] should be equal or larger then 4 characters."); } if (IsRegexCheck && !string.IsNullOrEmpty(Test)) { if (string.IsNullOrEmpty(Regex)) { Properties[nameof(Test)].Errors.Add($"Value of [{nameof(Test)}] should be a valid regex expression."); } if (!System.Text.RegularExpressions.Regex.IsMatch(Test, Regex)) { Properties[nameof(Test)].Errors.Add($"Value of [{nameof(Test)}] does not match the regular expression."); } } }); }
/// <summary> /// Default constructor /// </summary> /// <param name="context"></param> /// <param name="commonServices"></param> /// <param name="logger"></param> public Bootstrapper( IContext context, IBaseCommonServices commonServices, ILogger logger) : base(context, commonServices, logger) { }