Glide examples

I had seen a web link a couple of days ago with example xml and code for each glide control.
I lost it now. Can someone point me to it?.

1:
Is there an example for touch on a Image.
So I can get the co-ordinate of where it was touched?

2:
Is there a keyboard in glide?
So I can use for the textbox entry

Thanks

Use the following to attach the keyboard to an TextBox so that when the user clicks on it, the keyboard is automatically opened.


myText = (TextBox)CurrentWindow.GetChildByName("myText");
myText.TapEvent += new OnTap(Glide.OpenKeyboard);

You can manually create the XML but is easier with the Glide online editor.

https://www.ghielectronics.com/glide

Nice I can have the keyboard input now.

But I have a
"+ $exception {System.NullReferenceException} System.Exception {System.NullReferenceException}

when I move to another window by doing something like
Glide.MainWindow = WinSetup;
But this happens only if I have a Textbox control.
I am not sure if I have to do something to gracefully exit the window


Hope some one can answer my other questions

How are you creating the Window? Can you show the code that creates the WinSetup window.

Null Reference happens when you try to attach an XML control in your code and the name is miss-matched such as this one.


myText = (TextBox)CurrentWindow.GetChildByName("MyText");

In my example, the XML file, the control is called mytText bit I used MyText and the name is case sensitive.

I would single step into the function that creates the Window and check each control is not null as you called GetChildByName. This is the best way to find this type of error.

I use the designer.
The text box comes up ok and I am able to enter a value in it.
The error comes only when I am done and switch to a different window.


#### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (3) ####
#### Message:
#### Microsoft.SPOT.Font::ComputeExtent [IP: 0000] ####
#### Microsoft.SPOT.Font::ComputeExtent [IP: 000c] ####
#### GHI.Glide.FontManager::GetSize [IP: 000d] ####
#### GHI.Glide.UI.TextBlock::Render [IP: 0066] ####
#### GHI.Glide.Display.DisplayObjectContainer::Render [IP: 001a] ####
#### GHI.Glide.Display.Window::Invalidate [IP: 0004] ####
#### GHI.Glide.Glide::set_MainWindow [IP: 0020] ####
#### TouchLogger.MicGlide::WinSetup_OnExit [IP: 000e] ####
#### GHI.Glide.Display.DisplayObject::TriggerTapEvent [IP: 000e] ####
#### GHI.Glide.Display.DisplayObjectContainer::OnTouchUp [IP: 0035] ####
#### GHI.Glide.Display.Window::TouchUpEvent [IP: 0020] ####
#### GHI.Glide.TouchEventHandler::Invoke [IP: 0000] ####
#### GHI.Glide.GlideTouch::RaiseTouchUpEvent [IP: 0008] ####
#### GHI.Glide.GlideTouch+TouchConnection::OnEvent [IP: 0098] ####
#### Microsoft.SPOT.EventSink::ProcessEvent [IP: 0023] ####
#### Microsoft.SPOT.EventSink::EventDispatchCallback [IP: 0014] ####
A first chance exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.Graphics.dll
An unhandled exception of type ‘System.NullReferenceException’ occurred in Microsoft.SPOT.Graphics.dll

As Andre says, learn about debugging and setting breakpoints in your. Click on the left margin of the editor window and a red dot will appear. When you run this in debug mode, VS will stop on this line and you can hover over variables to read their values.

If you have never done this type of debugging before, do a search for it and find a few YouTube video’s. It will be your life saver in tracking down bugs like this.

It is hard to debug it. That is why I cannot find it
It happens in the Glide library like below

The Init() is run once at powerup



            Glide.MainWindow = WinGraph;  //Exception happens here

        public void Init()
        {
            GlideTouch.Initialize();

            WinSetup = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.WinSetup));
            WinGraph = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.WinGraph));

            //---------------------------------------------------------------------
            //Setup
            Button ButtonExit_WinSetup = (Button)WinSetup.GetChildByName("Exit");
            ButtonExit_WinSetup.TapEvent += WinSetup_OnExit;

            //If I remove these 2 line..there is no issue. I am wondering
            // if Glide.OpenKeyboard unloads some fonts when it closes.
            TextBox NumChnls = (TextBox)WinSetup.GetChildByName("NumChnls");
            NumChnls.TapEvent += Glide.OpenKeyboard;

            //Graph
            Button ButtonExit_WinGraph = (Button)WinGraph.GetChildByName("Exit");
            ButtonExit_WinGraph.TapEvent += WinGraph_OnExit;

            TextBlock Status1_WinGraph = (TextBlock)WinGraph.GetChildByName("Status1");
}



Andre’s idea is a good one as you can then step through the Glide code when you setup the window. I did this recently to find a fault with the datagrid.

Can you show the XML for your WinGraph window? I suspect there is an error in that.

How to I do this.

I have glide also as a project in my solution.

I have Visual studio 13 Express. Do I need Visual studio 13 Pro to debug app + DLL at the same time

Thanks Ande and Dave
My bad
I am using 2012


Error 1 The type or namespace name ‘Glide’ does not exist in the namespace ‘GHI’ (are you missing an assembly reference?) C:\RemoteDrive\Dropbox\Mic-Share\Software\FirmwareSourceCode\Mainboard\G120-1\TouchLogger-1\TouchLogger\MicGlide.cs 1 11 Logger

I have removed the current Gide DLL and have the Glide source as another project in the same solution.

I am not sure how to add this as a Project reference

Ok…found the issue

The textbox will raise an exception and terminate invalidate() in the middle of the redraw
if you assign a null value to it.
I was doing it to clear the textbox. Now I am assigning empty string “”

What event can I register to get

get the co-ordinate of where it was touched? on a bitmap

I have an issue with the Keyboard. Many times the done key does not sense and I have to press all over the place to sense it.

Does any body have the same issue?
All other keys seems to work ok.

Yes. Multiple times.

Then it feels like it works reasonable for some time and then it gets into this state.
Some times I just power cycle and it is ok.

I am wondering is it because the done button is on the edge

I found this was a big issue with the G120 based Cobra 2 and the TE35 display and I gave up on it and working on a new version with my 5" and cap touch. The standard resistive with the built in ADC for touch is just not reliable enough for me.

Since using the 5" I have had no issues with getting reliable 100% touch.

Thanks Dave

Now I am really worried.
I was thinking to pull this into a product and even 3D printed the front panel.
Now sure if there are 4.3" cap sense touch screens to replace the current one.

Can you send me a link to the 5 inch cap touch display you are using

I put it up on the turnkey website so it’s free for you to get them made.

https://www.turnkeyassembly.com/project/21

The board is designed to work with this LCD.

I’ll need to put the drivers and LCD setting on Codeshare and will get that done in the next few days.

I am using a t43 display with G120

I was debugging this further and see that the touch point are 3% less in the x axis and 10% less in the y axis.
So after calibration I did this adjustment in Glide code before the points are used. Now it looks reasonable. But not sure if it is the right thing to do.

–GlideTouch.cs-

Can GHI look into why that is the case. I could not debug this further because the lowest level calibration routines are in binary


public bool OnEvent(BaseEvent baseEvent)
            {
....
                    else if (e.EventMessage == 2)
                    {
                        if (!MicLCDCal)
                        {
                            int eX = e.Touches[0].X;
                            int eY = e.Touches[0].Y;

                            e.Touches[0].X = (eX * 103) / 100;
                            e.Touches[0].Y = (eY * 110) / 100;
                        }
                        wasMoveEvent = false;
                        RaiseTouchUpEvent(this, new TouchEventArgs(e.Touches));
                    }
                }
....

                return true;
            }
        }

Is this error repeatable after each calibration?

Yes…