Question

I'm having some trouble using ILNumerics in LinqPad. I have the following code in LinqPad:

void Main()
{
    var scene = new ILScene {
        new ILPlotCube(twoDMode: false) {
            new ILSurface(ILSpecialData.sincf(40, 60, 2.5f)) {
                Wireframe = { Color = Color.FromArgb(50, Color.LightGray) },
                Colormap = Colormaps.Jet
            }
        }
    };

    scene.First<ILPlotCube>().Rotation = Matrix4.Rotation(new Vector3(1f, 0.23f, 1f), 0.7f);
    scene.Camera.Add(new ILSphere());

    var panel = new ILPanel { Scene = scene };

    PanelManager.DisplayControl(panel);
}

This code results in a big blue circle (with the text "ILNumerics ILPanel (OpenGL)" in the center) in the "custom" linqpad tab. The "Results" tab in linqpad contains the following text:

Determining Design Mode...
 Entry Assembly: (null)
 CurrentTypeAssembly: ILNumerics32, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null
 Loaded Assemblies:

Design Mode: True

Questions:

  1. Is possible render this as a WPF element instead of a WinForms control? (I guess this will render the plot successfully)
  2. Alternatively; is it possible to "trick" the ILPanel to think it isn't being rendered in design mode?
Was it helpful?

Solution

1) ILNumerics targets Winforms only. But you may try to use a WPF WindowsFormsHost container? I don't have any experience with it and do not expect an improvement for your situation though.

2) The way ILNumerics is checking DesignMode right now: if the executing assembly (ILNumerics.dll) is not in the list of references of the entry assembly (LinqPad), DesignMode is considered. Therefore, I can see 2 "tricks":

  • Make LinqPad depend on ILNumerics. Probably not the best solution though.
  • Patch ILNumerics: Alter the helper method refered to by Joe Albahari to return false instead.

The second "trick" may could lead us to a future solution. I don't know, if the "normal" DesignMode property does work in conjunction with LinqPad either? Maybe we could combine the existing method with a settings switch for all uncommon cases.

OTHER TIPS

Yes, you can render WPF controls in LINQPad - either by using PanelManager.DisplayWpfElement (or just by dumping it).

I don't think it will help you though, because ILNumerics uses Windows Forms only. It doesn't reference any of the WPF libraries.

I don't know whether it's possible to trick ILNumerics into thinking it's not in design mode. Take a look in Reflector at ILNumerics.Drawing.ILHelper.IsDesignMode. It's doing something dodgy with referenced assemblies. I don't know why they don't just check the control's DesignMode property - that's the normal way of doing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top