|
While you are waiting for someone to more completely answer your query, I would suggest that you research (MSDN and GOOGLE) the InvokeRequired property.
This is a fundamental part of the solution and there are examples aplenty, which should at least get you thinking in the right areas.
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.”
|
|
|
|
|
thanks
but it is not really going to work. my form again goes to 'not responding'. why?
modified on Tuesday, April 21, 2009 3:44 PM
|
|
|
|
|
I've constructed a very simple sample using a System.Timers.Timer as it runs on a seperate thread. You should be able to figure it out from this.
[Edit] Changed the sample code to show how to call a method with parameters. [/Edit]
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
System.Timers.Timer timer;
public Form1()
{
InitializeComponent();
timer = new System.Timers.Timer();
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Start();
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (this.InvokeRequired)
{
BeginInvoke(new MethodInvoker(delegate() { UpdateText(sender, e); }));
}
else
{
UpdateText(sender, e);
}
}
private void UpdateText(object sender, System.Timers.ElapsedEventArgs e)
{
Text = e.SignalTime.ToString();
}
}
}
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 Tuesday, April 21, 2009 4:50 PM
|
|
|
|
|
Hello Everyone-
I have been programming with C# building database applications for a year or so. I have a new side project that I am working on and quite frankly, I don't know where to start! (I can't even figure out what to type in to google!) What I am looking for is a starting point to get me going in the right direction.
I am trying to build an application that will utilize a camera, take a picture of a table with a predefined (green) background, and calculate the square footage of the piece of stone that is laid on it. Interfacing with the camera is no problem, I can tell the camera to snap pictures and access them.
I want to then open up this image that the camera took and analyze it. The table will be painted green (or white or orange). The stone will be laid on top, so for the sake of this message lets say its a piece of stone on a pure white table. I want to analyze that image and figure out the area (square footage) of that piece of stone. I know that I can do the mathematical calculations based on how far the away the camera is from the table, but I'm not sure how to open up an image and read that image, and tell the area of "space that is not white". If anyone could point me in the right direction I would really appreciate it!
Thanks so much in advance!
|
|
|
|
|
Take a look at Range Finder[^] article. recently published here on CP.
Find the range of the four corners, a bit of trig and Bob's your uncle.
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.”
|
|
|
|
|
First you have to figure out what format the picture was taken in. If it's RAW or BMP, then you've got nice little bytes of information for each rgb value of each pixel. If it was JPEG, then you've got to decompress it to get the pixel values.
I think it might help to search for the term "threshold" in regards to picture analysis. It is basically getting rid of the colors that you don't want.
Another way to find areas of the same color, since your data is basically a matrix, is to treat the column number as "x", treat the RGB value as "y", then find the change in y as x increases, along the row (aka a derivative). Then you've got an array of 0's for filled in areas of the same color, and enormous values at the border zones, and you can fill in your shape w/ whatever geometry you want to get the area.
Or, if this is a long term project, you could check out Activision Tools or Euresys E-Vision. They already do this all this and much more.
|
|
|
|
|
Here are my requirements:
1) A PDF viewer that is embedded in a window in my windows app.
2) I must be able to reference button_click events in the PDF from my windows app. (i.e. if i click a button in the PDF, the event occurs in my windows app.
Pertaining to the above requirements:
Here is what I've noticed so far. The Adobe Reader ActiveX works great at simply viewing PDF's and the buttons are shown too. However, I haven't found anything in the Reader library that allows me to reference the buttons in the PDF. This leaves the following questions.
Possible Solutions: (need your help/recommendations)
1) Can I use the Acrobat SDK to reference the document that is open inside my Adobe Reader ActiveX control? (If I can, then i can get a hold of my buttons and events). If I can do this, does anyone have any clue about the proper syntax? All of the the samples I've seen actually reference a document that acrobat opens, not the reader....
2) Can I embed the Adobe Acrobat (not the reader) in my windows app in order to view the files? I haven't seen this done yet. Every example I've seen opens the acrobat in it's own window!!!
3) Is there other software out there that offers both functionalities: 1) Embedded viewing window with 2) Full access to PDF library?
Any help in this matter would be greatly appreciated, as I have searched High, Low, and In Between for a solution.
Thanks,
jpc
|
|
|
|
|
Hi again,
I wonder if there is any possibility to accomplish the following:
A GUI has a button with attached eventhadler (button_click).
In this eventhandler, there shall be called a function, that gathers some information. The information iInfo shall be returned like
int iInfo = gatherSomeInfo();
to the eventhandler button_click in the GUI.
Here is the Problem: The gatherSomeInfo() function needs eventhandling to collect all information. So I have to leave the gatherSomeInfo() function before knowing what to return and loosing the ability to send the needed information back (as return value). It is not possible to collect all information and immediatly return from this gatherSomeInfo() function back to the eventhandler in the GUI.
The gatherSomeInfo() Function is hooked into another event (of another thread in fact) that finally signals the info. From that moment on I could send a return value but I don't know how.
The function call of gatherSomeInfo() within the button_click eventhandler would block the further execution (if waiting for return value) until the return is done but that would exactly be what I need for this procedure.
How can I do this??? I can't believe that there is no way to do that. Can anyone help please???
|
|
|
|
|
What you need is an asynchronous event. Have a look at my article here[^] or google with that search term.
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 all
I have an xml document created from a treeview. I want to delete a node from xml (and treeview at the same of course)
Here is my codes:
treeView1.Nodes.Remove(treeView1.SelectedNode);
XmlNode t=dom.SelectSingleNode(treeView1.SelectedNode.Text);
t.ParentNode.RemoveChild(t);
dom.Save("test.Xml"); //this is where program fails it gives the message "invalid xml document"
Can anyone help?
|
|
|
|
|
Your treeview text is an xpath to the node ? I doubt that, and suspect that you're erasing the entire document. Did you look in the debugger to see what t is, what gets returned and what the dom XML is when you save ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi, is there a way to list the contents of constants?
ie. is there a function ConstantCollection() (see below) or something similar?
class Test()
{
const string c1="blah1";
const string c2="blah2";
const string c3="blah3";
const string c4="blah4";
void Print()
{
foreach(object Constant in <code>ConstantCollection(this)</code>)Debug.Print(Constant.Contents);
}
}
Output:
blah1
blah2
blah3
blah4
Ariadne
|
|
|
|
|
Not that I know of, although if the constants are all of the same type then you could use an enum instead.
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)
|
|
|
|
|
That won't work in this case - enum values cannot be strings.
|
|
|
|
|
But it is possible to attach strings to enums using the Description attribute.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am an idiot! Provided the consts are single words, you can use them in an enum and use the names as const strings.
enum sample
{
Hello = 0,
There,
Last
}
static void Main(string[] args)
{
for (sample t = 0; t < sample.Last; t++)
{
Console.WriteLine(t);
}
Console.WriteLine("---");
}
I think I'd rather define a class to hold my const strings and use a method to iterrate, though.
|
|
|
|
|
Using reflection:
List<string> list = new List<string>();
FieldInfo[] fis = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
foreach (FieldInfo fi in fis)
{
if (fi.IsLiteral && !fi.IsInitOnly)
list.Add(fi.Name);
}
return list;
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks Pete,
that's what I'm looking for. It works fine.
Ariadne
|
|
|
|
|
HI,
I'm not sure if exist something like ConstantCollection, but this works for me (VB.net):
Firts a simple class:
Public Class Class1
Public Const c1 As String = "c1"
Public Const c2 As String = "c2"
Const c3 As String = "c3"
Dim var1 As String
Public var2 As String
Public Enum myEnum
value1
value2
End Enum
End Class
For Each field As FieldInfo In getConstants(GetType(Class1))
Console.WriteLine(field.Name)
Next
Private Function getConstants(ByVal pType As System.Type) As List(Of System.Reflection.FieldInfo)
Dim fis() As FieldInfo
Dim result As New List(Of System.Reflection.FieldInfo)
fis = pType.GetFields()
For Each fi As FieldInfo In fis
If fi.IsLiteral And Not fi.IsInitOnly Then
result.Add(fi)
End If
Next
Return result
End Function
This returns:
c1
c2
The constants must be declared public.
RolCr.
|
|
|
|
|
Hi,
I'm accessing files from remote PC (basically in from different domain) in Windows Service. During debug (when i put break point and debug through line by line) it goes well, but in deployment mode it throws following error
"Bad user name or password"
How to fix this?
Thanks
|
|
|
|
|
Hi,
Verifie the "Log on" Tab for the service, which account are you using?
|
|
|
|
|
Hi
im trying to implement a calendar interface in my C# application but im not sure what the best way to draw the calendar is - i had a look at the form controls in visual C# 2005 and thought the datagridview might be a good start then populate it with events from an Xml file
Another possible solution would be google calender but i couldnt find any help with drawing google calender in C# application and thier tutorial was about adding and manipultaing events using .NET cliet libraries.
Does anyone have any ideas for this? i would appreciate any help
Cheers
|
|
|
|
|
The DateTimePicker control does it all for you presuming your working with WinForms and not WebForms.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for the reply, Rob. this is not what i im looking for though. i want to draw a calendar for a schedule and to have the days of the week displayed vertically and the time horizontally (similar to school timetable format) and then to populate this with shifts created in the program.
|
|
|
|
|
Personally I would handle the paint event for a panel and draw with the Graphics class, that way I can make it look anyway I want it to
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|