/// <summary>
 /// </summary>
 /// <param name="mainWindow"></param>
 /// <param name="ni"></param>
 /// <param name="activeDevices"></param>
 /// <param name="rotateDisplay"></param>
 /// <param name="rotateButtonAndCanvas"></param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="mainWindow" /> is <see langword="null" />.
 ///     <paramref name="ni" /> is <see langword="null" />.
 ///     <paramref name="activeDevices" /> is <see langword="null" />.
 ///     <paramref name="rotateDisplay" /> is <see langword="null" />.
 ///     <paramref name="rotateButtonAndCanvas" /> is <see langword="null" />.
 /// </exception>
 public ApplicationSettings(MainWindow mainWindow, NotifyIcon ni, IActiveDevices activeDevices, IRotateDisplay rotateDisplay, IRotateButtonAndCanvas rotateButtonAndCanvas)
 {
     if (mainWindow == null)
     {
         throw new ArgumentNullException(nameof(mainWindow));
     }
     if (ni == null)
     {
         throw new ArgumentNullException(nameof(ni));
     }
     if (activeDevices == null)
     {
         throw new ArgumentNullException(nameof(activeDevices));
     }
     if (rotateDisplay == null)
     {
         throw new ArgumentNullException(nameof(rotateDisplay));
     }
     if (rotateButtonAndCanvas == null)
     {
         throw new ArgumentNullException(nameof(rotateButtonAndCanvas));
     }
     _mainWindow = mainWindow;
     _ni = ni;
     _activeDevices = activeDevices;
     _rotateDisplay = rotateDisplay;
     _rotateButtonAndCanvas = rotateButtonAndCanvas;
 }
 /// <summary>
 /// </summary>
 /// <param name="mainWindow"></param>
 /// <param name="taskbarIcon"></param>
 /// <param name="activeDevices"></param>
 /// <param name="rotateDisplay"></param>
 /// <param name="rotateButtonAndCanvas"></param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="mainWindow" /> is <see langword="null" />.
 ///     <paramref name="taskbarIcon" /> is <see langword="null" />.
 ///     <paramref name="activeDevices" /> is <see langword="null" />.
 ///     <paramref name="rotateDisplay" /> is <see langword="null" />.
 ///     <paramref name="rotateButtonAndCanvas" /> is <see langword="null" />.
 /// </exception>
 public TaskbarIconConfiguration(MainWindow mainWindow, TaskbarIcon taskbarIcon, IActiveDevices activeDevices, IRotateDisplay rotateDisplay,
                                 IRotateButtonAndCanvas rotateButtonAndCanvas)
 {
     _mainWindow            = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
     _taskbarIcon           = taskbarIcon ?? throw new ArgumentNullException(nameof(taskbarIcon));
     _activeDevices         = activeDevices ?? throw new ArgumentNullException(nameof(activeDevices));
     _rotateDisplay         = rotateDisplay ?? throw new ArgumentNullException(nameof(rotateDisplay));
     _rotateButtonAndCanvas = rotateButtonAndCanvas ?? throw new ArgumentNullException(nameof(rotateButtonAndCanvas));
 }
Exemplo n.º 3
0
        public void BuildDeviceButtons(IActiveDevices activeDevices)
        {
            var x = 10;
            var w = 192;
            var h = 108;

            foreach (var device in activeDevices.Value.OrderBy(d => d.PositionX))
            {
                var buttonHeight = device.Width > device.Height ? h : w;
                var buttonWidth  = device.Width > device.Height ? w : h;
                // ReSharper disable once UseObjectOrCollectionInitializer
                var displayButton = new Button
                {
                    Name       = $"ButtonDisplay{device.Id}",
                    Height     = buttonHeight,
                    Width      = buttonWidth,
                    Background = (SolidColorBrush)FindResource("AccentColorBrush"),
                    Content    = new TextBlock
                    {
                        //Text = $"{displayHelper.Name}{Environment.NewLine}{displayHelper.Width} x {displayHelper.Height}",
                        Text          = $"{device.Name}",
                        TextAlignment = TextAlignment.Center,
                        TextWrapping  = TextWrapping.Wrap
                    },
                    BorderThickness = new Thickness(2),
                    ToolTip         = device.Id
                };

                displayButton.Click += DisplayButtonOnClick;

                var displayCanvas = new Canvas
                {
                    Name   = $"CanvasDisplay{device.Id}",
                    Margin = new Thickness(x, 0, buttonWidth, 0)
                };
                displayCanvas.Children.Add(displayButton);
                DisplayStackPanel.Children.Add(displayCanvas);
            }

            SetWindowMargins();
            ActivateFirstDisplay();
        }
        public void BuildDeviceButtons(IActiveDevices activeDevices)
        {
            var x = 10;
            var w = 192;
            var h = 108;

            foreach (var device in activeDevices.Get().OrderBy(d => d.PositionX))
            {
                var buttonHeight = device.Width > device.Height ? h : w;
                var buttonWidth = device.Width > device.Height ? w : h;
                // ReSharper disable once UseObjectOrCollectionInitializer
                var displayButton = new Button
                                    {
                                        Name = $"ButtonDisplay{device.Id}",
                                        Height = buttonHeight,
                                        Width = buttonWidth,
                                        Background = (SolidColorBrush) FindResource("AccentColorBrush"),
                                        Content = new TextBlock
                                                  {
                                                      //Text = $"{displayHelper.Name}{Environment.NewLine}{displayHelper.Width} x {displayHelper.Height}",
                                                      Text = $"{device.Name}",
                                                      TextAlignment = TextAlignment.Center,
                                                      TextWrapping = TextWrapping.Wrap
                                                  },
                                        BorderThickness = new Thickness(2),
                                        ToolTip = device.Id
                                    };
                displayButton.Click += DisplayButtonOnClick;

                var displayCanvas = new Canvas
                                    {
                                        Name = $"CanvasDisplay{device.Id}",
                                        Margin = new Thickness(x, 0, buttonWidth, 0)
                                    };
                displayCanvas.Children.Add(displayButton);
                DisplayStackPanel.Children.Add(displayCanvas);
            }

            SetWindowMargins();
        }