|
Braulio Díez wrote:
But I would like to know the time that the application has been activated or used by the "user"
Well, "activated" and "used" are two different things, philosophically. For example, I may have several browser windows open that I'm referencing while writing something in Word, which is the only active doc. So, how do you measure which app I'm using? I'm using all of them, active or not!
Still, it would be a cute app to write. I wonder if someone's done it already? (A very brief search on google came up with nothing).
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Hi,
I have seen some software that monitors that usage. I would be happy just having the time that the user has a windows active ( and it's doing something with it), the CPU time consumed is not valid for me because a Math app can consume more, and surf in the internet or write a doc in Ms Word doesn't consume much CPU...
Braulio
|
|
|
|
|
The user can open the app without using it. To calculate the real time of usage, I think you can use Form.KeyPreview and the Mouse-Events.
1) Mouse enters the main form: Capture the time
2) Mouse leaves the main form: Capture the time
3) Calculate the time span
While the user is typing, the mouse cursor can be anywhere on the screen, so you have to define a maximum time span between two keys:
1) Key is pressed: Capture the time
2) Another key is pressed: Capture the time
3) Time span is longer than the timeout: The app has not been used since the first captured time.
|
|
|
|
|
Mmmm. but how to do it for any process ( e.g. I want to know how much time did somebody spent really using Ms-Word).
Braulio
|
|
|
|
|
As has been pointed out , just 'cos an app is active does not mean it is being used. I could run up word and then go for a coffee. Or I could run up word and type as 120 words per minute or 4 words per minute , they would all come up with the same result for word useage but not for any 'real productivity'.
The altenative is to simply look at the statistics for the word document , but even that needs interpreting , I could be typing slow because I do not want to go fast , or because I am thinking so hard I cannot go fast .
If you are happy with the time the app is loaded then it is easy , but getting more useful information is very difficult since it all needs interpretation . What specific problem are you trying to solve.
|
|
|
|
|
I have more than one Table in a DataSet,How can I REQUERY one of them without interacting with other one or disposing dataset itself?
Mazy
No sig. available now.
|
|
|
|
|
If you use a DataAdapter , call its Fill method against on the same DataSet using a different DbCommand that only queries info for that table. Be sure to read the docs on the appropriate data adapter (like SqlDataAdapter ) because there are other things you might want to be mindful of, so that changes in the DataSet don't get updated on the database itself while filling the DataSet .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi, we are making a tool for extracting data from our companys database.
in hte current version you can build "queries" and execute them.
the tool is to be used by idiots* so the gui/behavior may not be to hightech.
in the current version you can build query filters like:
customer = 1234 Tacco Locco
product = 50050 coca cola
the criterias are then "and"'ed together
this works fairly good , BUT , it would be very nice to be able to build filters that is not just "and"'ed
so now to my question , how should one design the gui for such thing in order to keep the filter builder simple ?
what would be the most intuitive way to build such filter?
say i want to build the filter:
customer=123 and (product=666 or product=777)
the users are far to dumb to understand ( ) groups , so thats not an option :/
any ideas?
//Roger
|
|
|
|
|
This may require more coding than you like, but perhaps you could take a page from Microsoft Access and allow graph-driven query building. A lot of idiots use Access (as opposed to SQL, Oracle, et. al. RDBMS's) so your answer may lay there. Just allow them to draw some shape around a group of graphical filters and choose whether to OR or AND them (or whatever else trips your trigger).
Just my $0.02.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
One way to do this is to create a couple of objects. You can create a Criteria object which will store one criteria. Also create a Query object which will store a collection of criteria objects.
The way I have done this myself is the criteria stores the name of the field and the values. For example, the field name would be Customer and the value would be 123. I have one method which returns a user friendly display string and another which will return the SQL. I have made it so the values are delimited so I can store multiple values. If the field was Product and the value was 666,777 I would then parse the values and when building the SQL I would or those values together.
The query object should expose a method to return the whole SQL statement. It should build the select then ask each of the Criteria items for it condition statements. It should wrap each criteria item in () and AND each one together.
I made a screen shot of how I made the GUI. http://www.desertware.com/images/queryscreen1.jpg
This is quite a bit of work, but in the end it pays off by having a powerful yet easy to use query builder.
Larry Allen
Desertware Technologies
|
|
|
|
|
Here is button click event code:
private void btnCompile_Click(object sender, System.EventArgs e)
{
string srcFile = @"D:\Temp\WindowsApplication6\Form2.cs";
string destFile = @"D:\Temp\WindowsApplication6\Form2.dll";
try
{
CompileCode(srcFile, destFile);
System.Reflection.Assembly a =
Assembly.LoadFile(destFile);
if(a != null)
MessageBox.Show("Ok");
System.Type type = a.GetType("Form2");
object obj = Activator.CreateInstance(type);
Form form = obj as Form;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
}
In the above code, function CompileCode(string srcFile, string destFile) is defined by me to compile the srcFile(.cs file) into the destFile(.dll file).
No doublt to say, every time execute this function, application will write the .dll file. The problem is when the code is executed for the second time
,there will be a exception which say that access collision,another application is accessing the .dll file.
Yes, I think that when the code execute for the second time, the dll has loaded into the current application domain, so cannot write into it. I have ever try to load the dll into another application domain in order that unload
the application domain after I have used the assembly. But some document say that when return assembly object of an appdomain into another appdomain, the later appdomain will also load the assembly. The problem also cannot be solved.
So I'd like to ask how can I realize the functionality of above btnCompile_Click()function?
Waiting for your answer.
Thank you!
|
|
|
|
|
Are there any reasons why you loading the assembly?
Have a look at my Plugin Manager article. It mite serve your purpose.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thank you very much,leppie.
|
|
|
|
|
Hello,
I'm recently implementing the drag and drop function of listview. I just need to drag-drop item inside listveiw, e.g, drag one item upper or lower.
However, my code didn't work so good, does any experts got this experience?
The main difficult part for me is to calulate the position of item. for example:
If I drag item 5 over item 3 and then release mouse, item 5 suppose will be placed at the location of item 3, and it works ,item 3 became item 4;
If I drag item 1 over item 3 and then release mouse, item 1 suppose will be placed at the location of item 3, but it always place at location of item 2.
I don't know how to solve it at all, hope someone can help me and show me the example code~~
Thank you
|
|
|
|
|
Simple. The DragOverEventArgs (for the DragOver event) contains an X and Y coordinate in screen coordinates. First, get the window coordinates by a simple translation:
Point p = myListView.PointToClient(new Point(args.X, args.Y)); Next, get the item at that point in the ListView and add the ListViewItem you're dragging below it.:
ListViewItem item = myListView.GetItemAt(p.X, p.Y);
if (item != null)
{
myListView.Items.Insert(item.Index + 1, draggedItem);
} Of course, getting the ListViewItem you're dragging is implementation-specific, and it appears you've already got that part figured out.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thanks for your reply, Stewart.
<small>Heath Stewart wrote:</small>
myListView.Items.Insert(item.Index + 1, draggedItem);
my codes are little same as that you provided,however, there is a problem that it will always insert the new item below the target item.
My code :
private void List_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
Point cp = List.PointToClient(new Point(e.X, e.Y));
ListViewItem dragToItem = List.GetItemAt(cp.X, cp.Y);
int num = List.SelectedItems.Count;
int locationIndex = dragToItem.Index;
for(int i=0; i<<num; i++)
{
ListViewItem dragItem = List.SelectedItems[i];
ListViewItem insertItem = (ListViewItem)dragItem.Clone();
List.Items.Insert(locationIndex, insertItem);
locationIndex++;
}
foreach(ListViewItem olditem in List.SelectedItems)
{
List.Items.Remove(olditem);
}
}
I felt some part of my code can be improved, but could you check what's worng with me?
|
|
|
|
|
For one, your for loop contains a bit-shift operator (<<) instead of a comparison operator (<). Other than that, while perhaps not the most efficient designer, it looks okay. Just step through it in the debugger and see what's going wrong. After all, good debugging skills is half the battle of good development.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Ops, that's just a typing mistake.
ok, I give up that,
now I hope to show a line between ListView items that reperesents the location of being insert.
e.g. if I dragged an item to item 5 location, the line shows between item 4 and 5.
Do you have any idea to do that?
Pls help, thank you~
|
|
|
|
|
You have to custom draw a line using the Graphics class between the two items (by centering a line between the bottom of one and the top of the other, such that a line would (normally) be 2 pixels wide - 1 pixel overlapping the bottom of the upper ListViewItem , and 1 pixel overlapping the top of the lower ListViewItem ).
You can get a reference to a Graphics object by either handling the Paint event and using several variables to track when you should draw a line and where, or (preferrably) you can do it by calling ListView.CreateGraphics (actually inheritted from Control.CreateGraphics ) to get the Graphics object and draw a line in the appropriate place. Just be sure to draw it uniformly. That is, make sure that you are consistent in where you draw it in relation to the insertion point.
I know there are several good articles on this subject (both with lists and trees) on CodeProject. You really should try searching for a solution here on CP.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey dudes,
I'm prepared to be shot down here, but...
Is it possible to add C# functions/files
into a C++ Project in Visual Studio .NET??
Any assistance would be
greatly appreciated.
SLY.
|
|
|
|
|
|
Thanks for the quick reply That should work great!
SLY.
|
|
|
|
|
|
hi, i'm totally flabberghasted by the event model, at least for what i want to do which is to copy the event delegate (as part of copying a template control).
the short story is, copying the event delegate works no problem from within the scope of the class which defines the event, but the compiler does not let you do it from outside the class-- similar to the behavior of a field marked "private", although the event is clearly public.
can anybody clue me into the rhyme or reason of this behavior? it presumably is related to the "non-field" implemplementations of events using add and remove, but i still don't understand why the support isnt there for me to determine how events were implemented in the class and clone them from one instance to another.
thanks in advance! here's the snippet:
<br />
public class Bar <br />
{<br />
public event EventHandler BarEvent; <br />
}<br />
<br />
public class Foo <br />
{<br />
public event EventHandler MyEvent; <br />
Foo foo; <br />
Bar bar, foobar; <br />
<br />
this.MyEvent = foo.MyEvent;
foo.MyEvent = this.MyEvent;
bar.BarEvent = foobar.BarEvent;
}<br />
|
|
|
|
|
You should check-out MSDN for this: http://msdn.microsoft.com/library/en-us/cpguide/html/cpconevents.asp[^]
Essentially, as is common in COM and other platforms as well, think of an event as a collection of delegates (managed function pointers). For this reason, you use incremental (+=) and decremental (-=) assignment operators like all the examples use in the .NET Framework SDK documentation.
You can't directly assign (=) your event handler to another class's event. That's why your getting the compiler error when you're doing it to another class and not your own (this). You should be doing it to your own event anyway. Events are actually based on MulticastDelegate derivatives, because when you use the delegate keyword, it will actually derive from MulticastDelegate . See the docs for details.
In comparison, you can use delegates as callback functions throughout your app, but events really aren't callbacks. As I said before, they're more like a collection of callbacks.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|