コード例 #1
0
        private void AddChristmasLightsWindows()
        {
            var screenNumber = 0;

            foreach (var s in WinForms.Screen.AllScreens)
            {
                var m = new BackWindow(this)
                {
                    WindowStartupLocation = WindowStartupLocation.Manual,
                    Left               = s.Bounds.Left,
                    Top                = s.Bounds.Top,
                    Width              = s.Bounds.Width,
                    Height             = s.Bounds.Height,
                    WindowStyle        = WindowStyle.None,
                    Topmost            = true,
                    AllowsTransparency = true,
                    Background         = Brushes.Transparent,
                    Name               = "ChristmasLights_Window" + screenNumber++.ToString(),
                    Screen             = s,
                    Owner              = Application.Current.MainWindow
                };
                _windows.Add(m);
                m.Show();
            }
            _lastShuffle = DateTime.Now;
        }
コード例 #2
0
 private int NextLight(BackWindow w)
 {
     return(FindLight(w, 0, 1));
 }
コード例 #3
0
 private int PreviousLight(BackWindow w)
 {
     return(FindLight(w, 0, -1));
 }
コード例 #4
0
        private int FindLight(BackWindow w, int offset, int step)
        {
            var found = (((w.CurrentLight + offset) + step) + w.LightsCount) % w.LightsCount;

            return(found);
        }
コード例 #5
0
        private void AddLights(BackWindow m)
        {
            m.Lights.Clear();

            m.lightsCanvas.Children.Clear();
            ILight l;

            var leftSide     = new List <ILight>();
            var rightSide    = new List <ILight>();
            var topLeftSide  = new List <ILight>();
            var topRightSide = new List <ILight>();

            var lightSpacing = _lightSpacing;
            var offset       = 0;

            if (Settings.Default.BurninPrevention)
            {
                offset = _rnd.Next(-1 * (lightSpacing / 4), (_lightSpacing / 4));
            }

            for (var x = (lightSpacing / 2); x < (m.Screen.WorkingArea.Height - (lightSpacing / 2)); x += lightSpacing)
            {
                l = CreateLight();
                l.Rotate(90 + RandomAngle());
                Canvas.SetLeft((UIElement)l, 5);
                Canvas.SetTop((UIElement)l, (-1 * offset) + x);

                leftSide.Insert(0, l);
                m.lightsCanvas.Children.Add((UIElement)l);

                l = CreateLight();
                l.Rotate(-90 + RandomAngle());
                Canvas.SetRight((UIElement)l, 5);
                Canvas.SetTop((UIElement)l, offset + x);

                rightSide.Add(l);
                m.lightsCanvas.Children.Add((UIElement)l);
            }

            for (var y = (lightSpacing / 2) + (m.Screen.WorkingArea.Width / 2); y < (m.Screen.WorkingArea.Width - (lightSpacing / 2)); y += lightSpacing)
            {
                l = CreateLight();
                l.Rotate(180 + RandomAngle());
                Canvas.SetTop((UIElement)l, -5);
                Canvas.SetLeft((UIElement)l, offset + y);

                topRightSide.Add(l);
                m.lightsCanvas.Children.Add((UIElement)l);

                l = CreateLight();
                l.Rotate(180 + RandomAngle());
                Canvas.SetTop((UIElement)l, -5);
                Canvas.SetRight((UIElement)l, (-1 * offset) + y);

                topLeftSide.Insert(0, l);
                m.lightsCanvas.Children.Add((UIElement)l);
            }

            m.Lights.AddRange(leftSide);
            m.Lights.AddRange(topLeftSide);
            m.Lights.AddRange(topRightSide);
            m.Lights.AddRange(rightSide);
            m.LightsCount  = m.Lights.Count();
            m.CurrentLight = 0;
        }