Here are the examples of the csharp api class System.Drawing.Graphics.FromHwnd(System.IntPtr) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
178 Examples
0
1. Example
Project: route-planner-csharp
Source File: DockManager.xaml.cs
Source File: DockManager.xaml.cs
private void _InitDesktopDpiFactors() { // 1. Variant. // The code gets the horizontal (M11), vertical (M22) DPI. // The actual value are divided by 96 [going back to WPF's device independent logical // units in wpf being 1/96 of an inch], // so for example, on system at 144 DPI - get 1.5 // System.Windows.Media.Matrix m = // PresentationSource.FromVisual(App.Current.MainWindow).CompositionTarget.TransformToDevice; // _desktopDpiFactorX = m.M11; // _desktopDpiFactorY = m.M22; // 2. Variant (MSDN). // Obtain the window handle for WPF application IntPtr mainWindowPtr = new WindowInteropHelper(App.Current.MainWindow).Handle; // Get System Dpi System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr); _desktopDpiFactorX = desktop.DpiX / DEFAULT_DESCTOP_DPI; _desktopDpiFactorY = desktop.DpiY / DEFAULT_DESCTOP_DPI; }
0
2. Example
Project: AdmiralRoom
Source File: KanColleBrowser.xaml.cs
Source File: KanColleBrowser.xaml.cs
private static Size GetSystemDpi() { Size dpi; using (var graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi = new Size(graphics.DpiX, graphics.DpiY); } return dpi; }
0
3. Example
Project: the_building_coder_samples
Source File: CmdNewTextNote.cs
Source File: CmdNewTextNote.cs
static float GetDpiX() { float xDpi, yDpi; using( Graphics g = Graphics.FromHwnd( IntPtr.Zero ) ) { xDpi = g.DpiX; yDpi = g.DpiY; } return xDpi; }
0
4. Example
Project: ReClass.NET
Source File: DpiUtil.cs
Source File: DpiUtil.cs
private static void EnsureInitialized() { if (initialized) { return; } try { using (var g = Graphics.FromHwnd(IntPtr.Zero)) { dpiX = (int)g.DpiX; dpiY = (int)g.DpiY; if (dpiX <= 0 || dpiY <= 0) { dpiX = StdDpi; dpiY = StdDpi; } } } catch { } scaleX = dpiX / (double)StdDpi; scaleY = dpiY / (double)StdDpi; initialized = true; }
0
5. Example
Project: RTVS
Source File: BrowserWindow.cs
Source File: BrowserWindow.cs
private static int GetZoomFactor() { using (var g = Graphics.FromHwnd(Process.GetCurrentProcess().MainWindowHandle)) { const int baseLine = 96; var dpi = g.DpiX; if (baseLine == (int)dpi) { return 100; } // 150% scaling => 225 // 250% scaling => 400 double scale = dpi * ((dpi - baseLine) / baseLine + 1); return Convert.ToInt32(Math.Ceiling(scale / 25)) * 25; // round up to nearest 25 } }
0
6. Example
Project: Analysis-Services
Source File: HighDpiUtils.cs
Source File: HighDpiUtils.cs
public static float GetDpiFactor() { float factor = 1.0F; try { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { factor = (float)graphics.DpiX / 96F; //96 is the default windows DPI if (factor > 1.3 && factor < 1.7) { HighDPIUtils.PrimaryFudgeFactor = 0.66f; HighDPIUtils.SecondaryFudgeFactor = 1.1f; } else if (factor >= 1.7) { if (!Settings.Default.OptionHighDpiLocal) { HighDPIUtils.PrimaryFudgeFactor = 0.72f; HighDPIUtils.SecondaryFudgeFactor = 1.6f; } else { HighDPIUtils.PrimaryFudgeFactor = 0.54f; HighDPIUtils.SecondaryFudgeFactor = 1.2f; } } } } catch (Exception) { // Swallow any exceptions related to system DPI and use the default } return factor; }
0
7. Example
Project: Analysis-Services
Source File: HighDpiUtils.cs
Source File: HighDpiUtils.cs
public static float GetDpiWindowMonitor() { float dpi = 0; try { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi = (float)graphics.DpiX; } } catch (Exception) { // Swallow any exceptions related to system DPI and use the default } return dpi; }
0
8. Example
Project: P8Coder
Source File: FastColoredTextBox.cs
Source File: FastColoredTextBox.cs
public void ChangeFontSize(int step) { var points = Font.SizeInPoints; using (var gr = Graphics.FromHwnd(Handle)) { var dpi = gr.DpiY; var newPoints = points + step * 72f / dpi; if(newPoints < 1f) return; var k = newPoints / originalFont.SizeInPoints; Zoom = (int)(100 * k); } }
0
9. Example
Project: BaijiGenerator.Net
Source File: FastColoredTextBox.cs
Source File: FastColoredTextBox.cs
public void ChangeFontSize(int step) { var points = Font.SizeInPoints; using (var gr = Graphics.FromHwnd(Handle)) { var dpi = gr.DpiY; var newPoints = points + step * 72f / dpi; if(newPoints < 1f) return; var k = newPoints / originalFont.SizeInPoints; Zoom = (int)(100 * k); } }
0
10. Example
Project: dash-core
Source File: FastColoredTextBox.cs
Source File: FastColoredTextBox.cs
public void ChangeFontSize(int step) { var points = Font.SizeInPoints; using (var gr = Graphics.FromHwnd(Handle)) { var dpi = gr.DpiY; var newPoints = points + step * 72f / dpi; if(newPoints < 1f) return; var k = newPoints / originalFont.SizeInPoints; Zoom = (int)(100 * k); } }
0
11. Example
Project: HTML-Renderer
Source File: HtmlRender.cs
Source File: HtmlRender.cs
private static Size MeasureHtmlByRestrictions(HtmlContainer htmlContainer, Size minSize, Size maxSize) { // use desktop created graphics to measure the HTML using (var g = Graphics.FromHwnd(IntPtr.Zero)) using (var mg = new GraphicsAdapter(g, htmlContainer.UseGdiPlusTextRendering)) { var sizeInt = HtmlRendererUtils.MeasureHtmlByRestrictions(mg, htmlContainer.HtmlContainerInt, Utils.Convert(minSize), Utils.Convert(maxSize)); if (maxSize.Width < 1 && sizeInt.Width > 4096) sizeInt.Width = 4096; return Utils.ConvertRound(sizeInt); } }
0
12. Example
Project: oxyplot
Source File: PlotModelExtensions.cs
Source File: PlotModelExtensions.cs
public static string ToSvg(this PlotModel model, double width, double height, bool isDocument) { using (var g = Graphics.FromHwnd(IntPtr.Zero)) { using (var rc = new GraphicsRenderContext(g) { RendersToScreen = false }) { return OxyPlot.SvgExporter.ExportToString(model, width, height, isDocument, rc); } } }
0
13. Example
Project: ShadowsocksR-Csharp
Source File: Util.cs
Source File: Util.cs
public static int GetDpiMul() { int dpi; using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi = (int)graphics.DpiX; } return (dpi * 4 + 48) / 96; }
0
14. Example
Project: Elysium-Extra
Source File: DragManager.cs
Source File: DragManager.cs
private static Vector GetCurrentDisplayScaling() { using (var graphics = Graphics.FromHwnd(IntPtr.Zero)) { return new Vector(graphics.DpiX / 96.0, graphics.DpiY / 96.0); } }
0
15. Example
Project: shadowsocksr-csharp
Source File: Util.cs
Source File: Util.cs
public static int GetDpiMul() { int dpi; using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi = (int)graphics.DpiX; } return (dpi * 4 + 48) / 96; }
0
16. Example
Project: shadowsocksr-csharp
Source File: Util.cs
Source File: Util.cs
public static int GetDpiMul() { int dpi; using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi = (int)graphics.DpiX; } return (dpi * 4 + 48) / 96; }
0
17. Example
Project: ynoteclassic
Source File: FastColoredTextBox.cs
Source File: FastColoredTextBox.cs
public void ChangeFontSize(int step) { var points = Font.SizeInPoints; using (var gr = Graphics.FromHwnd(Handle)) { var dpi = gr.DpiY; var newPoints = points + step * 72f / dpi; if (newPoints < 1f) return; var k = newPoints / originalFont.SizeInPoints; Zoom = (int)(100 * k); } }
0
18. Example
Project: GerberTools
Source File: GerberPanelize.cs
Source File: GerberPanelize.cs
private void Zoom1to1() { using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) { try { var dx = g.DpiX; var dy = g.DpiY; Zoom = 1 * dx / 25.4; CenterPoint.X = ThePanel.TheSet.Width / 2; CenterPoint.Y = ThePanel.TheSet.Height / 2; } catch (Exception) { Zoom = 1; CenterPoint = new PointD(0, 0); } } }
0
19. Example
Project: ultraviolet
Source File: DesktopScreenDensityService.cs
Source File: DesktopScreenDensityService.cs
private Boolean InitFallback(UltravioletContext uv, IUltravioletDisplay display) { using (var graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero)) { this.densityX = graphics.DpiX; this.densityY = graphics.DpiY; this.densityScale = graphics.DpiX / 96f; this.densityBucket = GuessBucketFromDensityScale(densityScale); } return true; }
0
20. Example
Project: BismNormalizer
Source File: HighDpiUtils.cs
Source File: HighDpiUtils.cs
public static float GetDpiFactor() { float factor = 1.0F; try { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { factor = (float)graphics.DpiX / 96F; //96 is the default windows DPI if (factor > 1.3 && factor < 1.7) { HighDPIUtils.PrimaryFudgeFactor = 0.66f; HighDPIUtils.SecondaryFudgeFactor = 1.1f; } else if (factor >= 1.7) { if (!Settings.Default.OptionHighDpiLocal) { HighDPIUtils.PrimaryFudgeFactor = 0.72f; HighDPIUtils.SecondaryFudgeFactor = 1.6f; } else { HighDPIUtils.PrimaryFudgeFactor = 0.54f; HighDPIUtils.SecondaryFudgeFactor = 1.2f; } } } } catch (Exception) { // Swallow any exceptions related to system DPI and use the default } return factor; }
0
21. Example
Project: BismNormalizer
Source File: HighDpiUtils.cs
Source File: HighDpiUtils.cs
public static float GetDpiWindowMonitor() { float dpi = 0; try { using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { dpi = (float)graphics.DpiX; } } catch (Exception) { // Swallow any exceptions related to system DPI and use the default } return dpi; }
0
22. Example
Project: ContinuousTests
Source File: StatusBar.cs
Source File: StatusBar.cs
public void OnTestStarting( object sender, TestEventArgs e ) { string fullText = "Running : " + e.TestName.FullName; string shortText = "Running : " + e.TestName.Name; Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( fullText, Font ); if ( statusPanel.Width >= (int)sizeNeeded.Width ) { statusPanel.Text = fullText; statusPanel.ToolTipText = ""; } else { sizeNeeded = g.MeasureString( shortText, Font ); statusPanel.Text = statusPanel.Width >= (int)sizeNeeded.Width ? shortText : e.TestName.Name; statusPanel.ToolTipText = e.TestName.FullName; } }
0
23. Example
Project: ContinuousTests
Source File: StatusBar.cs
Source File: StatusBar.cs
public void OnTestStarting( object sender, TestEventArgs e ) { string fullText = "Running : " + e.TestName.FullName; string shortText = "Running : " + e.TestName.Name; Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( fullText, Font ); if ( statusPanel.Width >= (int)sizeNeeded.Width ) { statusPanel.Text = fullText; statusPanel.ToolTipText = ""; } else { sizeNeeded = g.MeasureString( shortText, Font ); statusPanel.Text = statusPanel.Width >= (int)sizeNeeded.Width ? shortText : e.TestName.Name; statusPanel.ToolTipText = e.TestName.FullName; } }
0
24. Example
Project: ContinuousTests
Source File: StatusBar.cs
Source File: StatusBar.cs
public void OnTestStarting( object sender, TestEventArgs e ) { string fullText = "Running : " + e.TestName.FullName; string shortText = "Running : " + e.TestName.Name; Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( fullText, Font ); if ( statusPanel.Width >= (int)sizeNeeded.Width ) { statusPanel.Text = fullText; statusPanel.ToolTipText = ""; } else { sizeNeeded = g.MeasureString( shortText, Font ); statusPanel.Text = statusPanel.Width >= (int)sizeNeeded.Width ? shortText : e.TestName.Name; statusPanel.ToolTipText = e.TestName.FullName; } }
0
25. Example
Project: dp2
Source File: PatronCardControl.cs
Source File: PatronCardControl.cs
public Graphics GetGraphics() { Control control = this.GetControl(); if (control == null) return null; return Graphics.FromHwnd(control.Handle); }
0
26. Example
Project: dp2
Source File: BinaryEditor.cs
Source File: BinaryEditor.cs
void InitialSizes(Font font) { // ??? ?????? this.m_nLineHeight = (int)(font.SizeInPoints + (font.SizeInPoints / 2)); // ?????????????? // ??????????? using (Graphics graphicsTemp = Graphics.FromHwnd(this.Handle)) { string strTextTemp = "MM"; SizeF size = graphicsTemp.MeasureString( strTextTemp, font); this.m_nCellWidth = (int)(size.Width + (size.Width / 2)); strTextTemp = "MMMMMMMM"; // 8 size = graphicsTemp.MeasureString( strTextTemp, font); this.m_nLineTitleWidth = (int)(size.Width + (size.Width / 8)); this.m_nCommentWidth = (int)(size.Width * 2 + (size.Width / 8)); } }
0
27. Example
Project: dp2
Source File: ClosedXmlUtil.cs
Source File: ClosedXmlUtil.cs
public static double GetAverageCharPixelWidth(Control control) { StringBuilder sb = new StringBuilder(); // Using the typical printable range for (int i = 32; i < 127; i++) { sb.Append((char)i); } string printableChars = sb.ToString(); // Choose your font Font stringFont = control.Font; // Now pass printableChars into MeasureString SizeF stringSize = new SizeF(); using (Graphics g = Graphics.FromHwnd(control.Handle)) { stringSize = g.MeasureString(printableChars, stringFont); } // Work out average width of printable characters return stringSize.Width / (double)printableChars.Length; }
0
28. Example
Project: dp2
Source File: Record.cs
Source File: Record.cs
internal void InitializeWidth() { using (Graphics g = Graphics.FromHwnd(this.marcEditor.Handle)) { string strTempName = "###"; // Font font = this.marcEditor.Font;//.DefaultTextFont; /* if (this.marcEditor.m_fixedSizeFont == null) this.marcEditor.m_fixedSizeFont = this.marcEditor.CreateFixedSizeFont(); * */ Font fixedfont = null; try { fixedfont = this.marcEditor.FixedSizeFont; // ??? Windows XP ????????? Courier New ??????????? } catch { fixedfont = this.marcEditor.Font; } Size size = MeasureSize(g, fixedfont, strTempName); this.NamePureWidth = size.Width + 1; this.NamePureHeight = size.Height; string strTempIndicator = "99"; size = MeasureSize(g, fixedfont, strTempIndicator); this.IndicatorPureWidth = size.Width + 1; this.IndicatorPureHeight = size.Height; } }
0
29. Example
Project: dp2
Source File: Text.cs
Source File: Text.cs
public override int GetHeight(int nWidth) { Item item = this.GetItem(); using (Graphics g = Graphics.FromHwnd(item.m_document.Handle)) { StringFormat sf = new StringFormat(); sf.Trimming = StringTrimming.None; SizeF size = g.MeasureString(Text + "\r\n", //?????????'\r\n'???????????????? GetFont(), nWidth, sf); int nTempHeight = (int)size.Height; //?????????????????? if (nTempHeight <= 0) nTempHeight = 20; return nTempHeight + this.TotalRestHeight; } }
0
30. Example
Project: arcobjects-sdk-community-samples
Source File: InputForm.cs
Source File: InputForm.cs
private static void SizeCaption(InputForm currForm, string caption) { // Work out how big the text will be. SizeF layoutSize = new SizeF (currForm.lblCaption.Width, SystemInformation.WorkingArea.Height); System.Drawing.Graphics grph = System.Drawing.Graphics.FromHwnd(currForm.Handle); SizeF stringSize = grph.MeasureString(caption, currForm.lblCaption.Font, layoutSize); // Resize the caption label and other controls appropriately. if ( ((int) stringSize.Height) > currForm.lblCaption.Height) { currForm.SuspendLayout(); currForm.lblCaption.Height = ((int) stringSize.Height) + 4; currForm.txtInput.Top = currForm.lblCaption.Bottom + 12; currForm.btnCancel.Top = currForm.txtInput.Bottom + 8; currForm.btnOK.Top = currForm.btnCancel.Top; currForm.Height = currForm.btnOK.Bottom + (30); currForm.ResumeLayout(true); } }
0
31. Example
Project: fomm
Source File: RememberSelectionMessageBox.cs
Source File: RememberSelectionMessageBox.cs
protected void Init(string p_strMessage, string p_strCaption, MessageBoxButtons p_mbbButtons, /n ..... /n //View Source file for more details /n }
0
32. Example
Project: gitter
Source File: TextBoxSpellChecker.cs
Source File: TextBoxSpellChecker.cs
private void OnSizeChanged(object sender, EventArgs e) { if(_textBoxGraphics != null) { _textBoxGraphics.Dispose(); } _textBoxGraphics = Graphics.FromHwnd(_textBox.Handle); }
0
33. Example
Project: the_building_coder_samples
Source File: CmdNewTextNote.cs
Source File: CmdNewTextNote.cs
static double GetStringWidth( string text, Font font ) { double textWidth = 0.0; using( Graphics g = Graphics.FromHwnd( IntPtr.Zero ) ) { textWidth = g.MeasureString( text, font ).Width; } return textWidth; }
0
34. Example
Project: TDMaker
Source File: GraphPane.cs
Source File: GraphPane.cs
public void AxisChange() { using ( Graphics g = Graphics.FromHwnd( IntPtr.Zero ) ) AxisChange( g ); }
0
35. Example
Project: TDMaker
Source File: MasterPane.cs
Source File: MasterPane.cs
public void AxisChange() { using ( Graphics g = Graphics.FromHwnd( IntPtr.Zero ) ) AxisChange( g ); }
0
36. Example
Project: mRemoteNG
Source File: frmTaskDialog.cs
Source File: frmTaskDialog.cs
private SizeF GetMainInstructionTextSizeF() { var mzSize = new SizeF(pnlMainInstruction.Width - MAIN_INSTRUCTION_LEFT_MARGIN - MAIN_INSTRUCTION_RIGHT_MARGIN, 5000.0F); var g = Graphics.FromHwnd(Handle); var textSize = g.MeasureString(_mainInstruction, _mainInstructionFont, mzSize); _mainInstructionHeight = (int)textSize.Height; return textSize; }
0
37. Example
Project: PowerPointLabs
Source File: MouseUtil.cs
Source File: MouseUtil.cs
private static float GetScalingFactor() { var g = Graphics.FromHwnd(IntPtr.Zero); var desktop = g.GetHdc(); var LogicalScreenHeight = NativeUtil.GetDeviceCaps(desktop, (int)NativeUtil.DeviceCap.VERTRES); var PhysicalScreenHeight = NativeUtil.GetDeviceCaps(desktop, (int)NativeUtil.DeviceCap.DESKTOPVERTRES); var ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight; return ScreenScalingFactor; // 1.25 = 125% }
0
38. Example
Project: SystemEx
Source File: EmulateExpInfoButton.cs
Source File: EmulateExpInfoButton.cs
private void EmulateExpInfoButton_Enter ( object sender, EventArgs e ) { // Focus rectangle. // http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint.drawfocusrectangle(VS.71).aspx ControlPaint.DrawFocusRectangle ( Graphics.FromHwnd ( this.label.Handle ), this.label.ClientRectangle ); }
0
39. Example
Project: SystemEx
Source File: EmulateExpInfoButton.cs
Source File: EmulateExpInfoButton.cs
private void EmulateExpInfoButton_Leave ( object sender, EventArgs e ) { // Lost focus. // Correct way to erase a border? ControlPaint.DrawBorder ( Graphics.FromHwnd ( this.label.Handle ), this.label.ClientRectangle, this.label.BackColor, ButtonBorderStyle.Solid ); }
0
40. Example
Project: Touchmote
Source File: DrawingProviderHandler.cs
Source File: DrawingProviderHandler.cs
public void connect() { graphic = Graphics.FromHwnd(IntPtr.Zero); OnConnect(); }
0
41. Example
Project: TorrentParser
Source File: TorrentExtension.cs
Source File: TorrentExtension.cs
protected override ContextMenuStrip CreateMenu() { var menu = new ContextMenuStrip(); var graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero); var dpi = (int)graphics.DpiX; var itemParse = new ToolStripMenuItem { Name = "tsmP", Text = InfoText, Image = dpi < 192 ? Properties.Resources.magnet_16 : Properties.Resources.magnet_32 }; var itemParseL = new ToolStripMenuItem { Name = "tsmPL", Text = LInfoText, Image = dpi < 192 ? Properties.Resources.magnet_16 : Properties.Resources.magnet_32 }; itemParse.Click += ItemParse_Click; itemParseL.Click += ItemParse_Click; menu.Items.Add(itemParse); menu.Items.Add(itemParseL); return menu; }
0
42. Example
Project: Vocaluxe
Source File: CDrawWinForm.cs
Source File: CDrawWinForm.cs
private void _OnResizeEvent(object sender, EventArgs e) { Graphics frontBuffer = Graphics.FromHwnd(Handle); frontBuffer.Clear(Color.Black); }
0
43. Example
Project: xenadmin
Source File: AutoHeightLabel.cs
Source File: AutoHeightLabel.cs
public override Size GetPreferredSize(Size proposedSize) { using (var g = Graphics.FromHwnd(Handle)) { var textSize = TextRenderer.MeasureText(g, Text, Font, new Size(proposedSize.Width - Padding.Left - Padding.Right, _maxHeight), _flags); return new Size(Width, textSize.Height + Padding.Top + Padding.Bottom); } }
0
44. Example
Project: Zydeo
Source File: ZenControlBase.cs
Source File: ZenControlBase.cs
protected SizeF MeasureText(string text, Font font, StringFormat fmt) { using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) { return g.MeasureString(text, font, int.MaxValue, fmt); } }
0
45. Example
Project: AutoTest.Net
Source File: StatusBar.cs
Source File: StatusBar.cs
public void OnTestStarting( object sender, TestEventArgs e ) { string fullText = "Running : " + e.TestName.FullName; string shortText = "Running : " + e.TestName.Name; Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( fullText, Font ); if ( statusPanel.Width >= (int)sizeNeeded.Width ) { statusPanel.Text = fullText; statusPanel.ToolTipText = ""; } else { sizeNeeded = g.MeasureString( shortText, Font ); statusPanel.Text = statusPanel.Width >= (int)sizeNeeded.Width ? shortText : e.TestName.Name; statusPanel.ToolTipText = e.TestName.FullName; } }
0
46. Example
Project: AutoTest.Net
Source File: StatusBar.cs
Source File: StatusBar.cs
public void OnTestStarting( object sender, TestEventArgs e ) { string fullText = "Running : " + e.TestName.FullName; string shortText = "Running : " + e.TestName.Name; Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( fullText, Font ); if ( statusPanel.Width >= (int)sizeNeeded.Width ) { statusPanel.Text = fullText; statusPanel.ToolTipText = ""; } else { sizeNeeded = g.MeasureString( shortText, Font ); statusPanel.Text = statusPanel.Width >= (int)sizeNeeded.Width ? shortText : e.TestName.Name; statusPanel.ToolTipText = e.TestName.FullName; } }
0
47. Example
Project: AutoTest.Net
Source File: StatusBar.cs
Source File: StatusBar.cs
public void OnTestStarting( object sender, TestEventArgs e ) { string fullText = "Running : " + e.TestName.FullName; string shortText = "Running : " + e.TestName.Name; Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( fullText, Font ); if ( statusPanel.Width >= (int)sizeNeeded.Width ) { statusPanel.Text = fullText; statusPanel.ToolTipText = ""; } else { sizeNeeded = g.MeasureString( shortText, Font ); statusPanel.Text = statusPanel.Width >= (int)sizeNeeded.Width ? shortText : e.TestName.Name; statusPanel.ToolTipText = e.TestName.FullName; } }
0
48. Example
Project: Krypton
Source File: VisualForm.cs
Source File: VisualForm.cs
protected void InvalidateNonClient(Rectangle invalidRect, bool excludeClientArea) { if (!IsDisposed && !Disposing && IsHandleCreated) { if (invalidRect.IsEmpty) { Padding realWindowBorders = RealWindowBorders; Rectangle realWindowRectangle = RealWindowRectangle; invalidRect = new Rectangle(-realWindowBorders.Left, -realWindowBorders.Top, realWindowRectangle.Width, realWindowRectangle.Height); } using (Region invalidRegion = new Region(invalidRect)) { if (excludeClientArea) invalidRegion.Exclude(ClientRectangle); using (Graphics g = Graphics.FromHwnd(Handle)) { IntPtr hRgn = invalidRegion.GetHrgn(g); PI.RedrawWindow(Handle, IntPtr.Zero, hRgn, (uint)(PI.RDW_FRAME | PI.RDW_UPDATENOW | PI.RDW_INVALIDATE)); PI.DeleteObject(hRgn); } } } }
0
49. Example
Project: ContinuousTests
Source File: ExpandingLabel.cs
Source File: ExpandingLabel.cs
protected override void OnMouseHover(System.EventArgs e) { Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( Text, Font ); bool expansionNeeded = Width < (int)sizeNeeded.Width || Height < (int)sizeNeeded.Height; if ( expansionNeeded ) Expand(); }
0
50. Example
Project: ContinuousTests
Source File: ExpandingTextBox.cs
Source File: ExpandingTextBox.cs
private void OnMouseHover( object sender, System.EventArgs e ) { if ( autoExpand ) { Graphics g = Graphics.FromHwnd( Handle ); SizeF sizeNeeded = g.MeasureString( Text, Font ); bool expansionNeeded = Width < (int)sizeNeeded.Width || Height < (int)sizeNeeded.Height; if ( expansionNeeded ) Expand(); } }