public static void MoveLocation()
        {
            Initialize();

            while (true)
            {
                var boxIds = SelectSocketBox();
                if (boxIds.Count == 0)
                {
                    return;
                }

                var layerName = AutoCad.Db.Entity.GetLayerName(boxIds[0]);
                if (layerName == Const.Layer.電気_SocketPlan_Specific)
                {
                    //バラ品移動処理へ
                    return;
                }
                else if (layerName != Const.Layer.電気_SocketPlan)
                {
                    MessageDialog.ShowWarning("this is not a socket box.");
                    return;
                }

                int?boxId       = boxIds[0];  //IsTypeだとなんかだめなので。。。
                var boxSize     = AutoCad.Db.BlockReference.GetSize(boxId.Value);
                var beforePoint = AutoCad.Db.BlockReference.GetPosition(boxId.Value);
                var bounds      = AutoCad.Db.BlockReference.GetBlockBound(boxId.Value);

                if (IsOSnap())
                {
                    OffOSnap();
                }

                var afterPoint = SocketBoxObject.GetClickPoint();
                if (afterPoint == null)
                {
                    throw new ApplicationException(Messages.FailedToGetPoint());
                }

                var leaderId = SocketBoxObject.GetLeaderObjectId(bounds);
                if (!leaderId.HasValue)
                {
                    throw new ApplicationException("Failed to get leader.");
                }

                var leaderFirstPoint = AutoCad.Db.Leader.GetFirstVertex(leaderId.Value);
                AutoCad.Db.Leader.Erase(leaderId.Value);
                AutoCad.Status.WaitFinish();
                AutoCad.Command.RefreshExEx();

                AutoCad.Command.SendLine("MOVE\n" + ToStringNoSpace(beforePoint) + "\n\n" +
                                         ToStringNoSpace(beforePoint) + "\n" + ToStringNoSpace(afterPoint));
                AutoCad.Status.WaitFinish();
                AutoCad.Command.RefreshExEx();

                SocketBoxObject.MakeLeader(leaderFirstPoint, afterPoint, boxSize);
                AutoCad.Command.RefreshExEx();
            }
        }
        public static void Delete()
        {
            WindowController2.BringAutoCadToTop();
            AutoCad.Command.Prepare();
            AutoCad.Command.SetCurrentLayoutToModel();

            AutoCad.Command.SendLineEsc("PICKSTYLE 1"); //グループ選択必須

            var dwg       = Drawing.GetCurrent();
            var leaderIds = AutoCad.Db.Leader.GetAll(Const.Layer.電気_SocketPlan);

            leaderIds.AddRange(AutoCad.Db.Leader.GetAll(Const.Layer.電気_SocketPlan_Specific));

            var           ids      = SocketBoxObject.SelectSocketBoxes();
            var           blockIds = new List <int>();
            List <PointD> bounds   = new List <PointD>();

            //PointD bottomleft = new PointD(double.MaxValue, double.MaxValue);
            //PointD topRight = new PointD(double.MinValue, double.MinValue);
            double bottom = double.MaxValue;
            double top    = double.MinValue;
            double left   = double.MaxValue;
            double right  = double.MinValue;

            var deleteSeqs = new List <string>();

            foreach (var id in ids)
            {
                var layerName = AutoCad.Db.Entity.GetLayerName(id);
                if (layerName != Const.Layer.電気_SocketPlan && layerName != Const.Layer.電気_SocketPlan_Specific)
                {
                    continue;
                }

                //Block削除
                if (AutoCad.Db.BlockReference.IsType(id))
                {
                    var socketboxAttribute = Attribute.GetAll(id);
                    var seqAttr            = socketboxAttribute.Find(p => p.Tag == "seq");
                    if (seqAttr == null)
                    {
                        throw new ApplicationException("Please execute generating.");
                    }

                    var seq = seqAttr.Value.ToString();
                    if (!string.IsNullOrEmpty(seq))
                    {
                        deleteSeqs.Add(seq);
                    }

                    bounds = AutoCad.Db.BlockReference.GetBlockBound(id);

                    if (left > bounds[0].X)
                    {
                        left = bounds[0].X;
                    }
                    if (left > bounds[1].X)
                    {
                        left = bounds[1].X;
                    }

                    if (right < bounds[0].X)
                    {
                        right = bounds[0].X;
                    }
                    if (right < bounds[1].X)
                    {
                        right = bounds[1].X;
                    }

                    if (bottom > bounds[0].Y)
                    {
                        bottom = bounds[0].Y;
                    }
                    if (bottom > bounds[1].Y)
                    {
                        bottom = bounds[1].Y;
                    }

                    if (top < bounds[0].Y)
                    {
                        top = bounds[0].Y;
                    }
                    if (top < bounds[1].Y)
                    {
                        top = bounds[1].Y;
                    }

                    AutoCad.Db.BlockReference.Erase(id);
                    blockIds.Add(id);
                }
                //枠削除(バラ品のみ)
                else if (AutoCad.Db.Polyline.IsType(id))
                {
                    AutoCad.Db.Polyline.Erase(id);
                }
            }

            //LeadLine削除
            var leaderId = SocketBoxObject.GetLeaderObjectId(new List <PointD>()
            {
                new PointD(left, bottom), new PointD(right, top)
            }, leaderIds);
            PointD leaderStart = new PointD();
            PointD leaderEnd   = new PointD();

            if (leaderId.HasValue)
            {
                leaderStart = AutoCad.Db.Leader.GetStartPoint(Int32.Parse(leaderId.ToString()));
                leaderEnd   = AutoCad.Db.Leader.GetEndPoint(Int32.Parse(leaderId.ToString()));
                AutoCad.Db.Leader.Erase(Int32.Parse(leaderId.ToString()));
            }

            //DB削除
            using (var service = new SocketPlanService())
            {
                service.DeleteSocketBoxes(Static.ConstructionCode, deleteSeqs.ToArray());
            }
            AutoCad.Command.RefreshEx();
        }