Exemplo n.º 1
0
 public static void UpdateNotNameHotaruSwitchSerials()
 {
     using (var service = new SocketPlanService())
     {
         notNameHotaruSwitchSerials = new List <NotNameHotaruSwitchSerial>(service.GetNotNameHotaruSwitchSerials());
     }
 }
        private void UpdateTree(bool fromDb)
        {
            this.treeView.Nodes.Clear();

            var categories = UnitWiring.Masters.SocketBoxSpecificCategories;

            if (fromDb)
            {
                categories.Clear();
                using (var service = new SocketPlanService())
                {
                    categories.AddRange(service.GetAllSocketBoxSpecificCategories());
                }
            }

            foreach (var category in categories)
            {
                var node = new TreeNode(category.Name);
                node.Tag = category;

                foreach (var specific in category.Specifics)
                {
                    var child = new TreeNode(specific.Serial);
                    child.Tag = specific;
                    node.Nodes.Add(child);
                }

                this.treeView.Nodes.Add(node);
            }
        }
        private void UpdateTree()
        {
            this.treeView.Nodes.Clear();

            var categories = new List <SocketBoxCategory>();

            using (var service = new SocketPlanService())
            {
                categories.AddRange(service.GetAllSocketBoxCategories());
            }

            foreach (var category in categories)
            {
                var node = new TreeNode(category.DisplayName);
                node.Tag = category;

                foreach (var pattern in category.Patterns)
                {
                    var child = new TreeNode(pattern.NodeName);
                    child.Tag = pattern;
                    node.Nodes.Add(child);
                }

                this.treeView.Nodes.Add(node);
            }
        }
Exemplo n.º 4
0
 public static void UpdateSocketBoxSpecificCategories()
 {
     using (var service = new SocketPlanService())
     {
         socketBoxSpecificCategories = new List <SocketBoxSpecificCategory>(service.GetAllSocketBoxSpecificCategories());
     }
 }
Exemplo n.º 5
0
 public static void UpdateSingleSocketBoxEquipments()
 {
     using (var service = new SocketPlanService())
     {
         singleSocketBoxEquipments = new List <SingleSocketBoxEquipment>(service.GetAllSingleSocketBoxEquipments());
     }
 }
Exemplo n.º 6
0
 public static void UpdateSocketBoxPatterns()
 {
     using (var service = new SocketPlanService())
     {
         socketBoxPatterns = new List <SocketBoxPattern>(service.GetAllSocketBoxPatterns());
     }
 }
Exemplo n.º 7
0
        private void DrawSpecificItmes()
        {
            var items = this.resultListView.Items;

            if (items.Count == 0)
            {
                this.ShowErrorMessage("please select specific items.");
                return;
            }

            this.Hide();

            int seq = 0;

            using (var service = new SocketPlanService())
                seq = service.GetNextSocketBoxSeq(Static.ConstructionCode);

            var drawItems = new List <SocketBoxSpecific>();

            foreach (ListViewItem item in items)
            {
                drawItems.Add((SocketBoxSpecific)item.Tag);
            }

            SymbolDrawer.DrawSpecifics(ref drawItems, seq);

            //シンボルの詳細を探す
            this.GetSymbolDetails(ref drawItems);

            //DB書き込み
            this.RegisterSocketBoxData(drawItems);
        }
