ColorEdit report errors

SyntaxEditor for WPF Forum

Posted 2 years ago by SPF - Appeon
Version: 22.1.2
Platform: .NET 6.0
Environment: Windows 11 (64-bit)
Avatar

We use the "ColorEdit" control to bind the "Foreground" attribute of "HighlightingStyle" in the form of MVVM. When the transparency of the color is zero, the code reports an error.

System.ArgumentNullException
  HResult=0x80004003
  Message=Value cannot be null. Arg_ParamName_Name
  Source=ActiproSoftware.Shared.Wpf
  StackTrace:
   at ActiproSoftware.Windows.Controls.Rendering.TextLayout.aeX(String  , Single  , Brush  , FontWeight  , FontStyle  )
   at ActiproSoftware.Windows.Controls.Rendering.TextLayout..ctor(CanvasDrawCache cache, ITextProvider textProvider, Single maxWidth, String fontFamilyName, Single fontSize, Brush foreground, FontWeight fontWeight, FontStyle fontStyle, IEnumerable`1 spacers)
   at ActiproSoftware.Windows.Controls.Rendering.CanvasControl.CreateTextLayout(ITextProvider textProvider, Single maxWidth, String fontFamilyName, Single fontSize, Brush foreground, FontWeight fontWeight, FontStyle fontStyle, IEnumerable`1 spacers)
   at ActiproSoftware.Windows.Controls.Rendering.CanvasControl.CreateTextLayout(ITextProvider textProvider, Single maxWidth, String fontFamilyName, Single fontSize, Color foreground, FontWeight fontWeight, FontStyle fontStyle, IEnumerable`1 spacers)
   at ActiproSoftware.Windows.Controls.Rendering.CanvasControl.CreateTextLayout(String text, Single maxWidth, String fontFamilyName, Single fontSize, Color foreground)
   at ActiproSoftware.Windows.Controls.SyntaxEditor.TextStylePreview.OnDraw(CanvasDrawEventArgs e)
   at ActiproSoftware.Windows.Controls.SyntaxEditor.TextStylePreview.qcM(Object  , CanvasDrawEventArgs  )
   at ActiproSoftware.Windows.Controls.Rendering.CanvasControl.Xef(DrawingContext  )
   at ActiproSoftware.Windows.Controls.Rendering.CanvasControl.OnRender(DrawingContext drawingContext)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.StackPanel.StackArrangeHelper(IStackMeasure arrangeElement, IStackMeasureScrollData scrollData, Size arrangeSize)
   at System.Windows.Controls.StackPanel.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.ScrollContentPresenter.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
   at System.Windows.Controls.ScrollViewer.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Controls.Decorator.ArrangeOverride(Size arrangeSize)
   at System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.Window.ArrangeOverride(Size arrangeBounds)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.UIElement.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
   at System.Windows.Window.SetRootVisual()
   at System.Windows.Window.SetRootVisualAndUpdateSTC()
   at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.CreateSourceWindowDuringShow()
   at System.Windows.Window.SafeCreateWindowDuringShow()
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()
   at ActiproSoftware.Windows.Controls.UserPromptWindow.ShowDialog(UserPromptControl userPromptControl, String title, Window owner, Action`1 initializeAction)
   at ActiproSoftware.Windows.Controls.UserPromptWindow.ShowDialog(UserPromptControl userPromptControl, String title, Window owner)
   at ActiproSoftware.Windows.Controls.UserPromptWindow.ShowDialog(UserPromptControl userPromptControl, String title)
   at SnapDevelop.Controls.SDMessageBox.ShowException(Exception ex, String header) in C:\SVN\dotnet\branches\SnapDevelop\2022\R1-GA\Frameworks\SnapDevelop.Controls\Controls\SDMessageBox.cs:line 292
   at SnapDevelop.Controls.SDMessageBox.ShowException(Exception ex) in C:\SVN\dotnet\branches\SnapDevelop\2022\R1-GA\Frameworks\SnapDevelop.Controls\Controls\SDMessageBox.cs:line 229
   at SnapDevelop.Hosting.WpfApplication.OnException(Exception ex) in C:\SVN\dotnet\branches\SnapDevelop\2022\R1-GA\Frameworks\SnapDevelop.Hosting\WpfApplication.cs:line 76
   at SnapDevelop.Hosting.WpfApplication.OnDispatcherUnhandledException(Object sender, DispatcherUnhandledExceptionEventArgs e) in C:\SVN\dotnet\branches\SnapDevelop\2022\R1-GA\Frameworks\SnapDevelop.Hosting\WpfApplication.cs:line 47
   at System.Windows.Threading.Dispatcher.CatchException(Exception e)
   at System.Windows.Threading.Dispatcher.CatchExceptionStatic(Object source, Exception e)
   at System.Windows.Threading.ExceptionWrapper.CatchException(Object source, Exception e, Delegate catchHandler)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

  This exception was originally thrown at this call stack:
    ActiproSoftware.Windows.Controls.Rendering.TextLayout.aeX(string, float, System.Windows.Media.Brush, System.Windows.FontWeight, System.Windows.FontStyle)
    ActiproSoftware.Windows.Controls.Rendering.TextLayout.TextLayout(ActiproSoftware.Windows.Controls.Rendering.CanvasDrawCache, ActiproSoftware.Windows.Controls.Rendering.ITextProvider, float, string, float, System.Windows.Media.Brush, System.Windows.FontWeight, System.Windows.FontStyle, System.Collections.Generic.IEnumerable<ActiproSoftware.Windows.Controls.Rendering.ITextSpacer>)
    ActiproSoftware.Windows.Controls.Rendering.CanvasControl.CreateTextLayout(ActiproSoftware.Windows.Controls.Rendering.ITextProvider, float, string, float, System.Windows.Media.Brush, System.Windows.FontWeight, System.Windows.FontStyle, System.Collections.Generic.IEnumerable<ActiproSoftware.Windows.Controls.Rendering.ITextSpacer>)
    ActiproSoftware.Windows.Controls.Rendering.CanvasControl.CreateTextLayout(ActiproSoftware.Windows.Controls.Rendering.ITextProvider, float, string, float, System.Windows.Media.Color, System.Windows.FontWeight, System.Windows.FontStyle, System.Collections.Generic.IEnumerable<ActiproSoftware.Windows.Controls.Rendering.ITextSpacer>)
    ActiproSoftware.Windows.Controls.Rendering.CanvasControl.CreateTextLayout(string, float, string, float, System.Windows.Media.Color)
    ActiproSoftware.Windows.Controls.SyntaxEditor.TextStylePreview.OnDraw(ActiproSoftware.Windows.Controls.Rendering.CanvasDrawEventArgs)
    ActiproSoftware.Windows.Controls.SyntaxEditor.TextStylePreview.qcM(object, ActiproSoftware.Windows.Controls.Rendering.CanvasDrawEventArgs)
    ActiproSoftware.Windows.Controls.Rendering.CanvasControl.Xef(System.Windows.Media.DrawingContext)
    ActiproSoftware.Windows.Controls.Rendering.CanvasControl.OnRender(System.Windows.Media.DrawingContext)
    System.Windows.UIElement.Arrange(System.Windows.Rect)
    ...
    [Call Stack Truncated]

Comments (3)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Can you please let us know how to duplicate this in one of our samples?  We tried changing values in the Highlighting Style Viewer to make transparent colors and don't see any problems there in our testing.

Also, we already have checks in the code to ensure the text being rendered in TextStylePreview.OnDraw is not null before ever calling CanvasControl.CreateTextLayout.


Actipro Software Support

Posted 2 years ago by SPF - Appeon
Avatar

The demo has been emailed to you.

Answer - Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Thank you, we were able to duplicate the issue and have a fix in for the next maintenace release.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.