Welcome to MSDN Blogs Sign in | Join | Help

Updates on my Visio Automation library

Version 2.2 posted here: http://www.codeplex.com/visioautoext

 

A summary of the interesting changes

#1: The name changed from "AutoVisio" to "VisioAutoExt".

I found that "AutoVisio" was being used by someone, so to avoid confusion I've renamed it to something that doesn't collide with an existing usage.

#2: A new Demo

I was looking for a way to create a very simple calendar to show progress on our project. I knew I wanted a visio diagram, but I also wanted to tool to be more lightweight that an application dedicated to the task. The project called DemoSimpleSprintCalendar is the result. It takes a simple text file as input and draws the calendar for you.

So this input text file:

            * setup / MSI (dev1)
                design :: week1 , week2
                implement  :: week3
                check-in :: week4

            * setup/ functional spec (pm1)
                first draft:: week1
                review :: week3
                update :: week4
                2nd review:: week5
                sign-off :: week5

            * setup / test (sdet1)
                investigation :: week4, week5
                first draft :: week5
                item1
                item2 ::

            * autorun / test (sdet2)
            * backup / test (sdet3)

 

Generates this output in Visio 2007

image

#3: Experimental support for simple use of SetFormulas

See the "BatchTest.cs" file in the project called "VisioAutoExtTestProject1"

Inspired by this post by Bill Morein, I wanted to see if I could get some of the performance improvements in a way that was easily expressible.

First, yes, there is a big difference in the performance. In this attempt at simplification I took the approach of turning on a special "batch mode" using a batch-aware wrapper for SetFormula and then a call to finish the batch mode by executing the SetFormulas method. It's a step in the right direction, but I'm still thinking of how this could be made simpler.

Here's some partial sample code that illustrates the usage:

 

page.XBatchSetFormula_Start();

foreach (var pos in layout.EnumGrid(num_cols, num_rows))
{
    Visio.Shape shape = page.DrawRectangle(pos.rect);
    int color_int = vista_desktop_colors[pos.index % vista_desktop_colors.Length];
    System.Drawing.Color color = System.Drawing.Color.FromArgb(color_int);
    Isotope.Drawing.ColorHSL hsl_color = ColorHSL.FromColor(color);

    hsl_color = Isotope.Drawing.ColorUtil.PickNiceLabelColor(hsl_color);

    shape.Text = string.Format("{0}", color.ToWebColorString());

    string str_hsl_color = VisioUtil.SystemDrawingColorToVisioRGBColorString(color);

    // ORIGINAL CALL: shape.SetFillForegroundColor(color);
    // BATCH VERSION FOLLOWS:
    shape.XBatchSetFormula(
        Visio.VisSectionIndices.visSectionObject,
        Visio.VisRowIndices.visRowFill,
        Visio.VisCellIndices.visFillForegnd, str_hsl_color );

    // ORIGINAL CALL: shape.SetLinePattern(0);
    // BATCH VERSION FOLLOWS:
    shape.XBatchSetFormula(
        Visio.VisSectionIndices.visSectionObject,
        Visio.VisRowIndices.visRowLine,
        Visio.VisCellIndices.visLinePattern, "0");

    // ORIGINAL CALL: shape.SetTextColor(hsl_color.ToSystemDrawingColor());
    // BATCH VERSION FOLLOWS:
    string textcolor = VisioUtil.SystemDrawingColorToVisioRGBColorString(hsl_color.ToSystemDrawingColor());

    shape.XBatchSetFormula(
        Visio.VisSectionIndices.visSectionCharacter,
        Visio.VisRowIndices.visRowCharacter,
        Visio.VisCellIndices.visCharacterColor, textcolor);

}

page.XBatchSetFormula_End();

Published Wednesday, November 14, 2007 8:02 PM by saveenr

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# MSDN Blog Postings » Updates on my Visio Automation library

Thursday, November 15, 2007 1:50 AM by MSDN Blog Postings » Updates on my Visio Automation library

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker