Code: Select all
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
Graphics graphics=e.Graphics;
graphics.SmoothingMode=SmoothingMode.HighQuality;
Rectangle rectangleOnControl;//the rectangle of the entire area under consideration. We cycle through subsections of the control.
Rectangle rectangleClip;//frequently smaller than e.ClipRectangle.
Rectangle rectangleSource;//source within the bitmap we are pulling from
float widthProvs;
if(_showProvBars){
widthProvs=_widthProv*_listProvsVisible.Count;
}
else{
widthProvs=0;
}
//main area
if(_bitmapMain!=null){
rectangleOnControl=new Rectangle(Round(_widthTime+widthProvs),Round(_heightProvOpHeaders),_widthMainVisible,_heightMainVisible);
if(rectangleOnControl.IntersectsWith(e.ClipRectangle)){
//We don't want to redraw the entire image. If we are dragging a small appt across this, we only want to redraw a small rect.
rectangleClip=Rectangle.Intersect(rectangleOnControl,e.ClipRectangle);
rectangleSource=new Rectangle(rectangleClip.X-Round(_widthTime+widthProvs)+hScrollBar1.Value,
rectangleClip.Y-Round(_heightProvOpHeaders)+vScrollBar1.Value,
rectangleClip.Width,rectangleClip.Height);
graphics.DrawImage(_bitmapMain,rectangleClip,rectangleSource,GraphicsUnit.Pixel); <-------------------------------------
}
}
Here is the exception:
Code: Select all
System.OutOfMemoryException
HResult=0x8007000E
Message=Out of memory.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
at OpenDental.UI.ControlApptPanel.OnPaint(PaintEventArgs e) in C:\Users\wjs\Desktop\ODVersions\EASyMT_23.1\opendental23.1\OpenDental\UI\Appt\ControlApptPanel.cs:line 1304
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
This exception was originally thrown at this call stack:
[External Code]
OpenDental.UI.ControlApptPanel.OnPaint(System.Windows.Forms.PaintEventArgs) in ControlApptPanel.cs
[External Code]
Sometimes if I clean the solution or reboot it'll go away for awhile. I've tried in VS2019 and 2022.
Any idea why? it's happening in both the latest 23.1.x and 23.2.x builds. I'm on a largish display (34" LG) - my resolution is 3440 x 1440 if that matters.
Here is the 'Parameter not valid' exception:
Code: Select all
System.ArgumentException
HResult=0x80070057
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at OpenDental.UI.ControlApptPanel.SetBitmapMain(Graphics gPrinting) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\UI\Appt\ControlApptPanel.cs:line 2327
at OpenDental.UI.ControlApptPanel.RedrawAsNeeded() in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\UI\Appt\ControlApptPanel.cs:line 1839
at OpenDental.UI.ControlApptPanel.set_IsWeeklyView(Boolean value) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\UI\Appt\ControlApptPanel.cs:line 593
at OpenDental.ControlAppt.SetWeeklyView(Boolean isWeeklyView, Boolean skipModuleSelection) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\ControlAppt.cs:line 4965
at OpenDental.ControlAppt.InitializeOnStartup() in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\ControlAppt.cs:line 2859
at OpenDental.FormOpenDental.SetModuleSelected(Boolean menuBarClicked) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\FormOpenDental.cs:line 4048
at OpenDental.FormOpenDental.SetModuleSelected() in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\FormOpenDental.cs:line 4041
at OpenDental.FormOpenDental.ProcessCommandLine() in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\FormOpenDental.cs:line 1193
at OpenDental.FormOpenDental.FormOpenDentalShown() in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\FormOpenDental.cs:line 813
at OpenDental.FormOpenDental.FormOpenDental_Shown(Object sender, EventArgs e) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\FormOpenDental.cs:line 385
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnShown(EventArgs e)
at System.Windows.Forms.Form.CallShownEvent()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 980
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 927
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 916
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at OpenDental.FormODBase.WndProc(Message& m) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\UI\BordersDpi\FormODBase.cs:line 1609
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at OpenDental.ProgramEntry.Main(String[] args) in C:\Users\wjs\Desktop\ODVersions\EASy_23.2\OpenDental23.2\OpenDental\Main Modules\ProgramEntry.cs:line 143