示例#1
0
        private void GetSizeFromMonitor(Screen monitor)
        {
            this.SuspendUI = true;
            ScreenColourSettings settings1 = this.Settings;
            Rectangle            bounds1   = monitor.Bounds;
            int x1 = bounds1.X;

            bounds1 = monitor.Bounds;
            int   y1     = bounds1.Y;
            Point point1 = new Point(x1, y1);

            settings1.TopLeft = point1;
            ScreenColourSettings settings2 = this.Settings;
            Rectangle            bounds2   = monitor.Bounds;
            int x2 = bounds2.X;

            bounds2 = monitor.Bounds;
            int width = bounds2.Width;
            int x3    = x2 + width;

            bounds2 = monitor.Bounds;
            int y2 = bounds2.Y;

            bounds2 = monitor.Bounds;
            int   height = bounds2.Height;
            int   y3     = y2 + height;
            Point point2 = new Point(x3, y3);

            settings2.BottomRight = point2;
            this.SetPositionTextBoxesFromSettings();
            this.SuspendUI = false;
            ProcessorBase.SaveSettings <ScreenColourSettings>(this.Settings, (string)null);
        }
示例#2
0
        public ScreenColourUI(ScreenColourSettings settings)
        {
            InitializeComponent();
            SuspendUI = true;

            Settings = settings;
            SetPositionTextBoxesFromSettings();
            SetupLabels(lbLabels, Settings.LabelsAndLocations.Select(x => x.Label).ToList(), Settings);
            SuspendUI = false;
        }
        public void ScreenColour(MaxLifxBulbController bulbController, Random random)
        {
            var frames = 0;
            var start  = DateTime.Now;

            if (Settings == null)
            {
                Settings = new ScreenColourSettings();
            }

            foreach (var bulb in bulbController.Bulbs.Select(x => x))
            {
                if (!SettingsCast.LabelsAndLocations.Select(x => x.Label).Contains(bulb.Label))
                {
                    // populating SettingsCast fields
                    var l = new LabelAndLocationType();
                    l.Label          = bulb.Label;
                    l.ScreenLocation = ScreenLocation.All;
                    l.Zones          = bulb.Zones;
                    // default to None if more than 1 zone, so that can proper setup
                    if (bulb.Zones > 1)
                    {
                        l.ScreenLocation = ScreenLocation.None;
                        // if multizone enabled keep track of number of zones
                        SettingsCast.MultiColourZones.Add(bulb.Zones);
                    }
                    SettingsCast.LabelsAndLocations.Add(l);
                }
            }

            while (!TerminateThread)
            {
                // check if area has changed
                if (TopLeft == SettingsCast.TopLeft && BottomRight == SettingsCast.BottomRight)
                {
                    DoMainLoop(bulbController, ref frames, start);
                }
                else
                {
                    // if it has changed then recalculate zones and set
                    zoneCalculation();
                    TopLeft     = SettingsCast.TopLeft;
                    BottomRight = SettingsCast.BottomRight;
                }
            }
        }
示例#4
0
        public void ScreenColour(MaxLifxBulbController bulbController, Random random)
        {
            var frames = 0;
            var start  = DateTime.Now;

            if (Settings == null)
            {
                Settings = new ScreenColourSettings();
            }

            foreach (var label in bulbController.Bulbs.Select(x => x.Label))
            {
                if (!SettingsCast.LabelsAndLocations.Select(x => x.Label).Contains(label))
                {
                    var l = new LabelAndLocationType();
                    l.Label          = label;
                    l.ScreenLocation = ScreenLocation.All;
                    SettingsCast.LabelsAndLocations.Add(l);
                }
            }

            var payload = new SetColourPayload {
                Kelvin = 3500, TransitionDuration = (uint)(SettingsCast.Fade)
            };

            while (!TerminateThread)
            {
                using (var screenPixel = new Bitmap(CaptureResolution.Width, CaptureResolution.Height, PixelFormat.Format32bppArgb))
                {
                    using (var gdest = Graphics.FromImage(screenPixel))
                    {
                        using (var gsrc = Graphics.FromHwnd(IntPtr.Zero))
                        {
                            DoMainLoop(bulbController, ref frames, start, ref payload, screenPixel, gdest, gsrc);
                        }
                    }
                }
            }
        }