네트워크 맵을 그리는 응용 프로그램을 만들려고합니다. 저는이 패널에 패널을 사용하고이 패널에 동적으로 ShapeContainer를 캔버스로 만듭니다. 내가 어떤 모양과 동적 라인을 만들이 캔버스에 런타임시 ShapeContainer에 이름을 지정하는 방법
(이 모양을 만들을 위해 내가 사용하는 두 방법) lineshape에 대한:
private void CreateLine(int StartX,int StartY,int EndX,int EndY,Color lineColor,String ControlName)
{
LineShape newline = new LineShape();
canvas.Parent = panMap;
newline.Parent = canvas;
newline.StartPoint = new Point(StartX+ZoomScale , StartY+ZoomScale);
newline.EndPoint = new Point(EndX + ZoomScale, EndY + ZoomScale);
newline.BorderColor = lineColor;
newline.BorderWidth = 2;
newline.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid;
newline.Name = "Link_" + ControlName;
newline.Tag = "Link_" + ControlName;
newline.BringToFront();
canvas.Shapes.Add(newline);
}
과 사각형을 만들을 위해 내가이 방법합니다
을private void CreateBox(int X, int Y, int ObjectType)
{
ShapeContainer canvas = new ShapeContainer();
RectangleShape box = new RectangleShape();
box.Parent = canvas;
box.Size = new System.Drawing.Size(100, 90);
box.Location = new System.Drawing.Point(X, Y);
box.Name = "Box" + ObjectType.ToString();
box.BackColor = Color.Transparent;
box.BorderColor = Color.Transparent;
box.BackgroundImage = img.Images[ObjectType];
box.BackgroundImageLayout = ImageLayout.Stretch;
box.BorderWidth = 0;
}
나는이 방법을 다음과 같이 호출
CreateBox(600, 160, 4);
CreateBox(600, 200, 3);
CreateLine(75, 83, 227, 176, Color.Green, "1");
CreateLine(227, 176, 367, 95, Color.Green, "2");
---- 이제 몇 가지 문제가 있습니다 : 1.이 모양의 이름을 설정하는 방법 (다른 방법으로 사용)? 내가 이것을 사용 텍스트 상자 컨트롤의 예를 들어 을 : 나는 모양을 위해 무엇을 할 수
TextBox txtbx = (TextBox)Controls["txtCityName"];
?
이 모양에 대한 방법을 만드는 방법은 무엇입니까? 예 :
newline.Click + = newliclick (개체 보낸 사람, EventArgs 이벤트, 색 linecolor)!?
은 내가 내 질문에 설명 할 수없는 경우 (내 영어하지 잘) 긴 질문에 대한 실례 미안 방법
에 1 개 이상의 객체를 전송합니다.
그 일을 너무 많은 친구. – user3290286
작동, tnx. 하지만 메서드에 줄 바꿈의 이름이나 인덱스를 보내야합니다. 새줄 이름, 태그 또는 색인을 원하는 경우 어떤 코드가 필요한지 알려주십시오. (폼로드 CreateLine() 또는 CreateBox() 여러 번 호출하십시오. tnx 다시. – user3290286