private void ListCommands()
        {
            PaintingControl1.SuspendLayout();
            PaintingControl1.PaintingObjects.Clear();
            dicLabelItems.Clear();
            dicCommands.Clear();
            int curY     = 10;
            int curWidth = 0;

            foreach (BaseCommand <eTypes> cmd in Script)
            {
                var po = new PaintingObject()
                {
                    EnableResize = false
                };
                PaintingControl1.PaintingObjects.Add(po);
                po.Text      = $"{cmd.ToString()}";
                po.TextColor = ForeColor;
                po.Type      = PaintingObjectType.Custom;
                po.TextFont  = new Font(po.TextFont.FontFamily, 12, po.TextFont.Style);
                po.HorizontalTextAlignment = StringAlignment.Near;
                var lb = new LabelX()
                {
                    Text = po.Text, Font = po.TextFont
                };
                string newName = Conversions.ToString(dicLabelItems.Count);
                lb.BackColor = PanelEx_PaintingControl1.Style.BackColor1.Color;
                po.Name      = newName;
                lb.Name      = newName;
                lb.Visible   = false;
                lb.Refresh();
                dicLabelItems.Add(newName, lb);
                dicCommands.Add(newName, cmd);
                po.Y = curY;
                po.X = 10;
                po.FitSizeToText();
                lb.Size     = Size.Round(po.Size);
                curWidth    = Conversions.ToInteger(Math.Max(curWidth, po.Width));
                curY       += (int)po.Height + 10;
                po.MouseUp += PaintingObject_MouseUp;
                po.DrawMethodes.Add(DrawCmdText);
            }

            PaintingControl1.Size = new Size(PanelEx_PaintingControl1.Width - 17, curY);
            PaintingControl1.ResumeLayout();
            PaintingControl1.Invalidate();
        }
        public static long OutPutFeat(ref IFeatureClass pDesFeatCls, ref IFeatureClass pOriFeatCls, string sSql, IGeometry pDomainGeometry, bool bIsCut, ref ISpatialReference pSpatialReference, Dictionary <string, string> pDicField, ref LabelX lblInfo, string sInfo)
        {
            //sSql = "";
            //pDomainGeometry = null;
            //bIsCut = false;
            //pSpatialReference = null;
            //pDicField = null;
            //vProgressBar = null;
            //lblInfo = null;
            //sInfo = null;

            long functionReturnValue = 0;
            //DevComponents.DotNetBar.LabelItem
            IFeatureCursor    pWithINFeatCursor = null;
            IFeatureCursor    pCrossFeatCursor  = null;
            IFeatureCursor    pFeatCursor       = default(IFeatureCursor);
            IFeatureLayer     pFeatLayer        = default(IFeatureLayer);
            IFeatureSelection pFeatSelection    = default(IFeatureSelection);

            int lFeatCount = 0;
            int l          = 0;
            int j          = 0;

            bool bInsertRight = true;

            //Insert是否成功

            // ERROR: Not supported in C#: OnErrorStatement


            if (pDesFeatCls == null | pOriFeatCls == null)
            {
                return(functionReturnValue);
            }

            if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPoint)
            {
                bIsCut = false;
            }

            if (pDomainGeometry == null)
            {
                bIsCut = false;
            }

            //如果需要剪切,则对面要素类和线要素类分成范围内的要素和与范围相交的要素,提高提取效率
            //否则,使用featurecursor进行提取,不进行选择,相对要快

            if (lblInfo != null)
            {
                lblInfo.Text = sInfo + "正在获得满足条件的要素,请稍候.....";
                lblInfo.Refresh();
                Application.DoEvents();
            }

            if (bIsCut)
            {
                pFeatLayer = new FeatureLayer();
                pFeatLayer.FeatureClass = pOriFeatCls;
                pFeatLayer.Name         = pOriFeatCls.AliasName;

                //获得选择集
                pFeatSelection = ClsSelectAndQuery.GetFeatSelection(ref pFeatLayer, sSql, esriSelectionResultEnum.esriSelectionResultNew, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry);
                lFeatCount     = pFeatSelection.SelectionSet.Count;

                //获得位范围内的以及与范围相交的要素集
                ClsSelectAndQuery.ClassifyFeatCursorByGeometry(ref pFeatSelection, pDomainGeometry, ref pWithINFeatCursor, pDesFeatCls.ShapeType);
                // 陈昉  2009-3-12  修改 修改原因 原来的方法不能搜索到包含一此Geometry的要素

                //ClassifyFeatCursorByGeometry(pFeatSelection, pDomainGeometry, pWithINFeatCursor, pCrossFeatCursor, pDesFeatCls.ShapeType)

                if (lblInfo != null)
                {
                    lblInfo.Text = sInfo + "正在输出要素,请稍候.....";
                    lblInfo.Refresh();
                    Application.DoEvents();
                }

                InsertFeatIntoFeatClsByCursor(ref pDesFeatCls, ref pWithINFeatCursor, true, pDomainGeometry, ref pSpatialReference, pDicField);
                //首先把位于图幅内的要素插入

                //InsertFeatIntoFeatClsByCursor(pDesFeatCls, pWithINFeatCursor, True, pDomainGeometry, pSpatialReference, _
                //                              pDicField, vProgressBar)
                //'再把与范围相交的要素插入,(插入时需要进行剪切)
                //InsertFeatIntoFeatClsByCursor(pDesFeatCls, pCrossFeatCursor, True, pDomainGeometry, pSpatialReference, _
                //                              pDicField, vProgressBar)
            }
            else
            {
                //获得需要提取的要素
                long lFeatCount2 = (long)lFeatCount;
                pFeatCursor = ClsSelectAndQuery.GetFeatCursor(pOriFeatCls, sSql, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry, true, ref lFeatCount2);
                lFeatCount  = (int)lFeatCount2;
                if (lblInfo != null)
                {
                    lblInfo.Text = sInfo + "正在输出要素,请稍候.....";
                    lblInfo.Refresh();
                    Application.DoEvents();
                }

                bInsertRight = InsertFeatIntoFeatClsByCursor(ref pDesFeatCls, ref pFeatCursor, false, pDomainGeometry, ref pSpatialReference, pDicField);

                //印骅 20081202 Insert失败,退出函数
                if (bInsertRight == false)
                {
                    functionReturnValue = -1;
                    return(functionReturnValue);
                }
            }
            //杨旭斌于20080825添加,返回提取的要素个数
            functionReturnValue = lFeatCount;

            pWithINFeatCursor = null;
            pCrossFeatCursor  = null;
            return(functionReturnValue);
        }
        private void RefreshHeaderLabels()
        {
            if (BusyPopulatingColumns)
            {
                return;
            }

            if (dataGridViewX1.Columns.Count == 0)
            {
                return;
            }

            int fullWidth = dataGridViewX1.RowHeadersVisible ? dataGridViewX1.RowHeadersWidth : 0;

            foreach (DataGridViewColumn col in dataGridViewX1.Columns)
            {
                if (!col.Frozen)
                {
                    fullWidth += col.Width;
                }
            }
            int horzOffset           = Convert.ToInt32(dataGridViewX1.HorizontalScrollingOffsetValue * fullWidth);
            int headerRowHeight      = dataGridViewX1.ColumnHeadersHeight;
            int realColumnIndex      = 0;
            int widthPrevCols        = dataGridViewX1.RowHeadersVisible ? dataGridViewX1.RowHeadersWidth : 0;
            int visibleGridWidth     = dataGridViewX1.Width;
            int widthOfFrozenColumns = 0;

            if (dataGridViewX1.VerticalScrollbarVisible)
            {
                visibleGridWidth -= dataGridViewX1.VerticalScrollbarWidth;
            }

            if (ShowDeleteColumn && dataGridViewX1.Columns.Count > 0)
            {
                widthPrevCols   = dataGridViewX1.Columns[0].Width;
                realColumnIndex = 1;
            }
            for (int i = 0; i < Columns.Count; i++)
            {
                int colWidth = dataGridViewX1.Columns[realColumnIndex].Width;

                //if (Columns[i].IsNullable)
                //    colWidth += dataGridViewX1.Columns[realColumnIndex + 1].Width;

                Rectangle rectColumn1 = new Rectangle();

                if ((!FrozenColumnIndex.HasValue || FrozenColumnIndex.Value < i + 1) &&
                    (widthPrevCols + colWidth < horzOffset ||
                     widthPrevCols >= horzOffset + visibleGridWidth))
                {
                    widthPrevCols += colWidth;

                    // This column is not in the current view window
                    //if (Columns[i].IsNullable)
                    //    realColumnIndex += 2;
                    //else
                    realColumnIndex += 1;

                    Labels[i].Visible = false;
                    continue;
                }
                if (FrozenColumnIndex.HasValue && i + 1 <= FrozenColumnIndex.Value)
                {
                    // Column is fully displayed
                    rectColumn1 = new Rectangle(widthPrevCols + horzOffset, 0, colWidth, headerRowHeight);

                    if (i + 1 == FrozenColumnIndex.Value)
                    {
                        widthOfFrozenColumns += widthPrevCols + colWidth;                        // +2;
                        //widthPrevCols = 0;
                        //    //horzOffset = widthPrevCols + horzOffset + colWidth;
                        //    widthPrevCols = widthPrevCols + horzOffset;
                    }
                }
                else
                {
                    if (widthPrevCols < widthOfFrozenColumns + horzOffset)
                    {
                        colWidth         -= widthOfFrozenColumns + horzOffset - widthPrevCols;    // -4;
                        rectColumn1.X     = widthOfFrozenColumns + horzOffset;
                        widthPrevCols     = widthOfFrozenColumns + horzOffset;                    // +2;
                        rectColumn1.Width = colWidth;
                    }
                    else if (widthPrevCols + colWidth > horzOffset + visibleGridWidth)
                    {
                        colWidth          = horzOffset + visibleGridWidth - widthPrevCols;
                        rectColumn1.X     = widthPrevCols;
                        rectColumn1.Width = colWidth;
                    }
                    else
                    {
                        rectColumn1 = new Rectangle(widthPrevCols, 0, colWidth, headerRowHeight);
                    }
                }
                rectColumn1.Height = headerRowHeight / 2;
                rectColumn1.X     += 2;
                rectColumn1.Y      = 1;
                rectColumn1.Width -= 4;

                widthPrevCols += colWidth;
                //realColumnIndex += Columns[i].IsNullable ? 2 : 1;
                realColumnIndex += 1;

                if (rectColumn1.Width <= 0)
                {
                    Labels[i].Visible = false;
                    continue;
                }
                Labels[i].Size    = rectColumn1.Size;
                Labels[i].Top     = dataGridViewX1.Top + rectColumn1.Height;
                Labels[i].Left    = rectColumn1.Left - horzOffset + dataGridViewX1.Left;
                Labels[i].Visible = true;
                Labels[i].Refresh();
            }

            #region Categories
            for (int catCounter = CategoryLabels.Count - 1; catCounter >= 0; catCounter--)
            {
                LabelX catLabel = CategoryLabels[catCounter];
                int    left     = -1;
                int    width    = 0;
                bool   found    = false;

                for (int i = 0; i < Columns.Count; i++)
                {
                    if (Columns[i].CategoryName == catLabel.Text)
                    {
                        found = true;

                        if (left < 0)
                        {
                            left = Labels[i].Left;
                        }

                        if (Labels[i].Width > 0)
                        {
                            width = Labels[i].Right - left;
                        }
                    }
                    else if (found)
                    {
                        break;
                    }
                }
                catLabel.Left = left;

                if (left > 0)
                {
                    width += 2;
                }

                catLabel.Width   = width;
                catLabel.Top     = dataGridViewX1.Top;
                catLabel.Height  = headerRowHeight / 2;
                catLabel.Visible = true;
                catLabel.BringToFront();
                catLabel.Refresh();
            }
            #endregion
        }