Simple Spline

Toolkits.SimpleSpline History

Hide minor edits - Show changes to output

January 16, 2006, at 11:39 AM by 136.159.7.228 -
Changed lines 88-89 from:
c). ''Initialize the DraggingObject and Offset''. Insert this code just after what you typed above.
to:
c) ''Initialize the DraggingObject and Offset''. Insert this code just after what you typed above.
January 16, 2006, at 11:38 AM by 136.159.7.228 -
Added line 89:
Added line 102:
//Calculate the dragging offset, and record which object is being dragged
Added line 114:
//-1 means we are done dragging
Added lines 125-126:
// If the object is still being dragged, move the control point to the new location
// and refresh (and thus repaint the spline)
Changed line 60 from:
private ArrayList ControlPoints; //An array that will hold the Control Points user control
to:
private ArrayList ControlPoints; //Array to hold the Control Points user control
Added line 81:
//Create an SDGMouseDown/Up callback for each control point user control
Changed line 60 from:
private ArrayList ControlPoints;
to:
private ArrayList ControlPoints; //An array that will hold the Control Points user control
Changed lines 5-6 from:
In this tutorial you will learn how to build a program that allows multiple users cooperating with each other to manipulate a spline curve.
to:
In this tutorial you will learn how to build a program that allows multiple users cooperating with each other to manipulate a spline curve. You will create control points as an SDG user control and add four of these to your application. You will then add code allowing people to move these control points with multiple mice, and a spline will be drawn that is dependant on the locations of these points.
Added line 33:
//Draw a red circle to fit the user control
Added line 50:
//Draw a spline curve around the current locations of the 4 control points
Added line 2:
%rfloat% Attach:SDGSplineOutput.png
Changed lines 127-129 from:
17) ''Compile''.

Attach:SDGSplineOutput
.png
to:
17) ''Compile''. From the running program, try to simultaneously drag control points to adjust the spline.
Added line 61:
Changed line 84 from:
c). ''Initialize the DraggingObject and Offset
to:
c). ''Initialize the DraggingObject and Offset''. Insert this code just after what you typed above.
Changed lines 58-59 from:
to:
=]
Changed lines 16-17 from:
!!!Tutorial
to:
!!!Tutorial - Part 1. Create an SDG-aware Form
Added line 22:
!!!Tutorial - Part 2. Create a User Control that displays a Control Point
Added lines 37-38:
!!!Tutorial - Part 3. Code the Main Application
Changed lines 52-53 from:
11) ''Add required storage variables''. Add the following code after the line "private System.ComponentModel.IContainer components;"
to:
11) ''Add several required storage variables''. Add the following declarations after the line "private System.ComponentModel.IContainer components;"
Changed lines 58-62 from:
=]

12) ''Initialization''. Add the following code after "InitializeComponent();"

Add control points to ControlPoints.
to:
12) ''Initialize these variables.''
a) Add the following code after ''
InitializeComponent()''
Added line 63:
// Add control point user controls to the ControlPoints Array.
Changed lines 71-74 from:
Add mouse down and up event handlers. Tips: Don't copy and paste this section of code. Type it. After you type "+=", hit Tab twice. An empty function of the handler will be automatically generated at the end of the class.
to:
b) ''Add mouse down and up event handlers for each control point user control.'' Insert this code just after what you typed above.
* Tip 1: Don't copy and paste this section of code. Type it. After you type "+=", hit Tab twice. An empty function of the handler will be automatically generated at the end of the class.
* Tip 2: Because we called our project ''SimpleSpline'', that is its namespace. If you called your project something different, you will have to replace SimpleSpine in the code below with your project name.
Added line 82:
c). ''Initialize the DraggingObject and Offset
Changed lines 86-87 from:

