public GraphicalView(MemVisualizer.MainWindow mainViewerWindow)
        {
            BlockSizeSelectionMutex = new System.Threading.Mutex();
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // TODO: Add any constructor code after InitializeComponent call
            mMainViewWindow = mainViewerWindow;

            mHasMemoryBlockOccupancyBeenCalculated = true;
            mWindowUpdate = false;
            mPopulateList = true;

            mInfo2Graph = new GVstruct();
            mPen = new Pen(Color.White, 1);
            mSolidBrush = new SolidBrush(Color.White);

            mStartIndexOfHeap = uint.MaxValue;
            mNumberBlocks = 0;
            mBytesInBlock = 8192 * 2;
            mBlocksInRow = 0;
            mEndIndexOfHeap = 0;

            // Set resize redraw
            SetStyle(ControlStyles.UserPaint, true);
            CreateBitmap(mMemoryView.Width, (int)mBlockHeight);
        }
 /**
  * Copy information to object member variables and initialize the menus.
  */
 public void CopyGvInfo(GVstruct input, Log log, SnapShot logSnap, ArrayList allocinfo, int category)
 {
     mInfo2Graph = input;
     mLog = log;
     mLogSnap = logSnap;
     mAllocators = allocinfo;
     mCategories =  mLog.GetCategories();
     mSelectedCategory = category;
     // Initialize first time
     PopulateDropDownMenu(category);
     PopulateBlockSize();
     SelectAppropriateBlockSize();
 }
        public void NewSnapShot(SnapShot logSnapShot)
        {
            mHighlightedLogEntry = -1;
              //  mHighlightLogSnap = null;
            mLogSnap = logSnapShot;

            mInfo2Graph = new GVstruct();
            for (int i = 0, e = mLogSnap.Count; i < e; i++)
            {
                LogEntry le = mLog[mLogSnap[i]];
            #if DEBUG
                if (!(mLowerBound < le.address && le.address < mUpperBound))
                    System.Diagnostics.Debug.Print( "!! Why this address is not in range?\n");
            #endif
                mInfo2Graph.mMemoryBlockIndex.Add(mLogSnap[i]);
            }

            Array.Clear(mMemoryMap, 0, mMemoryMap.Length);
            UpdateView(true);
        }
		//------------------------------------------------------------------
		private void GVClicked(object sender, System.EventArgs e)
		{
			MenuItem mi = (MenuItem) sender;
            checkSelectedItem(mi);
            string displayMode = LoadFromRegistry("displayMode", "category");

            GVstruct infoToGraph = new GVstruct();
            bool resizeGV = false;
            int[] dim = new int[4];
            if (mGraphicalView == null)
            {
                mGraphicalView = new GraphicalView(this);
                //resizeGV = true;                
               // mGraphicalView.Close();
               // mGraphicalView = null;
            }

            int catIndex = 0;
			if (mi != null)
			{
				string item = mi.ToString();
                catIndex = mLog.GetIndexForCategory(mi.Text);
                if (displayMode == "heap")
                    catIndex = 0;  // 0 means no category, or i.e. all categories
                mLogSnap = new MemManager.Log.SnapShot(mLog, mLog.FindHWIndexForCategory(catIndex), true);
                infoToGraph.PopulateGVStructFromSnapshot(mLog, mLogSnap, catIndex);
			}
            mGraphicalView.CopyGvInfo(infoToGraph, mLog, mLogSnap, mAllocators, catIndex);
            if (resizeGV)
                mGraphicalView.SetWindowSize(dim[0], dim[1]);
            
            mGraphicalView.Show();

            //the following goes after show to work correctly
            if (resizeGV)
                mGraphicalView.SetWindowLocation(new Point(dim[2], dim[3]));
        }