Exemplo n.º 8
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                var equipments = (this.dataGridView.DataSource as BindingSource).DataSource as List <SingleSocketBoxEquipment>;
                if (equipments == null)
                {
                    throw new ApplicationException("Faied to get list.");
                }

                using (var service = new SocketPlanService())
                {
                    service.RegisterSingleSocketBoxEquipments(equipments.ToArray());
                }

                UnitWiring.Masters.UpdateSingleSocketBoxEquipments();

                MessageDialog.ShowInformation(this, "Saved successfully.");
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (!this.Validate())
                {
                    return;
                }

                var pattern = new SocketBoxPattern();
                pattern.Id   = this.patternId;
                pattern.Name = this.nameText.Text;
                pattern.IndividualWRDwgPath = this.individualWRText.Text;
                pattern.IndividualWSDwgPath = this.individualWSText.Text;
                pattern.IndividualBRDwgPath = this.individualBRText.Text;
                pattern.IndividualBSDwgPath = this.individualBSText.Text;
                pattern.PatternWRDwgPath    = this.patternWRText.Text;
                pattern.PatternWSDwgPath    = this.patternWSText.Text;
                pattern.PatternBRDwgPath    = this.patternBRText.Text;
                pattern.PatternBSDwgPath    = this.patternBSText.Text;
                pattern.SocketBoxSize       = (int)this.sizeCombo.SelectedValue;
                pattern.NeedCSV             = this.outputCheck.Checked;
                pattern.CategoryId          = (int)this.categoryCombo.SelectedValue;

                if (this.detailGrid.Rows.Count == 0)
                {
                    pattern.DetailsList = new List <SocketBoxPatternDetail>();
                }
                else
                {
                    pattern.DetailsList = (this.detailGrid.DataSource as BindingSource).DataSource as List <SocketBoxPatternDetail>;
                }

                pattern.ColorsList = (this.colorGrid.DataSource as BindingSource).DataSource as List <SocketBoxPatternColor>;

                int id;
                using (var service = new SocketPlanService())
                {
                    id = service.RegisterSocketBoxPattern(pattern);
                }

                this.UpdateTree();
                this.SelectPatternNode(id);

                MessageDialog.ShowInformation(this, "Saved successfully.");
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 10
0
        private void RegisterSocketBoxData(List <SocketBoxSpecific> specifics)
        {
            var entities = this.CreateSocketBoxEntities(specifics);

            using (var service = new SocketPlanService())
            {
                service.RegisterSocketBoxBySpecific(Static.ConstructionCode, entities.ToArray());
            }
        }
Exemplo n.º 11
0
 /// <summary>廃盤チェックをすべき現場だったらtrueを返す</summary>
 public static bool ShouldCheckHaiban(string constructionCode)
 {
     using (var service = new SocketPlanService())
     {
         //加工依頼済みで長期物件以外だったら廃盤チェックしない
         var isBefore = service.IsBeforeProcessRequest(constructionCode);
         return(isBefore);
     }
 }
