Slides and documents on Devtalk 10 Apr 09
Go here to download the files
Go here to download the files
Windows 7 introduces several new shortcut keys to take advantage of design improvements. These shortcut keys will help save time and improve productivity while using Windows 7. To perform shortcut key strokes, press and hold the keys while performing the task. For example, hold the
key and press the arrow to maximize the selected window.
Table of Shortcuts
Besides upgraded my PC to Intel Q9400 Quad cores processor (I will share my experience on setting up a SharePoint clusters on Hyper-V) later. I also flashed my HTC Diamond to run the latest beta of Windows Mobile 6.5.
The phone upgrade process is not for the faint hearted (it could renders your phone unusable), for example during install Hard SPL to my phone at one point the screen on my Diamond gone blank and an error message appeared on my PC. Luckily thanks to the guidance here I find out this is normal and I just need to restart the application again.
All the while I don’t have intention to upgrade my phone to WM6.5 if not because of the new themes appear on the latest build. Although people still argue about how good looking the themes are but for me it is good enough. Beyond look, the usability of the new Today’s screen is similar to the one found on Smart Phone Edition of WM6.1 which I like very much when I loaned a Motorola Q9 from Pohz.
Below are the links to the latest ROM
HTC Touch Diamond (This is the one I installed)
The cooked ROM for Diamond does not comes with full set of themes so you got to download here.
Again, try this at your own risk, the best support you can get is from xda-developers.com
This is because FCKEditor only create a <embed> element to display Flash content which does not work for IE. IE requires the <object> element to embed Flash in a webpage where else <embed> only works for Firefox based browsers. This links shows the way to embed Flash object in HTML.
Changing the JavaScript code in FCKEditor is a bit troublesome (my JavaScript skill is not good enough) So if you are using .NET you can refer to this method I created to wrap the <embed> element with <object> element. This is more of a quick hack so I make no guarantee it will work in your environment. I am using LINQ to XML for this so you will need Visual Studio 2008 + .NET 3.5.
Public Function UpdateEmbedTag(ByVal content As String) As String Const embedTag As String = "<embed " Const objectTag As String = _ "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'" + _ "codebase='http://download.macromedia.com/pub/shockwave/cabs/" + _ "flash/swflash.cab#version=6,0,40,0' id='myMovieName'><embed " Const embedCloseTag As String = "</embed>" Const objectCloseTag As String = "</embed></object>" '<embed type="application/x-shockwave-flash" ' pluginspage="http://www.macromedia.com/go/getflashplayer" ' src="http://localhost:49427/userfiles/Video/test/flash.swf" ' play="true" loop="true" menu="true"></embed> ' 'TO ' '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' codebase="http://download.macromedia.com/pub/shockwave/cabs/ ' flash/swflash.cab#version=6,0,40,0" id="myMovieName"> ' <param name="movie" value=""/> '</object> Dim _newContent = "<div>" + content.Replace(" ", " ") + "</div>" _newContent = _newContent.Replace(embedTag, objectTag) _newContent = _newContent.Replace(embedCloseTag, objectCloseTag) Dim root = XElement.Parse(_newContent) Dim embedElementList = root.Descendants("embed") Dim flashLocation As String Dim height As String Dim width As String If embedElementList.Count > 0 Then For Each embedElement As XElement In embedElementList If ((embedElement.Attribute("pluginspage") = _ "http://www.macromedia.com/go/getflashplayer") _ Or embedElement.Attribute("type").ToString.Contains("flash")) Then flashLocation = embedElement.Attribute("src") height = embedElement.Attribute("height") width = embedElement.Attribute("width") If Not String.IsNullOrEmpty(width) Then _ embedElement.Parent.Add(New XAttribute("width", width)) If Not String.IsNullOrEmpty(height) Then _ embedElement.Parent.Add(New XAttribute("height", height)) Dim movie = New XElement("param") movie.Add(New XAttribute("name", "movie")) movie.Add(New XAttribute("value", flashLocation))
embedElement.Parent.Add(movie)
End If Next Return root.ToString Else Return content End If End Function
The news been circulating among SharePoint communities for the pass few weeks and now it is official. Microsoft is going to make SharePoint Designer FREE for all SharePoint customers.The open letter from SharePoint product team can be viewed here. Customers with SharePoint Designer 2007 Software Assurance (SA) current as of April 1, 2009 will receive upgrade rights to Expression Web for the lifetime of their SA agreement.
There is a lot of forward mail about this Conficker worm out in the wild and it is going to strike on 1st April. Go here to find out more about how it will affect you and how you can protect yourself.
http://www.microsoft.com/protect/computer/viruses/worms/conficker.mspx
Since Microsoft introduces the OpenXML format, one key innovation enabled for developers is the ease of manipulate the content of Office documents without using any additional component. What you need (since OpenXML documents are XML files packaged in ZIP) are the System.IO.Packaging as well as System.XML in .NET to do magic.
So one of the magic you can do is create a skeleton document which you can reuse later to pump data. This is suitable for used as document generator where mail merge is not the right solution as you might want to integrate business logic inside; and also you might want the application hosted as a server side solution running from the Web.
When it comes to surfacing tabular data onto the Word document, things get a little bit tricky. You document could have many tables inside, and there is no way in OpenXML at the moment to ID a table as in HTML. But there is another solution which will work that is wrapping the table with your custom XML Schema tag. I created one (below) with a Document and a Section element.
<?xml version="1.0" encoding="utf-8"?> <xs:schema id="SectionedDocument" targetNamespace="http://tempuri.org/SectionedDocument.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/SectionedDocument.xsd" xmlns:mstns="http://tempuri.org/SectionedDocument.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Document" type="DocumentType"> </xs:element> <xs:complexType name="DocumentType" mixed="true"> <xs:sequence> <xs:element name="Section" minOccurs="1" maxOccurs="unbounded"> </xs:element> </xs:sequence> </xs:complexType> </xs:schema>
Next time you need to do is to import this document into Word. Open up Word 2007, look out for the Developer tab
Click on Schema, a new Templates and Add-ins window will appear
Click on the ‘Add Schema…’ button
When a new file dialog opened, look for the xsd file you just created and double click to select it.
A Schema Settings windows will then appear asking you to give it a Alias. It can be anything for this exercise, I’ll name mine ‘document’
Then click OK and the Schema Settings window will be closed. You are now back to Templates and Add-ins windows. You can see the new schema ‘document’ inside the Available XML Schemas list.
You can now click OK at the bottom of the Templates and Add-ins windows
After that you will realize there is a new custom task pane opened up at the right hand side of the Word window called XML Sctructure
Look at the bottom and you will see a ‘Document’ item in the Choose an element… window. That Document item is the Document XML element you created inside the .xsd just now.
Before we bind the XML element to the document, let’s create some table first
Now click on the ‘Document’ item at the lower right of the screen. You should be able to see a screen like below
At the Apply to entire document window, click Apply to Entire Document
After that you shall see a ‘Document’ tag surrounding the document; you might also notice the lower right part of the list does not have the ‘Document’ item but instead a ‘Section’ item.
Now highlight the table by dragging the mouse around it. You might want to have line breaks before and after the table so you can insert the ‘Section’ tag to wrap around it. (as per pic below)
After that click on the ‘Section’ item at the task pane over the right hand side
Then this is what you will see at the document, the ‘Document’ and ‘Section’ tag wrapping the table.
Now you can save and close the Word document.
Open up Visual Studio 2008. As per mentioned before you can make use of any free ZIP and XML API from any platform and language to manipulate this but I found a better and easier way using LINQ to XML and OpenXML SDK v2.0. LINQ to XML comes out of the box with VS2008 but you have to download OpenXML SDK 2.0 here.
Install the SDK onto your PC. the start VS2008 and create a Console Application project for this exercise.
Add a reference to the OpenXML SDK by right click the project file and choose ‘Add reference’
Look for DocumentFormat.OpenXml.dll in C:\Program Files\Open XML Format SDK\V2.0\lib when the Add reference window pops up
After that open Module1.vb and copy and paste the codes below to replace the code inside.
Below as the code and I hope they are self explanatory. You can download my project from my SkyDrive.
Imports DocumentFormat.OpenXml.Wordprocessing Imports DocumentFormat.OpenXml.Packaging Imports DocumentFormat.OpenXml Module Module1 Sub Main() 'Constants for the XML Schema namespace and tags Const WORD_PROCESSING_NS As String = _ "http://schemas.openxmlformats.org/wordprocessingml/2006/main" 'replace the following with what you have in your own XSD Const CUSTOM_XML_SCHEMA_NS As String = "http://tempuri.org/SectionedDocument.xsd" Const DOCUMENT_TAG As String = "Document" Const SECTION_TAG As String = "Section" 'Open a document form the file location 'For SharePoint document, got to change that to IOStream Dim doc = WordprocessingDocument.Open("c:\test\table.docx", True) Using doc 'open up document.xml from the zip Dim mainPart = doc.MainDocumentPart 'There could be multi instances of XML Schema imported For Each documentXsdBlock In mainPart.Document.Body.Elements(Of CustomXmlBlock)() Dim uri = documentXsdBlock.GetAttribute("uri", WORD_PROCESSING_NS) Dim element = documentXsdBlock.GetAttribute("element", WORD_PROCESSING_NS) 'Every XML schema can have more than one element, so must double check '<w:customXml w:uri="http://tempuri.org/SectionedDocument.xsd" w:element="Document"> If uri.Value = CUSTOM_XML_SCHEMA_NS _ And element.Value = DOCUMENT_TAG Then For Each sectionXsdBlock In documentXsdBlock.Elements(Of CustomXmlBlock)() uri = sectionXsdBlock.GetAttribute("uri", WORD_PROCESSING_NS) element = sectionXsdBlock.GetAttribute("element", WORD_PROCESSING_NS) 'Every XML schema can have more than one element, so must double check '<w:customXml w:uri="http://tempuri.org/SectionedDocument.xsd" ' w:element="Section"> If uri.Value = CUSTOM_XML_SCHEMA_NS _ And element.Value = SECTION_TAG Then Dim table = sectionXsdBlock.Elements(Of Table).First Dim rows = table.Elements(Of TableRow)() 'Make a copy of the 2nd row (assumed that the 1st row is header) Dim dupRow = rows(1).CloneNode(True) 'Insert data into duplicated node 'This is the place to put in a For loop if you inserting more than 1 row 'A table cell in Word OOXML is arranged like this '<w:tc> --> This is the TableCell object ' <w:p> --> This is the Paragraph object ' <w:r> --> This is the Run object ' <w:t> --> This is the Text object, ' inside this XML element is the content For Each cell In dupRow.Elements(Of TableCell)() Dim paragrahs = cell.Elements(Of Paragraph)() Dim para As Paragraph 'Checking is need because a TableCell might not have content at all ' and vice versa for Paragraph and Run If paragrahs.Count < 1 Then para = New Paragraph cell.AppendChild(para) Else para = paragrahs.First End If Dim runs = para.Elements(Of Run)() Dim _run As Run If runs.Count < 1 Then _run = New Run para.AppendChild(_run) Else _run = runs.First End If Dim texts = _run.Elements(Of Text)() Dim _text As Text If texts.Count < 1 Then _text = New Text _run.AppendChild(_text) Else _text = _run.First End If 'You can use your business logic to insert something here _text.Text = "Something" Next ' End of Insert data program logic table.AppendChild(dupRow) 'You might want to delete the first row since you already duplicate it 'Place this line of code with caution if you are inserting more than 1 row. rows(1).Remove() End If Next End If Next doc.MainDocumentPart.Document.Save() End Using End Sub End Module
I had the privilege to deliver a talk for the folks of Scope International at their office last Thursday (26 Mar 09). Scope International is the IT arm of Standard Chartered Bank and they develop LOB applications to cater for the needs of Standard Chartered Bank users worldwide.
All thanks to Raymond Cheong who help arranged the session (and created a nice EDM for the talk) and the Training Dept for making this a success.
You can download the new VSeWSS 1.3 March 2009 CTP now.
New features in version 1.3 include:
What is a surprising to me from the VSeWSS team is a release of a set of 10 new theme projects for VSeWSS. These are individual Visual Studio 2008 projects which when deployed to SharePoint offer fresh new designed themes you can use in your projects. As the preview pic above, the themes are nicely designed.
About a year after the first beta (which was followed by another beta and a release candidate), Microsoft has announced the release of the final version of Internet Explorer 8, the company’s newest browser. The focus of Internet Explorer 8 is better standards compliance, security, and making "common online tasks faster and easier".