Exemplo n.º 1
0
        private void Reload(string data)
        {
            var clientsplit = data.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var clientx in clientsplit)
            {
                var datas = clientx.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                var key   = int.Parse(datas[0]);

                if (dsHinh.ContainsKey(key))
                {
                    dsHinh[key].Clear();
                }
                else
                {
                    dsHinh.Add(key, new List <BasicDraw>());
                }
                for (int i = 1; i < datas.Length; i++)
                {
                    string[] hinhsplit = datas[i].Split(new string[] { ".-." }, StringSplitOptions.RemoveEmptyEntries);

                    var       loaihinh = (Form1.DrawMode) int.Parse(hinhsplit[0]);
                    BasicDraw bd       = null;
                    switch (loaihinh)
                    {
                    case Form1.DrawMode.line:
                        bd = new LineDraw();
                        break;

                    case Form1.DrawMode.rectangle:
                        bd = new RectangleDraw();
                        break;

                    case Form1.DrawMode.eplise:
                        bd = new ElipseDraw();
                        break;

                    case Form1.DrawMode.circle:
                        bd = new CircleDraw();
                        break;

                    case Form1.DrawMode.polygon:
                        bd = new PolygonDraw();
                        break;
                    }
                    bd.Invalidate = () => Invalidate();
                    bd.Restore(datas[i]);
                    dsHinh[key].Add(bd);
                }
            }
            if (isSV)
            {
                Updates();
            }

            Invalidate();
        }
Exemplo n.º 2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (isDown)
            {
                isDown = false;
                if (DrawMode == Form1.DrawMode.polygon)
                {
                    if (isDouble)
                    {
                        isDouble = false;
                        AddPolygon();
                    }
                    else
                    {
                        if (PolygonTemp.Count == 0)
                        {
                            if (!pStart.Equals(pEnd))
                            {
                                PolygonTemp.Add(pStart);
                                PolygonTemp.Add(pEnd);
                            }
                        }
                        else if (!PolygonTemp[PolygonTemp.Count - 1].Equals(pEnd))
                        {
                            PolygonTemp.Add(pEnd);
                        }
                    }
                }

                else if (DrawMode != Form1.DrawMode.select)
                {
                    if (pEnd == pStart)
                    {
                        return;
                    }

                    BasicDraw shape = null;
                    switch (DrawMode)
                    {
                    case Form1.DrawMode.line:
                        shape = new LineDraw(pStart, pEnd, penCur);
                        break;

                    case Form1.DrawMode.rectangle:
                        shape = new RectangleDraw(pStart, pEnd, penCur);
                        break;

                    case Form1.DrawMode.eplise:
                        shape = new ElipseDraw(pStart, pEnd, penCur);
                        break;

                    case Form1.DrawMode.circle:
                        shape = new CircleDraw(pStart, pEnd, penCur);
                        break;
                    }
                    shape.Invalidate = () => Invalidate();
                    var Shapes = dsHinh[0];

                    Shapes.Add(shape);
                    Invalidate();
                    Updates();
                }
                else if (drawCur != null)
                {
                    drawCur.OnMouseUp(e);
                    Updates();
                }
            }
        }