Exemplo n.º 12
0
        private void InsertLayoutTexts(Drawing drawing, Layout currentLayout)
        {
            var texts = new List <LayoutText>();

            using (var service = new SocketPlanService())
            {
                texts = new List <LayoutText>(service.GetLayoutTextsByPlanNo(Static.ConstructionCode, Static.Drawing.PlanNoWithHyphen, currentLayout.Id));
            }
            LayoutDrawer.InsertLayoutTexts(texts);
        }
        private void UpdateCategoryCombo()
        {
            var categories = new List <SocketBoxCategory>();

            using (var service = new SocketPlanService())
            {
                categories.AddRange(service.GetAllSocketBoxCategoriesSimple());
            }

            this.categoryCombo.ValueMember   = "Id";
            this.categoryCombo.DisplayMember = "Name";
            this.categoryCombo.DataSource    = categories;
        }
        private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                this.treeView.AfterLabelEdit -= treeView_AfterLabelEdit;

                if (e.Node.Level != 0)
                {
                    MessageDialog.ShowWarning("Cannot change serial on tree view.");
                    e.CancelEdit = true;
                    return;
                }

                var category = e.Node.Tag as SocketBoxSpecificCategory;
                if (category == null)
                {
                    category    = new SocketBoxSpecificCategory();
                    category.Id = 0;
                }

                if (string.IsNullOrEmpty(e.Label))
                {
                    e.Node.Text = category.Name;
                    return;
                }

                category.Name = e.Label;

                using (var service = new SocketPlanService())
                {
                    category.Id = service.RegisterSocketBoxSpecificCategory(category);
                }

                this.UpdateCategoryCombo();

                UnitWiring.Masters.UpdateSocketBoxSpecificCategories();

                MessageDialog.ShowInformation(this, "Updated category successfully.");
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.treeView.AfterLabelEdit += treeView_AfterLabelEdit;
                this.Cursor = Cursors.Default;
            }
        }
        private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                this.treeView.AfterLabelEdit -= treeView_AfterLabelEdit;

                if (e.Node.Level != 0)
                {
                    MessageDialog.ShowWarning("Cannot change pattern name on tree view.");
                    e.CancelEdit = true;
                    return;
                }

                var category = e.Node.Tag as SocketBoxCategory;
                if (category == null)
                {
                    category           = new SocketBoxCategory();
                    category.Id        = 0;
                    category.SortOrder = this.treeView.Nodes.Count;
                }

                category.Name = e.Label;

                int id;
                using (var service = new SocketPlanService())
                {
                    id = service.RegisterSocketBoxCategory(category);
                }

                category.Id = id;
                this.UpdateCategoryCombo();

                UnitWiring.Masters.UpdateSocketBoxPatterns();

                MessageDialog.ShowInformation(this, "Updated category successfully.");

                this.treeView.AfterLabelEdit += treeView_AfterLabelEdit;
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 16
0
        private void RegisterToDB()
        {
            if (this.drawings.Count == 0)
            {
                return;
            }

            var constructionCode = this.drawings[0].ConstructionCode;
            var planNo           = this.drawings[0].PlanNo;
            var zumenNo          = this.drawings[0].RevisionNo;

            using (var service = new SocketPlanService())
            {
                this.items.AddRange(service.RegisterSocketBoxPickingItems(constructionCode, planNo, zumenNo));
            }
        }
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                this.commentGrid.RowsRemoved -= this.commentGrid_RowsRemoved;

                if (this.treeView.SelectedNode.Level != 1)
                {
                    this.ClearPanel();
                    this.saveButton.Enabled = false;
                    return;
                }

                var pattern = this.treeView.SelectedNode.Tag as SocketBoxPattern;

                var details = new List <SocketBoxPatternDetail>();
                var colors  = new List <SocketBoxPatternColor>();
                using (var service = new SocketPlanService())
                {
                    details.AddRange(service.GetSocketBoxDetails(pattern.Id));
                    colors.AddRange(service.GetSocketBoxColors(pattern.Id));
                }

                pattern.Details = details.ToArray();
                pattern.Colors  = colors.ToArray();
                this.UpdatePanel(pattern);
                this.saveButton.Enabled = true;

                this.patternId = pattern.Id;

                this.commentGrid.RowsRemoved += this.commentGrid_RowsRemoved;
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void treeView_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.F2 && this.treeView.SelectedNode.Level == 0)
                {
                    this.treeView.SelectedNode.BeginEdit();
                    return;
                }

                if (e.KeyCode == Keys.Delete)
                {
                    if (MessageDialog.ShowOkCancel("Node will be deleted. Are you sure?") != DialogResult.OK)
                    {
                        return;
                    }

                    using (var service = new SocketPlanService())
                    {
                        if (this.treeView.SelectedNode.Level == 0)
                        {
                            var id = (this.treeView.SelectedNode.Tag as SocketBoxCategory).Id;
                            service.DeleteSocketBoxCategory(id);
                        }
                        else
                        {
                            var id = (this.treeView.SelectedNode.Tag as SocketBoxPattern).Id;
                            service.DeleteSocetBoxPattern(id);
                        }
                    }

                    this.UpdateTree();

                    UnitWiring.Masters.UpdateSocketBoxPatterns();

                    MessageDialog.ShowInformation(this, "Deleted successfully.");
                }
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
        }
Exemplo n.º 19
0
        private void FinalizeCad()
        {
            Drawing.Bring1FDrawingToTop(this.type);
            AutoCad.FinalizeAutoProcess();

            if (this.drawings.Count == 0)
            {
                return;
            }

            var constructionCode = this.drawings[0].ConstructionCode;
            var planNo           = this.drawings[0].PlanNo;
            var zumenNo          = this.drawings[0].RevisionNo;

            using (var service = new SocketPlanService())
            {
                service.LogSocketPlanFramed(constructionCode, planNo, zumenNo);
            }
        }
Exemplo n.º 20
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                var equipments = (this.equipmentGrid.DataSource as BindingSource).DataSource as List <NotNameHotaruSwitch>;
                if (equipments == null)
                {
                    throw new ApplicationException("Faied to get list.");
                }

                var serials = (this.serialGrid.DataSource as BindingSource).DataSource as List <NotNameHotaruSwitchSerial>;
                if (serials == null)
                {
                    throw new ApplicationException("Faied to get list.");
                }

                using (var service = new SocketPlanService())
                {
                    service.RegisterNotNameHotaruSwitches(equipments.ToArray());
                    service.RegisterNotNameHotaruSwitchSerials(serials.ToArray());
                }

                UnitWiring.Masters.UpdateNotNameHotaruSwitches();
                UnitWiring.Masters.UpdateNotNameHotaruSwitchSerials();

                MessageDialog.ShowInformation(this, "Saved successfully.");
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (!this.Validate())
                {
                    return;
                }

                var specific = new SocketBoxSpecific();
                specific.Id        = this.specificId;
                specific.Serial    = this.serialText.Text;
                specific.ImagePath = this.imagePathText.Text;
                specific.BlockPath = this.blockPathText.Text;

                if ((int)this.sizeCombo.SelectedValue == 0)
                {
                    specific.SocketBoxSize = null;
                }
                else
                {
                    specific.SocketBoxSize = (int)this.sizeCombo.SelectedValue;
                }

                specific.Color              = this.colorCombo.SelectedItem.ToString();
                specific.Shape              = this.shapeCombo.SelectedItem.ToString();
                specific.SocketBoxDepth     = this.depthCombo.SelectedItem.ToString();
                specific.SpecificCategoryId = (int)this.categoryCombo.SelectedValue;
                specific.Relations          = this.CreateRelations().ToArray();

                using (var service = new SocketPlanService())
                {
                    specific.Id = service.RegisterSocketBoxSpecific(specific);
                }

#if !DEBUG
                var userName = Properties.Settings.Default.ServerUserName;
                var password = Properties.Settings.Default.ServerPassword;
                var source   = Paths.GetServerSystemDirectory();
                MasterFileLoader.Authorize(source, userName, password);
#endif

                this.CopyToServer(specific);
                this.IncrementMasterFileVersion();

                this.UpdateTree(true);
                this.SelectSpecificNode(specific.Id);

                UnitWiring.Masters.UpdateSocketBoxSpecificCategories();

                MessageDialog.ShowInformation(this, "Saved successfully.");
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (!this.Validate())
                {
                    return;
                }

                var pattern = new SocketBoxPattern();
                pattern.Id   = this.patternId;
                pattern.Name = this.nameText.Text;
                pattern.IndividualWRDwgPath = this.individualWRText.Text;
                pattern.IndividualWSDwgPath = this.individualWSText.Text;
                pattern.IndividualBRDwgPath = this.individualBRText.Text;
                pattern.IndividualBSDwgPath = this.individualBSText.Text;
                pattern.PatternWRDwgPath    = this.patternWRText.Text;
                pattern.PatternWSDwgPath    = this.patternWSText.Text;
                pattern.PatternBRDwgPath    = this.patternBRText.Text;
                pattern.PatternBSDwgPath    = this.patternBSText.Text;
                pattern.SocketBoxSize       = (int)this.sizeCombo.SelectedValue;
                pattern.SocketBoxDepth      = this.depthCombo.SelectedItem.ToString();
                pattern.NeedCSV             = this.outputCheck.Checked;
                pattern.CategoryId          = (int)this.categoryCombo.SelectedValue;

                if (this.detailGrid.Rows.Count == 0)
                {
                    pattern.DetailsList = new List <SocketBoxPatternDetail>();
                }
                else
                {
                    pattern.DetailsList = (this.detailGrid.DataSource as BindingSource).DataSource as List <SocketBoxPatternDetail>;
                }

                pattern.ColorsList = (this.colorGrid.DataSource as BindingSource).DataSource as List <SocketBoxPatternColor>;

                int id;
                using (var service = new SocketPlanService())
                {
                    id = service.RegisterSocketBoxPattern(pattern, Environment.MachineName);
                }

#if !DEBUG
                var userName = Properties.Settings.Default.ServerUserName;
                var password = Properties.Settings.Default.ServerPassword;
                var source   = Paths.GetServerSystemDirectory();
                MasterFileLoader.Authorize(source, userName, password);
