|
Hi, everyone, i am a new member of this website. i encounted a problem in my GUI.
Right now i want to create a progressbar with pencentage done status running beside it. Can someone give me a hand? i appreciate it.
Peishen
|
|
|
|
|
Welcome!
There is a progress bar control available. You have to calculate the progress percentage and set that to Value[^] property of progress bar.
|
|
|
|
|
|
Try searching the articles - there must be 6+ articles on PBs
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
We have an existing application (so I can't make wholescale changes) that has a number of user controls that are displayed as follows:
Call a method (MyUserControl.ShowVaseline(Control parentControl) which
1. Creates a bitmap from the parentControl.
2. 'Grayscales' the bitmap
3. Creates an empty usercontrol with this bitmap as the background
4. Docks this newly created user control within the parentControl (so it LOOKS as if the parent control is disabled, whereas in fact it is invisible, hidden behind the newly created control)
4. Positions MyUserControl centrally within this newly created user control
The effect is that MyUserControl is shown on top of the parent control, will move with the parent control, and the parent control is disabled and appears 'greyed out'
In most cases this is fine and dandy for its purposes - which is essentially a desire to be able to access some top-level controls on the parent form at all times, while maintaining workflow through apparent modality of dialogs).
But when shown like this it is not 'Modal' in the Windows sense of the word - ie the code following MyUserControl.ShowVaseline(parentControl) is executed without waiting for MyUserControl to complete.
So the 'closing' of the user control is handled by it events which are handled by the parent :
...
MyUserControl.Close += MyUserControlClosed;
MyUserControl.ShowVaseline(Control parentControl);
}
private void MyUserControlClosed(Dialogresult dialogResult)
{
if (DialogResult.OK)
{
SoSomeStuff();
}
}
I would dearly like the ability to treat the control just like a modal dialog form, in some cases - so the LOOK would be the same (centered on an apparently disabled background) but I could do something like
DialogResult dialogResult = MyControl.ShowVaselineModal(parentControl);
if (dialogresult == DialogResult.Ok)
{
DoSomeStuff();
}
I don't really understand, technically, how a dialog form 'works' so don't really know where to begin.
I can think of having my main program enter a loop, checking the user control for a modal result
MyControl.ShowVaselineModal(parentControl);
while (MyControl.DialogResult == DialogResult.None)
{
Application.ProcessMessages();
}
if (MyControl.Dialogresult == DialogResult.Ok)
{
DoSomeStuff();
}
But surely there's something clever I'm missing?
Incidentally, the reason I want to do this is for the occasional situation where, for example, I am iterating a collection, and want to open a 'dialog' for (possibly) several items in the collection - with a true dialog I can just put the code in the loop - but using the existing Vaseline stuff, I have to faff about keeping references to where I am in the collection and/or what has been handled so I can continually reprocess the collection until I have done. It's not so much hard as annoying.
All help gratefully appreciated.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Wow - what dogs breakfast to you have to go through to disable a form. Why not just walk the forms control tree and disable/grey the controls, you could even replace the vaseline (what a horrible name, brings back memo... oops) with a UC to do the disabling.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes - it is a dog's breakfast. But they didn't want the controls disabled because some of them became all but illegible in their default disabled state (due to particularly horrible colour schemes and the idiosyncrasies of the GUI (because some 3rd party controls look different when disabled to their windows counterparts, some user controls behaved differently etc.)
Initially all this faffing about was done using a series of helper classes (bizzarro world here, I tell you!) I at lewast put the functionality in the base class (so you can just say 'control.ShowVaseline' without worrying about what's going on behind). And you would still need some method of positioning the user control on top of the rest of the controls...
It actually looks quite nice - if you like that sort of thing.
The name stems from photography, where Vaseline is used to 'blur' an image, I believe, and not from any, ahem, medicinal usage, of which you appear to be over familiar
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
can't you do something like set a flag in the UC (dialogresult ) and make the main form wait till the flag is reset before allowing progress. or possibly have the parent subscribe to an event on the UC.
Can the UC be changed to a borderless form - and therefore a real dialogresult can be used.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
i am using IE objects. i am getting one IHTMLElement "textarea".
manually in browser if we click on this text area then some javascript code runs. and i get captch. if i see the page source then i am getting... likke this...
;
so what i have to do is, i have to click on textarea by IE automation using microsoft.mstml classes.
Thanks for reply.....
<div class="ForumSig">yogesh</div>
|
|
|
|
|
Hello,
here is a libary you searching for. I foud this some time ago. With this libary you have full control
of the internet explorer here is the link:
http://watin.sourceforge.net/[^]
i hope this helps you
|
|
|
|
|
I've been battling this for a few hours so now I need help!
I'm converting a 64bit fixed point timestamp (32bit integer part, 32bit fractional part) to a DateTime by converting it to a TimeSpan adding that to an epoch, as the timestamp represents the number of seconds since the epoch.
The problem is I'm losing precision (I assume because of the cast to/from double and UInt64 - see code), so converting back from DateTime to timestamp gets a different value.
Any ideas?
using System;
class Program
{
static void Main(string[] args)
{
UInt64 timestampA = 14844064336383267476;
Console.WriteLine("TimestampA: {0}", timestampA);
DateTime dateTime = NTPConversion.TimestampToDateTime(timestampA);
Console.WriteLine("DateTime: {0}", dateTime);
UInt64 timestampB = NTPConversion.DateTimeToTimestamp(dateTime);
Console.WriteLine("TimestampB: {0}", timestampB);
Console.WriteLine("Discrepancy: {0}", timestampB - timestampA);
Console.ReadKey();
}
}
public static class NTPConversion
{
public static readonly DateTime Epoch = new DateTime(1900, 1, 1);
public static DateTime TimestampToDateTime(UInt64 timestamp)
{
TimeSpan timeSpan = TimeSpan.FromSeconds((double)timestamp / 4294967296);
DateTime dateTime = Epoch + timeSpan;
return dateTime;
}
public static UInt64 DateTimeToTimestamp(DateTime dateTime)
{
TimeSpan timeSpan = dateTime - Epoch;
UInt64 timestamp = (UInt64)((timeSpan.TotalSeconds * 4294967296d));
return timestamp;
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
the problem is here: (double)timestamp
uint64 (aka long) has a 63-bit resolution, whereas double only has some 52 bits of mantissa, the remaining bits required to hold the exponent.
You'll have to smarten up your TimestampToDateTime() method by splitting the uint64 in two parts, and adding them separately to get the DateTime. Example:
long hipart=timestamp&0xFFFF0000;
long lopart=timestamp&0x0000FFFF;
DateTime dt=TimeSpan.FromSeconds(hipart*...);
dt.AddSeconds(lopart*...);
I strongly suggest you don''t use those magic numbers of yours either; they are incromprehensible; what I would do is write them as a formula, the compiler will multiply them for you, and better yet also make them named constants so their name indicates their meaning.
Cheers.
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.
|
|
|
|
|
|
Dave, I have just tried something for your TimestampToDateTime method and I got 09/07/2009 18:30:53 (dd/mm/yyyy), is that what you were hoping for?
If so I will post it for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry,
Happy to look at anything, some fresh eyes/new perspective is always good!
I can retrieve the same DateTime no problem when just looking down to the second, but it changes when using milli/micro/pico second precision. That isn't necessarily a problem, so long as I can get the Timestamp data consistant after going through the conversion processes - see my reply to Luc below.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
I have investigated a bit more, and there is a fundamental problem: DateTime and TimeSpan basically count ticks, there are 10 million ticks per second.
Your timestamp has much higher accuracy (4 billion parts in one second), so the extra information is lost forever when you turn them into DateTime/TimeSpan structs.
To convince yourself, make discrepancy a signed number, and try several timestamp values (even small numbers will show the problem, I tried numbers from 0.2 to 2.0 milliseconds where
ulong Shift32 = 0x0000000100000000UL;
ulong msec = Shift32 / 1000;
or use Reflector to peek into the code for DateTime properties Ticks and Seconds, and its AddSeconds() method.
Furthermore your unit changes from a binary one to a decimal one, and back; which is bound to cause round-off problems, similar to float and double having trouble representing 1.0/3.0*3 and 1.0/7.0*7
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.
modified on Thursday, July 9, 2009 8:02 PM
|
|
|
|
|
Thanks Luc, I figured that there would be problems with the internal resolution of DateTime vs the timestamp
Unfortunately, that is probably not solvable, as the Timestamp format is not one of my own, but part of the NTP/SNTP[^].
I think my best solution is to round any timestamps to the acheivable precision of DateTime so I can at least get consistant data. The level of precision provided in the protocol is for the most part unecessary IMO.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Further to my earlier reply, and after a little more thought, accuracy of less than 1ms is probably not required so I only need 40 of the 64 bits - the 32 integer bits, and 8 fractional ones. This should make it a little easier I hope.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Sure. Due to the different bases (1 in 1000 and 1 in 2^32) you still are bound to encounter some odd values that get modified when applying a round-trip conversion.
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.
|
|
|
|
|
I think I've sorted it Luc. Part of the problem was TimeSpan.FromSeconds and FromMilliseconds are only accurate to 1 millisecond so it was bound to do wierd stuff!
The answer to that was to use TimeSpan.FromTicks, in combination with Math.Round(), and now I appear get 1 picosecond 10 nanosecond precision. [Edit] The resolution of Ticks per second [/Edit]
Obviously the first pass results in a different timestamp still - but it's acceptably close. I just run it through a TimestampRound method first so future comparisons are made against that.
public static class NTPConversion
{
public static readonly DateTime Epoch = new DateTime(1900, 1, 1);
public static UInt64 TimestampRound(UInt64 timestamp)
{
long ticks = (long)(Math.Round(
(double)timestamp / 0x100000000, 7, MidpointRounding.AwayFromZero)
* TimeSpan.TicksPerSecond);
UInt64 newTimestamp = (UInt64)(((double)ticks / TimeSpan.TicksPerSecond) * 0x100000000);
return newTimestamp;
}
public static DateTime TimestampToDateTime(UInt64 timestamp)
{
long ticks = (long)(Math.Round(
(double)timestamp / 0x100000000, 7, MidpointRounding.AwayFromZero)
* TimeSpan.TicksPerSecond);
TimeSpan timeSpan = TimeSpan.FromTicks(ticks);
DateTime dateTime = Epoch + timeSpan;
return dateTime;
}
public static UInt64 DateTimeToTimestamp(DateTime dateTime)
{
TimeSpan timeSpan = dateTime - Epoch;
long ticks = timeSpan.Ticks;
UInt64 timestamp = (UInt64)(((double)ticks / TimeSpan.TicksPerSecond) * 0x100000000);
return timestamp;
}
} Thanks for your help! If you see any obvious flaws in this - let me know!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Friday, July 10, 2009 2:48 PM
|
|
|
|
|
Hi Dave,
I am confused, I used Reflector and got convinced ticks was the best you could ever get from DateTime/TimeSpan. I will need more time and a bigger screen to investigate further, I am on a tiny netbook right now, making some things harder. I'll come back on this next week.
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.
|
|
|
|
|
You're right - I was getting confused between nano and pico, this stuff has really fried my brain this week!
10ns is the smallest achievable resolution - good enough I think.
[Edit] After all that, once moved over to the real application, there were some serious errors in that code. I ended up dividing into the whole part and fractional part as you suggested initially. The code below works well (In the actual app the ulong's are converted to a big endian byte array)[/Edit]
private void DateTimeToTimestamp(DateTime dateTime, int startIndex)
{
UInt64 ticks = (UInt64)(dateTime - Epoch).Ticks;
UInt64 seconds = ticks / TicksPerSecond;
UInt64 fractions = ((ticks % TicksPerSecond) * 0x100000000L) / TicksPerSecond;
for (int i = 3; i >= 0; i--)
{
data[startIndex + i] = (byte)seconds;
seconds = seconds >> 8;
}
for (int i = 7; i >= 4; i--)
{
data[startIndex + i] = (byte)fractions;
fractions = fractions >> 8;
}
}
private DateTime TimestampToDateTime(int startIndex)
{
UInt64 seconds = 0;
for (int i = 0; i <= 3; i++)
seconds = (seconds << 8) | data[startIndex + i];
UInt64 fractions = 0;
for (int i = 4; i <= 7; i++)
fractions = (fractions << 8) | data[startIndex + i];
UInt64 ticks = (seconds * TicksPerSecond) + ((fractions * TicksPerSecond) / 0x100000000L);
return Epoch + TimeSpan.FromTicks((Int64)ticks);
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Saturday, July 11, 2009 8:11 PM
|
|
|
|
|
Hi,
I use the Stream class in a framework.dll to read and write a setting like this,
get
{
Stream stream = GetStreamForRead(ClientHelpFile);
if (stream == null)
return HelpOption.Automatic;
int HelpOptionRead = stream.ReadByte();
stream.Close();
}
set
{
Stream stream = GetStreamForWrite(ClientHelpFile);
stream.WriteByte((byte)value);
stream.Close();
}
private const string ClientHelpFile = "TAC.ClientHelpProfile.bin";
private const IsolatedStorageScope scope =
IsolatedStorageScope.Roaming |
IsolatedStorageScope.User |
IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain;
private static IsolatedStorageFile GetIsolatedStore()
{
return IsolatedStorageFile.GetStore(scope, null, null);
}
private static Stream GetStreamForWrite(string filename)
{
IsolatedStorageFile storage = GetIsolatedStore();
return new IsolatedStorageFileStream(filename, FileMode.Create, storage);
}
private static Stream GetStreamForRead(string filename)
{
IsolatedStorageFile storage = GetIsolatedStore();
if (storage.GetFileNames(filename).Length == 0)
return null;
return new IsolatedStorageFileStream(filename, FileMode.OpenOrCreate, storage);
}
the problem I am facing is I am using another application and referencing the same dll(FrameWork.dll).
the storage.GetFileNames returns null and I wish it return me whatever the file has saved in it. Am I missing something?
|
|
|
|
|
AnilUnni wrote: the problem I am facing is I am using another application and referencing the same dll(FrameWork.dll).
the storage.GetFileNames returns null and I wish it return me whatever the file has saved in it. Am I missing something?
I think, note that is bold, that the problem might be IsolatedStorageScope.Domain . Each application runs in its own domain, so the path to the isolated storage will be different from different applications.
Once again, this is not a certainty, just my interpretation of how it works.
If it were my app, I would start with just IsolatedStorageScope.User, see if it works for both apps add another scope see if it works etc until it fails. That way you will identify which scope(s) will break it and can avoid them.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi all,
Thanks a lot for your help in advance.
I am doing a Mail Merging Application. I can get all data from the source (database, file or anything) and using mail Merge fields in Word Document from C# code, I open up the word which is merged with data from database.
MS Word Document Opens –
--- should this be open in IE
--- Or should this be open as ordinary MS Word on Desktop
The problem is if I open it anyway, I loose all control over the Word Document which is opened. I don’t want to do that. I want to keep control over it and allow the Users to update the document with some standard messages which we have in the project. What that means is, the messages will be selected and those messages selected will be put at some point where cursor is kept in the document.
So, when mail merging happens
MS Word Document is opened.
A pop up with standard messages is opened.
User selects the messages he/ she wants to insert into the MS Word Document which is opened.
For these things to happen, I should have control over the MS Word Document which is opened on the client side. Do selection of the messages and populate in Word document (this is my understanding, is there any way to do it easily).
The Issues are:
I need a way to open the MS Word Document in a controlled manner where I can still control the User editing or help user in editing when he / she clicks on my standard messages and wants them to populate on the MS Word Document.
How can I save the MS Word document and make sure that user is not saving it locally and has to upload it again to save it on server.
I Hope I am clear in explaining the situation, please find the attachments which show the MS Word Doc and the popup on side .
ANY RUNNING CODE WILL BE OF GREAT HELP.
|
|
|
|
|