/// <summary>
        /// Initializes a new instance of the <see cref="SwatchesWindowControl"/> class.
        /// </summary>
        public SwatchesWindowControl()
        {
            InitializeComponent();
            Type environmentColors = typeof(EnvironmentColors);
            double tileSize = CalculateTileSize();

            foreach (PropertyInfo property in environmentColors.GetProperties(BindingFlags.Public | BindingFlags.Static))
            {
                if (property.Name.EndsWith("BrushKey"))
                {
                    Grid tile = new Grid
                    {
                        Width = tileSize,
                        Height = tileSize,
                        Tag = property.Name,
                        ToolTip = property.Name
                    };

                    tile.SetResourceReference(BackgroundProperty, property.GetValue(null));
                    tile.MouseDown += TileOnMouseDown;
                    Root.Children.Add(tile);
                }
            }

            SizeChanged += OnSizeChanged;
        }
Exemplo n.º 2
0
        public ThemedWindow()
        {
            this.ShouldBeThemed();

            WindowStyle = WindowStyle.None;
            ResizeMode = ResizeMode.CanResizeWithGrip;
            Background = Brushes.Transparent;
            AllowsTransparency = true;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            ShowInTaskbar = false;

            Grid host = new Grid();
            //Header
            host.RowDefinitions.Add(new RowDefinition
            {
                Height = GridLength.Auto
            });
            //Body
            host.RowDefinitions.Add(new RowDefinition());

            FrameworkElement header = BuildHeaderArea();
            header.SetValue(Grid.RowProperty, 0);
            host.Children.Add(header);

            ContentPresenter contentPresenter = new ContentPresenter();
            contentPresenter.SetValue(Grid.RowProperty, 1);
            contentPresenter.SetBinding(ContentPresenter.ContentProperty, new Binding
            {
                Mode = BindingMode.OneWay,
                RelativeSource = new RelativeSource
                {
                    Mode = RelativeSourceMode.FindAncestor,
                    AncestorType = typeof(ThemedWindow)
                },
                Path = new PropertyPath("Content")
            });
            contentPresenter.Resources = Resources;
            host.Children.Add(contentPresenter);

            host.SetResourceReference(BackgroundProperty, EnvironmentColors.ToolWindowBackgroundBrushKey);

            Border hostContainer = new Border
            {
                Child = host,
                //Margin = new Thickness(1, 1, 5, 5),
                BorderThickness = new Thickness(1)
            };
            hostContainer.SetResourceReference(BorderBrushProperty, EnvironmentColors.MainWindowActiveDefaultBorderBrushKey);
            //hostContainer.Effect = new DropShadowEffect
            //{
            //    Direction = -75,
            //    ShadowDepth = 2,
            //    BlurRadius = 2,
            //    Color = Colors.Azure
            //};

            base.Content = hostContainer;
        }
Exemplo n.º 3
0
        private FrameworkElement BuildHeaderArea()
        {
            Grid header = new Grid();
            header.ColumnDefinitions.Add(new ColumnDefinition());
            header.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto});
            header.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });

            //Move grip containing the icon and title
            Grid moveGrip = new Grid();
            moveGrip.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });
            moveGrip.ColumnDefinitions.Add(new ColumnDefinition());
            moveGrip.SetResourceReference(Border.BackgroundProperty, EnvironmentColors.ToolWindowBackgroundBrushKey);
            moveGrip.SetValue(Grid.ColumnProperty, 0);
            moveGrip.MouseLeftButtonDown += TitleBarLeftMouseButtonDown;

            Image icon = new Image
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(10, 5, 4, 0)
            };
            icon.SetBinding(Image.SourceProperty, new Binding
            {
                Source = this,
                Path = new PropertyPath("Icon"),
                Mode = BindingMode.OneWay
            });
            moveGrip.Children.Add(icon);

            Label label = new Label
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(0, 2, 0, 0)
            };
            label.SetValue(Grid.ColumnProperty, 1);
            label.SetBinding(ContentControl.ContentProperty, new Binding
            {
                Source = this,
                Path = new PropertyPath("Title"),
                Mode = BindingMode.OneWay
            });
            label.SetResourceReference(ForegroundProperty, EnvironmentColors.MainWindowActiveCaptionTextBrushKey);
            moveGrip.Children.Add(label);
            header.Children.Add(moveGrip);

            //Close button
            FrameworkElement closeGlyph;
            Path buttonPath;
            GenerateCloseGlyph(out closeGlyph, out buttonPath);

            Style closeButtonStyle = new Style(typeof(Button));
            closeButtonStyle.Setters.Add(new Setter(HeightProperty, (double)25));
            closeButtonStyle.Setters.Add(new Setter(WidthProperty, (double)25));
            closeButtonStyle.Setters.Add(new Setter(FocusVisualStyleProperty, null));
            closeButtonStyle.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonActiveGlyphBrushKey)));
            closeButtonStyle.Setters.Add(new Setter(BackgroundProperty, null));
            closeButtonStyle.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonActiveBorderBrushKey)));
            closeButtonStyle.Setters.Add(new Setter(TemplateProperty, FindResource("FlatButton")));

            Trigger closeButtonHoverTrigger = new Trigger
            {
                Property = IsMouseOverProperty,
                Value = true
            };

            closeButtonHoverTrigger.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveGlyphBrushKey)));
            closeButtonHoverTrigger.Setters.Add(new Setter(BackgroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveBrushKey)));
            closeButtonHoverTrigger.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveBorderBrushKey)));
            closeButtonStyle.Triggers.Add(closeButtonHoverTrigger);

            Trigger closeButtonPressTrigger = new Trigger
            {
                Property = ButtonBase.IsPressedProperty,
                Value = true
            };

            closeButtonPressTrigger.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownGlyphBrushKey)));
            closeButtonPressTrigger.Setters.Add(new Setter(BackgroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownBrushKey)));
            closeButtonPressTrigger.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownBorderBrushKey)));
            closeButtonStyle.Triggers.Add(closeButtonPressTrigger);

            Button closeButton = new Button
            {
                Style = closeButtonStyle,
                Name = "closeButton",
                Content = closeGlyph,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment = VerticalAlignment.Center
            };

            closeButton.SetValue(Grid.ColumnProperty, 2);
            header.Children.Add(closeButton);
            buttonPath.SetBinding(Shape.FillProperty, new Binding
            {
                Path = new PropertyPath("Foreground"),
                Source = closeButton,
                Mode = BindingMode.OneWay
            });

            closeButton.Click += CloseButtonClick;

            return header;
        }
Exemplo n.º 4
0
 //sets the style of the grid
 private bool SetTabStyle(Grid tab, Boolean toDefault)
 {
     if (toDefault)
         tab.SetResourceReference(Control.StyleProperty, "GridStyle_hover");
     else
         tab.SetResourceReference(Control.StyleProperty, "GridStyle_Selected");
     return true;
 }