#endif

                this.CopyToServer(pattern);
                this.IncrementMasterFileVersion();

                this.UpdateTree();
                this.SelectPatternNode(id);

                UnitWiring.Masters.UpdateSocketBoxPatterns();

                MessageDialog.ShowInformation(this, "Saved successfully.");
            }
            catch (Exception exp)
            {
                MessageDialog.ShowError(exp);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 23
0
        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();
        }
Exemplo n.º 24
0
        public static void ChangeColor()
        {
            Initialize();

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

                var layerName = AutoCad.Db.Entity.GetLayerName(selectedIds[0]);
                if (layerName == Const.Layer.電気_SocketPlan_Specific)
                {
                    //バラ品は不許可
                    throw new ApplicationException("The item that made by manual compose cannot change color.");
                }
                else if (layerName != Const.Layer.電気_SocketPlan)
                {
                    MessageDialog.ShowWarning("this is not a socket box.");
                    return;
                }

                int?boxId = selectedIds[0];

                // AutoGenerateのときにPatternNameでBOX作ってる
                var blockName   = AutoCad.Db.BlockReference.GetBlockName(boxId.Value);
                var patternName = blockName.Substring(0, blockName.IndexOf("_"));
                var pattern     = UnitWiring.Masters.SocketBoxPatterns.Find(p => p.Name == patternName);
                // 一度変えたら、戻せません
                if (pattern == null)
                {
                    throw new ApplicationException("This box is already changed color. Please auto generate again.");
                }

                var dialog = new OtherColorSelectForm(pattern.ColorsList);
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                foreach (var child in selectedIds)
                {
                    //Block削除
                    if (AutoCad.Db.BlockReference.IsType(child))
                    {
                        AutoCad.Db.BlockReference.Erase(child);
                    }
                    //CheckBox削除
                    else if (AutoCad.Db.Polyline.IsType(child))
                    {
                        AutoCad.Db.Polyline.Erase(child);
                    }
                }

                var boxPoint = AutoCad.Db.BlockReference.GetPosition(boxId.Value);
                var boxSize  = AutoCad.Db.BlockReference.GetSize(boxId.Value);
                var bounds   = AutoCad.Db.BlockReference.GetBlockBound(boxId.Value);
                var leaderId = GetLeaderObjectId(bounds);

                PointD firstVertex = null;
                if (leaderId.HasValue)
                {
                    firstVertex = AutoCad.Db.Leader.GetFirstVertex(leaderId.Value);
                    AutoCad.Db.Leader.Erase(leaderId.Value);
                }

                var path = dialog.SelectedColor.DwgPath;
                AutoCad.Command.InsertBlock(path, boxPoint);
                var id = Utilities.GetLastObjectId();
                AutoCad.Db.BlockReference.SetScaleFactor(id, BOX_SCALE);

                var name    = AutoCad.Db.BlockReference.GetBlockName(id);
                var newName = GetNewName(pattern.Name + "_" + dialog.SelectedColor.ColorName);
                Utilities.Rename(name, newName);

                var newBoxSize = AutoCad.Db.BlockReference.GetSize(id);
                bounds = AutoCad.Db.BlockReference.GetBlockBound(id);
                MakeLeader(firstVertex, boxPoint, newBoxSize);

                //var lineId = SymbolDrawer.DrawCheckBox(bounds[0], bounds[1]);
                //AutoCad.Db.Entity.SetColor(lineId, CadColor.Blue);

                //グループ化
                var groupingIds = new List <int>();
                groupingIds.Add(id);
                //groupingIds.Add(lineId);
                AutoCad.Db.Group.Make("SocketPattern_" + DateTime.Now.ToString("yyyyMMddhhmmssfff"), groupingIds); //名前は何でもいいが被ると困るので現在時刻で作る

                using (var service = new SocketPlanService())
                {
                    service.ChangeSocketBoxColor(
                        Static.Drawing.ConstructionCode,
                        (decimal)firstVertex.X,
                        (decimal)firstVertex.Y,
                        pattern.Id,
                        dialog.SelectedColor.ColorName);
                }
            }
        }