|
You can't prevent it from being fired so many times, but you could use a simple state variable to help performance and determine when the last event was fired over a period of time (using a timer, for example, a common approach to many such problems).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm having problems with another event:
how can I detect a doubleclick on a Shape?
How about a rightclick on a shape?
....
(Any help would be greatly appreciatted)
Thanks a lot
|
|
|
|
|
If these are not Control derivatives, then you have to implement the events yourself from their container. The container would receive these events and you'd have to use the MousePosition static property of a Control (and call PointToClient on that control with the coordinates from MousePosition since those are in screen coordinates). Using the returned Point you need to have a way to figure out which shape was clicked, and then cause it to fire it's own Click or DoubleClick events (which you'd have to implement) using the same timer concept I mentioned before.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Do you know how to obtain a shape's coordinated programmatically????
I can DROP a shape at particular coordinated, but not obtain a shapes coordinates....???
|
|
|
|
|
What I know is all from the object model documentation in MSDN Library. You should try reading it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I got it!
[CODE]
double iDropLocationX = myShape.get_Cells("PinX").get_Result(VisUnitCodes.visInches)+1;
double iDropLocationY = myShape.get_Cells("PinY").get_Result(VisUnitCodes.visInches)-0.5;
[/CODE]
|
|
|
|
|
Got another question, tho'
I am creating a method that receives two shapes and connects them programmatically.
How can I do that?
Is there any visio function that can draw that connection given the two shapes?
|
|
|
|
|
I'm using the methods Shape.SetBegin and Shape.SetEnd. But they don't seem to connect just fine.
|
|
|
|
|
This works:
Cell vsoCellGlueFromBegin = oShapeConnector.get_Cells("BeginX");
Cell vsoCellGlueFromEnd = oShapeConneor.get_Cells("EndX") ;
Cell vsoCellGlueToObject = oShape1.get_Cells("Connections.X");
Cell vsoCellGlueToObject2 = oShape2.get_Cells("Geometry1.X1");
vsoCellGlueFromBegin.GlueTo(vsoCellGlueToObject);
vsoCellGlueFromEnd.GlueTo(vsoCellGlueToObject2);
For whom it may concern.
|
|
|
|
|
This works:
Cell vsoCellGlueFromBegin = oShapeConnector.get_Cells("BeginX");
Cell vsoCellGlueFromEnd = oShapeConneor.get_Cells("EndX") ;
Cell vsoCellGlueToObject = oShape1.get_Cells("Connections.X1");
Cell vsoCellGlueToObject2 = oShape2.get_Cells("Connections.X1");
vsoCellGlueFromBegin.GlueTo(vsoCellGlueToObject);
vsoCellGlueFromEnd.GlueTo(vsoCellGlueToObject2);
For whom it may concern.
|
|
|
|
|
hi
i have problem in matrix determinant in 3d matrix so i want
to know how can i solve this programme of finding the
determinant in 3d matrix
bye
matrix determinant in 3*3d
|
|
|
|
|
|
Are you taking about a 3x3 matrix or a matrix of type 3x3x3? For that later you wuold have to approach the process through the Gram-Schmit Orthonormalization method. A google search reveals various articles on how to work with matrices of three dimensions.
|
|
|
|
|
I have a translation program called .net Framwork1.1. If it's running in .net Framwork 1.1, would there any error ocurr ?
does .net Framwoek is compatibled
study everyday
|
|
|
|
|
Uhhh....You have a what?
I take it you have a program written for the .NET Framework 1.1?
RageInTheMachine9532
|
|
|
|
|
The .NET Framework versions are both forward and backward compatible to a degree. If you use a new method (or whatever) introduced in a new version while running against an older version where that method (or whatever) isn't defined, you'll get an exception like a TypeLoadException . If you use an obsolete/deprecated method in an older framework that no longer exists in the newer framework, you'll get an exception (this is far less common, but still happens).
Read both Deploying Applications[^] and Configuring Applications[^] in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I have a xml-document and i place it in a datagrid with a dataset. One column is named "numbers". When i load the xml-document into the datagrid, the column looks like this 6,3,2,1,5,8 and when i press the column (the header) he arranges them nicely 1,2,3,5,6,8. But when i save the dataset (dataset.WriteXml(filepath)) and load it again nothing has changed, it's back to 6,3,2,1,5,8.
How can i save this?
thx in advance
|
|
|
|
|
The view of the data is changed, not the actual data (in reference to DataSet s and DataTable s, the DataView is what's changed).
If you need to sort your data, then you can use XPath navigation or XSLT transforms which makes sorting easy work.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
if i use the Xpath navigation, i should use XPathNavigator to select the nodes and XPathNodeIterator to walk through them? How do i move a node then?
|
|
|
|
|
Write them out as you iterate through them.
Personally, I'd use XSLT. You can easily write a template section that handles everything else and outputs it as-is while sorting the data you want using the sort element inside an apply-templates element. It certainly be a heck of a lot easier and would de-couple your code from sorting the XML data so that you could always transform it differently later by changing the XSLT document.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i'm trying to do what you said but i'm really new to this so it takes a while to make it. Now i have my xml file and i have a xsl file that looks like this:
<xsl:stylesheet version="1.0">
<xsl:output method="text"/>
<xsl:template match="libraries">
<xsl:apply-templates>
<xsl:sort select="loadorder"/>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
is this any good? how do i call this now in c#?
thx in advance
|
|
|
|
|
i think i got it
XslTransform test = new XslTransform();<br />
test.Load(@"c:\xslt.xsl");<br />
test.Transform(@"c:\file",@"c:\file2");
if forgot to say that it's not possible to just have a xsl-file because my program has to work on different computers
|
|
|
|
|
The XSLT Transform is handled completely by the .NET Framework so it will work on different computers, you just need to either use a file that you deploy with your application - using it from the Application.StartupPath or something - or embed it as a resource, get the stream using Assembly.GetManifestResourceStream , and load a Stream into both your XmlDocument (or XmlDataDocument , which works hand-in-hand with a DataSet nicely) and your XslTransform and then transform it using an appropriate Transform method. Note, the method you're currently using (with those parameters) is obsolete in .NET 1.1, so I suggest you see the documentation for the Transform Method[^] in the .NET Framework SDK for more information. If you use non-obsolete classes, members, etc. in your 1.0 application, it could be made to run under .NET 1.1 if 1.0 was not installed on a client machine.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i'm doing it now like this:
string xsl = "<xsl:stylesheet version=\"1.0\">" + "<xsl:output method=\"text\"/> " +
"<xsl:template match=\"//libraries\"> " +
" <xsl:apply-templates>"+
"<xsl:sort select=\"//loadorder\"/>"+
"</xsl:apply-templates>"+
"</xsl:template>"+
"</xsl:stylesheet>";
StreamWriter sw = File.CreateText(@"c:\xslt.xsl");
sw.WriteLine(xsl);
sw.Close();
XslTransform test = new XslTransform();
test.Load(@"c:\xslt.xsl");
test.Transform(@"c:\sessions.conf.xml",@"c:\sorted.xml");
but i'm getting a error (on the transform):
An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll
Additional information: System error.
|
|
|
|
|
You didn't declare the XML namespace for the "xsl" prefix in your stylesheet.
Also - like I mentioned - you don't need to save your XSLT to a file. You can save it to a stream and not have to worry about access permissions (the user may not be able to write files to the C:\ directory - besides, you should actually use Path.GetTempPath to get the user's TEMP directory).
It is better to create your XSLT as part of your application (as a project file) and set the Build Action to "Embedded Resource"). Then you only need to do something like this:
using (Stream s =
this.GetType().Assembly.GetManifestResourceStream("MyRootNamespace.File.xslt"))
{
if (s != null)
{
XslTransform xsl = new XslTransform();
xsl.Load(s);
XmlDocument xml = new XmlDocument();
xml.Load();
xsl.Transform(xml, Path.Combine(Path.GetTempPath(), "Output.xml"));
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|