コード例 #1
0
        /// <summary>
        /// 还原窗体
        /// </summary>
        private void RestoreCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            // 如果canExcute有效,那么那些触发窗体还原的菜单选项和按钮应该是被选中的
            bool canExecute = AvalonCommandsHelper.CanExecuteCommandSource(btnInvokeRestore);

            if (canExecute == true)
            {
                this.btnInvokeRestore.Visibility  = Visibility.Hidden;
                this.btnInvokeMaximize.Visibility = Visibility.Visible;
                this.mnuInvokeMaximize.IsEnabled  = true;
                this.mnuInvokeRestore.IsEnabled   = false;
            }
            this.WindowState = WindowState.Normal;
        }
コード例 #2
0
        /// <summary>
        /// 还原窗体
        /// </summary>
        private void RestoreCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            // 在使用尺寸改变对象改变窗体后保存其原始尺寸
            this.WindowState = WindowState.Normal;
            TransformGroup group     = this.pathTfg as TransformGroup;
            ScaleTransform transform = group.Children[0] as ScaleTransform;

            transform.ScaleX = 1;
            transform.ScaleY = 1;

            // 如果canExcute有效,那么那些触发窗体还原的菜单选项和按钮应该是被选中的.
            bool canExecute = AvalonCommandsHelper.CanExecuteCommandSource(btnInvokeRestore);

            if (canExecute == true)
            {
                this.btnInvokeRestore.Visibility  = Visibility.Hidden;
                this.btnInvokeMaximize.Visibility = Visibility.Visible;
                this.mnuInvokeMaximize.IsEnabled  = true;
                this.mnuInvokeRestore.IsEnabled   = false;
            }
        }
コード例 #3
0
        /// <summary>
        /// 最大化窗体
        /// </summary>
        private void MaximizeCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            // 使用规模改变对象来改变窗体规模
            this.WindowState = WindowState.Maximized;
            TransformGroup group     = this.pathTfg as TransformGroup;
            ScaleTransform transform = group.Children[0] as ScaleTransform;

            transform.ScaleX += 3;
            transform.ScaleY += 3;


            // 如果canExcute有效,那么那些触发窗体最大化的菜单选项和按钮应该是被选中的
            bool canExecute = AvalonCommandsHelper.CanExecuteCommandSource(btnInvokeRestore);

            if (canExecute == true)
            {
                this.btnInvokeRestore.Visibility  = Visibility.Visible;
                this.btnInvokeMaximize.Visibility = Visibility.Hidden;
                this.mnuInvokeMaximize.IsEnabled  = false;
                this.mnuInvokeRestore.IsEnabled   = true;
            }
        }