Пример #1
0
        public CompactButton(CompactHeader header)
        {
            Header     = header;
            Width      = header.HeaderSize;
            Height     = header.HeaderSize;
            windowDrag = new WindowDragger(this, header.Window);

            /*Random rand = new Random(Environment.TickCount + GetHashCode());
             * byte[] buff = new byte[3];
             * rand.NextBytes(buff);
             * BackColor = Color.FromArgb(255, buff[0], buff[1], buff[2]);*/

            header.Window.Deactivated += Window_Deactivated;
        }
Пример #2
0
        private void Initialize()
        {
            this.WindowStyle = System.Windows.WindowStyle.None;
            this.ResizeMode  = System.Windows.ResizeMode.CanResizeWithGrip;

            //this.Topmost = true;

            // This removes the resize border with CanResizeWithGrip
            this.AllowsTransparency = true;

            // Remove the resize grip
            Style gripStyle = new Style(typeof(ResizeGrip));

            gripStyle.Setters.Add(new Setter(ResizeGrip.TemplateProperty, null));
            Resources.Add(typeof(ResizeGrip), gripStyle);

            this.Loaded += WPFCompactForm_Loaded;

            container = new CompactContainer();
            container.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            container.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            contentGrid     = new Grid();
            contentSplitter = new GridSplitter();
            contentSplitter.ShowsPreview = true;
            contentSplitter.IsTabStop    = false;

            contentContainer = new CompactContentContainer(this);
            contentContainer.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            contentContainer.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            contentContainer.Children.Add(contentGrid);

            originalTextBox                                  = new CompactTextBox();
            originalTextBox.Background                       = Brushes.White;
            originalTextBox.VerticalAlignment                = System.Windows.VerticalAlignment.Stretch;
            originalTextBox.HorizontalAlignment              = System.Windows.HorizontalAlignment.Stretch;
            translatedTextBox                                = new CompactTextBox();
            translatedTextBox.TextBox.IsReadOnly             = true;
            translatedTextBox.TextBox.IsReadOnlyCaretVisible = ShowTranslatedTextBoxCaret;
            translatedTextBox.Background                     = Brushes.White;
            translatedTextBox.VerticalAlignment              = System.Windows.VerticalAlignment.Stretch;
            translatedTextBox.HorizontalAlignment            = System.Windows.HorizontalAlignment.Stretch;
            Header           = new CompactHeader(this);
            Header.BackColor = BorderColor;
            Header.Layout();

            this.SnapsToDevicePixels         = true;
            this.FocusVisualStyle            = null;
            contentSplitter.FocusVisualStyle = null;

            // Maybe shouldn't need BorderSize here, should the border be able to collapse into the header?
            //MinHeight = MinWidth = header.HeaderSize + BorderSize;
            this.MinWidth  = 150;
            this.MinHeight = 100;

            // Alternative method for borderless with resize functionality (buggy)

            /*this.BorderThickness = new Thickness(0);
             * WindowChrome windowChrome = new WindowChrome();
             * windowChrome.GlassFrameThickness = new Thickness(5);
             * windowChrome.CornerRadius = new CornerRadius(0);
             * windowChrome.CaptionHeight = header.HeaderSize - 4;
             * WindowChrome.SetWindowChrome(this, windowChrome);*/

            AddChild(container);
            CreateLayout();
        }