Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IntSliderViewModel"/> class.
        /// </summary>
        /// <param name="lifetime">
        /// The lifetime of the view model
        /// </param>
        /// <param name="context">
        /// The settings context
        /// </param>
        /// <param name="settingsScalarEntry">
        /// The settings entry this view model is bound to
        /// </param>
        /// <param name="text">
        /// The text to display for this option
        /// </param>
        /// <param name="minValue">
        /// The minimum allowed value
        /// </param>
        /// <param name="maxValue">
        /// The maximum allowed value
        /// </param>
        /// <param name="minValueText">
        /// The text to be displayed next to the lower end of the slider
        /// </param>
        /// <param name="maxValueText">
        /// The text to be displayed next to the upper end of the slider
        /// </param>
        /// <param name="toolTipText">
        /// The text to be shown in a tooltip. If left null, defaults to the description of the bound settings entry
        /// </param>
        public IntSliderViewModel(
            Lifetime lifetime,
            IContextBoundSettingsStoreLive context,
            SettingsScalarEntry settingsScalarEntry,
            string text,
            int minValue,
            int maxValue,
            string minValueText,
            string maxValueText,
            string toolTipText)
        {
            this.Text = text;
            this.MinValue = minValue;
            this.MaxValue = maxValue;
            this.MinValueText = minValueText;
            this.MaxValueText = maxValueText;
            this.ToolTipText = toolTipText ?? settingsScalarEntry.Description;
            this.IntProperty = new Property<int>(lifetime, "IntProperty");
            this.IsEnabledProperty = new Property<bool>(lifetime, "IntProperty") { Value = true };

            context.SetBinding(lifetime, settingsScalarEntry, this.IntProperty);
        }