コード例 #1
0
        //create an tabpage
        private bool CreateDWGThumnailCollection(ref TabPage Page)
        {
            string          PathStr   = Page.Tag as string;
            FlowLayoutPanel FlowPanel = new FlowLayoutPanel();

            if (Directory.Exists(PathStr))
            {
                List <string> DwgFiles = Directory.GetFiles(PathStr, "*.dwg", SearchOption.AllDirectories).ToList();
                BlockingCollection <DwgThumnail> DwgItemList = new BlockingCollection <DwgThumnail>();

                FlowPanel.Dock       = DockStyle.Fill;
                FlowPanel.BackColor  = System.Drawing.SystemColors.ButtonHighlight;
                FlowPanel.AutoScroll = true;
                int type = 0;

                if (Regex.Match(PathStr, @"StdBlock").Success)
                {
                    type = 0;
                }
                else
                {
                    type = 1;
                }
                Parallel.ForEach(DwgFiles, item =>
                {
                    DwgThumnail DwgItem = new DwgThumnail(item, type);
                    DwgItemList.Add(DwgItem);
                });
                if (DwgItemList.Count == 0)
                {
                    Label lb = new Label();
                    lb.Text     = "该路径下不包含任何DWG文件";
                    lb.Dock     = DockStyle.Top;
                    lb.AutoSize = true;

                    FlowPanel.Padding = new Padding(30);
                    FlowPanel.Controls.Add(lb);
                    Page.Controls.Add(FlowPanel);
                    return(false);
                }
                else
                {
                    FlowPanel.SuspendLayout();
                    List <DwgThumnail> DwgList = DwgItemList.ToList();
                    DwgList.Sort();
                    FlowPanel.Controls.AddRange(DwgList.ToArray());
                    FlowPanel.ResumeLayout();
                    Page.Controls.Add(FlowPanel);
                    return(true);
                }
            }
            else
            {
                AcadApp.ShowAlertDialog(string.Format("路径:{0} 不存在", PathStr));
                return(false);
            }
        }
コード例 #2
0
ファイル: dwgThumnail.cs プロジェクト: cughudson/DWGLib-2014
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            DwgThumnail _dwgThumnail = obj as DwgThumnail;

            if (_dwgThumnail == null)
            {
                return(1);
            }

            string Str1 = this.BlockName.Text;
            string Str2 = _dwgThumnail.BlockName.Text;

            return(Str1.CompareTo(Str2));
        }