Пример #1
0
        private void SetButtonInfo(string buttonIndex, string value)
        {
            string controlName = "button" + buttonIndex;
            Button pic         = panButtons.Controls[panButtons.Controls.IndexOfKey(controlName)] as Button;

            string[] info = value.Split(';');
            if (info[0] == "0")
            {
                pic.Image = Image.FromFile(info[1]);
                pic.Tag   = info[2];
            }
            else
            {
                Assembly         assembly    = GetType().Assembly;
                System.IO.Stream streamSmall = null;
                PublicToolNames  name        = (PublicToolNames)Convert.ToInt32(info[1]);
                switch (name)
                {
                case PublicToolNames.Calculator:
                    streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.calc.ico");
                    pic.Image   = new Bitmap(streamSmall);
                    break;

                case PublicToolNames.Cmd:
                    streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.cmd.ico");
                    pic.Image   = new Bitmap(streamSmall);
                    break;

                case PublicToolNames.Excel:
                    streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.excel.ico");
                    pic.Image   = new Bitmap(streamSmall);
                    break;

                case PublicToolNames.Notepad:
                    streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.notepad.ico");
                    pic.Image   = new Bitmap(streamSmall);
                    break;

                case PublicToolNames.Word:
                    streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.WINWORD.ico");
                    pic.Image   = new Bitmap(streamSmall);
                    break;
                }
                pic.Tag = info[1];
            }
            pic.Refresh();
        }
Пример #2
0
        public ElijahSoft(PublicToolNames name)
        {
            InitializeComponent();
            _name = name;
            Ini();
            _SoftType = 1;
            Assembly assembly = GetType().Assembly;

            System.IO.Stream streamSmall = null;
            switch (name)
            {
            case PublicToolNames.Calculator:
                streamSmall   = assembly.GetManifestResourceStream("Elijah_Window.Images.calc.ico");
                picLogo.Image = new Bitmap(streamSmall);
                labInfo.Text  = "使用屏幕“计算器”执行基本的算术任务";
                break;

            case PublicToolNames.Cmd:
                streamSmall   = assembly.GetManifestResourceStream("Elijah_Window.Images.cmd.ico");
                picLogo.Image = new Bitmap(streamSmall);
                labInfo.Text  = "执行基于文本的(命令行)功能";
                break;

            case PublicToolNames.Excel:
                streamSmall   = assembly.GetManifestResourceStream("Elijah_Window.Images.excel.ico");
                picLogo.Image = new Bitmap(streamSmall);
                labInfo.Text  = "使用 Microsoft Office Excel 执行计算、分析信息以及可视化电子表格中的数据";
                break;

            case PublicToolNames.Notepad:
                streamSmall   = assembly.GetManifestResourceStream("Elijah_Window.Images.notepad.ico");
                picLogo.Image = new Bitmap(streamSmall);
                labInfo.Text  = "使用基本文本格式创建和编辑文本文件";
                break;

            case PublicToolNames.Word:
                streamSmall   = assembly.GetManifestResourceStream("Elijah_Window.Images.WINWORD.ico");
                picLogo.Image = new Bitmap(streamSmall);
                labInfo.Text  = "使用 Microsoft Office Word 创建和编辑具有专业外观的文档,如信函、论文、报告和小册子";
                break;
            }
        }
Пример #3
0
 public ElijahSoft(PublicToolNames name) 
 {
     InitializeComponent();
     _name = name;
     Ini();
     _SoftType = 1;
     Assembly assembly = GetType().Assembly;
     System.IO.Stream streamSmall = null;
     switch (name) 
     {
         case PublicToolNames.Calculator: 
             streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.calc.ico");
             picLogo.Image = new Bitmap(streamSmall);
             labInfo.Text = "使用屏幕“计算器”执行基本的算术任务";
             break;
         case PublicToolNames.Cmd: 
             streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.cmd.ico");
             picLogo.Image = new Bitmap(streamSmall);
             labInfo.Text = "执行基于文本的(命令行)功能";
             break;
         case PublicToolNames.Excel:
             streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.excel.ico");
             picLogo.Image = new Bitmap(streamSmall);
             labInfo.Text = "使用 Microsoft Office Excel 执行计算、分析信息以及可视化电子表格中的数据";
             break;
         case PublicToolNames.Notepad:
             streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.notepad.ico");
             picLogo.Image = new Bitmap(streamSmall);
             labInfo.Text = "使用基本文本格式创建和编辑文本文件";
             break;
         case PublicToolNames.Word: 
             streamSmall = assembly.GetManifestResourceStream("Elijah_Window.Images.WINWORD.ico");
             picLogo.Image = new Bitmap(streamSmall);
             labInfo.Text = "使用 Microsoft Office Word 创建和编辑具有专业外观的文档,如信函、论文、报告和小册子";
             break;
     }
 }
Пример #4
0
        void picButton_Click(object sender, EventArgs e)
        {
            try
            {
                Button pic = sender as Button;
                if (pic.Tag != null)
                {
                    string value = pic.Tag.ToString();
                    if (value != "")
                    {
                        if (value.Length == 1)
                        {
                            PublicToolNames _name = (PublicToolNames)Convert.ToInt32(value);
                            #region 打开指定命令
                            switch (_name)
                            {
                            case PublicToolNames.Calculator:
                                System.Diagnostics.Process.Start("calc.exe");
                                break;

                            case PublicToolNames.Cmd:
                                System.Diagnostics.Process.Start("cmd.exe");
                                break;

                            case PublicToolNames.Excel:
                                try
                                {
                                    System.Type excelType = System.Type.GetTypeFromProgID("Excel.Application");
                                    Object      excel     = System.Activator.CreateInstance(excelType);
                                    excelType.InvokeMember("Visible", BindingFlags.SetProperty, null, excel, new Object[] { true });
                                    Object workbooks = excelType.InvokeMember("workbooks", BindingFlags.GetProperty, null, excel, null);
                                    Object workbook  = workbooks.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null, workbooks, null);
                                }
                                catch
                                {
                                    MessageBox.Show("在电脑中未找到Office软件");
                                }
                                break;

                            case PublicToolNames.Notepad:
                                System.Diagnostics.Process.Start("notepad.exe");
                                break;

                            case PublicToolNames.Word:
                                try
                                {
                                    System.Type wordType = System.Type.GetTypeFromProgID("Word.Application");
                                    Object      word     = System.Activator.CreateInstance(wordType);
                                    wordType.InvokeMember("Visible", BindingFlags.SetProperty, null, word, new Object[] { true });
                                    Object documents = wordType.InvokeMember("Documents", BindingFlags.GetProperty, null, word, null);
                                    Object document  = documents.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null, documents, null);
                                }
                                catch
                                {
                                    MessageBox.Show("在电脑中未找到Office软件");
                                }
                                break;
                            }
                            #endregion
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(value);
                        }
                    }
                }
            }
            catch { }
        }