|
A WebBrowser control does that. I think it instantiates a COM object representing a flash player behind the scenes anyway, just like the AxShockwaveFlash class. Alternatively, you could parse the file format and draw the shapes with the coordinates specified. I can't help you beyond that though
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hai!
How to Calculate Total Elapsed time from given starting value and ending value when the the given values are greater than 24(ie Meter Readings)(for eg:Starting time=1015:35,Ending time=1058:15)
Plz Send any Ideas,
Thank You
|
|
|
|
|
what do u mean by 1015:35 is it H:M if it's
TimeSpan end = new TimeSpan(1015, 35, 0);
TimeSpan start = new TimeSpan(1058, 15, 0);
TimeSpan sub= end.Subtract(start);
double TotalSeconds = sub.TotalSeconds;
|
|
|
|
|
DateTime date1 = System.Convert.ToDateTime(txtstarttime.Text);
DateTime date2 = System.Convert.ToDateTime(txtendtime.Text);
TimeSpan ts = new TimeSpan();
ts = date2.Subtract(date1);
DateTime dt = DateTime.MinValue.Add(ts);
txttottime.Text=ts.Hours + ":" + ts.Minutes + ":" + ts.Seconds ;
I have used this but it Produce error when the given values are greater than 24
|
|
|
|
|
What format are txtstarttime.Text and txtendtime.Text in? Are they hours:minutes:seconds like your output? If so, then you can replace the System.Convert.ToDateTime calls with System.DateTime.Parse("input goes here", "hh:mm:ss", null)
|
|
|
|
|
|
You can replace the System.Convert.ToDateTime calls with System.DateTime.Parse("input goes here", "hh:mm", null). The first parameter will be your Text properties instead of the string "input goes here"
|
|
|
|
|
Hi,
Hmm, you need to stop for a moment and think about what you are trying to do.
If the measured time span is 24 hours or more then information about the number of days that have passed is required to perform the calculation.
If the time span is guaranteed to be less than 24 hours the following pseudocode is valid
duration = endtime - starttime;
if duration < 0 then duration = duration + 24 hours;
Note how this would fail as soon as the actual time span is 24 hours or more.
Alan.
[EDIT corrected error in code fragment]
modified on Sunday, May 31, 2009 9:29 AM
|
|
|
|
|
u can use this but i don't recommend it
string x1="1015:35";
string[] r=x1.Split(':');
TimeSpan end = new TimeSpan(int.Parse(r[0]), int.Parse(r[1]), 0);
//bla bla bla
//bla bla bla
TimeSpan sub= end.Subtract(start);
|
|
|
|
|
If you convert those strings to DateTime structures (possibly using DateTime.ParseExact, I don't know the exact form of the strings you gave) then you can simply subtract the starting time from the ending time to get the elapsed time as an instance of the TimeSpan structure. That lets you access such properties as TotalHours, TotalMinutes, TotalSeconds and TotalMilliseconds
|
|
|
|
|
Dear all,
I am assigned to a project where I have to develop a web service which will serve client with different video files according to some certain criteria of the client. A large number of video files will be stored in the web server for this purpose and in the client end a C# application will be used for watching the sent video.
I am a newbie. I have basic idea on designing webservice and consume them from client end. But I've never dealt with video stuffs. Please give me an insight on how can I start designing this project. Also please refer me some useful articles regarding this. I have to design both the server and client end softwares.
with thanks
|
|
|
|
|
Hallo,
I have the follwing problem:
I bought es closed source dll which has several non
virtual methods which I want to override in order
to do model based testing.
Does anybody know a trick by using System.Reflection or
anything else to override a non virtual method?
|
|
|
|
|
You can try the "Subclass and override" technique for non-virtual members.
Here is an explanation of this technique: [^]
I hope this helps you to solve your problem.
Nuri
|
|
|
|
|
No, I don't know of any way to do that at runtime. Most mocking frameworks require methods to be virtual (DynamicProxy[^]..).
TypeMock[^] somehow manages to do that for non-virtual methods, but is unfortunately closed source.
Have you thought about doing this with compile time flags and the "using" declarative? Something like
#if DEBUG
using MyType = Project.MockTypes.MockType
#else
using MyType = Project.RealTypes.RealType
#endif
|
|
|
|
|
No, you can't, you should wrap the classes instead.
|
|
|
|
|
Hello,
i am using microsoft indexing services for searching documents. but when i search for arabic words an error occur indicating that following : --The query contained only ignored words--.
Any help was appreciated.
Regards.
dghdfghdfghdfghdgh
|
|
|
|
|
Show me the Query ,
And fix your Signature
I know nothing , I know nothing ...
|
|
|
|
|
I have an application that uses some transparent windows that are put on an other application's windows. These transparent windows contains some boxes that are meant to show some information on the windows of the other application. A need that when the use clicks on the transparent parts of my windows, mouse clicks are carried to the element that is below my transparent windows.
I use a .net Form with background color set to the transparentkey.
Everything works good under Win XP but under Vista the transparent window blocks every mouse click , it's transparent for the eyes but not for the mouse.
Anyone knows a solution?
|
|
|
|
|
i found a solution using interops
This works under Vista.
<pre>
--------------
public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 0x80000;
public const int LWA_ALPHA = 0x2;
public const int LWA_COLORKEY = 0x1;
[DllImport("user32.dll")]
static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey,
byte bAlpha, uint dwFlags);
-----------------------
//..in the form constructor
//if the win is not layered , the layered attribute needs to be speciefied in its styles
this.BackColor = Color.FromArgb(0xaf,0xaf,0xaf);
SetLayeredWindowAttributes(this.Handle, 0xafafaf, 255, LWA_COLORKEY);
|
|
|
|
|
Could you recommend me some services that allow us to generate C# code from a specification ? Thanks in advance
|
|
|
|
|
What specification?? What exactly are you trying to do?? Generate a class file from a database?? You're going to have to be pretty specific in what you you want generated and from what kind of spec.
|
|
|
|
|
Well, there is one called www.rentacoder.com
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi folks,
I have written 2 applications on my till running windows 2000. One is an epos system and the other is a "driver" which parses the text from the touch screen and moves the mouse accordingly.
I'm having a very strange issue. I have recently added network functionality to my epos app. There is a classwhich keeps retrying to connect to the server incase the network is down. What I find is that during this loop (which is run in a seperate thread from my epos app's main thread), my touchscreen driver just doesn't move the mouse or just crashes if you just wait long enough (circa 1 minute or so) with a Send/Don't Send style message "system.indexoutofrangeexception". Once the epos app connects to the server, the touch screen drivers works again (provided it hasn't crashed already...).
Here is my "connector" class used in the epos app:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Windows.Forms;
namespace Paypoint
{
class Connector
{
Network networkinterface;
IPEndPoint ipEnd;
public Connector(Network network, IPEndPoint endpoint)
{
networkinterface = network;
network.Connected = false;
ipEnd = endpoint;
}
public void Start()
{
while (true)
{
if (networkinterface.Connected == false)
{
networkinterface.initSocket();
connect();
}
Object objData = "ping";
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString());
networkinterface.send("ping");
Thread.Sleep(2000);
}
}
private void connect()
{
while (!networkinterface.Connected)
{
try
{
Network.m_clientSocket.Connect(ipEnd);
networkinterface.Connected = true;
}
catch
{
networkinterface.Connected = false;
Thread.Sleep(10000);
}
}
}
}
}
Here is my TouchScreen "driver". It's a small app so I've included all of it:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.IO.Ports;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
namespace EpsonTouchPanelDriver
{
class Device
{
static SerialPort spt;
public static int x;
public static int y;
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public static void init()
{
spt = new SerialPort();
if (spt.IsOpen) spt.Close();
spt.PortName = "COM4";
spt.BaudRate = 9200;
spt.DataBits = 8;
spt.StopBits = StopBits.One;
spt.DataReceived += new SerialDataReceivedEventHandler(spt_DataReceived);
spt.Open();
}
private static void spt_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
int i = 0;
byte[] bytesToReadArray = new byte[1024];
while (spt.BytesToRead > 0)
{
bytesToReadArray.SetValue((byte)spt.ReadByte(), i);
i++;
}
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(bytesToReadArray);
if (str.Substring(0, 1) == "T")
{
char[] delimiterChars = {','};
double scalex;
double scaley;
if (str.Length > 1)
{
try
{
str = str.Substring(1, str.Length - 1);
string[] xy = str.Split(delimiterChars);
if (xy[1].Length > 4) xy[1] = xy[1].Substring(0, 4);
if (int.Parse(xy[0]) < 525) scalex = 0.61 - ((525 - int.Parse(xy[0])) * 0.0004);
else scalex = 0.61 + ((int.Parse(xy[0]) - 525) * 0.00005);
if ((1000 - int.Parse(xy[1])) < 500) scaley = 0.4873 - ((500 - (1000 - int.Parse(xy[1]))) * 0.00005);
else scaley = 0.4873 + (((1000 - int.Parse(xy[1])) - 500) * 0.00005);
x = (int)(int.Parse(xy[0]) * scalex);
y = (int)((1000 - int.Parse(xy[1])) * scaley);
if ((x > 0) && (y > 0))
{
Cursor.Position = new Point((int)x, (int)y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, Cursor.Position.X, Cursor.Position.Y, 0, 0);
Thread.Sleep(100);
}
}
catch
{
MessageBox.Show("ERROR");
}
}
}
}
}
}
I find this behaviour very strange as these are 2 different assemblies! I simply don't have the knowledge required to understand how one app can cause another to crash.
Thanks for your help. It's appreciated
**Update**
Ok so the suitation gets weirder. I have found out that during the time when my epos app is trying to connect to the server (hense also the time when to touchscreen won't work), the mouse CAN move if the "driver" Winform is in Focus (normally, it is minimised to the system tray..)
Jonny
p.s. sorry about the bad formatting
**UPDATE 2**
OK folks yet another update! If I put a Thread.Sleep(10) in my driver app just before the if statement, then it works just VERY slowly (Unuseable but hey, there's life!).
modified on Saturday, May 30, 2009 5:36 PM
|
|
|
|
|
Hi,
first of all, please fix the post with real < pre> tags so code gets shown formatted and hopefully becomes readable. (you must now have & lt; instead of < signs)
there probably are several errors:
1.
I trust spt.BaudRate = 9200; is a typo (9600 and 19200 would be normal values). AFAIK SerialPort would not even accept that odd value.
2.
from the documentation: "The DataReceived event is raised on a secondary thread when data is received from ..."
you are not allowed to touch Controls inside the DataReceived handler, it will sooner or later cause nasty behavior such as freezing GUI or hanging app.
The one correct solution is using Control.InvokeRequired and Control.Invoke; google for that.
3.
in general when messages are coming in over a serial port, the SerialPort class only understand characters, not messages, and the DataReceived event may fire and offer you one partial message, one complete message, two partial messages, whatever. So your code needs to know how to handle these. Quite often by storing it all into a buffer, then looking for entire messages, and removing them when processed.
There probably are two exceptions:
- when quiet periods in between messages exist, you could insert a Thread.Sleep at the start of the DataReceived, with a delay large enough to be sure an entire message would have been received by the time you actually read it out.
- text messages ending on NewLine (some string you can set to SerialPort.NewLine) would cause a SerialPort.ReadLine to return just one message; this means you organize a thread calling ReadLine, and not using DataReceived event at all.
Overall remark:
your code has several try-catch blocks where the information is thrown out; that is a stupid idea. Best is to have
try {...}
catch(Exception exc) {
log(exc.ToString());
}
where log would be a method able to somehow log/print/show a multiline text.
In the rare case you don't want to see a very specific exception, check for that specific one like this:
try {...}
catch(SomeVerySpecificException exc) {
}
catch(Exception exc) {
log(exc.ToString());
}
This may be relevant to the networking part, where maybe something unexpected is happening without you knowing it at all.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
Thanks you for your great reply.
I found the solution to this. My network Listener class has an infinate while loop in it (which is used when the server isn't connected) and I forgot to add a Thread.Sleep(100) so it was taking up 100% of CPU time! Silly me!!
Thanks for spotting the 9200! I've been using that the whole time. What's strange it that it hasn't caused a problem. Maybe .NET rounds it up to the correct value?
Thanks
Jonny
|
|
|
|