Infloor-heating Diagram Maker Part II

by Bobbi Perreault 28. April 2008 11:39
Share on Facebook

Part One is here:  Silverlight Tools for eCommerce Sites: Infloor Heating Diagram Maker  You can find Scribbler here.  There's an old  1.1 Version of Scribbler too, if you want to spend a few hours converting - it looks like it has more functionality.  I haven't finished converting it yet, and probably won't.  But I got close, if that counts!

Since I learn by doing, and I have a goal in mind I thought I'd get started.  I described my project in an earlier post Silverlight Tools for eCommerce Sites: Infloor Heating Diagram Maker.  So, this is my adventure - enhancing and adding to that Scribbler app to turn it into a diagram maker.

Since the Infloor-heating Diagram Maker is a tool that uses a lot of the same types of actions as a drawing program, Scribbler seemed like a fantastic base.  I'm going to start by making a bit of a structural change to the locations of the classes that make up the application.  Since in Scribbler all the classes are in the root folder, I just made a BL folder and placed them in there instead.

Next, I took it to Blend and got things arranged for this application, which takes a bitmapped grid as a drawing surface.  I moved the tool palette.  I added a Pen Icon and a Line tool class.  And a Rectangle Icon and a Rectangle class.

Both Icon Button classes were modeled after the Brush tool icon which came with Scribbler.  BrushControl.xaml.  These classes use another Scribbler control called ToggleButton.  This control allows a different image to be specified for it's two states.  The two states translate to Selected and Unselected for the tool state.  If the tool is selected, when the user drags the mouse the represented object is drawn.  Just as you would expect.

I added some new Modes to the DrawingToolMode enum - which is located in Workspace.cs - so that it looks like this:

public enum DrawingToolMode {None,Brush,Select,Pen,Rectangle,} 

The enum which is in use by the active tool is checked in the DrawingSurface.cs class.  So this was modified to add the two new modes:

switch (this.Workspace.ToolMode) {

case DrawingToolMode.Brush:

this.currentTool = new DrawingPencilTool(this.Drawing, this);

break;

case DrawingToolMode.Select:

this.currentTool = new SelectionTool(this.Drawing, this);

break;

case DrawingToolMode.Pen:

this.currentTool = new PenTool(this.Drawing, this);

break;

case DrawingToolMode.Rectangle:

this.currentTool = new RectangleTool(this.Drawing, this);

break;

}

The two classes which allow either a straight line, or a rectangle to be drawn were both based on the same class as the existing Scribbler brush tool. That base class is DrawingTool. Using the same base class made the new classes automatically wired up into using the Drawing Surface and even hooked them into the color palette automatically. So that was cool. All I had to do was figure out one method for each new tool which would take care of getting the correct Geometric object onto the drawing surface.

In the PenTool.cs class, I used as a model the class that came with Scribbler and used with the Brush icon which is DrawingPencilTool.cs.  (Sorry, I didn't name these two.  Brush, Pencil - to me they're two different tools.  Anyway, besides changing class specific terms, the main change came down to one line in HandleMouseMove event handler, that line is

this.currentStroke.ChangeLine(point);
private void HandleMouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown)
{
Point2 point = new Point2(e.GetPosition(this.drawingSurface.DrawingDisplayer));
if ((point - this.lastPoint).Length > 2)
{
//drawingSurface a Line not add a point.
this.currentStroke.ChangeLine(point);
this.lastPoint = point;
}
}
}
And then the method which adds the line, I also used as a model the  AddPoint method which is called by the 

Pencil/Brush tool.So, here's the ChangeLine Method from the StrokeModel.cs class.

public void ChangeLine(Point2 point)        {            this.points.Add(point);            this.segments.Clear();                        LineSegment lineSegment = new LineSegment();            lineSegment.Point = point.Point;            this.segments.Add(lineSegment);            Point p1 = points[0].Point;            //1.            LineSegment lineSegment2 = new LineSegment();            lineSegment2.Point = p1;            this.segments.Add(lineSegment2);            //2.            Point p2 = new Point();            p2.X = point.Point.X;            p2.Y = point.Point.Y;            LineSegment lineSegment3 = new LineSegment();            lineSegment3.Point = p2;            this.segments.Add(lineSegment3);                      if (this.Parent != null)                this.Parent.FireBoundsChanged();            this.FireBoundsChanged();        }

for the rectangle tool, that method becomes:

        public void ChangeRectangle(Point2 point)        {            this.points.Add(point);            this.segments.Clear();            Point2 min =  points[0];            Point2 max = point;            LineSegment lineSegment = new LineSegment();            lineSegment.Point = min.Point;            this.segments.Add(lineSegment);            Point p1 = points[0].Point;            //1.            LineSegment lineSegment2 = new LineSegment();            lineSegment2.Point = p1;            this.segments.Add(lineSegment2);            //2.            Point p2 = new Point();            p2.X = p1.X;            p2.Y = point.Point.Y;            LineSegment lineSegment3 = new LineSegment();            lineSegment3.Point = p2;            this.segments.Add(lineSegment3);            //3.            Point p3 = new Point();            p3.X = point.Point.X;            p3.Y = point.Point.Y;            LineSegment lineSegment4 = new LineSegment();            lineSegment4.Point = p3;            this.segments.Add(lineSegment4);            Point p4 = new Point();            p4.X = point.Point.X;            p4.Y = p1.Y;            LineSegment lineSegment5 = new LineSegment();            lineSegment5.Point = p4;            this.segments.Add(lineSegment5);            LineSegment lineSegment6 = new LineSegment();//top            lineSegment6.Point = p1;            this.segments.Add(lineSegment6);                        if (this.Parent != null)                this.Parent.FireBoundsChanged();            this.FireBoundsChanged();        }

Minneapolis Silverlight User Group

by Bobbi Perreault 22. April 2008 07:04
Share on Facebook

ILM launches the Minnesota SilverLight/WPF User Group.

This user group is dedicated to anyone who is interested in learning all about SilverLight, WPF, Expressions, and XAML. We intend to provide a healthy mix of deverloper and designer focused presentations and discussions, and will meet once every month. If you are interested in hearing about the upcoming events then you can join the group at
http://www.ilmservice.com/silverlight/Membership.aspx

Tags:

Silverlight Tools for eCommerce Sites: Infloor Heating Diagram Maker

by Bobbi Perreault 21. April 2008 23:13
Share on Facebook

Here's my business need:   I need a way to keep people coming back to my eCommerce site.  My site sells Heating and Plumbing supplies and my customers are usually DIY'er types and very independent.  I'd like to help them while they're designing their heating systems.  So I've decided to add a tool to the user area of this site which will enable people to design their infloor heating layout.

This tool needs to be intuitive and self explanitory.  This software should be freely available.  It should allow them to work with their drawing (uploaded) or
to draw the areas out themselves.  It should draw to scale.  This software should be very easy to use and it should not make them think too much when they're trying to get their diagram produced.

Here's what I'm starting with:  Silverlight 2 SDK component - a drawing program called Scribbler.  See it here:  http://silverlight.net/Samples/2b1/Scribbler/run/default.html

Start with the WidgetCreator  (this is another of my projects, I'll tell you about it soon)- remove the pieces that make the imagemap and keep the shell.  Add in the drawing classes from Scribbler - place them into a folder out of the way to keep them organized.  Add to the Scribbler base classes to support special drawing objects such as Rectangle, Manifold,and Pex run.

So that's my starting point.  I'm going to share it all on this blog.  I hope it works!

Feed Reader Construction Tutorial

by Bobbi Perreault 21. April 2008 02:06
Share on Facebook

On my eCommerce site, http://store.ezburn.com - I have two different feeds showing on the landing page.  One of the projects I want to do for improving this site is to convert those displays to Silverlight.   Today, I came across this post that I'd like to revisit when it's time to start working on this piece: http://advertboy.wordpress.com/  Titled: 

My "Digg Mashup" that taught me so much about Silverlight 2.0 beta - part 1

Tags:

Link to Source Code Formatter

by Bobbi Perreault 19. April 2008 09:28
Share on Facebook

http://blogs.msdn.com/delay/archive/2008/03/13/blogging-code-samples-should-be-easy-free-convertclipboardrtftohtmltext-tool-and-source-code.aspx

Opening text of this post:  

Blogging code samples should be easy [Free ConvertClipboardRtfToHtmlText tool and source code!]

I've been including a lot of source code examples in my blog lately and needed a good way to paste properly formatted code in blog posts. I write my posts in HTML and wanted a tool that was easy to use, simple to install, produced concise HTML, and worked well with Visual Studio 2008. I was aware of a handful of tools for this purpose but none of them were quite what I was looking for, so I wrote my own one evening. :)

Tags:

StickyPad

Link to Silverlight Getting Started Information

by Bobbi Perreault 18. April 2008 23:43
Share on Facebook

For you if you haven't had an opportunity to get started with Silverlight yet. Here's a great "how to start working with Silverlight" blog entry: http://www.danielmoth.com/Blog/2008/04/silverlight-2-essential-getting-started.html

Belize - Paintings by BCP

Tags:

StickyPad

 

RSS Feed FriendFeed