New Site Theme

Saturday, 28 June 2008 12:43 by frimbob

I got a little bored today, so I decided to give a new theme a chance. As a base theme I download a theme called Envision. I found it in the list of themes on the blogengine.net homepage. The theme seemed to have the potential to be mine with a little tweaking of course. An example of the original is below. blog_270608

Why did I like this theme, well it is based on a light colour scheme, that would go well with my new colours. It's a 2 column page , my previous was a two column fluid layout, so I wanted something different. I love grey background and after examining the image files, I determined that I could re-colour the header, footer ,menu and the the main content frame background.

Out a pull Gimp and 2 hours of 'trial and error' I arrive at what you see now.

Conditional Style Sheets


This is the first time that I used a conditional Style-sheet. A quick explanation is necessary. HTML conditional comments are an IE propriety ability, they are used to target different versions of Internet Explorer. Other browsers will ignore the comments and using conditionals is considered a safe Hack.

   1: <!--[if IE]>
   2:   <link href="/blog/themes/Envision.1.0/css.axd?name=IE.css" 
   3:                         rel="stylesheet" type="text/css" />
   4: <![endif]-->

IE  interprets this conditional and if true will print the html inside as normal content, other browsers will treat the conditional as a comment only and will not evaluate the expression.

By using a link statement I was able to create and IE only CSS style sheet to override settings in the master Style-Sheet that would not render correctly in versions of IE.

Current I am using rendered content using cssclass:after attribute selector, which IE7 and below do not support, IE will ignore that declaration but will miss out on necessary css settings, by using and IE only Sheet I can override the cssClass and add back the missing details (if you supply cssclass:after it will only apply css you declare to the attribute value of 'content:').

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   CSS and Javascript | General
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Word Menus Update:

Friday, 20 June 2008 22:19 by frimbob

I have modified the code that I used to create a word menu to build a dynamic version of the previous code. The Application uses an xml file to store the names and location of a list of word-documents that need a menu button.

XML_File


   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <configuration>
   3:   <templates>
   4:     <name location="c:\template1.dot">Template1</name>
   5:     <name location="c:\template2.dot">Template2</name>
   6:     <name location="c:\template3.dot">Template3</name>
   7:     <name location="c:\template4.dot">Template4</name>
   8:   </templates>
   9: </configuration>

I then built a simple class to load and parse the xml file. The class uses and event handler to send the results to other class that are registered. (really an experiment for a delegate call back used in implementing patters like the observer, just for the practice).

ConfigData


   1: Imports System.Xml
   2: Imports System.Xml.Serialization
   3: Imports System.IO
   4:  
   5: '<summary> Reads a Config XmlFile and provides its data as Properties </summary>
   6: Public Class ConfigFile
   7:  
   8: #Region "Private Members"
   9:  
  10:     'Private Members
  11:     Dim TemplateNames_Collection As New System.Collections.Generic.Dictionary(Of String, String)
  12:     Dim objxmlDocument As New XmlDocument
  13:     Dim objRootNode As XmlNode
  14:  
  15:     Delegate Sub UpdateHandler(ByVal sender As Object)
  16:     Public Event UpdateEvent As UpdateHandler
  17:  
  18: #End Region
  19:  
  20: #Region "Properties"
  21:  
  22:     'Declare Properties
  23:     ReadOnly Property TemplateCollection() As System.Collections.Generic.Dictionary(Of String, String)
  24:         Get
  25:             Return TemplateNames_Collection
  26:         End Get
  27:     End Property
  28:  
  29: #End Region
  30:  
  31: #Region "Public Methods"
  32:  
  33:     Public Sub ReadXMLFile()
  34:         'declarations
  35:         Dim objRootChildNodes As XmlNodeList
  36:  
  37:         'get values out of the file and into the dataStructure
  38:         objRootChildNodes = objRootNode.ChildNodes
  39:  
  40:         For Each xmlnode As System.Xml.XmlNode In objRootChildNodes
  41:             For Each xmlNode2 As System.Xml.XmlNode In xmlnode.ChildNodes
  42:                 Dim strNodeValue As String = xmlNode2.InnerText
  43:                 Dim strNodeLocation As String = xmlNode2.Attributes.ItemOf(0).Value
  44:                 TemplateNames_Collection.Add(strNodeValue, strNodeLocation)
  45:             Next
  46:         Next
  47:  
  48:         RaiseEvent UpdateEvent(Me) ' Call the update Event
  49:  
  50:     End Sub
  51:  
  52: #End Region
  53:  
  54: #Region "Constructor"
  55:  
  56:     Public Sub New()
  57:         'loadtheXmlFile 
  58:         objxmlDocument.Load("C:\Users\Guest\Documents\Visual Studio 2005\Projects\WordAddIn1\WordAddIn1\Custom Classes\XMLFile1.xml")
  59:         objRootNode = objxmlDocument.DocumentElement
  60:     End Sub
  61:  
  62: #End Region
  63:  
  64:  
  65: End Class
  66:  

I used the collection in the above class in a For Each loop.  This loop creates a new commandbutton , which is then stored in an array declared at the class level. If the button object where not stored in the array they would go out of scope when the function ends and only the last instance of the button would still exist.

