Задается общее смещение dx, dy, проходится по всем элементам находящимся на cnvDrawPoly и имеющим имя в списке comboBoxDrwObj
#region DrawPolyMoved(double dx, double dy) -- переместить поле
public void DrawPolyMoved(double dx, double dy)
{
int i;
#region смещение line_scale
Line lnscale = (Line)cnvDrawPoly.Children[3];// линия масштаба
lnscale.X1 += dx;
lnscale.X2 += dx;
lnscale.Y1 += dy;
lnscale.Y2 += dy;
#endregion смещение line_scale
Line ln;
for (i = 0; i < comboBoxDrwObj.Items.Count; i++)
{
string ss = comboBoxDrwObj.Items[i].ToString();
#region смещение line
if (ss.Substring(0, ss.IndexOf("_")) == "line")
{
ln = (Line)cnvDrawPoly.Children[i + PrjProperty.drwCountBrush];// увеличен на PrjProperty.drwCountBrush так как 0 это линия для рисования 1-polyline
ln.X1 += dx;
ln.X2 += dx;
ln.Y1 += dy;
ln.Y2 += dy;
}
#endregion смещение line
#region смещение polyline
if (ss.Substring(0, ss.IndexOf("_")) == "polyline")
{
Polyline pl = (Polyline)cnvDrawPoly.Children[i + PrjProperty.drwCountBrush];// увеличен на PrjProperty.drwCountBrush так как 0 это линия для рисования 1-polyline
for (int ip = 0; ip < pl.Points.Count; ip++)
{
Point pnt = new Point(pl.Points[ip].X, pl.Points[ip].Y);
pnt.X += dx;
pnt.Y += dy;
pl.Points[ip] = pnt;
}
}
#endregion смещение polyline
#region смещение surve
if (ss.Substring(0, ss.IndexOf("_")) == "surve")
{
System.Windows.Shapes.Path path = (System.Windows.Shapes.Path)cnvDrawPoly.Children[i + PrjProperty.drwCountBrush];// увеличен на PrjProperty.drwCountBrush так как 0 это линия для рисования 1-polyline
GeometryGroup gg = (GeometryGroup)path.Data;
for (int ip = 0; ip < gg.Children.Count; ip++)
{
if (gg.Children[ip].GetType().Name == "LineGeometry")
{
LineGeometry line = (LineGeometry)gg.Children[ip];
double sx = line.StartPoint.X;
double sy = line.StartPoint.Y;
double ex = line.EndPoint.X;
double ey = line.EndPoint.Y;
sx += dx;
sy += dy;
ex += dx;
ey += dy;
line.StartPoint = new Point(sx, sy);
line.EndPoint = new Point(ex, ey);
}
}
}
#endregion смещение surve
}
// SelectCurentObj();
}
#endregion DrawPolyMoved(double dx, double dy) -- переместить поле
Масштабирование объектов#region DrawPolyZoom(double scale) -- Zoom
public void DrawPolyZoom(double scale)
{
#region смещение line_scale
Line lnscale = (Line)cnvDrawPoly.Children[3];// линия масштаба
lnscale.X1 *= scale;
lnscale.X2 *= scale;
lnscale.Y1 *= scale;
lnscale.Y2 *= scale;
Line ln;
#endregion смещение line_scale
int i;
for (i = 0; i < comboBoxDrwObj.Items.Count; i++)
{
string ss = comboBoxDrwObj.Items[i].ToString();
#region смещение line
if (ss.Substring(0, ss.IndexOf("_")) == "line")
{
ln = (Line)cnvDrawPoly.Children[i + PrjProperty.drwCountBrush];// увеличен на PrjProperty.drwCountBrush так как 0 это линия для рисования 1-polyline
ln.X1 *= scale;
ln.X2 *= scale;
ln.Y1 *= scale;
ln.Y2 *= scale;
ln.StrokeThickness *= scale;
}
#endregion смещение line
#region смещение polyline
if (ss.Substring(0, ss.IndexOf("_")) == "polyline")
{
Polyline pl = (Polyline)cnvDrawPoly.Children[i + PrjProperty.drwCountBrush];// увеличен на PrjProperty.drwCountBrush так как 0 это линия для рисования 1-polyline
for (int ip = 0; ip < pl.Points.Count; ip++)
{
Point pnt = new Point(pl.Points[ip].X, pl.Points[ip].Y);
pnt.X *= scale;
pnt.Y *= scale;
pl.Points[ip] = pnt;
}
pl.StrokeThickness *= scale;
}
#endregion смещение polyline
#region смещение surve
if (ss.Substring(0, ss.IndexOf("_")) == "surve")
{
System.Windows.Shapes.Path path = (System.Windows.Shapes.Path)cnvDrawPoly.Children[i + PrjProperty.drwCountBrush];// увеличен на PrjProperty.drwCountBrush так как 0 это линия для рисования 1-polyline
GeometryGroup gg = (GeometryGroup)path.Data;
for (int ip = 0; ip < gg.Children.Count; ip++)
{
if (gg.Children[ip].GetType().Name == "LineGeometry")
{
LineGeometry line = (LineGeometry)gg.Children[ip];
double sx = line.StartPoint.X;
double sy = line.StartPoint.Y;
double ex = line.EndPoint.X;
double ey = line.EndPoint.Y;
sx *= scale;
sy *= scale;
ex *= scale;
ey *= scale;
line.StartPoint = new Point(sx, sy);
line.EndPoint = new Point(ex, ey);
}
}
}
#endregion смещение surve
}
//SelectCurentObj();
}
#endregion DrawPolyZoom(double scale)