public static Color RampedColourByIntensityRange(Color aMaxIntensity, long aValue, long aMin, long aMax) { // Calculate the difference between the maximum and minimum. This tells us how many different // "intensity" values we have to work with. long valueSpan = (aMax - aMin); // Get the brightness of the baseline colour and then scale it based upon the number of different // value intensities we must cope with. float brightness = aMaxIntensity.GetBrightness(); float brightnessPerValue = (brightness / (float)valueSpan); // Ramp the cell colour based upon the index float percentage = brightness - (brightnessPerValue * (aValue - aMin)); Color ret = ColourUtils.Darken(aMaxIntensity, percentage); return(ret); }
private void PopupShow() { //System.Diagnostics.Debug.WriteLine( "PopupBase - POPUP SHOW NOW - Visible: " + Visible + ", iShowPos[ " + iShowPos.X + ", " + iShowPos.Y + " ]" ); if (!Visible) { // Should we colourise the form header & footer // based upon the mouse co-ordinates at the time of // the asynch display? if (ColourFromHoverCoordinate) { using (Bitmap bmp = new Bitmap(1, 1)) { using (Graphics gfx = Graphics.FromImage(bmp)) { Color c = SymbianUtils.Graphics.ScreenUtils.ColorAtPixel(iHoverPos); ColourTitle = c; // Make the border slightly darker ColourBorder = ColourUtils.Darken(ColourTitle); } } } // Get the screen size Rectangle rect = Screen.GetWorkingArea(this); // Make sure that the popup is displayed within the screen bounds. Point pos = iShowPos; if (iShowPos.X + this.Width > rect.Right) { pos.X = rect.Width - this.Width; } if (iShowPos.Y + this.Height > rect.Bottom) { pos.Y = rect.Bottom - this.Height; } // Now make the form visible and topmost. ShowWindow(this.Handle, SW_SHOWNOACTIVATE); SetWindowPos(this.Handle, HWND_TOP_MOST, pos.X, pos.Y, 0, 0, SWP_NOMOVE | SWP_NOSIZE); Location = pos; } }
public Color CellColour(HeapCell aCell) { Color fillColour = Color.LightGray; // if (aCell.Type == HeapCell.TType.EAllocated) { // Get the cell colour that is associated with the cell symbol object type. This // makes oldest cells very light and youngest cells very dark. We really want // it the other way around... // float maxBrightness = KRampBaselineColour.GetBrightness(); float allocationNumberPercentage = ((float)aCell.AllocationNumber / (float)iHighestCellAllocationNumber); float targetBrightness = allocationNumberPercentage * maxBrightness; float amountToDarkenBy = maxBrightness - targetBrightness; fillColour = ColourUtils.Darken(KRampBaselineColour, amountToDarkenBy); } // return(fillColour); }
public static Color RampedColourByBoxNumber(Color aBaseline, int aBoxCount, uint aCellBaseAddress, uint aAddress) { float cellAddressOffset = (float)((aAddress - aCellBaseAddress) / 4); Color dark = ColourUtils.Darken(aBaseline, 0.30f); Color light = ColourUtils.Lighten(aBaseline, 0.30f); // This is the baseline brightness for the colour float brightnessBaseline = light.GetBrightness() - dark.GetBrightness(); // This is how much brightness we can apply to each box. float brightnessPerBox = (brightnessBaseline / aBoxCount); // This is the brightness of the target box float brightnessPercentage = brightnessPerBox * cellAddressOffset; Color ret = ColourUtils.Lighten(aBaseline, brightnessPercentage); return(ret); }
public virtual void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats) { // Set title and border colour HeapCell firstCell = aCells[0]; ColourTitle = HeapCtrlLib.Renderers.Utilities.HeapCellRendererColour.ColourByCellType(firstCell); ColourBorder = ColourUtils.Darken(ColourTitle); // Get stats long lengthPayload = aCells.Statistics.SizeTotalPayload; long lengthHeader = aCells.Statistics.SizeTotalHeader; float lengthsAsHeapPercentage = aStats.CellLengthAsHeapPercentage(lengthHeader + lengthPayload); // Header length iLbl_Title_Length_Header.Text = "H: [" + lengthHeader.ToString("d6") + "]"; // Payload length iLbl_Title_Length_Payload.Text = "P: [" + lengthPayload.ToString("d8") + "]"; // Set cell allocation number (for allocated cells) or then // the cell index for free cells. string heapSpecificPrefix = "H: "; if (aCells.Count == 1) { float lengthsAsTypePercentage = aStats.CellLengthAsTypePercentage(firstCell); // string typeSpecificPrefix = "A: "; if (firstCell.Type == HeapCell.TType.EFree) { typeSpecificPrefix = "F: "; } // if (HeapCell.IsDebugAllocator) { switch (firstCell.Type) { case HeapCell.TType.EAllocated: iLbl_Footer.Text = "Alloc #: [" + firstCell.AllocationNumber.ToString("d6") + " / " + aStats.StatsAllocated.CellAllocationNumberLargest.AllocationNumber.ToString("d6") + "]"; break; case HeapCell.TType.EFree: iLbl_Footer.Text = "Free cell #: [" + firstCell.AllocationNumber.ToString("d4") + " / " + aStats.StatsFree.TypeCount.ToString("d4") + "]"; break; } } else { iLbl_Footer.Text = "[ " + firstCell.Address.ToString("x8") + " ]"; } // iLbl_Footer_Percentage_OfType.Text = typeSpecificPrefix + "[" + lengthsAsTypePercentage.ToString("#00.00") + "%]"; } else { heapSpecificPrefix = "Of Heap: "; iLbl_Footer.Text = string.Empty; iLbl_Footer_Percentage_OfType.Visible = false; } // iLbl_Footer_Percentage_OfTotal.Text = heapSpecificPrefix + "[" + lengthsAsHeapPercentage.ToString("#00.00") + "%]"; }
public void PaintContentBorder(Graphics aGraphics, HeapCellMetaData aMetaData, HeapCell aCell, uint aAddress, Point aPosition, Size aBoxSize, Size aPaddingSize) { SymRect rect = new SymRect(aPosition, aBoxSize + aPaddingSize); // Right and bottom get darker borders Color rightAndBottomColour = ColourUtils.Darken(aMetaData.CellBoxColor, 0.15f); using (Pen rightAndBottomPen = new Pen(rightAndBottomColour)) { if (aMetaData.Borders[THeapCellBorderType.ERight]) // Draw right-hand outline { Point start = rect.TopRight; Point end = rect.BottomRight; start.Offset(-1, 0); end.Offset(-1, 0); // aGraphics.DrawLine(rightAndBottomPen, start, end); } if (aMetaData.Borders[THeapCellBorderType.EBottom]) // Draw bottom-side outline { Point start = rect.BottomLeft; Point end = rect.BottomRight; start.Offset(0, -1); end.Offset(0, -1); // aGraphics.DrawLine(rightAndBottomPen, start, end); } } // Left and Top get lighter borders Color leftAndTopColour = ColourUtils.Lighten(aMetaData.CellBoxColor, 0.15f); using (Pen leftAndTopPen = new Pen(leftAndTopColour)) { if (aMetaData.Borders[THeapCellBorderType.ELeft]) // Draw left-hand outline { Point start = rect.TopLeft; Point end = rect.BottomLeft; start.Offset(1, 0); end.Offset(1, 0); // aGraphics.DrawLine(leftAndTopPen, start, end); } if (aMetaData.Borders[THeapCellBorderType.ETop]) // Draw top-side outline { Point start = rect.TopLeft; Point end = rect.TopRight; start.Offset(0, 1); end.Offset(0, 1); // aGraphics.DrawLine(leftAndTopPen, start, end); } } // Now draw black border which will cover any over-spill from above. if (aMetaData.Borders[THeapCellBorderType.ELeft]) // Draw left-hand outline { aGraphics.DrawLine(Pens.Black, rect.TopLeft, rect.BottomLeft); } if (aMetaData.Borders[THeapCellBorderType.ERight]) // Draw right-hand outline { aGraphics.DrawLine(Pens.Black, rect.TopRight, rect.BottomRight); } if (aMetaData.Borders[THeapCellBorderType.ETop]) // Draw top-side outline { aGraphics.DrawLine(Pens.Black, rect.TopLeft, rect.TopRight); } if (aMetaData.Borders[THeapCellBorderType.EBottom]) // Draw bottom-side outline { aGraphics.DrawLine(Pens.Black, rect.BottomLeft, rect.BottomRight); } }