Inheritance: System.Windows.Forms.UserControl
示例#1
0
        public Animatroller.Framework.PhysicalDevice.DigitalOutput AddDigitalOutput(string name)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var centerControl = new Control.CenterControl();
            moduleControl.ChildControl = centerControl;

            var control = new Animatroller.Simulator.Control.Bulb.LedBulb();
            control.On = false;
            control.Size = new System.Drawing.Size(20, 20);
            centerControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalOutput(x =>
            {
                this.UIThread(delegate
                {
                    control.On = x;
                });
            });

            return device;
        }
        public Animatroller.Framework.PhysicalDevice.MotorWithFeedback AddMotor(MotorWithFeedback logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();

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

            var control = new Control.Motor();

            moduleControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.MotorWithFeedback((target, speed, timeout) =>
            {
                control.Target  = target;
                control.Speed   = speed;
                control.Timeout = timeout;
            });

            control.Trigger = device.Trigger;

            device.Connect(logicalDevice);

            return(device);
        }
        public Control.StrobeBulb AddNewLight(string name)
        {
            var moduleControl = new Control.ModuleControl();

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

            var control = new Control.StrobeBulb();

            moduleControl.ChildControl = control;
            control.Color = Color.Black;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return(control);
        }
        public Control.PixelLight1D AddNewRope(string name, int pixels)
        {
            int scale = 4;

            var moduleControl = new Control.ModuleControl();

            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(scale * pixels + 6, 40);

            var control = new Control.PixelLight1D(scale);

            moduleControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return(control);
        }
        public Control.PixelLight2D AddNewMatrix(string name, int width, int height)
        {
            int scaleX = 12;
            int scaleY = 12;

            var moduleControl = new Control.ModuleControl();

            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(scaleX * width + 6, scaleY * height + 26);

            var control = new Control.PixelLight2D(scaleX, scaleY);

            moduleControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return(control);
        }
        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);
        }
示例#7
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;
        }
        public Label AddLabel(string label)
        {
            var moduleControl = new Control.ModuleControl();

            moduleControl.Text = label;
            moduleControl.Size = new System.Drawing.Size(150, 80);
            flowLayoutPanelLights.Controls.Add(moduleControl);

            var centerControl = new Control.CenterControl();

            moduleControl.ChildControl = centerControl;

            var labelControl = new Label();

            labelControl.Size          = new System.Drawing.Size(150, 60);
            labelControl.Font          = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            labelControl.TextAlign     = ContentAlignment.MiddleCenter;
            centerControl.ChildControl = labelControl;

            return(labelControl);
        }
        public Animatroller.Framework.PhysicalDevice.DigitalOutput AddDigitalOutput(DigitalOutput2 logicalDevice)
        {
            var moduleControl = new Control.ModuleControl();

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

            var centerControl = new Control.CenterControl();

            moduleControl.ChildControl = centerControl;

            var control = new Animatroller.Simulator.Control.Bulb.LedBulb();

            control.On   = false;
            control.Size = new System.Drawing.Size(20, 20);
            centerControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.DigitalOutput(x =>
            {
                if (PendingClose)
                {
                    return;
                }

                Task.Run(() =>
                {
                    this.UIThread(delegate
                    {
                        control.On = x;
                    });
                });
            });

            device.Connect(logicalDevice);

            return(device);
        }
示例#10
0
        public Animatroller.Framework.PhysicalDevice.MotorWithFeedback AddMotor(string name)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(160, 80);

            var control = new Control.Motor();
            moduleControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            var device = new Animatroller.Framework.PhysicalDevice.MotorWithFeedback((target, speed, timeout) =>
            {
                control.Target = target;
                control.Speed = speed;
                control.Timeout = timeout;
            });

            control.Trigger = device.Trigger;

            return device;
        }
示例#11
0
        public Control.RopeLight AddNewRope(string name, int pixels)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(4 * pixels, 50);

            var control = new Control.RopeLight();
            moduleControl.ChildControl = control;
            control.Pixels = pixels;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return control;
        }
示例#12
0
        public Control.StrobeBulb AddNewLight(string name)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(80, 80);

            var control = new Control.StrobeBulb();
            moduleControl.ChildControl = control;
            control.Color = Color.Black;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return control;
        }
示例#13
0
        public Control.PixelLight1D AddNewRope(string name, int pixels)
        {
            int scale = 4;

            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(scale * pixels + 6, 40);

            var control = new Control.PixelLight1D(scale);
            moduleControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return control;
        }
示例#14
0
        public Control.PixelLight2D AddNewMatrix(string name, int width, int height)
        {
            int scaleX = 12;
            int scaleY = 12;

            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = name;
            moduleControl.Size = new System.Drawing.Size(scaleX * width + 6, scaleY * height + 26);

            var control = new Control.PixelLight2D(scaleX, scaleY);
            moduleControl.ChildControl = control;

            flowLayoutPanelLights.Controls.Add(moduleControl);

            return control;
        }
示例#15
0
        public Label AddLabel(string label)
        {
            var moduleControl = new Control.ModuleControl();
            moduleControl.Text = label;
            moduleControl.Size = new System.Drawing.Size(150, 80);
            flowLayoutPanelLights.Controls.Add(moduleControl);

            var centerControl = new Control.CenterControl();
            moduleControl.ChildControl = centerControl;

            var labelControl = new Label();
            labelControl.Size = new System.Drawing.Size(150, 60);
            labelControl.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            labelControl.TextAlign = ContentAlignment.MiddleCenter;
            centerControl.ChildControl = labelControl;

            return labelControl;
        }