<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Misha Shneerson : ActionsPane</title><link>http://blogs.msdn.com/mshneer/archive/tags/ActionsPane/default.aspx</link><description>Tags: ActionsPane</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Getting plain VSTO ActionsPane to work.</title><link>http://blogs.msdn.com/mshneer/archive/2005/08/16/452059.aspx</link><pubDate>Tue, 16 Aug 2005 10:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:452059</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/452059.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=452059</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Adding programmable task pane aka ActionsPane with VSTO is a piece of cake. All you really need to do is just add controls to the ActionsPane object using the familiar WinForms paradigm. Here is how you would show a button on the task pane in Word.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Globals.ThisDocument.Controls.Add(new Button());&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;This code produces less than sofisticated task pane but if you remember to do this&amp;nbsp;you are only "this" close to be the ActionsPane&amp;nbsp;expert . If you need to construct something more fancy you do not write any code at all - you use the WinForms designer. Couple clicks to add new UserControl to your project, then couple drag&amp;amp;drops to design the UserControl and set all the right properties in the Property Browser (especially useful is setting the left and right anchors for the text boxes - then those text boxes can resize with the task pane). Then write this code in ThisDocument_Startup event handler:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Globlas.ThisDocument.Controls.Add(new MyUserControl());&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;if you still have not removed the code that adds the empty button then you should see the UserControl stack below the button. This automatic stacking is useful when you want to conditionally add/remove additional UserControls (e.g. you would like to display a currency converter when user fills in expenses part of the trip report - I know the scenario is lame but just bear with me for a moment [:)]).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Additionally your document just became a SmartDocument. It has an XML Expansion Pack (XEP) attached to it. Check out the Tools-&amp;gt;Templates and Add-ins ... dialog. You will see that your document references ActionsPane.xsd schema (which is empty and is there because a schema is required to get whole SmartDocs mechanism get going) and has "Microsoft Actions Pane" XEP as well.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Here is a fun thing to try: delete the "Microsoft Actions Pane" XEP. It is hard to get rid of. It is not the case with other SmartDoc solutions, but this one seems to have an extra protection. Any insights on what is going on here?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;P.S. I am making my posts shorter and aimed to deliver a short point and I am still on the fence whether this is the right thing to do. Is this better than cramming &lt;a href="http://blogs.msdn.com/mshneer/archive/2005/08/10/450069.aspx"&gt;vacations and introductions&lt;/A&gt; into the same post? Or sacrificing the readability and delivering as much information as possible is gonna be more useful when people look for answers later? &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=452059" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/ActionsPane/default.aspx">ActionsPane</category></item><item><title>Back from vacation. ActionsPane, Part 0.</title><link>http://blogs.msdn.com/mshneer/archive/2005/08/10/450069.aspx</link><pubDate>Wed, 10 Aug 2005 22:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:450069</guid><dc:creator>Misha Shneerson</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/mshneer/comments/450069.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mshneer/commentrss.aspx?PostID=450069</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I took some time off from work for a family vacation. We spent our relaxation week on Vancouver Island in Canada. Here is &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;more info since already couple of people have asked. The place we stayed at is called &lt;A href="http://www.beachacresresort.com/"&gt;Beach Acres&lt;/A&gt; in Parksville, BC. We &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;rented an ocean view unit with kitchenette and 2 bedrooms. It was just half a minute away from getting to the sand of the &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;beautiful &lt;A href="http://www.comox-valley-realty.com/index.php?content=php.showpic.php%3F&amp;amp;image=DCP_4214.JPG"&gt;Rathtrevor Beach&lt;/A&gt;. The beach is located in the bay which keeps the waters incredibly calm (just like in the pool but &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;with presence of some marine life and without getting allergies from the chlorine). It is very shallow so despite being &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;generally part of the Pacific the water warms up in this place. It also makes for a nice walk during the low-tide. &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;One can wade hundreds of meters into the ocean and dig up the abundant shellfish, catch crabs, build sand castles that are &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;destroyed with the next tide. The kids had fantastic time as well. The only thing that still puzzles me is some irregularity &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;of the tides - one day it would be 2 tides, another day it is 3. It all would happen during different times of the day &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;without any easily understandable cycle. One low-tide could go up to 400 meters away others would be just 200. No &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;recognizable pattern for me whatsoever although reading the local newspapers could help - they do run the tides guide.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;So, it was then and now I am back in my office. Oh, not exactly. &lt;a href="http://blogs.msdn.com/eric_carter"&gt;Eric&lt;/A&gt; made some arrangements for part of our team to go on an &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;offsite and spend some time in building 36 with Office. Nothing super secretive but I can not tell you about it to not spoil &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;anything that might come out of this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;In other news - in mid-September I am getting out of my Redmond office and going to PDC. Meeting the customers and seeing &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;their side is always fun and gives us inspiration as well. I am looking forward for this especially since Office has so &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;much content to present they even got a separate track in the conference.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;Now back to the ActionsPane. The conception of ActionsPane was a perfect example of a customer driven inspiration. &lt;A href="http://blogs.officezealot.com/chris"&gt;Chris Kunicki&lt;/A&gt; was the early adopter of then new SmartDocs technology in Office 2003. SmartDocs umbrella has more than just a &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;programmable task pane but the programmable task pane is the pivotal feature. You could finally plug your own rich UI into Office. Chris was understandably excited and he even &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;contracted to put together samples of SmartDocs that went out as part of Office 2003 Beta programs. He did this only to &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;realize there is something missing to make SmartDocs a success. &lt;BR&gt;Putting together a programmable task pane using SmartDocs technology is not for weak hearted. To name a few difficulties:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;The &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;central piece is an ISmartDocument interface with 25 methods in it most of which need to be implemented to show a single &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;button control. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;The controls in the SmartDocs are stateless. Once the cursor moves from one XML element to another the &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;controls were destroyed and re-created again. So it was up to the developer to maintain the controls state. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#800080&gt;You could have only 1 button click event handler which was called if any &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;of the buttons were clicked. So if you had 5 &lt;FONT face=Verdana color=#800080&gt;buttons you needed to assign every one of those an ID.&amp;nbsp;When button was clicked this ID was passed to the event handler (which is just another method on the interface) and you would go from there. Messy...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;I can go on and on with the list ... And there was no designer whatsoever! So during the early &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;planning days of VSTO Chris sent an e-mail and ask for the designer experience. Then he asked again. And we would reply that &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;it is very hard to put up a designer to support ISmartDocument interface - it took several years to develop WinForms designer &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;we just did not have the resources. But he would ask again.&lt;BR&gt;And then the light bulb went off. We realized we did not need to create the ISmartDocument designer. All we needed is just to &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;find a way to host WinForms inside the task pane. This WinForm would fill the entire pane area and would serve as a container &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;for the components designed by the developers. &lt;BR&gt;Then things started to happen with the speed of light. The first prototype was just positioning a WinForm form on top of the &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;task pane. It had some message routing problems but it did gave people the ability to see the potential behind the concept. &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;The right hosting solution is to host the WinForms natively e.g. the way IE does it - through ActiveX interfaces. Next, &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;Office added the capability to stretch the ActiveX control to fill the task pane area entirely. This was especially &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;incredibly because it happened only 2 months before Office 2003 shipped. Next Brian fixed for us the issues in WinForms that &lt;/FONT&gt;&lt;FONT face=Verdana color=#800080&gt;cause some focus management issues - you can see those issues if you use .NET Fx 1.1 to show UserControl in the task pane. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;And it was ready. Chris likes to say &lt;A href="http://blogs.officezealot.com/chris/archive/2005/08/02/7635.aspx"&gt;ActionsPane is his favorite feature&lt;/A&gt; and I could not agree more.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080&gt;In my next posts I will talk about creation of vanilla ActionsPane, then using UserControls to design ActionPane components, adding context sensitivity to the ActionsPane using new XMLNode's ContextEnter and ContextLeave events, discuss some usability aspects of the ActionsPane, answer questions (if any)&amp;nbsp;and possibly provide some peek under the hood.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=450069" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mshneer/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/mshneer/archive/tags/ActionsPane/default.aspx">ActionsPane</category></item></channel></rss>