コード例 #1
0
 public CompactContentContainer(WPFCompactForm window)
 {
     Window = window;
 }
コード例 #2
0
        public CompactHeader(WPFCompactForm window)
        {
            Window = window;

            HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            HeaderSize          = 31;
            DrawItemPadding     = true;
            ItemPadding         = 1;
            //ItemPaddingBrush = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));

            FontFamily               = "Arial";
            FontSize                 = 13;
            TextPadding              = 6;
            TextColor                = Colors.White;
            TextBackgroundColor      = Color.FromArgb(25, 255, 255, 255);
            TextColorDeactivatedDraw = Colors.LightGray;

            ControlBoxFontFamily = "Arial";//Estrangelo Edessa
            ControlBoxFontSize   = 15;
            //ControlBoxImageColorOffset = Colors.Tomato;

            ControlBoxPaddingTop    = 3;
            ControlBoxPaddingBottom = 3;
            ControlBoxPaddingLeft   = 3;
            ControlBoxPaddingRight  = Window.BorderSize;
            ControlBoxFadeSize      = 25;

            IconPaddingBorder      = false;
            IconPaddingHalfBorder  = false;
            IconPaddingHalf2Border = true;
            if (IconPaddingHalf2Border)
            {
                IconPadding = (int)(Window.BorderSize / 1.2f);
            }
            else if (IconPaddingHalfBorder)
            {
                IconPadding = Window.BorderSize / 2;
            }
            else if (IconPaddingBorder)
            {
                IconPadding = Window.BorderSize;
            }

            AllowBorderResizeOnButtons = true;
            AllowWindowDragOnButtons   = false;
            AdditionalWindowDrag       = true;

            //DrawDeactivated = true;

            Window.Activated   += Window_Activated;
            Window.Deactivated += Window_Deactivated;

            creatingLayout = true;

            ///////////////////////////////////////////////////
            // Left controls
            ///////////////////////////////////////////////////

            iconButton = new CompactButton(this);
            iconButton.IsIconButton = true;
            iconButton.Click       += iconButton_Click;
            leftButtons.Add(iconButton);
            Children.Add(iconButton);

            languageButton        = new CompactButton(this);
            languageButton.Click += languageButton_Click;
            leftButtons.Add(languageButton);
            Children.Add(languageButton);

            layoutButton        = new CompactButton(this);
            layoutButton.Click += layoutButton_Click;
            leftButtons.Add(layoutButton);
            Children.Add(layoutButton);

            ocrEngineButton        = new CompactButton(this);
            ocrEngineButton.Click += ocrEngineButton_Click;
            leftButtons.Add(ocrEngineButton);
            Children.Add(ocrEngineButton);

            ocrEngineProfileButton        = new CompactButton(this);
            ocrEngineProfileButton.Click += ocrEngineProfileButton_Click;
            leftButtons.Add(ocrEngineProfileButton);
            Children.Add(ocrEngineProfileButton);

            translateAPIButton        = new CompactButton(this);
            translateAPIButton.Click += translateAPIButton_Click;
            leftButtons.Add(translateAPIButton);
            Children.Add(translateAPIButton);

            captureButton        = new CompactButton(this);
            captureButton.Click += captureButton_Click;
            leftButtons.Add(captureButton);
            Children.Add(captureButton);

            captureAreaButton        = new CompactButton(this);
            captureAreaButton.Click += captureAreaButton_Click;
            leftButtons.Add(captureAreaButton);
            Children.Add(captureAreaButton);

            captureAreaFrozenButton        = new CompactButton(this);
            captureAreaFrozenButton.Click += captureAreaFrozenButton_Click;
            leftButtons.Add(captureAreaFrozenButton);
            Children.Add(captureAreaFrozenButton);

            captureAreaEditableButton        = new CompactButton(this);
            captureAreaEditableButton.Click += captureAreaEditableButton_Click;
            leftButtons.Add(captureAreaEditableButton);
            Children.Add(captureAreaEditableButton);

            //iconButton.IsEnabled = false;
            //languageButton.IsEnabled = false;
            //layoutButton.IsEnabled = false;
            //ocrEngineButton.IsEnabled = false;
            //ocrEngineProfileButton.IsEnabled = false;
            translateAPIButton.IsEnabled = false;

            captureButton.IsEnabled             = false;
            captureAreaButton.IsEnabled         = false;
            captureAreaFrozenButton.IsEnabled   = false;
            captureAreaEditableButton.IsEnabled = false;

            ///////////////////////////////////////////////////
            // Right controls
            ///////////////////////////////////////////////////

            sizeControlsOverlay = new CompactButton(this);
            sizeControlsOverlay.IsControlBoxOverlay = true;
            Children.Add(sizeControlsOverlay);
            Canvas.SetRight(sizeControlsOverlay, 0);

            sizeControlsFadeOverlay = new CompactButton(this);
            sizeControlsFadeOverlay.IsControlBoxFade = true;
            Children.Add(sizeControlsFadeOverlay);

            closeButton = new CompactButton(this);
            closeButton.IsControlBoxButton = true;
            closeButton.Click += closeButton_Click;
            rightButtons.Add(closeButton);
            Children.Add(closeButton);

            minimizeButton = new CompactButton(this);
            minimizeButton.IsControlBoxButton = true;
            minimizeButton.Click += minimizeButton_Click;
            rightButtons.Add(minimizeButton);
            Children.Add(minimizeButton);

            Canvas.SetZIndex(sizeControlsFadeOverlay, 999);
            Canvas.SetZIndex(sizeControlsOverlay, 1000);
            Canvas.SetZIndex(closeButton, 1001);
            Canvas.SetZIndex(minimizeButton, 1002);

            iconButton.Width           += IconPadding * 2;
            iconButton.Image            = Properties.Resources.Default27.ToBitmapImage();
            iconButton.DeactivatedImage = Properties.Resources.LostFocus27.ToBitmapImage();

            //minimizeButton.Text = "_";
            //minimizeButton.TextOffset = new Point(0, -2);
            //closeButton.Text = "X";
            //closeButton.TextOffset = new Point(0, 0);
            if (ControlBoxImageColorOffset != default(Color))
            {
                using (var closeImage = Properties.Resources.Close.ColorTint(ControlBoxImageColorOffset))
                {
                    closeButton.Image = closeImage.ToBitmapImage();
                }
                using (var minimizeImage = Properties.Resources.Minimize.ColorTint(ControlBoxImageColorOffset))
                {
                    minimizeButton.Image = minimizeImage.ToBitmapImage();
                }
            }
            else
            {
                closeButton.Image    = Properties.Resources.Close.ToBitmapImage();
                minimizeButton.Image = Properties.Resources.Minimize.ToBitmapImage();
            }
            closeButton.HoverBackColor    = Color.FromArgb(0xFF, 0xFC, 0x3A, 0x3A).DarkenBy(3);
            minimizeButton.HoverBackColor = Color.FromArgb(0xFF, 0x37, 0x9D, 0xE6);
            closeButton.PressBackColor    = closeButton.HoverBackColor.DarkenBy(12);
            minimizeButton.PressBackColor = minimizeButton.HoverBackColor.DarkenBy(12);

            languageButton.Text         = "Chinese (Traditional) - English";
            layoutButton.Text           = "Translated";
            ocrEngineButton.Text        = "Windows";
            ocrEngineProfileButton.Text = "1x Linear";

            creatingLayout = false;
            Layout();
        }