/// <summary> /// Перемещение /// </summary> /// <param name="x">Координата Х</param> /// <param name="y">Координата У</param> /// <param name="networkWires">Группа проводов</param> /// <param name="build">Идентификатор здания</param> public void MoveElem(int x, int y, ref GroupOfNW networkWires, int build) { int difx = 0; int dify = 0; if (type == 2) { difx = MainRectangle.Points[0].X; dify = MainRectangle.Points[0].Y; MainRectangle.MoveElem(x, y); difx = MainRectangle.Points[0].X - difx; dify = MainRectangle.Points[0].Y - dify; _MainRectangle._MoveElem(difx, dify); } else if (type == 3) { difx = MainPolygon.Points[0].X; dify = MainPolygon.Points[0].Y; MainPolygon.MoveElem(x, y); difx = MainPolygon.Points[0].X - difx; dify = MainPolygon.Points[0].Y - dify; _MainPolygon._MoveElem(difx, dify); } else if (type == 360) { difx = MainCircle.MainCenterPoint.X; dify = MainCircle.MainCenterPoint.Y; MainCircle.MoveElem(x, y); difx = MainCircle.MainCenterPoint.X - difx; dify = MainCircle.MainCenterPoint.Y - dify; } Entrances.MoveElem(difx, dify); InputWires.MoveElem(difx, dify, ref networkWires, build); MT._MoveElem(difx, dify); }
public SearchDialog(GroupOfMT GOMT, GroupOfBuildings GOB, GroupOfNE GONE, GroupOfNW GONW) { InitializeComponent(); this.GOMT = GOMT; this.GOB = GOB; this.GONE = GONE; this.GONW = GONW; FormClosed += SearchDialog_FormClosed; }
/// <summary> /// Проверка входа провода /// </summary> /// <param name="build">Идентификатор зданий</param> /// <param name="networkWires">Группа проводов</param> public void CheckIW(int build, GroupOfNW networkWires) { int i = 0; foreach (var iw in Buildings[build].InputWires.InputWires.Circles) { Point point = iw.MainCenterPoint; Point _point = iw.LocalCenterPoint; networkWires.CheckNW(point.X, point.Y, i, true, build, iw.MainDL); networkWires.CheckNW(_point.X, _point.Y, i, true, build, iw.LocalDL); i++; } }
/// <summary> /// Редактирование элемента /// </summary> /// <param name="x">Координата Х</param> /// <param name="y">Координата У</param> /// <param name="id">Идентификатор</param> /// <param name="networkWires">Группа проводов</param> internal void SetPoint(int x, int y, int id, GroupOfNW networkWires) { texture.width = (int)((Math.Abs(texture.location.X - x) + Math.Abs(texture.location.Y - y))); networkWires.CheckNW(texture.location.X + (int)((double)texture.width / 2 / MainForm.zoom), texture.location.Y + (int)((double)texture.width / 2 / MainForm.zoom), id, false, -1, DL); string text = Options.Name + Environment.NewLine; text += "/" + Options.HostName; Font font = new Font(FontFamily.GenericSansSerif, texture.width / 5); Point CP = new Point(texture.location.X + (int)(texture.width / 2), texture.location.Y - (int)(texture.width / 2.5f)); Size size = TextRenderer.MeasureText(text, font); MT.__MoveElem(CP.X - (size.Width / 2), CP.Y + (size.Height / 2)); MT.size = size; }
/// <summary> /// Поворот здания /// </summary> /// <param name="x">Координата Х</param> /// <param name="y">Координата У</param> /// <param name="type">Тип здания</param> /// <param name="networkWires">Группа сетевых элементов</param> /// <param name="build">Идентификатор здания</param> internal void SetPoint(int x, int y, int type, ref GroupOfNW networkWires, int build) { Point cp = new Point(); Point _cp = new Point(); double difangle = 0; double angle = 0; double _angle = 0; switch (type) { case 2: cp = new Point((int)MainRectangle._CenterPointX, (int)MainRectangle._CenterPointY); _cp = new Point((int)MainRectangle._CenterPointX, (int)MainRectangle._CenterPointY); angle = CalcAlfa(_cp, new Point(x, y)) * 57.2958d; _angle = CalcAlfa(cp, MainRectangle.Points[0]); difangle = (angle - _angle) / 57.2958d; MainRectangle.Points.Clear(); for (int i = 0; i < 4; i++) { MainRectangle.Points.Add(RotatePoint(difangle, cp, TempRectangle.Points[i])); } break; case 3: cp = new Point((int)MainPolygon._CenterPointX, (int)MainPolygon._CenterPointY); _cp = new Point((int)MainPolygon._CenterPointX, (int)MainPolygon._CenterPointY); angle = CalcAlfa(_cp, new Point(x, y)) * 57.2958d; _angle = CalcAlfa(cp, MainPolygon.Points[p1]); difangle = (angle - _angle) / 57.2958d; MainPolygon.Points.Clear(); foreach (var p in TempPolygon.Points) { MainPolygon.Points.Add(RotatePoint(difangle, cp, p)); } break; } for (int i = 0; i < Entrances.Enterances.Circles.Count; i++) { Entrances.Enterances.Circles[i].MainCenterPoint = RotatePoint(difangle, cp, TempEntrances.Enterances.Circles[i].MainCenterPoint); } for (int i = 0; i < InputWires.InputWires.Circles.Count; i++) { if (InputWires.InputWires.Circles[i].MainDL.Level == -1) { InputWires.InputWires.Circles[i].MainCenterPoint = RotatePoint(difangle, cp, TempInputWires.InputWires.Circles[i].MainCenterPoint); } } InputWires.MoveElem(0, 0, ref networkWires, build); }
/// <summary> /// Перемещение элемента /// </summary> /// <param name="difx">Разница по Х</param> /// <param name="dify">Разница по У</param> /// <param name="networkWires">Группа проводов</param> /// <param name="build">Идентификатор здания</param> public void MoveElem(int difx, int dify, ref GroupOfNW networkWires, int build) { int i = 0; foreach (var cir in InputWires.Circles) { if (cir.MainDL.Level == -1) { cir.MainCenterPoint = new Point(cir.MainCenterPoint.X + difx, cir.MainCenterPoint.Y + dify); Point point = cir.MainCenterPoint; Point _point = cir.LocalCenterPoint; networkWires.CheckNW(point.X, point.Y, i, true, build, cir.MainDL); networkWires.CheckNW(_point.X, _point.Y, i, true, build, cir.LocalDL); } i++; } }
/// <summary> /// Перемещение входа провода /// </summary> /// <param name="x">Координата Х</param> /// <param name="y">Координата У</param> /// <param name="id">Идентификатор элемента</param> /// <param name="build">Идентификатор здания</param> /// <param name="networkWires">Список проводов</param> internal void MoveIW(int x, int y, int id, int build, GroupOfNW networkWires) { var iw = InputWires.InputWires.Circles[id]; if (iw.MainDL.Level == -1 & MainForm.drawLevel.Level == -1) { this.id = id; isMoveIW = true; InputWires.InputWires.TempCircle = new Circle { MainCenterPoint = MainForm.GenZoomPoint(iw.MainCenterPoint), delete = false, koef = iw.koef, side = iw.side }; InputWires.InputWires.Circles[id].delete = true; MoveIW(x, y); InputWires.InputWires.TempCircle.LocalCenterPoint = CalcLocalPoint(MainForm._GenZoomPoint(InputWires.InputWires.TempCircle.MainCenterPoint)); Point point = MainForm._GenZoomPoint(InputWires.InputWires.TempCircle.MainCenterPoint); Point _point = InputWires.InputWires.TempCircle.LocalCenterPoint; networkWires.CheckNW(point.X, point.Y, id, true, build, iw.MainDL); networkWires.CheckNW(_point.X, _point.Y, id, true, build, iw.LocalDL); } else if (iw.MainDL.Level != -1 & MainForm.drawLevel.Level != -1) { this.id = id; isMoveIW = true; isInBuild = true; InputWires.InputWires.TempCircle = new Circle { MainCenterPoint = MainForm.GenZoomPoint(iw.MainCenterPoint), LocalCenterPoint = MainForm.GenZoomPoint(iw.LocalCenterPoint), delete = false, koef = iw.koef, side = iw.side }; InputWires.InputWires.Circles[id].delete = true; MoveIWInBuild(x, y); Point point = MainForm._GenZoomPoint(InputWires.InputWires.TempCircle.MainCenterPoint); Point _point = MainForm._GenZoomPoint(InputWires.InputWires.TempCircle.LocalCenterPoint); networkWires.CheckNW(point.X, point.Y, id, true, MainForm.drawLevel.Level, InputWires.InputWires.TempCircle.MainDL); networkWires.CheckNW(_point.X, _point.Y, id, true, MainForm.drawLevel.Level, InputWires.InputWires.TempCircle.LocalDL); } }
/// <summary> /// Перемещение элемента /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="id"></param> /// <param name="networkWires"></param> internal void MoveElem(int x, int y, int id, GroupOfNW networkWires) { int difx = texture.location.X; int dify = texture.location.Y; texture.location = MainForm._GenZoomPoint(new Point(x, y)); difx = texture.location.X - difx; dify = texture.location.Y - dify; //CalcCenterPoint(); networkWires.CheckNW(texture.location.X + (int)((double)texture.width / 2), texture.location.Y + (int)((double)texture.width / 2), id, false, -1, DL); string text = Options.Name + Environment.NewLine; text += "/" + Options.HostName; Font font = new Font(FontFamily.GenericSansSerif, texture.width / 5); Point CP = new Point(texture.location.X + (int)(texture.width / 2), texture.location.Y - (int)(texture.width / 2.5f)); Size size = TextRenderer.MeasureText(text, font); MT.location = new Point(MT.location.X + difx, MT.location.Y + dify); MT.size = size; }