cmiles – blog

Charles Miles – Tucson Hiking, Outside and Adventures, Excel, .net, Life

End of Project Notes

In October of 2007 I started work on a project to convert and extend an older True BASIC data processing program. Early this year, after releasing several versions, work on this project ended and I thought it would be interesting to share some thoughts and experiences. I do not consider myself a ‘master programmer’ and these notes are not intended as ‘expert guidance’ – so why post them? Because I have enjoyed similar posts from other programmers!

Overview:

Platform: The requested target for the project was a Windows desktop application. Windows desktop applications do not get much love/hype these days and at various times during the project we talked about doing a web version. But with no existing server/host to use and without manpower/budget to acquire and maintain a server/host a desktop application was a good choice. Application installation and updates can be a challenging part of a desktop application – but in this case we only ran into a few support issues and it was really not a problem.

Programming Language/Platform: C#/.NET (eventually 3.5)/Visual Studio (eventually 2010). Since Windows desktop was the target and we had existing experience with this stack we did not seriously consider other choices…

Gui: We started the project in WinForms and later moved to WPF. The WinForms version worked fine, but I find WinForms hard to love – in particular I dislike the GUI designer and generated code. It was refreshing to move to WPF, working with XAML for the UI is quite nice and I have found WPF to be a quicker, easier and more maintainable way to create UI (I have used WPF for several other projects as well). I would hesitate to start a new project in WinForms – but I have started to strongly suspect that UI technology/framework matters less than I would have guessed several years ago. My personal experience has been that many technologies have reasonable basic functionality – you are going to be able to get a decent/basic UI built without too much time/pain. But it seems like that in every technology it is going to cost quite a bit of time to tweak/create/craft all of the details needed to make the UI something you would actually want to use (UI hints to help users solve their problems, help for beginners, understandable error messages, good editing, great validation, smart interaction with the database, attractive visuals, great layout, etc…). WPF seems like a step forward compared to WinForms – but not a big enough step forward to make creating good UI easy or to make achieving your vision uncomplicated… I would pick WPF over WinForms for a new project – but certainly not with the illusion that a great UI can be created quickly in any technology.

Data: We used Microsoft SQL Server Express for this project (2005 and 2008 versions). For this project a carefully constructed schema helped us to enforce rules about the data, catch errors and query the data much more easily than a non-relational store would have. We did 95% of our data processing with SQL queries – for this project that turned out to be a very pleasant way to work.

Version Control System: We started this project in 2007 and used Subversion and Trac at hosted-projects.com. While I currently do not have much love for Subversion I did realize after switching to Mercurial that it is easier to explain, understand and use for simple scenarios – a great benefit in some situations. About two years into the project we moved to Mercurial and Assembla. Mercurial is fantastic – my experience has been that Mercurial has quite a few benefits (easier check-ins, faster access to history, nicer branch/merge, quick cloning of the entire repository for experiments) without any additional hassles once you get over the initial learning curve. We stayed with Mercurial for the rest of the project but did move from Assembla to Fogbugz and Kiln. Moving to FogBugz was nice – we found that the default FogBugz setup worked better for us than a default Trac setup (we were not interested in spending time customizing Trac). Moving to Kiln was FANTASTIC – I love the features that Kiln provides for working with Mercurial repositories. The ability to maintain and organize multiple repositories made it much easier to work simultaneously on different releases and features. We took advantage of the 2-person Student/Start-up (free) plan. I really like FogBugz and Kiln, but I do wish they had some additional pricing options – while these services are certainly ‘worth’ $30 per person per month that could be tough to justify for smaller/experimental/less profitable endeavors with more than two developers.

Details:

LINQ to SQL – For a simple strongly typed data access this was great! Creating the data layer via SqlMetal on the command line was a nice part of our workflow. But I am very glad that we did not try to do all of our data processing via LINQ – when we experimented with trying to do everything in LINQ we quickly found that complex queries were more readable, easier to create and faster to change done directly in SQL. While LINQ to SQL is still supported by Microsoft I think it is fair to say all their energy is going into the ADO.NET Entity Framework and I don’t think I would choose LINQ to SQL for a new project.

SQL Server Compact – As noted above we ended up going with SQL Server Express – but our original intention was to use SQL Server Compact edition as the primary database and include an option for advanced users to use an existing SQL Server instance. Unfortunately my ignorance killed the SQL Server Compact part of our plans – I was developed for months via Sql Server and had written hundreds of lines of SQL before I realized that some of the syntax that I had used was not available in SQL Server Compact edition. At that point we felt it would have taken too much time to rewrite the SQL and we went forward with just SQL Server Express. This was a learning experience for me about the differences in SQL databases…

Importing Data – We, of course, ran into problems with users supplying invalid data – but I think that is always true of user input. The more interesting problem we ran into was that we underestimated the user’s ability to understand and fix the problems in their data. For the second version we added a validation layer that gave us a chance to both catch errors in the data AND give the user detailed/helpful error messages – it was certainly not perfect but it helped quite a bit to have detailed user targeted error messages.

Conclusion:

Like any project if I was going to do this again I could do a better job – but we managed to produce a working application that we were able to maintain and constantly improve for several years! I think most of our choices were reasonable given the goals and resources – but certainly database and desktop application would be two things that I would consider carefully if were starting again from the beginning.

CM

Filed under: .net, Software

Generating WPF with T4 Templates for Localization

Recently I had the opportunity to explore setting up a small WPF application for globalization/localization. I had no previous experience with this process, so I started by doing some searching and reading. I thought the links below were particularly interesting:

WPF Localization Guidance – Included in this project is The WPF Localization Guidance PDF by Rick Strahl and Michele Leroux Bustamante – I highly recommend reading this! Great details, several approaches are examined.

Creating an Internationalized Wizard in WPF by Josh Smith, Karl Shifflett. Very nice walk thru of building an Internationalized Wizard style app with resource files. This is a very approachable place to start.

WPF Multi-Lingual at Runtime by Andrew Wood – A XmlDataProvider based solution.

Localizing WPF Applications using Locbaml by brunzefb – This link is notable for its comparison of several different approaches.

WPF Localization by Sacha Barber – Interesting because of the third method shown in the article that uses ResourceDictionaries. For more information on using Resource Dictionaries see the answer to this question on Stack Overflow by  Ray Burns.

 

One interesting thing about many of the approaches above is that the focus seems to on localizing strings/text, and to a lesser degree settings, images and other resources. In the context of WPF I was surprised not to find more information about customizing the layout of the UI as part of the translation into another language. I think the structure of XAML encourages a UI composed of many elements that will need more than string substitution to be ideal in another language.

For example, the XAML below and UI it generates seems typical of the kind of composition and ‘richness’ encouraged by WPF/XAML’s structure and tools:

<UserControl
		xml:lang="en"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="basic_styles.xaml" />
                <ResourceDictionary Source="equations.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

	<WrapPanel Style="{StaticResource description_wrap_panel_style}">

		<TextBlock	x:Name="c_textblock"
					Style="{StaticResource description_textblock_style}"
					AutomationProperties.Name = "Enter a Constant, C, that satisfies the following equation: the standard error of the estimate is equal to the constant C over the square root of the sample size">
			Enter a constant, <Italic>C</Italic>, that satisfies
    	<InlineUIContainer Style='{StaticResource image_container_style}'>
    		<Image x:Name='formula_11'
					Source='{StaticResource equation_11}'
					Style='{StaticResource image_style}'>
                <Image.Height>
                    <MultiBinding Converter='{StaticResource image_size}'>
                        <Binding Mode='OneWay'
								ElementName='formula_11'
								Path='Tag'/>
                        <Binding Mode='OneWay'
								ElementName='c_textblock'
								Path='FontSize'/>
                    </MultiBinding>
                </Image.Height>
            </Image>
    	</InlineUIContainer>
	    </TextBlock>

		<TextBlock 	Style="{StaticResource description_textblock_style}"
					KeyboardNavigation.TabIndex="1">
			(<Hyperlink AutomationProperties.Name='More information about the constant C' x:Name='c_hyperlink'>more info</Hyperlink>)
		</TextBlock>

		<TextBox 	Style="{StaticResource entry_textbox_style}"
					AutomationProperties.LabeledBy="{Binding ElementName=c_textblock}"
					KeyboardNavigation.TabIndex="0">
		</TextBox>

	</WrapPanel>
</UserControl>

Certainly changing out all of the strings to translate this example is possible (slightly painful because of the number of string to change out…). In French or Spanish this would work fine:

 

 

However, here is the same UI translated into Japanese – notice that the translator did not keep the elements in the same position.

 

To accommodate a flexible layout in this application I decided to use T4 templates to generate ‘loose’ XAML files. These files are included in the output and parsed at runtime based on the CurrentCulture.

The code below is the contents of the file base_block.tt – this t4 template holds the common elements of the XAML files and will be ‘imported’ by the language specific t4 templates. The language specific templates will provide values for the variables introduced in base_block.tt. One important detail is the use of encoding="Unicode" – I assumed “Utf-8” would work but the XamlParser would error on some characters when the template specified Utf-8, apparently because of the BOM setting…

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".xaml" encoding="Unicode"#>

<UserControl
		xml:lang="<#= this.xml_lang #>"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="basic_styles.xaml" />
                <ResourceDictionary Source="equations.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

	<WrapPanel Style="{StaticResource description_wrap_panel_style}">

		<TextBlock	x:Name="c_textblock"
					Style="{StaticResource description_textblock_style}"
					AutomationProperties.Name = "<#= this.textblock_automation_name #>">
			<#= this.textblock_constant_C_contents #>
	    </TextBlock>

		<TextBlock 	Style="{StaticResource description_textblock_style}"
					KeyboardNavigation.TabIndex="1">
			<#= this.hyperlink_textblock_contents #>
		</TextBlock>

		<TextBox 	Style="{StaticResource entry_textbox_style}"
					AutomationProperties.LabeledBy="{Binding ElementName=c_textblock}"
					KeyboardNavigation.TabIndex="0">
		</TextBox>

	</WrapPanel>
</UserControl>

<#+

	private string xml_lang = @"";
	private string textblock_constant_C_contents = @"";
	private string textblock_automation_name = @"";
	private string hyperlink_textblock_contents = @"";

#>

Note that the variables hold all of the information that I wanted to be able to manipulate – not just the string portions of the UI. The file for English, en.tt:

<# 
	
	xml_lang = @"en";

	textblock_constant_C_contents = 
		@"Enter a constant, <Italic>C</Italic>, that satisfies
    	<InlineUIContainer Style='{StaticResource image_container_style}'>
    		<Image x:Name='formula_11' 
					Source='{StaticResource equation_11}' 
					Style='{StaticResource image_style}'>
                <Image.Height>
                    <MultiBinding Converter='{StaticResource image_size}'>
                        <Binding Mode='OneWay' 
								ElementName='formula_11' 
								Path='Tag'/>                        
                        <Binding Mode='OneWay' 
								ElementName='c_textblock' 
								Path='FontSize'/>
                    </MultiBinding>
                </Image.Height>
            </Image>
    	</InlineUIContainer>";

	textblock_automation_name = @"Enter a Constant, C, that satisfies the following equation: the standard error of the estimate is equal to the constant C over the square root of the sample size";

	hyperlink_textblock_contents = @"(<Hyperlink AutomationProperties.Name='More information about the constant C' x:Name='c_hyperlink'>more info</Hyperlink>)";

#>

<#@ include file="base_block.tt" #>

The file for the Spanish version:

    <#
	
        xml_lang = @"es";

        textblock_constant_C_contents =
            @"Ingrese una constante, <Italic>C</Italic>, para resolver
            <InlineUIContainer Style='{StaticResource image_container_style}'>
                <Image x:Name='formula_11'
                        Source='{StaticResource equation_11}'
                        Style='{StaticResource image_style}'>
                    <Image.Height>
                        <MultiBinding Converter='{StaticResource image_size}'>
                            <Binding Mode='OneWay'
                                    ElementName='formula_11'
                                    Path='Tag'/>
                            <Binding Mode='OneWay'
                                    ElementName='c_textblock'
                                    Path='FontSize'/>
                        </MultiBinding>
                    </Image.Height>
                </Image>
            </InlineUIContainer>";

        textblock_automation_name = @"Ingrese una constante, C, que satisface la siguiente ecuación: el error estándar de la estimación es igual a la constante C sobre la raíz cuadrada del tamaño de la muestra.";

        hyperlink_textblock_contents = @"(<Hyperlink AutomationProperties.Name='Más información acerca de la constante C'>más información</Hyperlink>)";

    #>

    <#@ include file="base_block.tt" #>

Each of the XAML files has a Build Action of ‘Content’ so that it is included in the output for the project.  At runtime I look at the CurrentCulture, compare that to the names of the generated XAML files that are available, feed the file to XamlReader.Load() and add the resulting UserControl into the UI as needed. A small sample app demonstrating this is a available here.

 

I do not have enough experience with globalization/localization to be confident this approach would work in all situations, but for this application it did work and I enjoyed that it: easily allows flexible UI layout, generated XAML files that could be viewed in the VS editor and is simple to use. I seems to me that the biggest downsides to this approach are that it does not allow translators to work on a simple value pair style file and the loose XAML does not allow for a code-behind (which is usually fine but occasionally awkward – at least for me). I would love to hear any comments or feedback on this approach!

 

Special thanks to Lance and Kent for translating for me!! And extra thanks to Lance for pointing out how to cleanly post source code on WordPress.com

 

Enjoy!

CM

Filed under: .net, , , , , ,

Mercurial and White Presentations

I recently had the opportunity to do two presentations at a Tucson .NET User Group meeting – Aaron Wagner and I gave a ~40 minute presentation on Mercurial and I did a short presentation on White!

It was a privilege to have the opportunity to share information about these tools and great to get some extra motivation to keep learning. The Mercurial presentation was 2/3 slides and 1/3 live demo (Mercurial/TortoiseHg and Kiln) targeted at providing a basic introduction to Mercurial. I have put the slides here for download (Creative Commons Attribution-Share Alike 3.0 Unported), if you are doing a similar short presentation they may be useful – if you are just looking for tutorials/information about Mercurial I suggest you skip these slides and look at this tutorial and this book – both great starting points. (Powerpoint and Impress files are included in the download – the Impress file is not ideal but should be clean enough to easily use or copy).

Enjoy!

CM

Filed under: .net, , ,

Some Experiences in the Display of Mathematical Equations in WPF

I recently needed to display ‘notes’ in a WPF application – the interesting detail was that the notes contained both text and mathematical equations. I did not find a tremendous amount of information about presenting mathematical equations in WPF – so I thought I would share my experiences.

The notes for the application were delivered by the client as a Microsoft Word document.

Because I do not have any experience with Adobe Illustrator or any of the Expression products none of the solutions I investigated involves those products.

 

jsMath – My first idea was to display the notes in a browser control with the hope of reusing them on the web. I quickly found jsMath which generates equations from TeX input (if formulas in TeX are not a familiar idea see Help:Displaying a Formula). Setup was quick and my test page looked nice in Firefox. However, the rendering in the WPF Browser control was unacceptable. It is completely possible that I did not have something configured correctly and/or that there were settings I needed to change, but I decided to move on…

 

MathML – As an alternative to having jsMath handle the equations I briefly looked into using MathML. Unfortunately this page failed to open correctly on my machine in IE8, Chrome, Safari and Opera. That was enough to steer me away from MathML. The page opened without problems in Firefox 3.5…

 

WPF Chromium WebBrowser control – I was not quite ready to give up on the idea of presenting the notes in a browser control with jsMath and thought the rendering in this control might be better. I did not get very far with this and did not try the control in my project – not because of problems with the control, but because the Awesomium project that this control uses is going closed source. I was unsure about the future of the WPF Chromium WebBrowser control without updated versions of Awesomium so I moved on to my next idea.

 

DocumentViewer -  I already had nicely formatted text and equations in the original Word document and thought that I might be able to leverage that. The WPF DocumentViewer control can display XPS documents – and Word documents can be saved as XPS. I saved the first note from the Word document as a .XPS file and – after figuring out that System.Windows.Xps.Packaging is in ReachFramework.dll – quickly put together a test. The file displayed quickly and easily (including equations) and for some applications this could be a great option!  However, I felt the DocumentViewer was too page and print focused for this application. I do not think – at least in it’s default configuration – that the DocumentViewer is a very good solution for displaying shorter items for easy on-screen reading (esp. in a smaller screen area). I am sure I could have tweaked options to improve the DocumentViewer for use in this application, but this seemed like the wrong approach.

 

Word/XPS converted to FlowDocument – I thought these articles were interesting, but was skeptical about the time/results, and did not try this approach – Converting FixedDocument (XPSDocument too) to FlowDocument and WordML to FlowDocument – how to convert docx files to WPF FlowDocument. I would be really curious to hear from anyone how the conversion of Word equations works with the ideas/code presented in these articles.

 

Flow Document  + Images – Images seem like an obvious/traditional choice for presenting the equations and the FlowDocument seemed like an interesting choice for presenting text and images for on-screen reading. One easy way to produce the images is Roger’s Online Equation Editor which transforms LaTeX equations into images. It is easy to work with images in WPF – but the problem I had was getting the images to look as sharp as the text in the FlowDocument when they were resized. If this was a document for printing, or had specific static layout requirements, I think that the images would have worked great. But as the images were resized (either because of dynamic layout changes or changes to the applications design) I was not able to keep them as sharp as the surrounding text. If I had more graphics expertise I may have been able to find a better image type/resolution/rescaling combination.

 

FlowDocument + Shapes – a good friend suggested that I look for ways to represent the equations as SVG. What I eventually found was Inkscape + textext. textext works as an add-in to Inkscape that allows you to render LaTeX. The install and troubleshooting steps near the bottom of the textext page are critical in finding the dependencies (MikTex, Pstoedit, Ghostscript) and dealing with errors (I had to add a directory to my path to get textext working). Once it is up and running textext worked great – it is very easy to create an equation and save it as an SVG file. The next problem is moving the equation from SVG into XAML.

 

SVG to XAML Canvas – All of the methods below can be used to convert an SVG file  into shapes in a XAML Canvas object. In the case of the equations I was producing all of the solutions below generally produced usable output. The Canvas output could be inserted directly into your application – or it could be placed in a resource file by stripping out the Name elements and adding a Key. In addition to using the Canvas directly it could also be used as a VisualBrush.

Xsl – I was able to use the xsl on this page to get canvas based output (and do a some xsl debugging in Visual Studio – a great feature and the first time I have used it).

Inkscape – Inkscape has save as XAML built-in. In the past, for simple images, this worked great for me. For the equations that I was producing in this project the canvas that Inkscape produced apparently lacked a RenderTransform that was crucial to correct display. The problem was fairly easy to fix, but mainly because I had the output from XamlTune as a comparison.

XamlTune – The command line executable in this project worked great – and could potentially be integrated into a build script which is a nice bonus. I had trouble with the gui portion of this project crashing.

The Canvas with shapes output is ok – but I want to reuse the same equation multiple times, use the same equations both as larger stand-alone figures and inline with the text and rescale the larger images as the application’s size changes. I assume that I could get the canvas based resources working for all of those requirements (although I not sure exactly how and imagine a bit of awkward code…). However, I know that having the equations as DrawingImages in a resource file would allow me to use the equations inside an Image tag, solving the problems above.

 

FlowDocument + DrawingImage – The only programs I found that produced DrawingImage output from SVG input were ViewerSvg Professional or Ab2d.ReaderSvg Professional (the ‘Basic’ versions are not listed as having ‘Export as Geometry’ support) from WPF Graphics (demo downloads available – note these will also convert from SVG to a Canvas). This software did nice conversions from SVG to DrawingImage with a good array of options. The Ab2d.ReaderSvg class library also includes a sample application that allows you to combine multiple SVGs into DrawingImages inside a ResourceDictionary, which is almost exactly what I wanted to do! For some situations these applications will not be appropriate since they are commercially licensed software with a cost of $169/$399.

 

Conclusion: The options above present several viable solutions for presenting mathematical equations in a WPF application. Every project will have different requirements that will dictate the best solution. With that said – in my opinion -  the combination of Inkscape and textext to create equations in SVG and Ab2d.ReaderSvg Professional to convert the SVG into DrawingImage resources is the best combination currently available for presenting mathematical  equations for on-screen reading in a WPF application.

 

Enjoy!

CM

Filed under: .net, , , , ,

A beginner’s view – Textual DSL with OSLO

For just over a month I have been working on a project at work that lets users select inventory items from a database using a textual DSL. This is the first DSL I have ever produced! I thought that it was interesting that with no significant experience in building DSLs I was able to produce a useful application in a relatively short period of time. Below are the best resources I found and a few remarks:

 

Overview/Perspective: The Herding Code interview with Markus Völter (who you might know from Software Engineering Radio) is interesting – while not strictly focused on textual DSLs he gives a great overview/critique of Microsoft’s OSLO effort and interesting information on the Eclipse tools in this space (some recent news related to topics in the interview from Douglas Purdy and a short post by Markus). If you want to see some of the Eclipse tools he mentions the second link will take you to a nice presentation.

Useful MGrammar/OSLO focused podcast: This podcast features Shawn Wildermuth and has some great discussion around DSLs with a focus on OSLO:

Bits and samples: The Oslo Developer Center – official downloads and samples (I thought the MGrammar samples were good study material):

Focused start: This three part series by Shawn Wildermuth was incredibly valuable because the focus of the articles matched what I was trying to accomplish quite well:

Digging deeper: There is a good chance that you will need to dig into some of the details of MGraph and MGrammar – I found the following references useful:

Skeptical? The application I developed is currently being tested by a handful of users, so far these are the points I would make in support of the DSL:

  • Less dev time than you might guess: this is a small business app with a tight focus, it was coded by one dev working part-time on the app in about 4 weeks. There are always more features to implement, but the app is useful now with a fairly low investment.
  • Powerful/Flexible Searching: For advanced users the DSL exposes many more search fields/categories/options than I know how to expose via a reasonable list/wizard/combo box/text box style query build screen, and it is not nearly as tedious! The textual interface allows advanced users to be more efficient and creative and gives them access to more options than they had in the past.
  • Conventional UI feeds the DSL: I found the ‘conventional’ query build screen to be fast and pleasant to develop because it simply constructs the text to be parsed! This means that anything I build for the conventional interface needs to be supported by the DSL – this forces all features to remain ‘exposed’ in the textual interface for more advanced users.

Pain points:

  • I was surprised by the amount of work that I had to to to turn the AST produced by parsing the user’s input into usable objects/actions. There are some samples/posts/ideas out that can help build objects automatically – but this seems like an obvious area for Microsoft to enhance since we are talking about an all MS tool chain. I imagine that most scenarios are going to involve walking the tree to build/modify objects? Is there an approach or scenario that really does not do that?
  • The lack of a text editor component to put in your application in conjunction with your DSL is disappointing. There is an obvious need to deliver an editor for your DSL embedded in your app with syntax highlighting and keyword completion, if that is currently available I am not aware of it… While inputting text into a vanilla textbox may be a good test of the simplicity and logic of your DSL I doubt it is really the user experience you want. If a commercial product is an option then Actipro’s WPF SyntaxEditor might be interesting – they have MGrammar support which sounds encouraging, but I have not made time to test it out.

While the jury is still out if the application mentioned in this post will be successful I think that it was the right choice to build and try a DSL – hopefully if you are interested in trying out a textual DSL in .NET the links and information above will be interesting!

CM

Filed under: .net, ,

Edward Tufte in Phoenix

Last week I went to Phoenix with my friend AJ to see a presentation by Edward Tufte – if you have not seen Edward Tufte’s work it is without a doubt worth a trip to his website. The price of the course includes four of his books and about six hours of presentation.

I really enjoyed the presentation! I have read various topics on his web site (‘ask E.T. forum’) and read part of Envisioning Information – with that background the best part was getting a broader overview of his ideas (which – in retrospect – I really missed in my previous reading) and a good framework for understanding the examples in his books. I also appreciated that E.T. was careful to give a number of interesting suggestions about ways to bring his ideas into the ‘everyday’ working world – useful information that was very much appreciated. Highly recommended!

CM

Filed under: .net

Multi Tap Tempo – Updated

I added several features and eliminated some bugs after using this for one of the first projects of the season. Updates are here:

Multi Tap Tempo Setup
Multi Tap Tempo Source

This post
describes the software…

Enjoy!
CM

Filed under: .net

Small Visuals Update 2

New version – I have worked through a few more features/fixes:

Source Code
Setup Files

Changes:
- Updated the application to correctly deal with multi-area selections (see screen shot for an example) [to me this is valuable for use with PivotTables where I do not want to turn off subtotals].

- Added a set of button to move the current selection 1 row/column left/right/up/down to assist in the use of multi-area selections (this is in large part for quick selections in PivotTables)

- Added progress and cancel to Add Values/Clear Lines/Draw Lines (these can be slow) – all are implemented through the BackGroundWorker Class. I read sections of Joseph Albarhi’s very very helpful Threading in C# several times while trying to code this.

This image shows the multi-area processing on a PivotTable connected to the AdventureWorks DB -

I also update my original Small Visuals post with two really good links that I missed when I put together my list of in-cell/sparkline/excel links:

Mike Schaeffer’s Weblog – Excel 12 Databars Now. (Sort Of)
: Another nice take on in-cell databars via a UDF.

Andrew’s Excel Tips – Bar Graphs In Cells/2: A different take on autoshapes to produce the graphs – very nice results.



And on a related (but different) note I added a link to: .NET & Excel XL-Dennis on .NET & Excel – I am sure this will be very interesting reading if the .net/Excel combo is interesting.

Enjoy!
CM

Filed under: .net, Excel

Excel Small Visuals – Update

Just a quick note that I put up some updated files for this project (original post with download links and update notes here).

Enjoy,
CM

Filed under: .net, Excel

