コード例 #1
0
ファイル: TreeMapItem.cs プロジェクト: dxc31202/ZXStudio
        public void Plot(DiskItem diskItem, RectangleF workArea, int maxDepth)
        {
            this.maxDepth = maxDepth;
            Key           = diskItem.FullPath;
            Rectangle     = workArea;
            TreeeNodeSize = diskItem.Size;
            DiskItem      = diskItem;
            DisplayName   = this.DiskItem.Name;

            if (diskItem.Files == 0)
            {
                return;
            }
            if (workArea.Height <= maxHeight && workArea.Width <= maxWidth)
            {
                return;
            }

            Reset(workArea);
            if (workArea.Height <= maxHeight && workArea.Width <= maxWidth)
            {
                return;
            }

            Squarify(PrepareTreeMapItems(diskItem.Children), new List <TreeMapItem>(), GetWidth());
        }
コード例 #2
0
ファイル: TreeMapEx.cs プロジェクト: dxc31202/ZXStudio
 public void RePlot(DiskItem disk)
 {
     if (disk.Type == DiskItem.NodeType.Disk)
     {
         this.disk = (DiskItem)disk;
     }
     currentObject = disk;
     RePlot();
 }
コード例 #3
0
ファイル: TreeMapItem.cs プロジェクト: dxc31202/ZXStudio
        private TreeMapItem PrepareTreeMapItems(List <DiskItem> values)
        {
            TreeMapItem TreeMapItems = new TreeMapItem();

            try
            {
                values.Sort(delegate(DiskItem x, DiskItem y) { return(y.Size.CompareTo(x.Size)); });
            }
            catch
            {
                return(TreeMapItems);
            }
            totalArea = workAreaWidth * workAreaHeight;

            float sumOfValues = this.TreeeNodeSize;

            for (int i = 0; i < values.Count; i++)
            {
                DiskItem diskItem   = values[i];
                double   percentage = (diskItem.Size / sumOfValues) * 100;
                float    area       = (float)((totalArea / 100) * percentage);
                if (area > 0)
                {
                    TreeMapItem tm = new TreeMapItem();
                    tm.Key             = diskItem.FullPath;
                    tm.Area            = area;
                    tm.Percentage      = percentage;
                    tm.DiskItem        = diskItem;
                    tm.TreeeNodeSize   = diskItem.Size;
                    tm.Key             = diskItem.FullPath;
                    tm.DisplayName     = diskItem.Name;
                    TreeMapItems.Area += area;
                    TreeMapItems.Add(tm);
                }
            }
            return(TreeMapItems);
        }
コード例 #4
0
ファイル: TreeMapEx.cs プロジェクト: dxc31202/ZXStudio
        void DrawFolder(Graphics offScreenDC, RectangleF rect, string text, bool highlight, DiskItem fileObject)
        {
            //if (fileObject.Depth > detailLevel) return;
            float x      = rect.X;
            float y      = rect.Y;
            float width  = rect.Width;
            float height = rect.Height;
            Color color  = Color.Orange;

            //if (fileObject.IsHidden || fileObject.IsSystem) color = ControlPaint.Dark(color);
            using (Brush folderBrush = new SolidBrush(highlight ? fileObject.Parent == null ? color : ControlPaint.LightLight(color) : color))
            {
                stringFormat.Alignment     = StringAlignment.Center;
                stringFormat.LineAlignment = StringAlignment.Near;
                stringFormat.Trimming      = StringTrimming.Character;
                stringFormat.FormatFlags   = StringFormatFlags.NoWrap;
                using (Pen folderPen = new Pen(folderBrush))
                {
                    if (height > 15)
                    {
                        offScreenDC.FillRectangle(folderBrush, x, y, width, 15);
                    }
                    else
                    {
                        offScreenDC.FillRectangle(folderBrush, x, y, width, height);
                    }

                    using (Pen pen = new Pen(highlight ? Color.White : Color.Black))
                    {
                        if (height >= 15)
                        {
                            offScreenDC.DrawRectangle(pen, rect.X, rect.Y, rect.Width, 15);
                        }
                        offScreenDC.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
                        //g.DrawRectangle(folderPen, x + 1, y + 1, width - 2, height - 2);
                        float h = 13;
                        if (height < 13)
                        {
                            h = height;
                        }
                        WriteCaption(offScreenDC, text + " " + FormatSize(fileObject.Size), new RectangleF(x + 2, y, width, h), GetContrast(color), highlight, 7f);
                    }
                }
            }
        }
