|
yes, if you want.
I have been developed an automation that controls many device for telecoms with some GUI.
Since always, I used the protocol series for the communication but recently, Ethernet connection is available and allows more control that a serialport(depends on speed d'exécution, the lenght of the datas) and allows also a profit in serialport connections with the servers connected to the system.
Best Regards
youssef
|
|
|
|
|
I'm looking to try and dock two Forms together side by side, basically each form can have its own dimensions. But they should move together when dragged. Can I get a shove in the right direction from anyone ?
|
|
|
|
|
Extend Form and override OnLocationChanged . Also add a property to the class of type Form that you set the Form to be docked.
In your implementation, get the Location of each Form (don't forget to check for null before accessing the other Form ). Some simple math will tell you which side the other Form is in relation to this . If the Left + Width of the other form is, for example, within a certain threshhold of your current Form , then adjust the Location * of the other Form in relation to your current Form.Location .
* Don't forget that since Location (a Point ) is a value type, you must create a new Point and set the Location . Setting Form.Location.X and/or Form.Location.Y will not move the other Form .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Great info Heath, thanks once again...
One last follow-up....how should I go about handling the z-order of the two forms, will one always be active and the other not ? Is it possible to have both windows active at the same time ? Didn't know if you had any tricks up your sleave for making both Forms active at the same time...If not then I think I have all the info I need...
Thanks Again
|
|
|
|
|
Only 1 form can be active at any one time. You could set the z-zorder of one of the forms to be on top and the other form to be directly 'behind' it in the z-order. When you switch the active forms, you can switch the zorder so the form you just left is directly behind the form you just activated.
This may seem stupid to implement because the form that loses focus just drops to the #2 place behind the form/app that gets the focus, but it makes more sense when you click on a different app to bring it to the top of the z-order, then click one of your forms. I think your find that the z-order will become your active form at the top, then the application you just left, the your second form in the #3 spot.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I figured as much, thanks for your reply too.
|
|
|
|
|
Also, if one of these forms acts as the "main" form, you could use Form.AddOwnedForm and pass your "child" forms. This way, each form can be active (only 1 at a time) but they will have a z-order in relation to other processes. So all your applications forms will be over or under other processes. Owned forms will also overlap the "main" form and will be closed when your "main" form is closed.
See the .NET Framework SDK documentation for Form.AddOwnedForm for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well I've implemented the changes you have suggested and the docking form works fine. However when the form is enlarged and then the large window is moved the movement becomes very jerky. I'm wondering if the movement of both forms is too much for the single thread. So now I'm attempting to multi-thread the app. I'd like to create the main form in one thread and the docked form in a second. However I'm running into a logistical problem where the second thread that creates the Docking form goes out of scope and terminates.
The following code is where I create the second thread.
private void FavWinThread()
{
this.ShowFavWin=true;
frmFav = new frmFavorites(this);
while(!frmFav.WinReady)
Thread.Sleep(10);
frmFav.Show();
}
if(frmFav==null)
{
FavThread = new Thread(new ThreadStart(FavWinThread));
FavThread.Start();
}
I assume I'm creating the thread in the wrong place or I'm not maintaining the thread correctly ? Perhaps someone could give me a suggestion ? Any insight would be appreciated.
|
|
|
|
|
First, you need to make sure that the variable does not go out of scope and that you have a message pump attached to the Form , otherwise it will be closed when the thread terminates (FYI, Application.Run does this with your main form). The easiest way is to call Form.ShowDialog , but don't forget to dispose the form (i.e., call Dispose ) when ShowDialog returns and (if you need to) you get all information from it before disposing it. There are other ways, and reading through the System.Windows.Forms namespace in the .NET Framework SDK at some of the more obscure classes should help if you have experience with native Win32 programming with Windows APIs.
One thing to keep in mind is that you will need to use Control.Invoke to communicate between to controls (i.e., Form s) created on different threads. Also, controls created on different threads cannot be hosted in the same container (which doesn't apply here, but I thought I'd mention it anyway).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ShowDialog() did the trick, but the jerky movement is still there. Again, the movement only slows down when the docking form's size in increased. Any thoughts as to a solution ? I know my question is quite vague, but I'm hoping you might have run into this problem before. Thanks again for all your help.
|
|
|
|
|
There's probably better ways to implement this, but I just threw out one idea. You could explore others using Windows messaging, thereby foregoing the .NET event system which would probably boost performance. I'm sure there's also a few examples out there. You could try to google for them or search http://www.sourceforge.net[^] or something.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi:
Does anyone have a sample onscreen keyboard app in c#?..
Thanks
|
|
|
|
|
Hi,
I incorporated a PLK for my VSPackage. I followed the exact instructions for the PLK implementation as mentioned in the VSIP help (including registering it in the registry). I also verified the PLK info.
When I attempt to run the package (by running project in debug mode – F5, using /noVSIP switch), it gives me an error message “Package XX has failed to load properly…”. Half the time the spawned app just goes blank and hangs and does not even give the pakage load failure message.
However, it does not give any clue as to why the package load failed or what the problem is. Is there any way (any log or anything else) in which I can find out why the package is not loading properly? It does not even produce any trace messages to indicate till what point the load went through.
When I run the app in debug mode (using F5) but without the /noVSIP switch, it runs fine and I can trace through it.
Any help will be greatly appreciated.
Thanks.
|
|
|
|
|
Anyone know how to initiate a file copy and display the progress of said copy?
I can't figure out how to use the CopyFileEx API and it's callback. That's the only way I've seen to do this.
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
you can open the file manually get the size and copy it in set sized buffers to another file you created, using a progress bar to show the progress.
|
|
|
|
|
It is the only way, unless you want to write your own file copy class with a dialog that shows progress.
Post the code that your using, including the DllImport, to call the function so we can figure out what your doing wrong. You don't need to supply a callback to the function. If you don't supply one (pass in null in that parameter), the CopyFileEx function will display it's own progress dialog.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, thats exactly what i figured out i few days before. I developed a filebrowser. And it also contains a dialog for copying files and it shows the progress. Look to class copydialog of the file clipboard.cs.
Download from www.slenders.be
It also contains examples for moving files, copying folders, etc.
Just take a look
Jonathan Slenders
|
|
|
|
|
I'm having some problems getting wsdl.exe to run (properly) on some wsdls that I have. I am trying to create a client using C# that uses these webservices that someone else created. I think the problem I am having has to do with the webservices were created using Java and the standard they use for WSDLs are a little different from the standards microsoft uses. Does anyone know of a converter that will take a Sun/IBM WSDL and convert it to a WSDL that microsoft can use?
Thanks for your help.
|
|
|
|
|
I have a question about how to get certain data from my dataset. I am trying to get rows from one table that have certain child relations to appear.
I have a table called stories. The table stories has 5 child relations. One relation goes to each table. One table, called categories, is a child of stories. The categories table has three columns.
1. id int
2. storyid string
3. catid int
id is just a sequential number as the primary key of the table. storyid is the number of the id of the story this entry in the category table belongs to. catid is a number that corresponds to a entry in the categoryinfo table.
So my idea is to select certain stories that have a given catid. So, for example, say I want to see all the stories that have 5 as a catid. What I am trying to do now is to use the select method available to tables. So the few lines of code are this:
//Notitia is the name of the class for the typeddataset I use.
storiesfiltered = new Notitia.StoriesDataTable();
string fil = "Child(storiescategories).catid = 5";
DataRow[] drows = stories.Select( fil );
foreach( DataRow row in drows )
{
storiesfiltered.ImportRow( row );
}
However, whenever I run this code i get an error at the stories.select line and the error says "Cannot interpret token 'Child' at position 1." I'm not sure why I get this error. I checked msdn about expressions and that is how it told me to write expressions involving relations to child tables.
If anyone has any ideas why that doesn't work or another way to do it I would appreciate the help. Thanks.
Paul Rogero
|
|
|
|
|
Create a typed DataSet using VS.NET and create relationships between the tables. You can access these relationships in code using the DataRelation . You specify this DataRelation using DataRow.GetChildRows . This is much faster and less prone to error than using just DataTable.Select .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hi,
I am getting a root element is missing when I try to read in the xml diffram from file. Also one key note I am using the compact framework which doesn't support Typed datasets.
Heres the code that I am trying out:
<br />
<br />
public static DataSet GetMyXmlDS(string sXmlFileName, string sPath ) <br />
{<br />
string sFileName = sPath + @"\MidnightData.xml";<br />
string sFileName2 = sPath + @"\MidnightRead2.xsd";<br />
<br />
<br />
DataSet IpacDS = new DataSet("Table1");<br />
<br />
try<br />
{<br />
<br />
SqlConnection myCon = new SqlConnection();<br />
myCon.ConnectionString = sCon1;<br />
SqlDataAdapter da = new SqlDataAdapter(@"Select * From MidnightReadings WHERE MR_Date = '12/1/2003'", myCon);<br />
<br />
da.Fill(IpacDS);<br />
<br />
FileStream myFileStream = new System.IO.FileStream<br />
(sFileName, FileMode.OpenOrCreate);<br />
<br />
XmlTextWriter myXmlWriter = <br />
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);<br />
<br />
IpacDS.WriteXml(myXmlWriter, XmlWriteMode.DiffGram);<br />
IpacDS.WriteXmlSchema(sFileName2);<br />
<br />
<br />
XmlTextReader myXmlTextRead = <br />
new System.Xml.XmlTextReader(myFileStream);<br />
<br />
<br />
IpacDS.ReadXml(myXmlTextRead);<br />
<br />
return IpacDS;<br />
<br />
}<br />
catch (SqlException e) <br />
{<br />
string errorMessage = "Message: " + e.Message + "\n" +<br />
"Source: " + e.Source + "\n" +<br />
"State: " + e.State + "\n" +<br />
"Procedure: " + e.Procedure + "\n";<br />
MessageBox.Show(errorMessage,"Error in DataCon");<br />
<br />
return IpacDS;<br />
}<br />
catch (XmlException xe) <br />
{<br />
string errorMessage = "Message: " + xe.Message + "\n" ;<br />
MessageBox.Show(errorMessage,"Error in DataCon");<br />
<br />
return IpacDS;<br />
} <br />
<br />
}<br />
<br />
Xml dataset :
<br />
<br />
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><br />
<Table1><Table diffgr:id="Table1" msdata:rowOrder="0"><br />
<MR_ID>110</MR_ID><br />
<MR_Date>2003-12-01T00:00:00.0000000-05:00</MR_Date><br />
<Coal_Feeder_Tot>690058</Coal_Feeder_Tot><br />
<Coal_Silo_Level_Prct>73</Coal_Silo_Level_Prct><br />
<Coal_Barn_Inv_Prct>25</Coal_Barn_Inv_Prct><br />
<Limestone_Feed_Total>171316</Limestone_Feed_Total><br />
<LS_Silo_Level_Prct>70</LS_Silo_Level_Prct><br />
<Ammonia_Totalizer>388974</Ammonia_Totalizer><br />
<Prop_to_Burn_Totalizer>14629</Prop_to_Burn_Totalizer><br />
<TwentyFourHr_SO2_Reduct>92</TwentyFourHr_SO2_Reduct><br />
<Limestone_Received>40800.37</Limestone_Received><br />
<Ammonia_Received>0</Ammonia_Received><br />
<Prop_Received>9004</Prop_Received><br />
<Est_hours_Dry_Oper_Hours>0</Est_hours_Dry_Oper_Hours><br />
<LAB_Sulfur_Content_Prct>2.13</LAB_Sulfur_Content_Prct><br />
<LAB_High_Heat_Val>6833</LAB_High_Heat_Val><br />
<CEMS_SO2_Daily_Avg>549</CEMS_SO2_Daily_Avg><br />
<Raw_Water_Pump_Meter>15795967</Raw_Water_Pump_Meter><br />
<Reservoir_Level>1844</Reservoir_Level><br />
<Date_Rec_Added>2003-12-08T08:47:15.0000000-05:00</Date_Rec_Added><br />
</Table></Table1><br />
</diffgr:diffgram><br />
<br />
Now what gets me is that as you can see in the code. I am writing the dataset to file and a schema to file. Then I turn right around and try reading it in but fails on the ReadXML statement. I have tried reading in the Schema file into dataset first and then without reading in schema. Any ideas?
Thanks,
JJ
|
|
|
|
|
You might want to Flush and Close the XMLTextWriter before you turn around and try and read the file it wrote. You'll have to reopen the FileStream for Read after you do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What is the easiest what to load 4000 rows into a SQLSever db from a C# program? The C# rows are in an ArrayList. And the "scheme" is very simple
[string, date, decimal, decimal, integer].
I’m looping threw the array, right now, and doing an insert for each row but I’m wondering if there is some way I can do this in bulk? I think BCP would be overkill in this case, so, I'm just wondering if there is something in ADO.NET that might handle a "large" number if inserts.
|
|
|
|
|
BCP would definitely be the best way. You could write out the file and execute BCP on it.
You could also use parameters inserts. Construct your SqlCommand with parameters for the fields. When enumerating over your ArrayList , set the SqlParameter.Value for each field and call SqlCommand.ExecuteNonQuery . BCP will probably be faster, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|