for (int i=0; i < sdgManager1.Mice.Count; ++i) {
to:
for (int i=0; i < sdgManager1.Mice.Count; ++i)
{
Changed line 89 from:
DraggingOffset[i] = new Point(0,0);
to:
DraggingOffset[i] = new Point(0,0);
Changed lines 93-94 from:
13) ''Add code for mouse down event''.
to:
13) ''Add this code to the c_SdgMouseDown event handler''.
Changed lines 104-105 from:
14) ''Add code for mouse up event''.
to:
14) ''Add this code to the c_SdgMouseUp event handler''.
Changed lines 110-111 from:
15) ''Add mouse move event of sdgManager1''. In the Properties, select '''sdgManager1''' in the drop down menu, click the lighting bolt, then double click MouseMove.
to:
15) ''Add this code to the mouse move event of sdgManager1''. In the Properties, select '''sdgManager1''' in the drop down menu, click the lighting bolt, then double click MouseMove.
January 13, 2006, at 08:03 PM by 136.159.7.228 -
Deleted lines 3-4:
'''Under Constructions. The following steps may not coorespond to the actual tutorial.'''
January 13, 2006, at 07:58 PM by 136.159.7.228 -
Changed lines 9-10 from:
(:cell:) [+ '''Download: ''' [[(Attach:)SdgSimpleText.zip]] +] \\
[+ '''Source: ''' [[(Attach:)SdgSimpleTextSrc.zip]] +] \\
to:
(:cell:) [+ '''Download: ''' [[(Attach:)SdgSimpleSpline.zip]] +] \\
[+ '''Source: ''' [[(Attach:)SdgSimpleSplineSrc.zip]] +] \\
January 13, 2006, at 07:49 PM by 136.159.7.228 -
Changed line 47 from:
Pen p = new Pen(new SolidBrush(Color.Black), 10);
to:
Pen p = new Pen(new SolidBrush(Color.Black), 2);
January 13, 2006, at 07:49 PM by 136.159.7.228 -
Changed lines 119-178 from:



4) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"

(:source lang=csharp tabwidth=2 :) [=
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2];
=]

6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
}
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
=]

7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.

(:source lang=csharp tabwidth=2 :) [=
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty;
=]

8) ''Build Solution''. Otherwise, TextPlaceWidget cannot be used. Hit Ctrl+Shift+b to build.

9) ''Add TextPlaceWidget to Form1''. Switch to the Form1 Designer. In the Toolbox under My User Controls, drag the TextPlaceWidget control to Form1 in the Design tab.

Attach:SDGTextPlaceWidget.png

10) ''Resize TextPlaceWidget''. In the Properties of TextPlaceWidget, change Dock to fill by clicking the middle square.

Attach:SDGTextDock.png

11) ''Compile''.

Attach:SDGTextOutput.png
to:
17) ''Compile''.

Attach:SDGSplineOutput.png
January 13, 2006, at 07:44 PM by 136.159.7.228 -
Changed lines 88-95 from:




4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
to:
13) ''Add code for mouse down event''.
Changed lines 91-92 from:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer
= new string[2];
to:
DraggingOffset[e.ID] = new Point(e.X, e.Y);
for (int i
=0; i < ControlPoints.Count; ++i) {
if (sender == ControlPoints[i]) {
DraggingObject[e.ID] = i;
}
}
Changed lines 99-100 from:
6) ''Add code for key down event''. Note that the text is associated with each key ID.
to:
14) ''Add code for mouse up event''.
Changed lines 102-103 from:
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string
.Empty;
to:
DraggingObject[e.ID] = -1;
=]

15
) ''Add mouse move event of sdgManager1''. In the Properties, select '''sdgManager1''' in the drop down menu, click the lighting bolt, then double click MouseMove.

Attach:SDGSplineMouseMove.png

16) ''Add code for mouse move event''.

(:source lang=csharp tabwidth=2 :) [=
if (-1 != DraggingObject[e.ID]) {
ControlPoint c = (ControlPoint) ControlPoints[DraggingObject[e.ID]];
c.Location = new Point(e.X - DraggingOffset[e.ID].X, e.Y - DraggingOffset[e.ID].Y);
this.Refresh()
;
Deleted lines 116-129:
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
Changed lines 119-120 from:
7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.
to:



4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
Changed lines 127-134 from:
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty
;
to:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
Added lines 131-165:
6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
}
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
=]

7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.

(:source lang=csharp tabwidth=2 :) [=
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty;
=]
January 13, 2006, at 07:30 PM by 136.159.7.228 -
Deleted line 61:
Deleted line 70:
January 13, 2006, at 07:30 PM by 136.159.7.228 -
Changed lines 59-72 from:










4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
to:
12) ''Initialization''. Add the following code after "InitializeComponent();"