Excel Small Visuals

[update 9/25/2006 - I have posted a new version (see links below) and noted changes below]

I have been working on a small project in my free time for the past couple of weeks –

The short version:
I wanted to produce a .net program that would produce ‘in-cell’ visualizations. There are already a number of techniques and programs for doing this (see links below) – many more beautiful and professional than my effort – but I think that a few of the features in this program (at least for me) are unique and useful. The Visual Studio VB.NET solution is available (and I had programmatic use in mind…) as well as a setup for the application (download links below) – BEWARE THIS IS ALPHA SOFTWARE AND MAY BE UNSTABLE AND UNPREDICTABLE. See the screenshots below.

The Long Version:
If you work with Excel long enough I think that you will eventually run into a situation where small/mini/’in-cell’ graphs – in the style of/informed/inspired by Edward Tufte’s Sparklines – become very interesting. Mini-graphs are a fantastic way to increase the density of information, I am especially fond of using them to visualize information that would not normally fit onto a single screen.

A Google search Sparklines returns nearly 2 million results – there is a lot to choose from! – I think the links below are exceptionally helpful with Excel and Sparklines in mind:

E.T. Sparklines – Pages from the Sparklines Chapter and a really interesting discussion.

Lightweight Data Exploration and More on Excel in-cell graphing from Juice Analytics: These articles have some awesome examples of lightweight data visualizations in Excel.

Daily Dose of Excel In-Cell Charting: Check out the Charting category for some other interesting ideas.


Mike Schaeffer’s Weblog – Excel 12 Databars Now. (Sort Of)
:Another nice take on in-cell databars via a UDF.

Andrew’s Excel Tips – Bar Graphs In Cells/2: A different take on autoshapes to produce the graphs – very nice results.

BonaVista Systems MicroCharts: I have only recently tried this – interesting stuff.

Bissantz SparkMaker: Very polished and beautiful with many great options – well worth the time to download and explore.

Particle Tree Sparklines Roundup: Nice set of links grouped by language – this points to some really useful links.

If you follow the links above you will quickly see that there are attractive code and applications already written – but I had some specific goals that I thought might be served by writing this program:

-Shapes based on Excel (Office) shapes rather than a font or an image – I did not expect the results to easily move to an application other than Excel, to scale as well or to be as sharp as a custom font or image, but I wanted a format that would easily and simply coexist with the ‘normal’ contents of a cell (text/formulas).

-Programmatic Use in .net/Windows Forms – I hope to use this in later projects and I was not sure that the examples I found would integrate nicely into a winforms application with the features I was looking for.

Some samples:

Primary elections

Downward rotation

UK Stacked Lines

Multiple Rotation

US verse Canadian

Potential Problems:

-ONLY LIGHTLY TESTED and may contain many severe bugs and possible problems, use at your own risk!!!

-Application needs the .net Excel PIA (there are several potential problems including getting the PIA, installing it and compatibility issues with Excel 2000 and earlier)

-There is currently either a variable type/rounding or resolution limit that creates poor spacing in some combinations of lines – the problem is easy to reproduce but has been lower on my list of things to fix…

-Runs outside of Excel rather than as an add-in – I REALLY like this approach, but it seems to create potential failure points during communication with Excel and can leave an Excel process behind if this application is closed after Excel (not sure best way to catch this)

-A certain lack of code comments and application help or documentation…

Source Code
Setup Files

Things on my higher up on the current ‘hope to get done’ list -
Explore ways to fix the gaps/unevenness in tightly spaced lines
Continue to find/fix/trap errors
Add grouping to sets of lines
Improve documentation

[Update 9/25/2006]
I finished a few changes over the weekend, the files linked above are now updated:
-Added Grouping UI options and code (need to refine but seems to be stable and working)
-Added to UI to attempt to make options slightly more clear
-Moved Stats to its own class making databinding the Summary information to the UI possible
-Moved code from main form into Collection class for better logic
-Provided for a case where a value set has same min and max (which previously crashed with divide by zero error)
[Update 9/25/2006]

Comments, Suggestions, Code Fixes and Improvements Very Welcome!
CM

Filed under: .net, Excel

twitter -> twitterings

  • Just saw the new Resharper 6.1 Early Access version has Async CTP support listed - downloading now... 6 months ago
  • Quick post about FeedDemon/Pinboard/Save to Pinboard on Android as my choice for Google Reader Sharing cmiles.info/2011/11/05/goo… 6 months ago
  • FeedDemon+Custom Sharing XML->Pinboard; NewsRob + Save to Pinboard on Android - replacing Google Reader sharing, Reader now just for sync... 7 months ago
  • Doing a few Max - cycling74.com - tutorials - what fun, first time in a decade I have played with this... 7 months ago

RSS pinboard -> links

  • Gmap4 - Share Enhanced Google Maps
    A very cool tool - free for non-commercial use - that can produce very nice (and very usable) topo maps that can have data (GPX, KML,...) overlaid on it very easily!
  • Vistoso Hiking Club Hikes Database
    Short descriptions of hikes near Tucson with a few off trail and interesting destinations - no doubt there are more informative sources but sometimes the simplest thing is nice...
  • Bill Hill - Pictures
    I don't stumble on that many well organized great sets of Tucson hiking photos so saving this link!
  • [WPF] How to bind to data when the DataContext is not inherited
    This solved a problem for me with control of DataGrid Column visibility via Data Binding. Did not test/research/profile this extensively, but for my problem this worked like a charm.

RSS cmiles-consuming -> posts

  • Kafka on the Shore and The Wind-Up Bird Chronicle, Haruki Murakami 2012 June 1
    Kafka on the Shore and The Wind-Up Bird Chronicle by Haruki Murakami are favorites of mine. To combine them into one blog post seems slightly odd – they are not part of a series and are complex enough that reducing them down to a few sentences seems like a disservice. But what these have in [...]
  • Hyperion and The Fall of Hyperion, Dan Simmons 2012 May 16
    I first read Dan Simmons‘s Hyperion in the early 1990s – the Hyperion Cantos is quite famous and I would occasionally see Hyperion listed in Amazon recommendations and ‘top’ lists (see the ISFDB Top 100 Lists and Your Picks: Top 100 Science-Fiction, Fantasy Books from npr books (note that you may get some amusement out [...]
  • Wool Omnibus (Wool 1-5), Hugh Howey 2012 May 1
    I don’t usually pay much attention to Amazon’s recommendations – but after finishing 1Q84 I wanted something new and, for whatever reason, the Wool Omnibus by Hugh Howey jumped out at me on Amazon’s list. Wool takes place in a bleak future where the characters live in self sufficient underground silos with only a vague [...]
  • 1Q84, Haruki Murakami 2012 April 15
    I am a fan of Haruki Murakami, so I was excited when the English version of 1Q84 became available. I picked up and put down this book several times while reading it and I have to admit that I just really don’t know what to say about it – Long/Interesting/What?/I am glad I read it/Why?/1984/hmmm… [...]
  • Ride the Divide 2012 April 2
    Ride the Divide has great scenery, interesting people, injuries, struggles and riding along the Great Divide Mountain Bike Route that goes from Banff, Canada to the Mexican border! While I am familiar with some of the long distance hiking trails in the US I had no idea this route existed and it was fascinating to [...]
  • Forks over Knives 2012 March 20
    Forks over Knives (official website), directed by Lee Fulkerson, is a rather long documentary with the singular message that plant based diets are better than meat based diets (it may be slightly more subtle than that, but I think that is a pretty fair summary). I watched the film days after seeing Tabloid and could [...]
  • Tabloid, The Thin Blue Line 2012 March 15
    Tabloid – by Errol Morris – is the story of Joyce McKinney. McKinney was involved in a widely publicized case/scandal/incident in England in the late 1970s sometimes given the colorful name ‘The Case of the Manacled Mormon’. I had no knowledge of the events prior to the film – which might have added to the [...]
  • Jig 2012 March 1
    Jig follows a number of dancers leading up to their participation in the 40th Irish Dancing World Championships (2010). This film is a friendly, short and entertaining glimpse into a world that I did not know even existed – great fun. Simple, good! Rating: 4 of 5 First Watch Date: December 2011 CM
email: charles@cmiles.info

flickr -> pictures

1205 Looking down Pontatoc Canyon

1205 Looking up canyon from the end of the Pontatoc Canyon Trail

1205 Pontatoc Canyon End of Trail Sign

1205 Looking up at the rocks above the end of the Pontatoc Canyon Trail

1205 Catepillar

1205 Maybe from the fire fighting

1205 Looking back up Sabino Canyon from Brinkley Point

1205 View towards Sabino Canyon from Brinkley Point

1205 Charles and Alison

1205 View from Brinkley Point

More Photos
Follow

Get every new post delivered to your Inbox.