|
本帖最后由 ET_ET 于 2014-3-5 16:58 编辑
CA-705D 作业...- using Microsoft.Office.Tools.Ribbon;
- using System.Diagnostics;
- namespace WordAddIn1
- {
- public partial class myFirstRibbon
- {
- private Process myProc = new Process();
- private bool hasNotepad = false;
- private void myFirstRibbon_Load(object sender, RibbonUIEventArgs e)
- {
- myProc.StartInfo.FileName = "notepad";
- myProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
- button1.OfficeImageId = "NextPageOneNote";
- }
- private void button1_Click(object sender, RibbonControlEventArgs e)
- {
- RibbonButton btn = (RibbonButton)sender;
- if (!hasNotepad)
- {
- myProc.Start();
- btn.Label = "关闭后台记事本";
- btn.OfficeImageId = "ClearRow";
- }
- else
- {
- myProc.Kill();
- btn.Label = "后台打开记事本";
- btn.OfficeImageId = "NextPageOneNote";
- }
- hasNotepad = !hasNotepad;
-
- }
- private void button2_Click(object sender, RibbonControlEventArgs e)
- {
- string myTry;
- myTry = this.checkBox1.Checked ? "http://www.office-cn.net" : "http://yy.com/91283328/2175343697?from=";
- try
- {
- Process.Start(myTry);
- }
- catch (System.Exception ex)
- {
- System.Windows.Forms.MessageBox.Show(ex.Message);
- }
- }
- private void checkBox1_Click(object sender, RibbonControlEventArgs e)
- {
- string lbl = checkBox1.Checked ? "打开Office中国" : " 打开YY ";
- checkBox1.Label = lbl;
- button2.Label = lbl;
- }
- }
- }
复制代码
|
评分
-
查看全部评分
|