[2nd release]SenseSlider .NET CF Control 0.2

Search This thread

LunaticShade

Member
Nov 7, 2007
19
0
Because the SenseSDK which is available at xda lacks a control for the HTC Slider I tried to create my own.

I finally fixed some bugs and changed a bit of the behavior and here is the first release version of my SenseSlider control.

The 2nd release is ready and stable. See Changelog for further info.

Features:
  • mimics HTC Slider
  • fully functional .net Control
  • does not depend on images for the bar background/slider thumb (drawn at runtime) and therefore allows different color-schemes
  • events for SelectedIndexChanged, StartedSliding, StoppedSliding, OnSliding (Gives thes index of the hovered icon)
  • supports vibration (aka haptic feedback)
  • includes a semi-transparent panel for overlay when sliding
  • does not depend on other control collections (SenseSDK only used for demo application; can be used with any other collection) (does not apply for new version, uses SmartDeviceFrameWork)

changes in the 2nd release:
  • uses the IImaging-Implementation of the SmartDevice-Framework and is now stable and more flexible (load the IImages with SDF in any way and add them to the slider)
  • supports an imagefile as slider thumb (see attached screenshot)
  • great speed improvement (fixed a bug which slowed drawing down)
  • made the source code of the demo application a lot more readable and understandable (or at least I hope so ;) )

I uploaded a demo application to show some of the control's features. The source code for the demo is also available.
To use the Slider in your own applications just add the SenseSlider.dll and instantiate LunaticShade.SenseSlider (see the source of the demo application for details). (The new Version needs also the OpenNETCF Assemblies enclosed in the package or an installed version of the SmartDeviceFramework on the target device)
At this time the control cannot be drawn at designtime (due to heavy P/Invokes) but you can set the properties and events with the property editor.

Please report any bugs you may encounter.

If you got questions just ask ;)
 

Attachments

  • senseslider.jpg
    senseslider.jpg
    26.5 KB · Views: 2,805
  • senseslider2.jpg
    senseslider2.jpg
    42.5 KB · Views: 2,758
  • senseslider3.jpg
    senseslider3.jpg
    35 KB · Views: 2,625
  • CustomThumbScreen.jpg
    CustomThumbScreen.jpg
    50.9 KB · Views: 725
  • SenseSliderDemo_src.rar
    1.4 MB · Views: 738
Last edited:

Obelix_A

Senior Member
Oct 19, 2007
81
1
Passau
looks quite interesting. I will give it a try as soon as I can integrate in my apps (testing makes no sense - I also have HD2 ;) )

keep on developing!
Obelix
 

ZaxXx

Senior Member
Jun 12, 2007
247
19
Prague
lukasklika.cz
Looks nice, not exactly like Sense (no vibration, no left-right/right-left gesture, if I tap&hold some icon and then swipe to left or right, the slider doesn't follow my finger), but good. Can't wait to be able to use it in my apps :D
 

Archer

Inactive Recognized Developer / Retired Senior Mod
Jul 9, 2008
14,002
4,003
Manchester
Google Pixel 8 Pro
That's VERY nice mate. I'm also particularly pleased that you used the Sense SDK interface in your demo, as I was considering using this slider in one of my apps that uses the Sense SDK heavily. I'm not considering it any more though - I'm all over it :D

I'm not currently at a dev machine and therefore can't really check out the control, so I do have one question that I may be able to answer if I looked in the IDE. Can you stop it changing page by sliding left and right on the page itself? I'd rather people had to use the slider to change page.

But yeah, very nice - thanks a lot!
 

LunaticShade

Member
Nov 7, 2007
19
0
I'm glad to hear that you like it.

Can you stop it changing page by sliding left and right on the page itself? I'd rather people had to use the slider to change page.
Actually it is the WinMo 6.5 TabControl which exposes this behavior. If you slide over a TabPage it changes the tab respectively, the senseslider then only reflects this action. So this is not the default behavior of the Slider (actually you could just set back the SelectedTab if it was not changed by the SenseSlider).
 

TeDeV

Senior Member
Aug 27, 2007
731
113
Athens
nice control man.

i got 4-5 times a crash on the program. when i changed the button slider color, and stopped the vibration, then when i moved the slider fast from left to right, etc, an error occured.

overall nice work. i don't know if it is your icons, or the real time drawing, but the icons at the slider have a very bad quality. hope you can make the graphics much more similar to the HTC Slider looks :)

well done for a 0.1 version.
 

TeDeV

Senior Member
Aug 27, 2007
731
113
Athens
anyone knows what is wrong with this line?

Dim imageNames = assembly.GetManifestResourceNames().Where(Function(r) r.Contains("_b"))

i can't get the slider to work having a vb code. this slider needs so many things. i guess the reason that my slider is not working right now is because of the above code line, which returns me nothing, even though i have a picture which contains _b in the name
 

LunaticShade

Member
Nov 7, 2007
19
0
anyone knows what is wrong with this line?

Dim imageNames = assembly.GetManifestResourceNames().Where(Function(r) r.Contains("_b"))

i can't get the slider to work having a vb code. this slider needs so many things. i guess the reason that my slider is not working right now is because of the above code line, which returns me nothing, even though i have a picture which contains _b in the name

your resources have to be embedded. in the file browser of visual studio open the Resources folder (not the resx file!) select the images and in the property window change Build action to embed in resx.
 

TeDeV

Senior Member
Aug 27, 2007
731
113
Athens
i tried that, but when i add the image in the resources file, and choose the embed build action, i get errors

DividedByZeroException

stackTrace....
"σε LunaticShade.SenseSlider.Draw(Graphics g, Int32 x, Int32 y) σε LunaticShade.SenseSlider.Draw(Graphics g) σε LunaticShade.SenseSlider.OnPaint(PaintEventArgs e) σε System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam) σε System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam) σε Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain) σε System.Windows.Forms.Application.Run(Form fm) σε PrimeKeys.Form1.Main() "

i also have a question.

how do you "connect" the senseSlider with the tabControl?

for example.... if i had two tabcontrols, how does the SenseSlider, knows which tabcontrol to bind?

i can't find that code in your sample.
 
Last edited:

LunaticShade

Member
Nov 7, 2007
19
0
i tried that, but when i add the image in the resources file, and choose the embed build action, i get errors

DividedByZeroException

stackTrace....
"σε LunaticShade.SenseSlider.Draw(Graphics g, Int32 x, Int32 y) σε LunaticShade.SenseSlider.Draw(Graphics g) σε LunaticShade.SenseSlider.OnPaint(PaintEventArgs e) σε System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam) σε System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam) σε Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain) σε System.Windows.Forms.Application.Run(Form fm) σε PrimeKeys.Form1.Main() "
hm, that's strange. are you using pngs? did you set the IconSize Property of the senseslider? maybe a call of senseslider.updatevalues() in your constructor helps.
i also have a question.

how do you "connect" the senseSlider with the tabControl?

for example.... if i had two tabcontrols, how does the SenseSlider, knows which tabcontrol to bind?

i can't find that code in your sample.
actually the senseslider does not know that it controls a tabcontrol. It raises the event SelectedIndexChanged when the user selects an icon. In this event I activate the corresponding TabPage to be active.
 

TeDeV

Senior Member
Aug 27, 2007
731
113
Athens
yes but the corresponding tabpage of which tabcontrol?

if i have 2 tabcontrols, with 5-6 tabpages inside each tabcontrol, how does the slider knows, to which tabcontrol to bind? i don't get it.

i am creating the senseSlider dynamically. and this is my code...

senseSlider.Location = New System.Drawing.Point(0, 554) '504
'senseSlider.Dock = DockStyle.Bottom
senseSlider.Size = New System.Drawing.Size(480, 84)
senseSlider.BackColor = System.Drawing.Color.FromArgb(CInt(CByte((239))), CInt(CByte((235))), CInt(CByte((239))))
senseSlider.BorderBaseColor = System.Drawing.Color.FromArgb(CInt(CByte((235))), CInt(CByte((235))), CInt(CByte((235))))
senseSlider.DarkBaseColor = System.Drawing.Color.Silver
senseSlider.DarkSliderColor = System.Drawing.Color.FromArgb(CInt(CByte((35))), CInt(CByte((35))), CInt(CByte((35))))
senseSlider.HapticFeedback = True
senseSlider.IconSize = New System.Drawing.Size(72, 72) '56,56
senseSlider.IconSpacing = 25
senseSlider.LightSliderColor = System.Drawing.Color.Silver

senseSlider.UpdateValues()

'=====================

anything wrong there?


ok i have figured it out. it is the IconSize! if i use other png images with different dimensions than yours, then i get that error, no matter what. i don't get it. what is 56,56? because none of your icons are 56x56
 
Last edited:

LunaticShade

Member
Nov 7, 2007
19
0
yes but the corresponding tabpage of which tabcontrol?
if i have 2 tabcontrols, with 5-6 tabpages inside each tabcontrol, how does the slider knows, to which tabcontrol to bind? i don't get it.
The senseslider does not bind to a TabControl it only informs you that the SelectedIndex was changed. In the event handler for SelectedIndexChanged you decide what to do then. That is which TabControl to refresh. If you do nothing, nothing will happen. (In the sample I subscribed to the SelectedIndexChanged event and change the SelectedIndex of the TabControl to the SelectedIndex of the Slider by code).
ok i have figured it out. it is the IconSize! if i use other png images with different dimensions than yours, then i get that error, no matter what. i don't get it. what is 56,56? because none of your icons are 56x56
The IconSize only says how big the Icons are drawn. If they are smaller or bigger they will be stretched. I don't know why this does not work but
i will try to figure this out.
 

richieacc

Member
May 18, 2009
21
4
Very nice. I've been wanting to write something similar for an app that I want to write. You've just saved me a boatload of work! Thanx!

One issue that I saw though; when the app starts up, the ons screen keyboard icon is displayed over the slider. Opening and closing the keyboard hides the icon. Is there a way to have the application hide the keyboard icon on startup?
 

TeDeV

Senior Member
Aug 27, 2007
731
113
Athens
the slider must be able to DOCK = bottom.

if i have an app which rotates, then i can't use the height thing, in order to anchor.

and depending on the pda resolution the height will be different. and you have to consider that people want menu bar at the bottom, and not just the slider. so it is difficult to have this without dock = bottom.

thanks
 

Archer

Inactive Recognized Developer / Retired Senior Mod
Jul 9, 2008
14,002
4,003
Manchester
Google Pixel 8 Pro
the slider must be able to DOCK = bottom.

if i have an app which rotates, then i can't use the height thing, in order to anchor.

and depending on the pda resolution the height will be different. and you have to consider that people want menu bar at the bottom, and not just the slider. so it is difficult to have this without dock = bottom.

thanks

But that's a very simple thing to manually code, so not an issue. It would be good to not have to code it though, so docking would be nice.

Edit:
Actually, forget coding. Just anchor it in a panel that's docked to the bottom of your form.
 
Last edited:

otherworld

Senior Member
Apr 13, 2008
131
13
Leeds
Wow

Fantastic work - really looking forward to seeing this develop. It's so frustrating that HTC don't just release this stuff so that the developers here can make the phone shine compared to android and iphone - the standard winmo controls are so 1980s ;) !

Cheers
Ian