|
jan212r wrote: the price is not that high (100€ in Be)
Just noticed, did a quick Google. Thank you for the hint, wouldn't have looked for the current price without a small push.
jan212r wrote: the older models are compatible (normaly).
That's what I expect from Windows, but it's not always guaranteed with other manufacturers. I stopped working on it when I got doubts on whether the product-line would be continued in the future.
jan212r wrote: there are no real libs. only 2 dll and almost no documentation
There's a wrapper on CodePlex[^], an example on using it is here[^]. If you don't mind the German, there's also a P/Invoke-example on this[^] forum.
Working without docs is a bit harder, but also a bit more rewarding; I can imagine Logitech not putting much effort in .NET documentation for the display. A shame, since it's really a convenient technology, and IMO a better location for status-indicators than the tray-icon.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
thanks eddy,
Now I already have one test program. menu and response to the buttons;
I just need to find a good font.
Jan
modified 28-Aug-12 14:00pm.
|
|
|
|
|
jan212r wrote: Now I already have on test program
A working prototype, within a day, without much useful examples to work from
Would you consider writing an article on it?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
starting from the example you gived me 2° link
i addapted to this
Module Module1
Public LCD As LgLcd
Public fnt As New Font("Calibri", 8)
Sub main()
Dim conn As New lgLcdClassLibrary.lgLcd.lgLcdConnectContext()
Dim opn As New lgLcdClassLibrary.lgLcd.lgLcdOpenContext()
Dim bmp As New lgLcdClassLibrary.lgLcd.lgLcdBitmap160x43x1()
Dim nAllButtonsReleased, nButton As Integer
Dim bmpNet As Bitmap
Dim gfx As Graphics
lgLcdClassLibrary.lgLcd.lgLcdInit()
conn.appFriendlyName = "Test Application"
conn.isAutostartable = False
conn.isPersistent = False
conn.connection = lgLcdClassLibrary.lgLcd.LGLCD_INVALID_CONNECTION
lgLcdClassLibrary.lgLcd.lgLcdConnect(conn)
opn.connection = conn.connection
opn.index = 1
lgLcdClassLibrary.lgLcd.lgLcdOpen(opn)
Dim installed_fonts As New Drawing.Text.InstalledFontCollection
Dim font_families() As FontFamily = installed_fonts.Families()
Dim nCounter As Integer = 0
Do
Try
fnt = New Font(font_families(nCounter).Name, 10)
Catch ex As Exception
End Try
bmpNet = New Bitmap(160, 43)
gfx = Graphics.FromImage(bmpNet)
gfx.FillRectangle(Brushes.White, New Rectangle(0, 0, 160, 43))
gfx.DrawString(fnt.Name, fnt, Brushes.Black, 10, 10)
gfx.DrawString("Play Stop Prev Next", fnt, Brushes.Black, 10, 27)
bmp.hdr = New lgLcdClassLibrary.lgLcd.lgLcdBitmapHeader()
bmp.hdr.Format = lgLcdClassLibrary.lgLcd.LGLCD_BMP_FORMAT_160x43x1
bmp.pixels = New Byte(6879) {}
For y As Integer = 0 To 42
For x As Integer = 0 To 159
Dim trueColor As Color = bmpNet.GetPixel(x, y)
Dim nColor As Byte = CByte(If((trueColor.R = 255 AndAlso trueColor.G = 255 AndAlso trueColor.B = 255), 0, 255))
bmp.pixels(y * 160 + x) = nColor
Next
Next
lgLcdClassLibrary.lgLcd.lgLcdUpdateBitmap(opn.device, bmp, lgLcdClassLibrary.lgLcd.LGLCD_PRIORITY_NORMAL)
lgLcdClassLibrary.lgLcd.lgLcdSetAsLCDForegroundApp(opn.device, lgLcdClassLibrary.lgLcd.LGLCD_LCD_FOREGROUND_APP_YES)
Do
lgLcdClassLibrary.lgLcd.lgLcdReadSoftButtons(opn.device, nButton)
Loop Until nButton > 0
If (nButton Or 4) = 4 Then
nCounter -= 1
If nCounter < 0 Then nCounter = 0
ElseIf (nButton Or 8) = 8 Then
nCounter += 1
If nCounter > font_families.Count Then nCounter = font_families.Count
End If
Do
lgLcdClassLibrary.lgLcd.lgLcdReadSoftButtons(opn.device, nAllButtonsReleased)
Loop Until nAllButtonsReleased = 0
Loop Until (nButton Or 2) = 2
lgLcdClassLibrary.lgLcd.lgLcdClose(opn.device)
lgLcdClassLibrary.lgLcd.lgLcdDisconnect(conn.connection)
lgLcdClassLibrary.lgLcd.lgLcdDeInit()
End Sub
End Module
So I can see all fonts that works with button 3 and 4
and exit with button 2
button 1 is not used in the quick test program.
For all comments remember its quick and dirty just to find out how everythi ng works
thanks fo the help
Jan
Jan
|
|
|
|
|
jan212r wrote: For all comments remember its quick and dirty just to find out how everythi ng works
For a prototype, does what it should do; a short clean example that it works, and how.
Thanks for sharing the code
|
|
|
|
|
I come from C# world. Now I am in here and need a bit of help.
Here is a C# program which add event handler:
private CenterTrigger_EventHandlerAdv m_CenterTriggerHandler = null;
if (m_CenterTriggerHandler == null)
{
m_CenterTriggerHandler = new CenterTrigger_EventHandlerAdv(BRIReader_EventHandlerCenterTrigger);
m_BRIReader.EventHandlerCenterTrigger += m_CenterTriggerHandler;
}
I convert it to VB.net.
AddHandler m_BRIReader.EventHandlerCenterTrigger, AddressOf BRIReader_EventHandlerCenterTrigger
Now in VB, how can I check if an event handler has been added? If it has, I would like to RemoveHandler.
|
|
|
|
|
I would have a read of this
How to check to see if an event exists[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Simon_Whale,
Thanks for your answer. I read the article posted in your link. I get the answer after I have read the first paragraph of the third 'floor' of answer. The rest (fourth floor to the 7th floor) of article does not help me that much. (Actually I don't really understand those answers. )
Anyway, I just call RemoveHandler before calling AddHandler with the same set of parameters.
|
|
|
|
|
Visual Basic is a very forgiving and accommodating language. In keeping with the VB6 legacy, it does a lot of plumbing for you behind the scenes without ever writing a single line of code. You don't need to check if an event handler exists before calling RemoveHandler, just call it.
|
|
|
|
|
Hi
Can anybody help me in defining how to control the number of users logged in to the application. I have tried writing to registry of the server but it seems that is not a very good idea since then lots of security related concerns arise.
I have checked Google but not found any good method. I know there are many ways which can be used but I need a method by which it can be kept hidden from the user/ client administrator and also will not be removed once the software is uninstalled for future reference.
Because of the connection problem in MySql, which happens to be the back-end, I would like to have a method which I can bind into my application.
Any help in this matter will be highly appreciated.
|
|
|
|
|
To answer that, you'll have to define "logged in user".
Assuming your users are listed in the database; add a table that references the users, and which adds a timestamp. Add a record when a user logs in. This is the "login-time". You could add a second, which gets updated with every action (over a trigger), called "last activity".
Problem; users do not always log out as required. Computers die, networks die, hence, connections die without notifying that the user is no longer active. Solution; consider every user active with a login-time that's not older than "today", and a last-activity not older than an hour or two. Require the inactive users to log in again, and you're there.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy. I think this should be fine. The only problem is the second part of my query where-in I would like to keep a track of future installations. I would like to keep a track on whether this application is installable or not.
Anyway as a first step this is good enough. In case you have any other idea do please share.
Thanks again.
|
|
|
|
|
SPSandy wrote: The only problem is the second part of my query where-in I would like to keep a track of future installations. I would like to keep a track on whether this application is installable or not.
The difficulty there is predicting future requirements; you don't know what the requirements of the utility (or it's dependencies) are.
Usually any updates on an application adhere to the requirements of the original application. That way one can install updates without performing a full system-check each time and without worrying about permissions. Anything that breaks the requirements is minimal a new release. Based on the logic that the old code cannot state claims over the new code (without outside help, like a webservice), it is the new code that provides the requirements-test.
The old code code be invoking something in the new code to ask whether it still complies with the old rules; sounds elegant, but given that it's the new code making the assessment anyway, it's more logical to have the installer for the current release perform the check, and the required updates. Typically run with admin-privileges, this mode enables you to take custom actions needed to meet any change in requirements, like downloading and installing extra required components, or beg the admin for a new harddisk
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy, Thanks for the explanation. I was actually referring to installations which can happen where they are not supposed to happen. For example If I install a trial version somewhere, I don't want the trial version to work again after un-installing and installing it again once the trial period is over. How do I stop this?
In this case I am not sure how the new version can check whether the installation is valid or not? This is where I am getting stuck. Not finding any logic to follow for this case. This is the reason why I thought of writing into the registry, but huge security concerns drove me away from that idea. The other idea was to create a text file and keep it in a highly populated area like Windows or anything of that sort. Again Security issues. Windows normally don't allow to write anything in its library.
This prompted me to come out to this forum and look for possibilities. But your idea of keeping a track of users through table is of course an area which I will take up.
Thanks again for replying.
|
|
|
|
|
SPSandy wrote: For example If I install a trial version somewhere, I don't want the trial version to work again after un-installing and installing it again once the trial period is over. How do I stop this?
Let's suppose I downloaded your software, and I done something stupid, had to reinstall Windows. Why prevent me from installing again? There's an alternative to stop people from indefinitely using your trial-software;
A trial-version does not need to include all features for test-driving your software. That's the best anti-piracy method I encountered. Visual Studio Express is downloadable for free, but the package is a lot smaller than the Pro-version. A feature that ain't there, can't be hacked. That's why some public-domain apps don't provide save-functionality for example; one can still test everything, but you'd have to buy the complete version if you want it all.
Anything on the local filesystem can be hacked, given enough time. Usually, it's not "worth" the time, and you clone the Virtual Machine. If you want more security, you'd use a web-server and ask it whether the user with given name has a (valid) license. It's a bit harder to circumvent that, but still, it might be possible to copy the answers of your server and later feed those copies to the client. If you want more security still, you need a hardware-token.
The additional advantage of not crippling the trial-version, but to offer an "express" version, is that you can start to encourage the sharing - and gain market-share. As soon as any of the express-users needs a pro-function, they'll convert.
The Pro-version could have the name of the client hardcoded in the source-code; if your webserver supports ASP.NET, you could inject the name of the client into a source-file once the download is requested, use the compiler to build it, and provide a custom download-location for their version. It's easily changed with the right tools, but it does discourage "sharing" the product a bit.
As you can see, no perfect strategy, and all with a cost. Invest your time wise
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
You need to handle it in Global.asax file. If you observe, this class inherits HttpApplication which has a property HttpApplicationState . So you can set a variable LoggedInUsers in ApplicationSate when the application starts (Application_Start method) and you can keep updating the variable in Session_Start & Session_End methods.
void Application_Start(object sender, EventArgs e)
{
Application["LoggedInUsers"] = 0;
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["LoggedInUsers"] = (int)Application["LoggedInUsers"] + 1;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["LoggedInUsers"] = (int)Application["LoggedInUsers"] - 1;
Application.UnLock();
}
|
|
|
|
|
Thanks for the reply Pramod. But unfortunately I am totally ignorant in C# or C whichever this is written in. So I neither understand what this does nor on how I can use this in my application. I am writing my application in VB.Net
But I do appreciate your taking time and providing the details.
|
|
|
|
|
If you are using vb.net, no problem at all. Copy these methods one by one any try converting them to Vb.net online.
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
If you have the confusion of placing this code, then search for Global.asax file in your web project.
If it is not there then add this file to your web project.
Right click on your web project. Select Add->NewItem, then select Global.asax template from the template library.
|
|
|
|
|
Thanks Pramod for your reply. I will surely look into this.
|
|
|
|
|
Hi all,
for my app I retrieve 'SOAP' data (using the PayPal Api), which have to be written to an Excel file in the end. I don't have any experience with web applications, XML, serialization etc., so that I'm afraid the idea of assigning each field to the properties of a 'Transaction' class might be useless or at least a long way round.
From my logfile I can see that it's transferred in the format
<Status xsi:type="xs:string">Completed</Status><GrossAmount xsi:type="cc:BasicAmountType" currencyID="EUR">41.80</GrossAmount> and I try to fill the class this way ((...).= abbreviated):
For Each transactionDetail As GetTransactionDetailsResponseType In detailsList
If transactionDetail(...).LastName IsNot Nothing Then
Dim t2 As New Transaction
With t2
.Transaction_ID = transactionDetail(...).TransactionID
.Street1 = transactionDetail(...).Street1
.Quantity = Val(transactionDetail(...).Quantity)
End With
End If
Next From some web sources – which all seem to be written for experts – I assume there must me much easier (and less error-prone) ways to process the data, but I don't know where to start or find code examples.
Would someone be so kind as to give me some guidance?
Thank you very much,
Mick
|
|
|
|
|
Honestly, AFAIK, there is nothing that is much easier than this.
One could use reflection to read the properties of the proxy object and then assign them to similar properties in your model - but then you need to ensure the model property names match, and that does sound difficult.
Perhaps someone else can provide a better solution.
|
|
|
|
|
Thank you for the advice, anyway!
Abhinav S wrote: use reflection to read the properties of the proxy object and then assign them to similar properties I'd still give it a try, since I know all the names and datatypes so that I could rename my 'transaction' class' properties. But how would I code this? Could you probably give me a few lines of sample code?
|
|
|
|
|
Hi
I am having a problem with "Too Many Connections" in accessing MySQL from VB.Net.
The issue is I am loading huge amount of data from Excel to MySql using VB Grid. There is a check that if the data is already available then it will not be loaded based on certain key. If a lot of this Data is already available in the MySQl Table then even though I am closing the Connection using MySqlCommand.connection.Close() it still leaves a thread in the MySql resulting in a huge number of connections still open.
Can anybody help me in solving this issue?
Thanks in Advance
|
|
|
|
|
I had a similar problem with one of my programs and my solution was to open the connection at the beginning of the program, then re-use the connection each time I had to query the database.
The best performance is if you have a single SQLcommand and make use of SQLparameters so that you only change the value of the parameter for each different query.
Basically one connection, one sqlcmd, keep changing the value of the parameters.
See if that works for you.
|
|
|
|
|
Considering the cost of a connection license to some SQL Servers can be very expensive, and the fact that the connection would be completely idle for the vast majority of your applications lifetime, that is a horribly bad practice.
Standard "play nice and share with others" practice is to open the connection, execute your query, then close the connection as soon as possible. Do that and you won't hog the license preventing others from using it and pissing off the DBA's.
|
|
|
|
|