public void SelectPen(int pen)
{
// -2 = pointer, -1 = erasor, 0+ = pens
if (pen == -2)
{
for (int b = 0; b < Root.MaxPenCount; b++)
{
btPen[b].Image = image_pen[b];
}
btEraser.Image = image_eraser;
btPointer.Image = image_pointer_act;
EnterEraserMode(false);
Root.Pointer();
}
else if (pen == -1)
{
if (this.Cursor != System.Windows.Forms.Cursors.Default)
{
this.Cursor = System.Windows.Forms.Cursors.Default;
}
for (int b = 0; b < Root.MaxPenCount; b++)
{
btPen[b].Image = image_pen[b];
}
btEraser.Image = image_eraser_act;
btPointer.Image = image_pointer;
EnterEraserMode(true);
Root.UnPointer();
if (Root.CanvasCursor == 0)
{
cursorred = new System.Windows.Forms.Cursor(gInk.Properties.Resources.cursorred.Handle);
IC.Cursor = cursorred;
}
else if (Root.CanvasCursor == 1)
{
SetPenTipCursor();
}
}
else if (pen >= 0)
{
if (this.Cursor != System.Windows.Forms.Cursors.Default)
{
this.Cursor = System.Windows.Forms.Cursors.Default;
}
IC.DefaultDrawingAttributes = Root.PenAttr[pen].Clone();
if (Root.PenWidthEnabled)
{
IC.DefaultDrawingAttributes.Width = Root.GlobalPenWidth;
}
for (int b = 0; b < Root.MaxPenCount; b++)
{
btPen[b].Image = image_pen[b];
}
btPen[pen].Image = image_pen_act[pen];
btEraser.Image = image_eraser;
btPointer.Image = image_pointer;
EnterEraserMode(false);
Root.UnPointer();
if (Root.CanvasCursor == 0)
{
cursorred = new System.Windows.Forms.Cursor(gInk.Properties.Resources.cursorred.Handle);
IC.Cursor = cursorred;
}
else if (Root.CanvasCursor == 1)
{
SetPenTipCursor();
}
}
Root.CurrentPen = pen;
if (Root.gpPenWidthVisible)
{
Root.gpPenWidthVisible = false;
Root.UponSubPanelUpdate = true;
}
else
{
Root.UponButtonsUpdate |= 0x2;
}
}