Inheritance: System.Windows.Forms.TrackBar
コード例 #1
0
        public Animatroller.Framework.PhysicalDevice.AnalogInput AddAnalogInput(AnalogInput3 logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();

            moduleControl.Text = logicalDevice.Name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var control = new Control.TrackBarAdv();

            moduleControl.ChildControl = control;
            control.Size          = new System.Drawing.Size(80, 80);
            control.Maximum       = 255;
            control.TickFrequency = 26;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.AnalogInput();

            control.ValueChanged += (sender, e) =>
            {
                device.Trigger((sender as TrackBar).Value / 255.0);
            };

            device.Connect(logicalDevice);

            control.Value = logicalDevice.Value.GetByteScale();

            logicalDevice.Output
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(x =>
            {
                control.SuspendChangedEvents = true;
                try
                {
                    control.Value = x.GetByteScale();
                }
                finally
                {
                    control.SuspendChangedEvents = false;
                }
            });

            return(device);
        }
コード例 #2
0
ファイル: SimulatorForm.cs プロジェクト: HakanL/animatroller
        public Animatroller.Framework.PhysicalDevice.AnalogInput AddAnalogInput(AnalogInput3 logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = logicalDevice.Name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var control = new Control.TrackBarAdv();
            moduleControl.ChildControl = control;
            control.Size = new System.Drawing.Size(80, 80);
            control.Maximum = 255;
            control.TickFrequency = 26;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.AnalogInput();

            control.ValueChanged += (sender, e) =>
            {
                device.Trigger((sender as TrackBar).Value / 255.0);
            };

            device.Connect(logicalDevice);

            control.Value = logicalDevice.Value.GetByteScale();

            logicalDevice.Output
                .ObserveOn(SynchronizationContext.Current)
                .Subscribe(x =>
                {
                    control.SuspendChangedEvents = true;
                    try
                    {
                        control.Value = x.GetByteScale();
                    }
                    finally
                    {
                        control.SuspendChangedEvents = false;
                    }
                });

            return device;
        }