예제 #1
0
        private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node.Nodes[0].Text == "")
            {
                e.Node.Nodes[0].Remove();

                List <BrowseItem> arr = fb.GetChildren((BrowseItem)e.Node.Tag);
                foreach (BrowseItem it in arr)
                {
                    if (it.Type == BrowseItemType.Container)
                    {
                        TreeNode tn = new TreeNode(it.name);
                        tn.Tag              = it;
                        tn.ImageKey         = it.info.Length == 0 ? "folder" : "dicomfolder";
                        tn.SelectedImageKey = tn.ImageKey;
                        tn.Nodes.Add("");
                        e.Node.Nodes.Add(tn);
                    }
                }
            }

            if (e.Node.Tag.GetType() == typeof(BrowseItem))
            {
                BrowseItem it = (BrowseItem)e.Node.Tag;
                e.Node.ImageKey         = it.info.Length == 0 ? "openfolder" : "dicomopenfolder";
                e.Node.SelectedImageKey = e.Node.ImageKey;
            }
        }
예제 #2
0
 public BrowseItem GetRoot()
 {
     if (root is null)
     {
         root      = new BrowseItem();
         root.name = "Computer";
     }
     return(root);
 }
예제 #3
0
 private void treeView1_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
 {
     if (e.Node.Tag.GetType() == typeof(BrowseItem))
     {
         BrowseItem it = (BrowseItem)e.Node.Tag;
         e.Node.ImageKey         = it.info.Length == 0 ? "folder" : "dicomfolder";
         e.Node.SelectedImageKey = e.Node.ImageKey;
     }
 }
예제 #4
0
        Bitmap GetImage(object key, Size sz)
        {
            if (key.GetType() != typeof(BrowseItem))
            {
                return(null);
            }

            try
            {
                BrowseItem it    = (BrowseItem)key;
                int        frame = -1;
                string     path  = "";
                if (it.info.StartsWith("dicom:image"))
                {
                    frame = 0;
                    path  = it.info.Remove(0, "dicom:image:".Length);
                }
                else if (it.info.StartsWith("dicom:frame"))
                {
                    string[] arr = it.info.Split(new char[] { ':' }, 4);
                    if (arr.Length == 4)
                    {
                        frame = int.Parse(arr[2]);
                        path  = arr[3];
                    }
                }

                if (frame < 0)
                {
                    return(null);
                }

                if (DicomFile.HasValidHeader(path))
                {
                    DicomImage img   = new DicomImage(path, frame);
                    Bitmap     bmp   = img.RenderImage(frame).AsBitmap();
                    float      ratio = (float)bmp.Width / bmp.Height;
                    if (ratio < 1)
                    {
                        sz.Width = (int)(sz.Height * ratio);
                    }
                    else
                    {
                        sz.Height = (int)(sz.Width / ratio);
                    }
                    return((sz.Width > 0 && sz.Height > 0) ? new Bitmap(img.RenderImage(frame).AsBitmap(), sz) : new Bitmap(img.RenderImage(frame).AsBitmap()));
                }
            }
            catch
            {
            }

            return(null);
        }
예제 #5
0
        void RetrieveVirtualItemImage(object sender, VirtualItemImageEventArgs e)
        {
            if (e.Key.GetType() != typeof(BrowseItem))
            {
                return;
            }

            BrowseItem it = (BrowseItem)e.Key;

            e.FileName = it.id;
        }
예제 #6
0
        void RetrieveVirtualItemDetails(object sender, VirtualItemDetailsEventArgs e)
        {
            if (e.Key.GetType() != typeof(BrowseItem))
            {
                return;
            }

            BrowseItem it = (BrowseItem)e.Key;

            e.FileName = it.name;
        }
예제 #7
0
        private void FileBrowser_Load(object sender, EventArgs e)
        {
            BrowseItem it = fb.GetRoot();

            TreeNode tn = new TreeNode(it.name);

            tn.Tag              = it;
            tn.ImageKey         = it.info.Length == 0 ? "folder" : "dicomfolder";
            tn.SelectedImageKey = tn.ImageKey;
            tn.Nodes.Add("");
            treeView1.Nodes.Add(tn);

            tn.Expand();
            OpenPath(lastPath);
        }
예제 #8
0
 public BrowseItem GetParent(BrowseItem item)
 {
     return(item.Parent);
 }
예제 #9
0
 public BrowseItem(BrowseItem p = null, BrowseItemType t = BrowseItemType.Container)
 {
     parent = p;
     type   = t;
 }