July 2010 - Digital Tool Factory blog July 2010 - Digital Tool Factory blog

The Digital Tool Factory Blog

Silverlight Tip – How to make bold text in a textblock from the CodeBehind

The Problem: You need to conditionally bold text in a text block, but you cannot find any way of doing so

The Cause: For inexplicable reasons, Microsoft chose not to include a FontWeight.Bold in their xaml specification

The Solution: Microsoft did include a FontWeights (note the S) class  To bold text in the codebehind, all you have to do is write this

tbbDownloader.FontWeight = FontWeights.Bold;

And presto!  Bold Text.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


27
Jul 10


Written By Steve French

 

How to fix a missing reference to mscorlib in Visual Studio 2010

Runtime compiling is greatI was trying to update my main app code to utilize the .Net Framework 4.0 and this happened:

The Problem: I could find no obvious way to update the mscorlib reference in my solution, so I decide to simply delete it and add it again, and hope that it magically updates to the most recent version.  This is actually what usually happens with Visual Studio.  However, I delete the mscorlib reference, and I am unable to add it back again, I get the error message telling me that mscorlib is already included in the project.

The Cause: This is a known problem in Visual Studio.

The Solution: I just went into my project (.csproj) file and added the following line

<Reference Include=”mscorlib” />

And that fixed it.  I still have no idea how to make it use the most recent .Net Framework though.

Creative Commons License photo credit: dasapfe

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


26
Jul 10


Written By Steve French

 

An odd thing I noticed after years and years of coding

365.8 (Distracted by Penmanship) Growing up all of my teachers told me that my handwriting was horrible and needed improvement.  I took two years of Russian in college and somehow learning Cyrillic made my handwriting even worse.  My first few jobs after college had varying degrees of handwriting needed, but over time, and especially after I moved to development full time, I wrote things out longhand less and less.

As I’ve gotten older I am now writing things out far more than I used to (thank you Pormodoro Technique) I’ve noticed that my printing has markedly improved, while I’ve forgotten how to write cursive, and I can no longer write anything in Cyrillic, though I can still read it to some degree.

Creative Commons License photo credit: kpwerker

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


21
Jul 10


Written By Steve French

 

A successful round of networking – with presentation lessons learned

Neural Network : basic schemeI just returned from a successful lunch at the Duluth Flash Networking event, sponsored brought to you by Solutions Marketing, and sponsored by Purdue Vision (a graphic design and marketing firm).  I had a good time and learned more about how to market both myself and Stronico.

I’m something of a novice presenter, so I’m sure that this will not be news to many of my readers, but here are the lessons I drew from the four 90 second presentations I made Continue reading →


15
Jul 10


Written By Steve French

 

CSS trick – how to use two classes on a single DOM object

I have no idea how this trick has eluded me for so long, but it is possible to use two classes on the same DOM object.  For example to combine a class called “TopNav” and a class called “SelectedNav” all you have to do is call them both with code like this

<div id=”HomeNavItem” class=”TopNav SelectedNav”>Home</div>

In other words, you’re just putting them in the same class declaration.  I’ve been doing this for years and I’ve never done that before.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


13
Jul 10


Written By Steve French

 

Productivity Tool – a printed call sheet

For unknown reasons I have embraced printed forms this past year.  I started using the Pomodoro Technique  (and their To Do Today sheet) for several months now and recently I came up with a form to keep phone calls on track, and I thought I would share it here.  This will probably make it into the Stronico at some point, but until then, this is what I intend to use.

Download:

Feel free to download and use!

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


08
Jul 10


Written By Steve French

 

A simple way to create a Microsoft Word document from a template in Asp.net/C#

Will code for food I recently had the need to create a Microsoft Word document from a template. I initially tried using Office Web Components and Interop but all that really wasn’t worth the trouble.  I wound up doing global replacements in the html of html   Here is how I did it:

  1. Open up your template document in word, and put any target areas in special Brackets, the text would read something like “I, [FULLNAME] do hereby affirm that”.  I found that the target area had to be in uppercase, I’m not sure why
  2. Go to “Save As Html, Filtered”, and save it in a writeable directory.
  3. In your C# code, first load the entire document into a string
  4. Convert that string into an instance of StringBuilder
  5. Use the StringBuilder Replace function, it would look something like this –  sb.Replace(“[FULLNAME]”, strFullName);
  6. Create a TextWriter, and write the StringBuilder to it – make sure you’re saving it with a “.doc” extension.
  7. Close the TextWriter

All told, the code looks like this

//Create a new filename
string strFileName = System.Guid.NewGuid().ToString();
string strPathRoot = “d:domainsMyDomainWord”;
string strPath = strPathRoot + “TemplateHtml.doc”;
string str = System.IO.File.ReadAllText(strPath);
StringBuilder sb = new StringBuilder();
sb.AppendLine(s);
//replace the text
sb.Replace(“[FULLNAME]”, strFullName);
//save it out
TextWriter tw = new StreamWriter(strPathRoot + strFileName + “.doc”);
// write a line of text to the file
tw.WriteLine(sb.ToString());
// close it
tw.Close();
tw.Dispose();

That’s it!

Creative Commons License
photo credit: pvera

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


06
Jul 10


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.