Operator '==' cannot be applied to operands of type 'OxyPlot.OxyColor' and 'null' (MonoTouchDemo)

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

Devin19 wrote at 2013-10-31 17:19:

The MonoTouch Demo won't build because of the above error. It seems that OxyColor isn't NULLable, but there are statements where it's compared to NULL, which crashes it. When I change this to oxycolor.Equals(null) it build, but crashes (obviously) when I'm trying to draw a graph.

I would expect since its not NULLable, there would be a value like 'undefined' which can be chosen instead, but this doesn't seem to be the case.

How can this be solved?

objo wrote at 2013-10-31 18:21:

OxyColor was recently changed to a value type. Try to use OxyColors.Undefined where no color should be applied and OxyColors.Automatic where OxyPlot should suggest or a default color should be used. Let me know where to correct the MonoTouch code, I cannot compile this myself.

Devin19 wrote at 2013-11-01 11:17:

Hi I've fixed it, I tried to upload the changes thru the fork feature here on codeplex, but I couldn't figure out how to update it through SVN.
Anyways, replacing OxyPlot.MonoTouch\MonoTouchRenderContext.cs by this should fix it.

I replaced the
foo != null
by
!foo.Equals(OxyColors.Undefined)
etc.

I've ran the demo on an iOS simulator, and didn't run into any bugs,
although the resolution seems a kinda low compared to the MonoForAndroid version.

objo wrote at 2013-11-01 19:59:

Thanks, I submited a fix with some modifications (using the OxyColor.IsVisible method), let me know if I broke something...

Devin19 wrote at 2013-11-02 09:34:

It's nearly correct, you just forgot to add the
using System;
I forgot to mention that I changed it, it's needed for the Math.PI at line 183.

For as far as I've tested it nothing else seems to be wrong, I'll let you know if I find something.

Edit:
  • The Microsoft.CSharp Reference in ExampleLibraryMT.csproj should be removed, it gives an error, but the project runs fine without the reference.
  • There is no 'splashscreen' for iPhone 5 resolution included.