Exemple #1
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            if (draftTableForm != null && !draftTableForm.IsDisposed)
            {
                if (!draftTableForm.Visible)
                {
                    draftTableForm.Show();
                }

                Restore(draftTableForm);

                return(Result.Success);
            }

            draftTableForm = new DraftTableForm();

            draftTableForm.Show();

            draftTableForm.LoadFolder("");
            draftTableForm.LoadDraftTableFoldersThumbnails();

            return(Result.Success);
        }
Exemple #2
0
        private void menu_FolderIcon(object sender, EventArgs e)
        {
            string ext = Path.GetExtension(filename).ToUpperInvariant();

            if (FileUtils.CadExtensions.Contains(ext))
            {
                using (Bitmap bmp = Rhino.FileIO.File3dm.ReadPreviewImage(filename))
                {
                    string folder = Path.GetDirectoryName(filename);

                    string folderThumbnail = Path.Combine(folder, "dtFolderThumb.png");

                    bmp.Save(folderThumbnail);
                    mainForm.LoadDraftTableFoldersThumbnails();
                }
            }


            if (ext.CompareTo(".GH") == 0)
            {
                Bitmap flag = new Bitmap(128, 128);
                using (Graphics flagGraphics = Graphics.FromImage(flag))
                {
                    flagGraphics.FillRectangle(Brushes.Gray, 0, 0, 128, 128);
                    flagGraphics.DrawImage(global::DraftTable.Properties.Resources.file_bitmap, 0, 128 - global::DraftTable.Properties.Resources.file_bitmap.Height / 2);

                    Font       drawFont  = new Font("Arial", 16);
                    SolidBrush drawBrush = new SolidBrush(Color.OrangeRed);

                    var stringFormat = StringFormat.GenericDefault;
                    stringFormat.Alignment = StringAlignment.Center;

                    Rectangle drawRect = new Rectangle(0, 0, 128, 128);

                    flagGraphics.DrawString(Path.GetFileNameWithoutExtension(filename), drawFont, drawBrush, drawRect, stringFormat);
                }

                string folder = Path.GetDirectoryName(filename);

                string folderThumbnail = Path.Combine(folder, "dtFolderThumb.png");

                using (var thumbNailImage = flag.GetThumbnailImage(512, 512, null, new IntPtr()))
                {
                    thumbNailImage.Save(folderThumbnail);
                }
                mainForm.LoadDraftTableFoldersThumbnails();
            }


            if (FileUtils.ImageExtensions.Contains(ext))
            {
                using (Image image = Image.FromFile(filename))
                {
                    string folder = Path.GetDirectoryName(filename);

                    string folderThumbnail = Path.Combine(folder, "dtFolderThumb.png");

                    using (var thumbNailImage = image.GetThumbnailImage(512, 512, null, new IntPtr()))
                    {
                        thumbNailImage.Save(folderThumbnail);
                    }
                    mainForm.LoadDraftTableFoldersThumbnails();
                }
            }
        }
Exemple #3
0
        public void AddFile(string f, bool import, string backup)
        {
            string ext = Path.GetExtension(f).ToUpperInvariant();

            if (FileUtils.ImageExtensions.Contains(ext))
            {
                using (var image = Image.FromFile(f))
                {
                    // Add binary data to List
                    ImageList.Add(image);
                    FileList.Add(f);

                    // Create a Thumnail of Image and add Thumbnail to Panel
                    MakeThumbnail(image, f, true, backup);
                }

                GC.GetTotalMemory(true);
            }

            if (ext.CompareTo(".GH") == 0)
            {
                using (Bitmap bmp = new Bitmap(128, 128))
                {
                    FileUtils.DrawStringToBmp(f, bmp);

                    MakeThumbnail(bmp, f, true, backup);
                }
            }

            if (ext.CompareTo(".PY") == 0 || ext.CompareTo(".RVB") == 0 || ext.CompareTo(".TXT") == 0)
            {
                using (Bitmap bmp = new Bitmap(128, 128))
                {
                    FileUtils.DrawStringToBmp(f, bmp);

                    MakeThumbnail(bmp, f, true, backup);
                }
            }

            if (FileUtils.CadExtensions.Contains(ext))
            {
                Bitmap bmp = Rhino.FileIO.File3dm.ReadPreviewImage(f);

                if (bmp == null)
                {
                    bmp = new Bitmap(128, 128);
                    FileUtils.DrawStringToBmp(f, bmp);
                }

                string folder = Path.GetDirectoryName(f);

                string folderThumbnail = Path.Combine(folder, "dtFolderThumb.png");

                if (!import)
                {
                    if (!File.Exists(folderThumbnail))
                    {
                        bmp.Save(folderThumbnail);
                        parentForm.LoadDraftTableFoldersThumbnails();
                    }
                }

                ImageList.Add(bmp);
                FileList.Add(f);

                MakeThumbnail(bmp, f, import, backup);

                bmp.Dispose();

                GC.GetTotalMemory(true);
            }
        }