コード例 #1
0
        void ReleaseDesignerOutlets()
        {
            if (BlueSlider != null)
            {
                BlueSlider.Dispose();
                BlueSlider = null;
            }

            if (ColorLabel != null)
            {
                ColorLabel.Dispose();
                ColorLabel = null;
            }

            if (ColorView != null)
            {
                ColorView.Dispose();
                ColorView = null;
            }

            if (GreenSlider != null)
            {
                GreenSlider.Dispose();
                GreenSlider = null;
            }

            if (RedSlider != null)
            {
                RedSlider.Dispose();
                RedSlider = null;
            }
        }
コード例 #2
0
ファイル: Filter.xaml.cs プロジェクト: glocklueng/LedTable
        /// <summary>
        /// The FilterOptionWindow needs a <see cref="Aurora.MainWindow"/> object
        /// <para>
        /// <list type="bullet">
        /// <listheader>
        /// <description>
        /// The user can change the properties:
        /// </description>
        /// </listheader>
        /// <item>
        /// <description>Brigthness</description>
        /// </item>
        /// <item>
        /// <description>Red component</description>
        /// </item>
        /// <item>
        /// <description>Blue component</description>
        /// </item>
        /// <item>
        /// <description>Green component</description>
        /// </item>
        /// </list>
        /// </para>
        /// </summary>
        /// <param name="mainWindow"></param>
        public FilterOptionWindow(MainWindow mainWindow)
        {
            InitializeComponent();

            ColorMask.Height   = mainWindow.Height;
            this.SizeToContent = System.Windows.SizeToContent.WidthAndHeight;
            this.Loaded       += Mask_Options_Loaded;


            Binding BrightnessBinding = new Binding("Brightness");

            BrightnessBinding.Source = mainWindow;
            BrightnessBinding.Mode   = BindingMode.TwoWay;
            BrightnessSlider.SetBinding(Slider.ValueProperty, BrightnessBinding);

            Binding RedBinding = new Binding("RedMask");

            RedBinding.Source = mainWindow;
            RedBinding.Mode   = BindingMode.TwoWay;
            RedSlider.SetBinding(Slider.ValueProperty, RedBinding);

            Binding BlueBinding = new Binding("BlueMask");

            BlueBinding.Source = mainWindow;
            BlueBinding.Mode   = BindingMode.TwoWay;
            BlueSlider.SetBinding(Slider.ValueProperty, BlueBinding);

            Binding GreenBinding = new Binding("GreenMask");

            GreenBinding.Source = mainWindow;
            GreenBinding.Mode   = BindingMode.TwoWay;
            GreenSlider.SetBinding(Slider.ValueProperty, GreenBinding);
        }
コード例 #3
0
    private void Start()
    {
        RedSlider.SetValueWithoutNotify(Color.r);
        GreenSlider.SetValueWithoutNotify(Color.g);
        BlueSlider.SetValueWithoutNotify(Color.b);
        SR.color = Color;

        RedSlider.onValueChanged.AddListener(RedChanged);
        GreenSlider.onValueChanged.AddListener(GreenChanged);
        BlueSlider.onValueChanged.AddListener(BlueChanged);
    }
コード例 #4
0
        public MainPage()
        {
            InitializeComponent();

            this.WhenActivated(disposables =>
            {
                NightModeBrightnessPicker.Items = Enumerable.Range(0, 255).ToArray();

                this.WhenAnyValue(x => x.ViewModel.Color)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Select(x => Color.FromRgba(x.R / 255f, x.G / 255f, x.B / 255f, x.A / 32f))
                .BindTo(this, x => x.Grid.BackgroundColor)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Color)
                .Select(x => x.GetBrightness())
                .Merge(this
                       .WhenAnyValue(x => x.ViewModel.Color.A)
                       .Select(x => x / 255f)
                       .Skip(1))
                .Select(x => 1 - x)
                .Select(x => Color.FromRgb(x, x, x))
                .SubscribeSafe(SetTextColors)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.ConnectionState.Message)
                .ObserveOn(RxApp.MainThreadScheduler)
                .BindTo(this, x => x.ConnectionStateLabel.Text)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.ConnectionState.Type)
                .Select(x => x == StateType.Connecting)
                .ObserveOn(RxApp.MainThreadScheduler)
                .BindTo(this, x => x.ProgressIndicator.IsVisible)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.ConnectionState.Type)
                .Select(x => x == StateType.Connected)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Do(SetSliderIsEnabled)
                .Select(x => x ? 1f : 0.5f)
                .Do(SetSliderOpacity)
                .SubscribeSafe()
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Red)
                .BindTo(this, x => x.RedLabel.Text)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Green)
                .BindTo(this, x => x.GreenLabel.Text)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Blue)
                .BindTo(this, x => x.BlueLabel.Text)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Alpha)
                .BindTo(this, x => x.BrightnessLabel.Text)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Red)
                .Take(1)
                .BindTo(this, x => x.RedSlider.Value)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Green)
                .Take(1)
                .BindTo(this, x => x.GreenSlider.Value)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Blue)
                .Take(1)
                .BindTo(this, x => x.BlueSlider.Value)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.Alpha)
                .Take(1)
                .BindTo(this, x => x.BrightnessSlider.Value)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.IsNightModeEnabled)
                .CombineLatest(GetInitialNightModePickerRowHeight(), Tuple.Create)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Do(AnimateNightModePickerLayout)
                .Select(x => x.Item1)
                .BindTo(this, x => x.NightModeSwitch.IsToggled)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.NightModeBrightness)
                .ObserveOn(RxApp.MainThreadScheduler)
                .BindTo(this, x => x.NightModeBrightnessPicker.SelectedIndex)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.NightModeFromTime)
                .ObserveOn(RxApp.MainThreadScheduler)
                .SubscribeSafe(x => NightModeFromTimePicker.GetUnderlyingPicker().Time = x)
                .DisposeWith(disposables);

                this.WhenAnyValue(x => x.ViewModel.NightModeToTime)
                .ObserveOn(RxApp.MainThreadScheduler)
                .SubscribeSafe(x => NightModeToTimePicker.GetUnderlyingPicker().Time = x)
                .DisposeWith(disposables);

                RedSlider
                .ValueChange()
                .Select(x => (int)x)
                .BindTo(ViewModel, x => x.Red)
                .DisposeWith(disposables);

                GreenSlider
                .ValueChange()
                .Select(x => (int)x)
                .BindTo(ViewModel, x => x.Green)
                .DisposeWith(disposables);

                BlueSlider
                .ValueChange()
                .Select(x => (int)x)
                .BindTo(ViewModel, x => x.Blue)
                .DisposeWith(disposables);

                BrightnessSlider
                .ValueChange()
                .Select(x => (int)x)
                .BindTo(ViewModel, x => x.Alpha)
                .DisposeWith(disposables);

                NightModeSwitch
                .ToggleChange()
                .BindTo(ViewModel, x => x.IsNightModeEnabled)
                .DisposeWith(disposables);

                NightModeBrightnessPicker
                .SelectionChange()
                .BindTo(ViewModel, x => x.NightModeBrightness)
                .DisposeWith(disposables);

                NightModeFromTimePicker
                .TimeChange()
                .BindTo(ViewModel, x => x.NightModeFromTime)
                .DisposeWith(disposables);

                NightModeToTimePicker
                .TimeChange()
                .BindTo(ViewModel, x => x.NightModeToTime)
                .DisposeWith(disposables);
            });
        }