MenuBuilder


   1: Public Class MenuBuilder
   2:  
   3: #Region "Declarations"
   4:  
   5:     Private TemplateCollection As System.Collections.Generic.Dictionary(Of String, String)
   6:     Private MenuTag As String = "Air Stories Helper Program"
   7:     Dim menuCommand() As Office.CommandBarButton
   8: #End Region
   9:  
  10: #Region "properties"
  11:     Private thisapp As Word.Application
  12:     Public Property ThisApplication() As Word.Application
  13:         Get
  14:             Return thisapp
  15:         End Get
  16:         Set(ByVal value As Word.Application)
  17:             thisapp = value
  18:         End Set
  19:     End Property
  20:  
  21: #End Region
  22:  
  23: #Region "Public Methods"
  24:     'loads the controls on the toolbar
  25:     Public Sub LoadData(ByVal subject As Object)
  26:         Dim configData As ConfigFile = TryCast(subject, ConfigFile)
  27:         If Not IsNothing(configData) Or Not IsDBNull(configData) Then
  28:             TemplateCollection = configData.TemplateCollection
  29:         End If
  30:     End Sub
  31:  
  32:  
  33:     Public Sub LoadControls()
  34:  
  35:         'Test for data
  36:         If Not IsNothing(TemplateCollection) Then
  37:             'check if menu bar exists function
  38:             Call CheckIfMenuBarExists()
  39:  
  40:             'load function
  41:             Call AddMenuBar()
  42:         Else
  43:             MessageBox.Show("No menu data present plese contant Administrator")
  44:  
  45:         End If
  46:     End Sub
  47:  
  48:     ' Create the menu, if it does not exist.
  49:     Private Sub AddMenuBar()
  50:         Try
  51:             Dim menuBar As Office.CommandBar = WordAddIn1.Globals.ThisAddIn.Application.CommandBars.ActiveMenuBar
  52:             Dim menuCaption As String = "AIR Template Menu"
  53:             Dim intcounter As Integer = 0
  54:  
  55:             If menuBar IsNot Nothing Then
  56:                 Dim cmdBarControl As Office.CommandBarPopup = Nothing
  57:                 Dim controlCount As Integer = menuBar.Controls.Count
  58:  
  59:                 ' Add the new menu.
  60:                 cmdBarControl = CType(menuBar.Controls.Add(Type:=Office.MsoControlType.msoControlPopup, Before:=controlCount, Temporary:=True),  _
  61:                     Office.CommandBarPopup)
  62:                 cmdBarControl.Caption = "AirStories"
  63:                 cmdBarControl.Tag = MenuTag
  64:  
  65:                 For Each item As String In TemplateCollection.Keys
  66:                     Dim Button As Office.CommandBarButton
  67:                     'Add the menu command.
  68:                     Button = CType(cmdBarControl.Controls.Add(Type:=Office.MsoControlType.msoControlButton, Temporary:=True), Office.CommandBarButton)
  69:                     With Button
  70:                         .Caption = item.ToString
  71:                         .Tag = item.ToString
  72:                         .FaceId = 300
  73:                     End With
  74:                     AddHandler Button.Click, AddressOf menuCommand_Click
  75:                     ReDim Preserve menuCommand(intcounter) ' re-size the array
  76:                     menuCommand(intcounter) = Button
  77:                     intcounter = intcounter + 1 ' increment the counter       
  78:                 Next
  79:  
  80:             End If
  81:         Catch ex As Exception
  82:             MessageBox.Show(ex.Message)
  83:         End Try
  84:     End Sub
  85:  
  86:  
  87: #Region "Constructor"
  88:     Public Sub New()
  89:  
  90:  
  91:     End Sub
  92: #End Region
  93:  
  94: #End Region
  95:  
  96: #Region "Private Methods"
  97:  
  98:     ' If the menu already exists, remove it.
  99:     Private Sub CheckIfMenuBarExists()
 100:         Try
 101:             Dim foundMenu As Office.CommandBarPopup = thisapp.Application.CommandBars.ActiveMenuBar.FindControl(Office.MsoControlType.msoControlPopup, Tag:=MenuTag, Visible:=True, Recursive:=True)
 102:             If foundMenu IsNot Nothing Then
 103:                 foundMenu.Delete(True)
 104:             End If
 105:  
 106:         Catch ex As Exception
 107:             MessageBox.Show(ex.Message)
 108:         End Try
 109:     End Sub
 110:  
 111:  
 112:     'Method to verify the template location
 113:     Private Function VerifyTemplateLoc(ByVal Template As String) As Boolean
 114:         Dim Applic As Word.Application = Globals.ThisAddIn.Application
 115:  
 116:         'split the file name and the location
 117:         Dim TemplateSplit() As String = Template.Split("\")
 118:         Dim fname As String = TemplateSplit(TemplateSplit.Length - 1)
 119:         Dim flocation As String = Template.Replace(fname, "")
 120:         flocation = flocation.Trim()
 121:  
 122:         'found bool
 123:         Dim found As Boolean = False 'default is false
 124:         Try
 125:             Applic.System.Cursor = Word.WdCursorType.wdCursorWait
 126:             With Applic.FileSearch
 127:                 .FileName = fname
 128:                 .LookIn = flocation
 129:                 .SearchSubFolders = True
 130:                 If .Execute() = 1 Then
 131:                     found = True
 132:                 Else
 133:                     found = False
 134:                 End If
 135:             End With
 136:         Finally
 137:             Applic.System.Cursor = Word.WdCursorType.wdCursorNormal
 138:         End Try
 139:         Return found 'return bool
 140:     End Function
 141:  
 142:     Private Sub Newdocument(ByVal location As String)
 143:         
 144:         MessageBox.Show(location.ToString)
 145:  
 146:     End Sub
 147:  
 148: #End Region
 149: