Main Site Documentation

Using Glide and FEZ Spider together


#1

Using Glide and FEZ Spider together is (almost) straightforward.
Compose the hardware in the Program.Gadgeteer window (include the Display).
It should be noted that some names collide (Button, Window) so you need to play tricks like fully qualifying some.
Here is an example:

 
        static GHIElectronics.NETMF.Glide.Display.Window window;
      void ProgramStarted()
        {
            // Create the Window XML string.
            string xml;
            xml = "<Glide Version=\"" + Glide.Version + "\">";
            xml += "<Window Name=\"window\" Width=\"320\" Height=\"240\" BackColor=\"FFFFFF\">";
            xml += "<TextBox Name=\"textBox\" X=\"85\" Y=\"104\" Width=\"150\" Height=\"32\" Alpha=\"255\" Text=\"Touch me\"           TextAlign=\"Left\" Font=\"4\" FontColor=\"000000\"/>";
            xml += "</Window>"; 
            xml += "</Glide>";
            // Resize any loaded Window to the LCD's size.
            Glide.FitToScreen = true;
            // Load the Window XML string.
            window = GlideLoader.LoadWindow(xml); 
            // Assign the Window to MainWindow; rendering it to the LCD.
            Glide.MainWindow = window;
            GHIElectronics.NETMF.Glide.UI.TextBox textBox = (GHIElectronics.NETMF.Glide.UI.TextBox)window.GetChildByName("textBox");
            textBox.TapEvent += new OnTap(textBox_TapEvent);
       }
       void textBox_TapEvent(object sender)
        {
            GHIElectronics.NETMF.Glide.UI.TextBox tb = (GHIElectronics.NETMF.Glide.UI.TextBox)sender;
            tb.Alpha = 0;
        }

However, touching the display will generate the following exception:
A first chance exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.TinyCore.dll
An unhandled exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.TinyCore.dll

Uncaught exception
#### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (3) ####
#### Message:
#### Microsoft.SPOT.Application::OnEvent [IP: 0098] ####
#### Microsoft.SPOT.EventSink::ProcessEvent [IP: 0023] ####
#### Microsoft.SPOT.EventSink::EventDispatchCallback [IP: 0014] ####

It looks like the touch events are not wired properly.


#2

Hi,

Can you try to add the following line to the ProgramStarted() method:


var wpfWindow = display.WPFWindow;

This is a bit counter-intuitive, but getting the WPFWindow property actually causes some intialization code to execute in the GadgeteerCore libraries, which enables touch events in amongst other things. We did not take into consideration using the touch events without a WPF window (which is the case if you are using Glide).

Please let us know if this fixes the problem for you, and we can address it in a future release of GadgeteerCore.

Nic


#3

Is this “The” Nicolas Villar from MS Research?

Regardless, welcome to the forum!


#4

You forgot to call

GlideTouch.Initialize();

.
Should work afterwards.


#5

Nicolas suggestion does not work. It seems that Glide does not use WPF so display.WPFWindow will make the screen go blank upon return of ProgramStarted();

GlideTouch.Initialize(); works fine.

Thank you guys for the suggestions!


#6

Hi,

I’m trying to use Glide but I get a deployment error, “An error has occurred: please check your hardware.”. Other applications are deploying just fine.

I tried the code from this thread but without any luck. Could someone send me a working project so I could have a look what I’m doing wrong? You can send it to steven[dot]hillaert[at]gmail[dot]com

Thanks,
Steven


#7

Found the problem, deploy only fails when I do “run” (F5), running debug from the project works.

Steven