コード例 #5
0
ファイル: TreeMapEx.cs プロジェクト: dxc31202/ZXStudio
        void DrawFile(Graphics offScreenDC, RectangleF rect, string text, bool highlight, DiskItem fileObject)
        {
            //if (fileObject.Depth > detailLevel) return;
            float x      = rect.X;
            float y      = rect.Y;
            float width  = rect.Width;
            float height = rect.Height;

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.Trimming      = StringTrimming.Character;
            stringFormat.FormatFlags   = StringFormatFlags.NoWrap;

            Color color = GetFileTypeColor(fileObject.Name);

            contrast = ControlPaint.Light(color);
            Color bright = ControlPaint.LightLight(Color.WhiteSmoke);
            Color dull   = ControlPaint.Light(bright);

            //if (fileObject.IsHidden && fileObject.IsSystem)
            color = ControlPaint.Dark(color);
            //else
            //    if (fileObject.IsHidden)
            //    color = ControlPaint.Dark(color);
            //else
            //        if (fileObject.IsSystem)
            //    color = ControlPaint.Dark(color);

            if (rect.Height >= 2 && rect.Width >= 2)
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddRectangle(rect);
                    using (PathGradientBrush fileBrush = new PathGradientBrush(path))
                    {
                        Color[] colors = { highlight?contrast : color };
                        fileBrush.SurroundColors = colors;
                        fileBrush.CenterColor    = dull;// highlight ? bright : dull;
                        offScreenDC.FillPath(fileBrush, path);
                    }
                }
            }
            else
            {
                if (rect.Height > 0 && rect.Width > 0)
                {
                    using (Brush fileBrush = new SolidBrush(highlight ? contrast : color))
                        offScreenDC.FillRectangle(fileBrush, rect.X, rect.Y, rect.Width, rect.Height);
                }
            }
            WriteCaption(offScreenDC, text + Environment.NewLine + FormatSize(fileObject.Size), new RectangleF(x + 2, y, width, height - 2), GetContrast(color), highlight, 7f);
            using (Pen pen = new Pen(highlight ? dull : Color.Gray))
                offScreenDC.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
        }
コード例 #6
0
ファイル: TreeMapItem.cs プロジェクト: dxc31202/ZXStudio
 public void Plot(DiskItem diskItem, RectangleF workArea)
 {
     depth = 0;
     Plot(diskItem, workArea, 0);
 }
コード例 #7
0
        void RecurseDirectory(string directory, DiskItem parent)
        {
            IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);

            NativeMethods.WIN32_FIND_DATA findData;
            IntPtr findHandle;

            if (Cancel)
            {
                return;
            }
            // please note that the following line won't work if you try this on a network folder, like \\Machine\C$
            // simply remove the \\?\ part in this case or use \\?\UNC\ prefix
            string slash  = directory.EndsWith(@"\") ? "" : @"\";
            string folder = directory + (slash);

            try
            {
                findHandle = NativeMethods.FindFirstFile(folder + @"*.*", out findData);
                int s = Marshal.GetLastWin32Error();
                if (findHandle != INVALID_HANDLE_VALUE)
                {
                    do
                    {
                        if (Cancel)
                        {
                            return;
                        }
                        if ((findData.dwFileAttributes & (int)FileAttributes.Directory) != 0)
                        {
                            if (findData.cFileName == ".")
                            {
                                continue;
                            }
                            if (findData.cFileName == "..")
                            {
                                continue;
                            }
                            {
                                if (((findData.dwFileAttributes & (int)FileAttributes.System) == 0) && ((findData.dwFileAttributes & (int)FileAttributes.Hidden) == 0))
                                {
                                    string   subdirectory = directory + (directory.EndsWith(@"\") ? "" : @"\") + findData.cFileName;
                                    DiskItem di           = new DiskItem(parent, findData.cFileName);
                                    RecurseDirectory(subdirectory, parent.Add(di));
                                    float percent = (float)FileSize / (float)TotalSize * 100f;
                                    if (lastPCT != (int)percent)
                                    {
                                        OnProgress(percent, item);
                                    }
                                    lastPCT = (int)percent;
                                }
                            }
                        }
                        else
                        {
                            if (((findData.dwFileAttributes & (int)FileAttributes.System) == 0) && ((findData.dwFileAttributes & (int)FileAttributes.Hidden) == 0))
                            {
                                long size = (findData.nFileSizeLow | (findData.nFileSizeHigh << 8));
                                FileSize += size;
                                CurrentSize++;
                                parent.Add(new DiskItem(parent, findData.cFileName, size));
                            }
                        }
                    }while (NativeMethods.FindNextFile(findHandle, out findData));
                    NativeMethods.FindClose(findHandle);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }