Ejemplo n.º 1
0
        /// <summary>
        /// Selects the specified bin.
        /// </summary>
        public void SelectBin(Bin bin)
        {
            long offset = mMap.Position;

            mMap.Seek(0, System.IO.SeekOrigin.Begin);
            while (!mMap.EOF)
            {
                Bin s = mMap.Read();
                if (s.GetHashCode() == bin.GetHashCode())
                {
                    mMap.Seek(s.Offset, System.IO.SeekOrigin.Begin);
                    selectedbin = s.GetHashCode();
                    Refresh();
                    return;
                }
            }
            mMap.Seek(offset, System.IO.SeekOrigin.Begin);
            return;
        }
Ejemplo n.º 2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (mMap.Length == 0)
            {
                return;
            }

            int x = (int)Math.Floor((float)e.X / xbin);
            int y = (int)Math.Floor((float)e.Y / ybin);

            if (y < 0 || y > rows)
            {
                Refresh();
                return;
            }

            long offset = mMap.Position;
            long loc    = y * cols + x + mMap.Position;

            if (loc < mMap.Length)
            {
                mMap.Seek(loc, System.IO.SeekOrigin.Begin);
                Bin s = mMap.Read();
                hoveredbin = s.GetHashCode();
                tip        = s.Name + Environment.NewLine +
                             "Offset: " + s.Offset.ToString() + Environment.NewLine +
                             "Length: " + s.Length.ToString();
                tipleft = true; // (e.X > ClientRectangle.Width / 2);
                tiptop  = (e.Y > ClientRectangle.Height / 2);

                mMap.Seek(offset, System.IO.SeekOrigin.Begin);
            }
            else
            {
                tip        = "";
                hoveredbin = -1;
            }
            Refresh();
        }
Ejemplo n.º 3
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            int x = (int)Math.Floor((float)e.X / xbin);
            int y = (int)Math.Floor((float)e.Y / ybin);

            if (y < 0 || y > rows)
            {
                Refresh();
                return;
            }

            long offset = mMap.Position;
            long loc    = y * cols + x + mMap.Position;

            if (loc < mMap.Length)
            {
                mMap.Seek(loc, System.IO.SeekOrigin.Begin);
                Bin s = mMap.Read();
                selectedbin = s.GetHashCode();
                mMap.Seek(offset, System.IO.SeekOrigin.Begin);
                if (BinSelect != null)
                {
                    BinSelect(this, s);
                }
            }
            else
            {
                selectedbin = -1;
            }
            Refresh();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Selects the specified bin.
 /// </summary>
 public void SelectBin(Bin bin)
 {
     long offset = mMap.Position;
     mMap.Seek(0, System.IO.SeekOrigin.Begin);
     while (!mMap.EOF)
     {
         Bin s = mMap.Read();
         if (s.GetHashCode() == bin.GetHashCode())
         {
             mMap.Seek(s.Offset, System.IO.SeekOrigin.Begin);
             selectedbin = s.GetHashCode();
             Refresh();
             return;
         }
     }
     mMap.Seek(offset, System.IO.SeekOrigin.Begin);
     return;
 }
Ejemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            // Draw the border
            e.Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);
            if (mBorderStyle == BorderStyle.FixedSingle)
            {
                ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle, Border3DStyle.Flat);
            }
            else if (mBorderStyle == BorderStyle.Fixed3D)
            {
                ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle, Border3DStyle.SunkenInner);
            }

            if (mMap.Length == 0)
            {
                return;
            }
            if (cols == 0 || rows == 0)
            {
                return;
            }

            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            e.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            float x = 0, y = 0;
            long  offset   = mMap.Position;
            long  loc      = offset;
            bool  inwindow = true;
            float xoffset  = (mBorderStyle != BorderStyle.None ? 1.0f : 0.0f);
            float yoffset  = (mBorderStyle != BorderStyle.None ? 1.0f : 0.0f);

            while (!mMap.EOF && inwindow)
            {
                Bin   s     = mMap.Read();
                bool  hi    = (s.GetHashCode() == hoveredbin);
                bool  sel   = (s.GetHashCode() == selectedbin);
                Color color = mMarkerColor[s.Marker];
                // Draw bins
                for (long i = loc - s.Offset; i < s.Length; i++)
                {
                    if (y >= 0 && y < rows)
                    {
                        if (s.Length == 1)
                        {
                            DrawSingleBin(e.Graphics, x * xbin + xoffset, y * ybin + yoffset, color, sel, hi);
                        }
                        else if (i == 0)
                        {
                            DrawBinLeft(e.Graphics, x * xbin + xoffset, y * ybin + yoffset, color, sel, hi);
                        }
                        else if (i == s.Length - 1)
                        {
                            DrawBinRight(e.Graphics, x * xbin + xoffset, y * ybin + yoffset, color, sel, hi);
                        }
                        else
                        {
                            DrawBinCenter(e.Graphics, x * xbin + xoffset, y * ybin + yoffset, color, sel, hi);
                        }
                    }
                    x++;
                    if (x >= cols)
                    {
                        x = 0;
                        y++;
                    }
                    if (y > rows)
                    {
                        inwindow = false;
                        break;
                    }
                }
                // Draw bin text
                if (showtext && s.Length > 2)
                {
                    float tx = x - (s.Offset + s.Length - loc) + 1;
                    float ty = y;
                    while (tx < 0)
                    {
                        tx += cols;
                        ty--;
                    }
                    if (ty >= 0 && ty < rows)
                    {
                        Rectangle r = new Rectangle((int)(tx * xbin), (int)(ty * ybin + yoffset), (int)(xbin * (s.Length - 2)), (int)ybin);
                        TextRenderer.DrawText(e.Graphics, s.Name, this.Font, r, ForeColor, TextFormatFlags.EndEllipsis | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.NoPrefix | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine);
                    }
                }

                loc = mMap.Position;
            }
            mMap.Seek(offset, System.IO.SeekOrigin.Begin);

            if (tip != "")
            {
                DrawTip(e.Graphics, tip, 5, 5, !tipleft, !tiptop);
            }
        }