Add control points to ControlPoints
.
Changed lines 64-65 from:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2];
to:
ControlPoints = new ArrayList();
ControlPoints.Add((object) controlPoint1);
ControlPoints.Add((object) controlPoint2);
ControlPoints.Add((object) controlPoint3);
ControlPoints.Add((object) controlPoint4)
;
Changed lines 71-72 from:
6) ''Add code for key down event''. Note that the text is associated with each key ID.
to:
Add mouse down and up event handlers. Tips: Don't copy and paste this section of code. Type it. After you type "+=", hit Tab twice. An empty function of the handler will be automatically generated at the end of the class.
Changed lines 74-75 from:
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
to:
foreach (SimpleSpline.ControlPoint c in ControlPoints){
c.SdgMouseDown += new Sdgt.SdgMouseEventHandler(c_SdgMouseDown);
c.SdgMouseUp += new Sdgt.SdgMouseEventHandler(c_SdgMouseUp)
;
Changed lines 78-79 from:
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID]
= TextBuffer[e.ID] + (char)e.KeyValue;
to:
=]

(:source lang=csharp tabwidth=2 :) [=

DraggingObject = new int[sdgManager1.Mice.Count];
DraggingOffset = new Point[sdgManager1
.Mice.Count];

for (int i=0; i < sdgManager1.Mice.Count; ++i) {
DraggingObject[i] = -1;
DraggingOffset[i] = new Point(0,0);
Deleted lines 87-97:

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
Changed lines 90-91 from:
7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.
to:




4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
Changed lines 99-106 from:
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty
;
to:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
Added lines 103-137:
6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
}
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
=]

7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.

(:source lang=csharp tabwidth=2 :) [=
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty;
=]
January 13, 2006, at 07:13 PM by 136.159.7.228 -
Changed lines 59-60 from:
12) ''Add mouse down and up events of ControlPoint in Form1.cs''. They are added in Form1.cs so that they can access the sotrage variables.
to:










4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
Changed lines 74-81 from:
private void controlPoint_SdgMouseDown(object sender, Sdgt.SdgMouseEventArgs e) {
DraggingOffset
[e.ID] = new Point(e.X, e.Y);
for (int i=0
; i < ControlPoints.Count; ++i) {
if (sender == ControlPoints[i]) {
DraggingObject[e.ID] = i;
}
}
}
to:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
Added lines 78-79:
6) ''Add code for key down event''. Note that the text is associated with each key ID.
Changed lines 81-82 from:
private void controlPoint_SdgMouseUp(object sender, Sdgt.SdgMouseEventArgs e) {
DraggingObject[e.ID] = -1;
to:
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
Added lines 84-97:
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
Changed lines 100-113 from:










4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
to:
7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.
Changed lines 103-104 from:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
to:
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty
;
Deleted lines 112-146:
6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
}
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
=]

7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.

(:source lang=csharp tabwidth=2 :) [=
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty;
=]
January 13, 2006, at 07:11 PM by 136.159.7.228 -
Changed lines 28-29 from:
5) ''Add paint event''. In the Properties of ControlPoint, click the lighting bolt, then double click Paint.
to:
5) ''Add paint event (to draw control points)''. In the Properties of ControlPoint, click the lighting bolt, then double click Paint.
Changed lines 42-48 from:



4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''
. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
to:
9) ''Add paint event (to draw a spline curve)''. In the Properties of Form1, click the lighting bolt, then double click Paint.

10) ''Draw a spline curve''. Add the following code for the paint event
.
Changed lines 47-48 from:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
to:
Pen p = new Pen(new SolidBrush(Color.Black), 10);
e.Graphics.DrawBezier(p, controlPoint1.Location, controlPoint2.Location, controlPoint3.Location, controlPoint4.Location)
;
Changed lines 51-52 from:
6) ''Add code for key down event''. Note that the text is associated with each key ID.
to:
11) ''Add required storage variables''. Add the following code after the line "private System.ComponentModel.IContainer components;"
Changed lines 54-55 from:
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty
;
to:
private int[] DraggingObject;
private Point[] DraggingOffset;
private ArrayList ControlPoints
;
=]

12) ''Add mouse down and up events of ControlPoint in Form1.cs''. They are added in Form1.cs so that they can access the sotrage variables.

