<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Would You share! &#187; Ribbon</title>
	<atom:link href="http://www.5ushare.com/tag/ribbon/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.5ushare.com</link>
	<description>Charlie Wu&#039;s blog</description>
	<lastBuildDate>Wed, 01 Sep 2010 09:28:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Developping Ribbon(设计Ｒibbon)</title>
		<link>http://www.5ushare.com/developping-ribbon/</link>
		<comments>http://www.5ushare.com/developping-ribbon/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 23:35:33 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
				<category><![CDATA[VSTO]]></category>
		<category><![CDATA[Ribbon]]></category>

		<guid isPermaLink="false">http://www.5ushare.com/?p=30</guid>
		<description><![CDATA[Nearly the end of the term, coupled with last weekend&#8217;s Northeast ACM, I am afraid not much time to write the VSTO. So taking advantage of this two-day idle, wrote this article. While developping a software, we always want a human surface, VSTO　projects versa. And I　have said before, these articles is mainly for the　users of [...]]]></description>
			<content:encoded><![CDATA[<p>Nearly the end of the term, coupled with last weekend&#8217;s Northeast ACM,<br />
I am afraid not much time to write the VSTO. So taking advantage of this two-day<br />
idle, wrote this article.</p>
<pre>        While developping a software, we always want
 a human surface, VSTO　projects versa. And I　have
said before, these articles is mainly for the　users
of VS2005, since VS2008 users do not have　to charge
too much effort, VS2008 enables them design a Ribbon
 easily, Figure:

<img src="http://allenlooplee.cnblogs.com/images/cnblogs_com/allenlooplee/e26c8d22-89dc-4dd1-a057-ca17cceaaabc.png" border="0" alt="" width="394" height="213" align="bottom" />

　As an example to VS2005 + PowerPoint2007 (the same
to Word, Excel),user　just need to create a　Add New
Item menu to create a new Ribbon. This creates　two
files　in your project:one for　Ribbon definition
and one　for the　Ribbon codebehind.Just simply edit
the methods　generated in the　Ribbon1 class　to
handle　these callbacks,you will see a new Ribbon,
a lovely　big smiles.</pre>
<p>Follow are the content of the XML file:</p>
<pre>&lt;customUI xmlns=
"http://schemas.microsoft.com/office/2006/01/customui"
onLoad="OnLoad"&gt;
  &lt;ribbon&gt;
    &lt;tabs&gt;
      &lt;tab id="myOwnTab" label="PowerPlugin" &gt;
       &lt;group id="Group_Options" label="PowerPlugin"&gt;
         &lt;toggleButton id="ButtonPassOn" size="large"
 label="PowerPlugin On"　screentip="我的按钮屏幕提示"　
onAction="OnToggleButton" imageMso="HappyFace"/&gt;
        &lt;/group&gt;
      &lt;/tab&gt;
    &lt;/tabs&gt;
  &lt;/ribbon&gt;
&lt;/customUI&gt;

   Here, it is not difficult to see the structure
of our Ribbon:a tab　whose id is　myOwnTab, a group
whose id is Group_Options and a toggleButton whose
id is ButtonPassOn.

&lt;toggleButton id="ButtonPassOn" size="large"
label="PowerPlugin On"　screentip="我的按钮屏幕提示"
　onAction="OnToggleButton" imageMso="HappyFace"/&gt;</pre>
<p>Analysising this statement, we can easily guess the<br />
role of onAction. However,　from where could we see<br />
the statement of OnToggleButton?</p>
<p>Back to our source, we can easily find this function.<br />
public void OnToggleButton(Office.IRibbonControl control, bool isPressed){</p>
<p>}<br />
Thus, the whole process is relatively clear of.</p>
<p>In addition, I would like to introduce several of my control commonly used.</p>
<table style="height: 140px;" border="1" cellspacing="0" cellpadding="4" width="351" bordercolor="#000000">
<col width="85*"></col>
<col width="85*"></col>
<col width="85*"></col>
<tbody>
<tr valign="top">
<td width="33%">
<p align="center">name</p>
</td>
<td width="33%">
<p align="center">Ope1</p>
</td>
<td width="33%">
<p align="center">Ope2</p>
</td>
</tr>
<tr valign="top">
<td width="33%">Box</td>
<td width="33%">OnAction</td>
<td width="33%"></td>
</tr>
<tr valign="top">
<td width="33%">dropDown</td>
<td width="33%">onAction=</p>
<p>&#8220;HandleIndexedAction&#8221;</td>
<td width="33%"></td>
</tr>
<tr valign="top">
<td width="33%">labelControl</td>
<td width="33%">onAction</td>
<td width="33%"></td>
</tr>
<tr valign="top">
<td width="33%">editBox</td>
<td width="33%">getText=&#8221;getText&#8221;</td>
<td width="33%">onChange=</p>
<p>&#8220;HandleOnChange&#8221;</td>
</tr>
<tr valign="top">
<td width="33%">button</td>
<td width="33%">onAction=&#8221;getText&#8221;</td>
<td width="33%"></td>
</tr>
</tbody>
</table>
<p>public string getText(Office.IRibbonControl control){</p>
<pre>}
public void HandleOnChange(Office.IRibbonControl control, string text){
}
public void HandleIndexedAction( Office.IRibbonControl control,
string selectedId, int index){
}

 　　期末将近，再加上周末的ACM东北赛，恐怕无太多时间再写VSTO了。于是
趁着这两天的空闲，写下这篇文章。

　　 开发一款软件，我们往往希望能有一个人性化的界面，VSTO的项目亦是
如此。当然，我以前说过，这些文章主要是针对VS2005的用户的，用VS2008
的用户则不必费太多功夫，VS2008中能直接设计器扩展Ribbon，如图：

 <img src="http://allenlooplee.cnblogs.com/images/cnblogs_com/allenlooplee/e26c8d22-89dc-4dd1-a057-ca17cceaaabc.png" border="0" alt="" width="403" height="255" align="bottom" />
        以VS2005 + PowerPoint2007为例（Word、Excel等类似），用
户倘若要新建一个加载项只需新建类中新建一个功能区支持。这时，将会产生
两个文件，一个Ribbon XML文件，一个Ribbon的源文件。只要按照提示将部
分代码注释取消便能在我们的powerpoint中看到一个新的加载项，一个可爱
的大笑脸。

        Ribbon XML文件的大致内容如下：

&lt;customUI xmlns=
"http://schemas.microsoft.com/office/2006/01/customui"
 onLoad="OnLoad"&gt;
  &lt;ribbon&gt;
    &lt;tabs&gt;
      &lt;tab id="myOwnTab" label="PowerPlugin" &gt;
        &lt;group id="Group_Options" label="PowerPlugin"&gt;
            &lt;toggleButton id="ButtonPassOn" size="large"
 label="PowerPlugin On"　screentip="我的按钮屏幕提示"
onAction="OnToggleButton" imageMso="HappyFace"/&gt;
        &lt;/group&gt;
      &lt;/tab&gt;
    &lt;/tabs&gt;
  &lt;/ribbon&gt;
&lt;/customUI&gt;

        从这儿，我们不难看到我们的Ribbon的构造，是由一个
id为myOwnTab的tab，一个id为Group_Options的group及一个
id为ButtonPassOn的toggleButton构成。其中，tab就是一个
选项卡，计上图中标为的PowerPlugin的选项卡；group也是一个
容器，便是陈放大笑脸的那个容器了；而toggleButton便是那个
大笑脸。

 &lt;toggleButton id="ButtonPassOn" size="large"
 label="PowerPlugin On"　screentip="我的按钮屏幕提示"
onAction="OnToggleButton" imageMso="HappyFace"/&gt;
        分析这个语句，我们可以很轻松地猜测到onAction的作用。
但是，OnToggleButton这个事件又是在哪儿声明的呢？

        回到我们的Ribbon的源文件，在这我们不难找到这个函数。
public void OnToggleButton(Office.IRibbonControl control,
 bool isPressed){
}
        于是，整个过程也相对明晰了。
        另外，我再介绍几个我常用的控件及其处理函数。至于其他
控件，用户可自己尝试或查阅相关资料。</pre>
<table style="height: 116px;" border="1" cellspacing="0" cellpadding="4" width="483" bordercolor="#000000">
<col width="85*"></col>
<col width="85*"></col>
<col width="85*"></col>
<tbody>
<tr valign="top">
<td width="33%">
<p align="center">name</p>
</td>
<td width="33%">
<p align="center">Ope1</p>
</td>
<td width="33%">
<p align="center">Ope2</p>
</td>
</tr>
<tr valign="top">
<td width="33%">Box</td>
<td width="33%">OnAction</td>
<td width="33%"></td>
</tr>
<tr valign="top">
<td width="33%">dropDown</td>
<td width="33%">onAction=</p>
<p>&#8220;HandleIndexedAction&#8221;</td>
<td width="33%"></td>
</tr>
<tr valign="top">
<td width="33%">labelControl</td>
<td width="33%">onAction</td>
<td width="33%"></td>
</tr>
<tr valign="top">
<td width="33%">editBox</td>
<td width="33%">getText=&#8221;getText&#8221;</td>
<td width="33%">onChange=</p>
<p>&#8220;HandleOnChange&#8221;</td>
</tr>
<tr valign="top">
<td width="33%">button</td>
<td width="33%">onAction=&#8221;getText&#8221;</td>
<td width="33%"></td>
</tr>
</tbody>
</table>
<pre>public string getText(Office.IRibbonControl control){
}
public void HandleOnChange(Office.IRibbonControl control, string text){
}
public void HandleIndexedAction( Office.IRibbonControl control,
string selectedId, int index){
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.5ushare.com/developping-ribbon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
