• 不错的东东


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.IO;

    namespace AppleInPicture
    {
        public partial class frmMain : Form
        {
            public frmMain()
            {
                InitializeComponent();
            }

            private void btnSelectPicture_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "(*.jpg)|*.jpg|(*.gif)|*.gif";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    this.tbPicture.Text = ofd.FileName;
                }
            }

            private void btnSelectApple_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Apple file|*.rar;*.zip;*.7z";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    this.tbApple.Text = ofd.FileName;
                }
            }

            private void btnMake_Click(object sender, EventArgs e)
            {
                if (this.tbApple.Text.Length == 0 || this.tbPicture.Text.Length == 0)
                {
                    return;
                }

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "Image file|*.jpg";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    Process p = new Process();
                    p.StartInfo.FileName = "cmd.exe";
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardInput = true;
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.RedirectStandardError = true;
                    p.StartInfo.CreateNoWindow = true;
                    p.Start();
                    p.StandardInput.WriteLine(this.makeCommand(this.tbPicture.Text, this.tbApple.Text, sfd.FileName));
                    p.StandardInput.WriteLine("exit");
                    p.WaitForExit();

                    if (File.Exists(sfd.FileName))
                    {
                        MessageBox.Show("製作完成!", "提示");
                    }
                    else
                    {
                        MessageBox.Show("製作失敗!", "提示");
                    }
                }
            }

            private string makeCommand(string f1, string f2, string f3)
            {
                return string.Format("copy /b {0}+{1} {2}", f1, f2, f3);
            }
        }
    }

  • 相关阅读:
    读取XML示例:C#获取XML的数据
    GridView不換行
    List<T> 的条件筛选 where使用方法
    [HDU] 1016 Prime Ring Problem
    [HDU] 1072 Nightmare 和HDU1180有点类似
    [HDU] 1180 诡异的楼梯个人觉得比较有趣的广搜索
    [HDU] 1312Red and Black 用广搜求能探寻到的点的数目
    [HDU] 1026 Ignatius and the Princess I 简单建模后广搜索求最短路径生成树
    [HDU] 1010 Tempter of the Bone最基本的深搜
    [HDU] 1175 连连看 剪枝优化后的性能飙升
  • 原文地址:https://www.cnblogs.com/caishuowen/p/2046415.html
Copyright © 2020-2023  润新知