zoukankan      html  css  js  c++  java
  • C# WPF

            /// <summary>
            /// 打开Windows对话框
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                WindowDlg windowDlg = new WindowDlg();
                windowDlg.ShowDialog();
                lbLogs.Items.Add(windowDlg.DialogResult);
            }
    
            /// <summary>
            /// 打开文件对话框
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == true)
                {
                    lbLogs.Items.Add("打开成功:" + openFileDialog.FileName);
                }
                else
                {
                    lbLogs.Items.Add("打开失败");
                }
            }
    
            /// <summary>
            /// 打开保存文件对话框
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Button_Click_2(object sender, RoutedEventArgs e)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                if (saveFileDialog.ShowDialog() == true)
                {
                    lbLogs.Items.Add("保存成功:" + saveFileDialog.FileName);
                }
                else
                {
                    lbLogs.Items.Add("保存失败");
                }
            }
    
            /// <summary>
            /// 打开打印对话框
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Button_Click_3(object sender, RoutedEventArgs e)
            {
                PrintDialog printDialog = new PrintDialog();
                if (printDialog.ShowDialog() == true)
                {
                    lbLogs.Items.Add("打印成功");
                }
                else
                {
                    lbLogs.Items.Add("打印失败");
                }
            }
    
            /// <summary>
            /// 打开文字对话框
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Button_Click_4(object sender, RoutedEventArgs e)
            {
                FontDialog fontDialog = new FontDialog();
                if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    lbLogs.Items.Add("字体选择成功:" + fontDialog.Font);
                }
                else
                {
                    lbLogs.Items.Add("字体选择失败");
                }
    
            }
    
            /// <summary>
            /// 打开颜色对话框
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Button_Click_5(object sender, RoutedEventArgs e)
            {
                ColorDialog colorDialog = new ColorDialog();
                if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    lbLogs.Items.Add("颜色选择成功!" + colorDialog.Color);
                }
                else
                {
                    lbLogs.Items.Add("颜色选择失败!");
                }
            }
        

      作者:Jeremy.Wu
      出处:https://www.cnblogs.com/jeremywucnblog/
      本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    深入了解Java ClassLoader、Bytecode 、ASM、cglib (I)
    如何在ant里import
    敏捷练习(1)评估我的生活方向盘
    你是一个合格的孩子吗?
    [转] C# 路径(目录)
    XML学习记录
    js学习总结不断更新(1)
    LINQ TO XML练习
    做技术,切不可沉湎于技术
    js学习总结持续更新(2)
  • 原文地址:https://www.cnblogs.com/jeremywucnblog/p/12666691.html
Copyright © 2011-2022 走看看