(:source lang=csharp tabwidth=2 :) [=
private void controlPoint_SdgMouseDown(object sender, Sdgt.SdgMouseEventArgs e) {
DraggingOffset[e.ID] = new Point(e.X, e.Y);
for (int i=0; i < ControlPoints.Count; ++i) {
if (sender == ControlPoints[i]) {
DraggingObject[e.ID] = i;
}
}
Changed lines 70-71 from:
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e
.KeyValue;
to:
=]

(:source lang=csharp tabwidth=2 :) [=

private void controlPoint_SdgMouseUp(object sender, Sdgt.SdgMouseEventArgs e) {
DraggingObject[e.ID] = -1
;
Deleted lines 75-85:

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
Changed lines 78-79 from:
7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.
to:










4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
Changed lines 93-100 from:
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty
;
to:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
Added lines 97-131:
6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
}
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
=]

7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.

(:source lang=csharp tabwidth=2 :) [=
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty;
=]
Changed line 144 from:
Attach:SDGTextOutput.png
to:
Attach:SDGTextOutput.png
January 13, 2006, at 05:55 PM by 136.159.7.228 -
Changed lines 36-37 from:
7) ''Add 4 control points to Form1''. Switch to the Form1 Designer. In the Toolbox under My User Controls, drag the ControlPoint control to Form1 in the Design tab. Drag four of them in total.
to:
7) ''Build Solution''. Otherwise, ControlPoint cannot be used. Hit Ctrl+Shift+b to build.

8
) ''Add 4 control points to Form1''. Switch to the Form1 Designer. In the Toolbox under My User Controls, drag the ControlPoint control to Form1 in the Design tab. Drag four of them in total.
January 13, 2006, at 05:52 PM by 136.159.7.228 -
Changed lines 24-25 from:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleSpline''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. (These first three steps are the same as the previous tutorial (Simple Text)).
to:
3) ''Add Inherited User Control''. In the Solution Explorer, right click '''SimpleSpline'''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. (These first three steps are the same as the previous tutorial (Simple Text)).
January 13, 2006, at 05:50 PM by 136.159.7.228 -
Changed lines 24-25 from:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleSpline''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. (These first three steps are the same as the last tutorial).
to:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleSpline''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. (These first three steps are the same as the previous tutorial (Simple Text)).
January 13, 2006, at 05:50 PM by 136.159.7.228 -
Changed lines 36-40 from:
to:
7) ''Add 4 control points to Form1''. Switch to the Form1 Designer. In the Toolbox under My User Controls, drag the ControlPoint control to Form1 in the Design tab. Drag four of them in total.

Attach:SDGSplineControlPoint.png
January 13, 2006, at 05:37 PM by 136.159.7.228 -
Changed lines 30-31 from:
6) ''Add circle as control point''. Add the following code for the paint event.
to:
6) ''Draw circle as control point''. Add the following code for the paint event.
January 13, 2006, at 05:36 PM by 136.159.7.228 -
Changed lines 24-31 from:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleSpline''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. The next few steps will involve programming this User Control rather than the Form.

Attach:SDGTextAddControl.png

4) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double
click SdgMouseDown.

5) ''Add two text buffers, one for each person
''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
to:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleSpline''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. (These first three steps are the same as the last tutorial).

4) ''Resize
the control point''. In the ControlPoint Design tap, scale it down to the desired size of a control point.

5) ''Add paint event''. In the Properties of ControlPoint,
click the lighting bolt, then double click Paint.

6)
''Add circle as control point''. Add the following code for the paint event.
Changed lines 33-34 from:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2]
;
to:
e.Graphics.FillEllipse(new SolidBrush(Color.Red), 0, 0, this.Width, this.Height);
Changed lines 36-37 from:
6) ''Add code for key down event''. Note that the text is associated with each key ID.
to:





4
) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"
Added lines 46-52:
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2];
=]

6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
January 13, 2006, at 05:17 PM by 136.159.7.228 -
Changed lines 16-17 from:
Below is the full code required to make a minimal SDG Spline program that works for up to four people with four attached mice. Users can drag the control points of a spline curve with their own mice simultaneously. The curve will change its shape correspondingly.
to:
Below is the full code required to make a minimal SDG Simple Spline program that works for up to four people with four attached mice. Users can drag the control points of a spline curve with their own mice simultaneously. The curve will change its shape correspondingly.
Changed lines 20-21 from:
1) ''Create the empty project''. As in the other tutorials, create a C# project (Windows Application). Call it SimpleText.
to:
1) ''Create the empty project''. As in the other tutorials, create a C# project (Windows Application). Call it SimpleSpline.
Changed lines 24-25 from:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleText''->Add->Add Inherited Control. Highlight Inherited User Control and name it TextPlaceWidget. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click "OK". The next few steps will involve programming this User Control rather than the Form.
to:
3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleSpline''->Add->Add Inherited Control. Highlight Inherited User Control and name it ControlPoint. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click OK. The next few steps will involve programming this User Control rather than the Form.
January 13, 2006, at 04:59 PM by 136.159.7.228 -
Changed lines 4-5 from:
'''Under Constructions. The following steps may not cooresponding to the actual tutorial.'''
to:
'''Under Constructions. The following steps may not coorespond to the actual tutorial.'''
January 13, 2006, at 04:58 PM by 136.159.7.228 -
Added lines 4-5:
'''Under Constructions. The following steps may not cooresponding to the actual tutorial.'''
January 13, 2006, at 04:57 PM by 136.159.7.228 -
Added lines 1-82:
[[Toolkits.SDGToolkit | << Back to the SDG Toolkit page]]
\\
\\
In this tutorial you will learn how to build a program that allows multiple users cooperating with each other to manipulate a spline curve.

(:table border=1 cellpadding=17 cellspacing=0 align=entre bgcolor=#eeeeee :)
(:cell:) [+ '''Download: ''' [[(Attach:)SdgSimpleText.zip]] +] \\
[+ '''Source: ''' [[(Attach:)SdgSimpleTextSrc.zip]] +] \\
Unzip all files (executables plus dependancies) into a single folder
(:tableend:)

!!!Introduction

Below is the full code required to make a minimal SDG Spline program that works for up to four people with four attached mice. Users can drag the control points of a spline curve with their own mice simultaneously. The curve will change its shape correspondingly.

!!!Tutorial

1) ''Create the empty project''. As in the other tutorials, create a C# project (Windows Application). Call it SimpleText.

2) ''Add SdgManager to the Form''. Sdg Manager Component in the Toolbox in the Tab where you had previously installed it. Click on the SdgManager component and drag an instance onto the form. In Properties (bottom right), change RelativeTo to Form1.

3) ''Add Inherited User Control''. In the Solution Explorer, right click ''SimpleText''->Add->Add Inherited Control. Highlight Inherited User Control and name it TextPlaceWidget. Click open, then Browse. Find the location where you saved the SDG Toolkit and double click the dll. Highlight the dll and then click "OK". The next few steps will involve programming this User Control rather than the Form.

Attach:SDGTextAddControl.png

4) ''Add keyboard event and mouse event''. In the Properties of TextPlaceWidget, double click SdgKeyDown. Select the Design tab of TextPlaceWidget again, and double click SdgMouseDown.

5) ''Add two text buffers, one for each person''. Add the following code after the line "private System.ComponentModel.IContainer components = null;"

(:source lang=csharp tabwidth=2 :) [=
private PointF[] TextEntryPoints = new PointF[2];
private string[] TextBuffer = new string[2];
=]

6) ''Add code for key down event''. Note that the text is associated with each key ID.

(:source lang=csharp tabwidth=2 :) [=
if (e.KeyCode == Keys.Enter) {
TextBuffer[e.ID] = string.Empty;
}
else if (e.KeyCode != Keys.ShiftKey) {
TextBuffer[e.ID] = TextBuffer[e.ID] + (char)e.KeyValue;
}

Font f = new Font("Times", 12, FontStyle.Italic);
Color c = Color.Red;

if (e.ID > 0) {
f = new Font("Arial", 14, FontStyle.Bold);
c = Color.Blue;
}

Graphics g = this.CreateGraphics();
g.DrawString(TextBuffer[e.ID], f, new SolidBrush(c), TextEntryPoints[e.ID]);
=]

7) ''Add code for mouse down event''. Note that what happens is specific to each mouse ID.

(:source lang=csharp tabwidth=2 :) [=
TextEntryPoints[e.ID] = new PointF((float) e.X, (float) e.Y);
Graphics g = this.CreateGraphics();

if (e.ID > 0)
g.DrawEllipse(Pens.Blue, e.X, e.Y, 2, 2);
else
g.DrawEllipse(Pens.Red, e.X, e.Y, 2, 2);
TextBuffer[e.ID] = string.Empty;
=]

8) ''Build Solution''. Otherwise, TextPlaceWidget cannot be used. Hit Ctrl+Shift+b to build.

9) ''Add TextPlaceWidget to Form1''. Switch to the Form1 Designer. In the Toolbox under My User Controls, drag the TextPlaceWidget control to Form1 in the Design tab.

Attach:SDGTextPlaceWidget.png

10) ''Resize TextPlaceWidget''. In the Properties of TextPlaceWidget, change Dock to fill by clicking the middle square.

Attach:SDGTextDock.png

11) ''Compile''.

Attach:SDGTextOutput.png