コード例 #1
0
        //public Grid ayLayerAboveArea = null;

        #region 为元素注册事件
        public override void OnApplyTemplate()
        {
            ControlTemplate baseWindowTemplate = this.Template;

            this.StateChanged += AyWindowShellNew_StateChanged;
            TransitionPresenter tp = (TransitionPresenter)baseWindowTemplate.FindName("tpMainImage", this);

            if (tp != null)
            {
                int a;
                if (int.TryParse(AyWindowShellConfigSetting.GetXmlValue("skinSwitchAnimation"), out a))
                {
                    tp.Transition = AyTransitionGetter.AyTransitionOneWay()[a];
                }
                else
                {
                    tp.Transition = AyTransitionGetter.AyTransitionOneWay()[16];
                }
            }

            Button skinBtn = (Button)baseWindowTemplate.FindName("PART_SKIN", this);

            if (skinBtn != null)
            {
                skinBtn.Click += delegate
                {
                    if (SkinWindowMethodOverride != null)
                    {
                        SkinWindowMethodOverride();
                    }
                    else
                    {
                        OpenSkinWindowShow();
                    }
                };
            }
            Button closeBtn = (Button)baseWindowTemplate.FindName("PART_CLOSE", this);

            if (closeBtn != null)
            {
                closeBtn.Click += delegate
                {
                    try
                    {
                        if (CloseWindowMethodOverride != null)
                        {
                            CloseWindowMethodOverride();
                        }
                        else
                        {
                            DoCloseWindow();
                        }
                    }
                    catch
                    {
                    }
                };
            }


            Button minBtn = (Button)baseWindowTemplate.FindName("PART_MIN", this);

            if (minBtn != null)
            {
                minBtn.Click += delegate
                {
                    if (MinWindowMethodOverride != null)
                    {
                        MinWindowMethodOverride();
                    }
                    else
                    {
                        DoMinWindow();
                    }
                };
            }

            Button maxBtn = (Button)baseWindowTemplate.FindName("PART_MAX", this);

            if (maxBtn != null)
            {
                maxBtn.Click += delegate
                {
                    if (MaxWindowMethodOverride != null)
                    {
                        MaxWindowMethodOverride();
                    }
                    else
                    {
                        DoRestoreOrMax();
                    }
                };
            }

            Button menuWindow = (Button)baseWindowTemplate.FindName("PART_MENU", this);

            if (menuWindow != null)
            {
                if (WindowMenu != null)
                {
                    WindowMenuVisibility       = Visibility.Visible;
                    WindowMenu.Placement       = PlacementMode.Bottom;
                    WindowMenu.PlacementTarget = menuWindow;
                }

                menuWindow.Click += delegate
                {
                    if (MenuWindowMethodOverride != null)
                    {
                        MenuWindowMethodOverride();
                    }
                    else
                    {
                        ShowWindowMenu();
                    }
                };
            }

            Button restoreBtn = (Button)baseWindowTemplate.FindName("restoreWindow", this);

            if (restoreBtn != null)
            {
                restoreBtn.Click += delegate
                {
                    if (MaxWindowMethodOverride != null)
                    {
                        MaxWindowMethodOverride();
                    }
                    else
                    {
                        DoRestoreOrMax();
                    }
                };
            }
            AllCP = (ContentPresenter)baseWindowTemplate.FindName("AllCP", this);

            ayLayerArea      = (Grid)baseWindowTemplate.FindName("AyLayerArea", this);
            ayLayerAboveArea = (Grid)baseWindowTemplate.FindName("AyLayerAboveArea", this);
            AyWindowMaskArea = GetTemplateChild("AyWindowMaskArea") as Rectangle;

            if (this.WindowState == WindowState.Normal)
            {
                restoreWindowVisibility = Visibility.Collapsed;
                maxWindowVisibility     = Visibility.Visible;
            }
            else
            {
                restoreWindowVisibility = Visibility.Visible;
                maxWindowVisibility     = Visibility.Collapsed;
            }



            if (WindowState == WindowState.Maximized)
            {
            }
            if (p != null)
            {
                p.Radius          = CornerRadius.TopLeft;
                p.StrokeThickness = BorderThickness.Top;
                p.Stroke          = BorderBrush;
                this.BgData       = p;
            }

            AyBackgroundBehindLayer = (Border)baseWindowTemplate.FindName("AyBackgroundBehindLayer", this);
            AyBackgroundLayer       = (Border)baseWindowTemplate.FindName("AyBackgroundLayer", this);
        }
コード例 #2
0
        void AyGaosiBackgroundLayer_Loaded(object sender, RoutedEventArgs e)
        {
            Loaded -= AyGaosiBackgroundLayer_Loaded;

            tpMainImage.Transition = AyTransitionGetter.AyTransitionOneWay()[2];
        }