Uncategorized

Beta Experience セミナー (2006/07/25) デモ サンプルコード (2)

環境:
Office Professional 2007 Beta 2
VSTO v3 JuneCTP

(→ このサンプルの Beta2TR 及び VSTO 2005 SE Beta 版は、ここ を参照してください)

こんにちは、松崎です。

掲記セミナーで別途使用した単一の XML_Node に対する複数 ビュー のサンプルを追加で添付します。

またお時間が少なく説明不足でした環境構築につきましても、以下、補足しておきます。

1. Office 2007 Professional
※ Sharepoint Server 等は不要です

2.WinFX Runtime FebCTP
http://www.microsoft.com/downloads/details.aspx?FamilyID=f51c4d96-9aea-474f-86d3-172bfa3b828b&DisplayLang=en

3.Visual Studio 2005 Team Suite または Visual Studio 2005 Tools fro Office
(こちらはMSDNサブスクライバーダウンロード、もしくは購入が必要です。)
※ Tools for Office (VB, C#)、Team Developer などのコンポーネントは外して入れて頂いてOKです

4. Visual Studio Tools For Office “v3” – June Community Technology Preview (CTP) http://www.microsoft.com/downloads/details.aspx?familyid=68978824-CA55-4208-A55E-5C4858183B31&displaylang=en

1. Office 2007 Professional

2. WinFX Runtime Beta2
http://www.microsoft.com/downloads/details.aspx?FamilyID=4a96661c-05fd-430c-bb52-2ba86f02f595&DisplayLang=en

3. Visual Studio 2005
※ Express Edition などでも大丈夫です

4.Windows SDK for Beta2
http://www.microsoft.com/downloads/details.aspx?familyid=13F8E273-F5EA-4B7B-B022-97755838DB94&displaylang=en

5. Visual Studio Extenstion for WinFX
http://www.microsoft.com/downloads/details.aspx?familyid=31F9F15D-00E0-4241-8014-2F12679119AA&displaylang=en

6. Windows Workflow Foundation Runtime Beta 2.2 and Visual Studio Extensions for Windows Workflow Foundation Beta 2.2 http://www.microsoft.com/downloads/details.aspx?familyid=5C080096-F3A0-4CE4-8830-1489D0215877&displaylang=en

7. Office Sharepoint Server 2007 Beta2
※その他、必要に応じ、Sharepoint Designer、Project Server等をインストールしてください。

以上です。

=========================================
添付ファイルのソースの一部 (ご参考)

using System;using System.Windows.Forms;using Microsoft.VisualStudio.Tools.Applications.Runtime;using Word = Microsoft.Office.Interop.Word;using Office = Microsoft.Office.Core;using VSTO = Microsoft.Office.Tools;namespace Word_Expense_AddIn{public partial class ThisApplication{#region Fieldsprivate ExpenseTaskPaneControl rfpControl;private VSTO.CustomTaskPane rfpTaskPane;private Office.CustomXMLPart documentRFPData;public const string CUSTOMXMLNAMESPACE = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-03-10T22:27:53";public const string CUSTOMXPATHNSMAPPING = "xmlns:c='http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-03-10T22:27:53'";#endregion#region Initializationprivate void ThisApplication_Startup(object sender, System.EventArgs e){try{this.WindowActivate += new Word.ApplicationEvents4_WindowActivateEventHandler(ThisApplication_WindowActivate);this.WindowDeactivate += new Word.ApplicationEvents4_WindowDeactivateEventHandler(ThisApplication_WindowDeactivate);this.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(ThisApplication_DocumentOpen);this.DocumentBeforeClose += new Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(ThisApplication_DocumentBeforeClose);AddTaskPane(null);}catch (Exception ex){MessageBox.Show(ex.ToString(), "ThisApplication_Startup");}}#endregion#region TaskPaneprivate void AddTaskPane(Word.Window parentWindow){try{if (rfpTaskPane != null){if (rfpTaskPane.Window == parentWindow){return;}}rfpControl = new ExpenseTaskPaneControl();rfpTaskPane = this.CustomTaskPanes.Add(rfpControl, "MSDN Beta Experience Japan !", parentWindow);rfpTaskPane.Visible = true;}catch (Exception ex){MessageBox.Show(ex.ToString(), "AddTaskPane");}}private void RemoveTaskPane(Word.Window Wn){try{if (rfpTaskPane != null){if (rfpTaskPane.Window == Wn){this.CustomTaskPanes.Remove(0);rfpTaskPane = null;}}}catch (Exception ex){MessageBox.Show(ex.ToString(), "RemoveTaskPane");}}#endregion#region Document Eventsvoid ThisApplication_DocumentBeforeClose(Word.Document Doc, ref bool Cancel){RemoveTaskPane(Doc.ActiveWindow);}void ThisApplication_DocumentOpen(Word.Document Doc){AddTaskPane(Doc.ActiveWindow);SetupRFP();}void ThisApplication_WindowDeactivate(Word.Document Doc, Word.Window Wn){RemoveTaskPane(Wn);}void ThisApplication_WindowActivate(Word.Document Doc, Word.Window Wn){AddTaskPane(Wn);}#endregion#region XMLEventsprivate void SetupRFP(){try{//See if this document has the RFP XML PayloadOffice.CustomXMLParts docParts =Globals.ThisApplication.ActiveDocument.CustomXMLParts.SelectByNamespace(CUSTOMXMLNAMESPACE);if (docParts.Count > 0){documentRFPData = docParts[1];//Clean up XML (comes in with empty vendor node)documentRFPData.NamespaceManager.AddNamespace("c", CUSTOMXMLNAMESPACE);//bind to the onChange event of the datedocumentRFPData.NodeAfterReplace += new Microsoft.Office.Core._CustomXMLPartEvents_NodeAfterReplaceEventHandler(documentRFPData_NodeAfterReplace);documentRFPData.NodeAfterInsert += new Microsoft.Office.Core._CustomXMLPartEvents_NodeAfterInsertEventHandler(documentRFPData_NodeAfterInsert);}}catch (Exception ex){MessageBox.Show(ex.ToString(), "SetupRFP");}}void documentRFPData_NodeAfterInsert(Microsoft.Office.Core.CustomXMLNode NewNode, bool InUndoRedo){try{if (NewNode != null){if (NewNode.ParentNode != null)switch (NewNode.ParentNode.BaseName){case "requestDate":rfpControl.RefreshCalendar();break;default:break;}}}catch (Exception ex){MessageBox.Show(ex.ToString(), "ThisApplication.rfpData_NodeAfterReplace");}}void documentRFPData_NodeAfterReplace(Microsoft.Office.Core.CustomXMLNode OldNode, Microsoft.Office.Core.CustomXMLNode NewNode, bool InUndoRedo){try{if (NewNode != null){if (NewNode.ParentNode != null)switch(NewNode.ParentNode.BaseName){case "requestDate":rfpControl.RefreshCalendar();break;default:break;}}}catch (Exception ex){MessageBox.Show(ex.ToString(), "ThisApplication.rfpData_NodeAfterReplace");}}#endregion#region standard VSTO code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InternalStartup(){this.Startup += new System.EventHandler(ThisApplication_Startup);this.Shutdown += new System.EventHandler(ThisApplication_Shutdown);}private void ThisApplication_Shutdown(object sender, System.EventArgs e){}#endregion}}

============================================================

attachment.zip

Categories: Uncategorized

Tagged as:

1 reply»

  1. Hospitality mind Beta Experience セミナー (2006/07/25) デモ サンプルコード Beta Experience セミナー (2006/07/25) デモ サンプルコード (2) 〜ている (teiru) an experience of a difficulty of breathing in europe Making Sense of Japanese: What the Textbooks Don

    Like

Leave a reply to Experience Cancel reply