private void btnAddLine_Click(object sender, EventArgs e)
 {
     if (pwdPass.Text.Equals(Info.masterPass))
     {
         Line l = new Line();
         l.setLineId(txtLine.Text);
         l.setLineName(txtLine.Text);
         l.AddLine();
         MessageBox.Show("Đã thêm");
     }
     else
     {
         MessageBox.Show("Mật khẩu không đúng, bạn không được phép");
     }
     txtLine.Clear();
 }
Exemplo n.º 2
0
        private void onMouseDown(object sender, MouseButtonEventArgs e)
        {
            //for (int i = 0; i < map.LayerCount; i++)
            //{
            //    map.GetLayer(i).ClearSelection();
            //}
            //Refresh();
            switch (mapMode)
            {
            case Mode.Edit:
                break;

            case Mode.Pan:
                preMouseLocation = e.GetPosition(this);
                break;

            case Mode.ZoomIn:
                ZoomByCenter(e.GetPosition(this), 1.25);
                Refresh();
                break;

            case Mode.ZoomOut:
                ZoomByCenter(e.GetPosition(this), 1 / 1.25);
                Refresh();
                break;

            case Mode.None:
                break;

            case Mode.Select:
                for (int i = 0; i < map.LayerCount; i++)
                {
                    map.GetLayer(i).ClearSelection();
                }
                Refresh();
                preMouseLocation = e.GetPosition(this);
                break;

            case Mode.EditAdd:

                Point curLocation = e.GetPosition(this);
                //Double click to end the input process
                if (e.ClickCount == 2)
                {
                    switch (curLayer.Type)
                    {
                    case LayerType.Point:
                        break;

                    case LayerType.Line:
                        if (tempLine != null)
                        {
                            tempLine.AddLine(tempPart);
                            curLayer.Add(tempLine);
                            tempPart = null;
                            tempLine = null;
                            trackingLine.Clear();
                            Refresh();
                        }
                        break;

                    case LayerType.Polygon:
                        if (tempPolygon != null)
                        {
                            tempPolygon.AddPolygon(tempPart);
                            curLayer.Add(tempPolygon);
                            tempPart    = null;
                            tempPolygon = null;
                            trackingLine.Clear();
                            Refresh();
                        }
                        break;

                    case LayerType.Text:
                        break;

                    default:
                        break;
                    }
                }
                else if (e.ClickCount == 1)
                {
                    trackingPoint = curLocation;
                    switch (curLayer.Type)
                    {
                    case LayerType.Point:
                        curLayer.Add(ToMapPoint(curLocation));
                        Refresh();
                        break;

                    case LayerType.Line:
                        if (tempLine == null)
                        {
                            tempLine = new Line(0);
                            tempPart = new PList(0);
                            tempPart.AddPoint(ToMapPoint(curLocation));
                            trackingLine.Add(new List <Point>());
                            trackingLine.Last().Add(curLocation);
                        }
                        else
                        {
                            if (tempPart == null)
                            {
                                tempPart = new PList(0);
                                tempPart.AddPoint(ToMapPoint(curLocation));
                                trackingLine.Add(new List <Point>());
                                trackingLine.Last().Add(curLocation);
                            }
                            else
                            {
                                tempPart.AddPoint(ToMapPoint(curLocation));
                                trackingLine.Last().Add(curLocation);
                            }
                        }
                        Refresh();
                        break;

                    case LayerType.Polygon:
                        if (tempPolygon == null)
                        {
                            tempPolygon = new Polygon(0);
                            tempPart    = new PList(0);
                            tempPart.AddPoint(ToMapPoint(curLocation));
                            trackingLine.Add(new List <Point>());
                            trackingLine.Last().Add(curLocation);
                        }
                        else
                        {
                            if (tempPart == null)
                            {
                                tempPart = new PList(0);
                                tempPart.AddPoint(ToMapPoint(curLocation));
                                trackingLine.Add(new List <Point>());
                                trackingLine.Last().Add(curLocation);
                            }
                            else
                            {
                                tempPart.AddPoint(ToMapPoint(curLocation));
                                trackingLine.Last().Add(curLocation);
                            }
                        }
                        Refresh();
                        break;

                    case LayerType.Text:
                        break;

                    default:
                        break;
                    }
                }
                break;

            default:
                break;
            }
        }