|
Hi,
yes it is big, and that was just the one abstract class...
my first impression is you create a lot of matrix objects, and you try to do
all the transformations (translation, rotation) yourself.
So it is my guess your app is repainting fine (e.g. when resizing the form),
but is slow when changing a shape (moving/rotating/whatever).
For one, I would give each shape one instance of Matrix, and Reset it when a new
matrix is needed, rather than creating matrix instances all the time.
But overall I think I would do it all differently: have each shape remember
its properties (size, color, whatever) and also its translation and rotation,
then use the transformations offered by Graphics in the paint handler itself.
As a result:
1) methods such as Move() would become very simple, they just accumulate translation,
but dont modify all the coordinates.
2) method draw() for one shape becomes something like:
g.ScaleTransform(...);
g.TranslateTransform(...);
g.RotateTransform(...);
NowDrawTheOriginalShape();
I realize this is quite a change from what you have, and I would suggest you
perform some small experiment before changing everything...
As a last thought, you may want to try repainting only the part of your drawing
that has changed, by using Control.Invalidate(Rectangle/Region).
|
|
|
|
|
I understand your idea that create the transformation status in each shape instance, for example:
float _scaleOffsetX;<br />
float _scaleOffsetY;<br />
float _rotateAngle;<br />
float _movingOffsetX;<br />
float _movingOffsetY;
and then use this information to draw the shape.
But did you notice my _border field? It is the bound of the shape. Client will use it to determine the shape's position and size, so it has to change when any transformation of the shape has done. The problem is when you rotate the shape, you have to re-calculate the _border again and of course its not accuracy.
I know you and I is so close to the final solution, but it's still the gap...
I will think about your solution more carefully.
|
|
|
|
|
Yes, you are right you need the final coordinates to support shape selection...
I have to think about this.
Can you confirm my assumption: "So it is my guess your app is repainting fine
(e.g. when resizing the form), but is slow when changing a shape (moving/rotating/whatever)."
Can you give a quantization on "slow drawing" ? And how many shapes are involved then ?
Please also show the draw method for a simple specific shape.
I am particularly interested in how you repaint (or let the system repaint) your
drawing.
|
|
|
|
|
Yes, its fast drawing, but not as fast as Word does. I just use and old-fashion double-buffer drawing techique.
For object moving, I use GDI rubberband line and curve to draw. It not good for now, fast on drawing rectangle, but for ellipse, I have to flatten the graphics path, so it's extremly slow when drawing moving ellipse.
I will show you the code (or even send mail to you all the source code) the next Monday, because I don't bring code to home and today is Saturday
Anyway, do you interest of building a canvas component that can draw and transform shapes, group shapes, support zooming, ect or know any body experienced about this?...... I'm stuck on this now because I working alone
|
|
|
|
|
How can I set enable true on Named Pipe using C# code?
Regards.
I Love SQL
|
|
|
|
|
Hi,
Its awesome really fantastic but it would be much better if we hide all the replies of a perticular query until one clicks on the respective query (as of tree view model) and at a time one can able to view only one replay, is it possible to view other replies opend at a time and more over if i click on the parent query then all the opend childs should be closed.
Please suggest me some ideas to implement the changes
very urgent ....
|
|
|
|
|
What on earth are you talking about ? Does this relate to a previous question ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: What on earth are you talking about ? Does this relate to a previous question ?
Probably this one[^] - But it still won't make any sense.
|
|
|
|
|
Wow...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
That's awesomely fantastic that is.
Can anyone decipher this?
|
|
|
|
|
1. Don't multiple post.
2. What are you smoking?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All,
I am sure the solution to this is *Really* easy, but i've been staring at it for a while now and have got nowhere. I've written the test below in both C# and VB and both do the same thing.
I need to use an XmlReader object to read in an xml document. Note that it is essential that i use an XmlReader object as I need to perform schema validation. The code below does not incluse schema validation as as this stage i'm just trying to get an xml file into an XmlReader.
Looking in the msdn and a range of examples in google i should be able to get an XmlReader object containing my xml document by using XmlReader.Create(TextReader o). Everything is working right up until that step, but using the debug tools my XmlReader object appears to remain content-less. Here's the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
namespace XmlTest
{
class Program
{
static void Main(string[] args)
{
String file = "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\web.config";
XmlDocument doc = new XmlDocument();
doc.Load(new System.IO.StreamReader(file));
String docString = doc.OuterXml;
TextReader tr = new StringReader(docString);
XmlReader xr = XmlReader.Create(tr);
System.Console.ReadKey();
}
}
}
So we're loading in an xml file, putting it into an XmlDocument and getting the Xml as a string out of it. This is because ultimately when i slot this work back into what i'm doing i'll be obtaining the xml document via a string.
A TextReader object is then created from the string via a StringReader. If i debug the code i can see the document correctly loaded into the TextReader (tr) in it's entirity. It just doesn't seem to be converted into an XmlReader object via XmlReader.Create(tr).
Similarly, if i replace XmlReader.Create(tr) with XmlReader.Create(new System.IO.StreamReader(file)) I have the same problem, proving it's none of the logic inbetween that is messing things up.
What am i missing about XmlReader? Please help if you can, this is driving me absolutely nuts. When i look at it in debug the object has a depth of zero and looking in items i see "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user." I have no idea what this means and google doesn't help.
You should be able to copy and paste the code and replicate the issue easily.
Many thanks,
Rolf
|
|
|
|
|
It's morning, but, try use some method of XmlReader starting with "Read"
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Tried that.
Using the ReadInnerXml and ReadOuterXml i get nothing.
Interestingly if i pass the XmlReader to an XmlDocument.load method and then inspect the XmlDocument, i see my xml is in there. But why can't i see it in the XmlReader object anywhere? Using both read methods and inspecting the object via 'watch' yields nothing.
|
|
|
|
|
Rolf Baxter wrote: Using the ReadInnerXml and ReadOuterXml i get nothing.
But these read content of current node. To move on node, use Read() method. Check out example[^].
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hi,
Its awesome really fantastic but it would be much better if we hide all the replies of a perticular query until one clicks on the respective query (as of tree view model) and at a time one can able to view only one replay, is it possible to view other replies opend at a time and more over if i click on the parent query then all the opend childs should be closed.
Please suggest me some ideas to implement the changes
very urgent ....
santy
|
|
|
|
|
s a n t o s h wrote: Its awesome really fantastic but...
What is?
|
|
|
|
|
blackjack2150 wrote: s a n t o s h wrote:
Its awesome really fantastic but...
What is
I'm glad it wasn't just me who was thinking that.
|
|
|
|
|
Hope to use C# for ActiveX in Excel VBA. Success to call as COM, but fail to add the control from "Control Toolbox" as ActiveX
I want to use C# for ActiveX in Excel, but fail to add the control from "Control Toolbox".
I have write a COM object using C#, and I can call those function in Excel VBA normally.
But when I try to change it as a ActiveX, I fail.
The Excel can detect my COM object as a ActiveX, that means it can show in the "Control Toolbox".
Once I select it, and try to put it in the Excel, it show me a dialog box said "Cannot insert object".
I have read the following link about the error message, but for my ActiveX in C# do not have the .odl file.
http://support.microsoft.com/default.aspx/kb/171280/
Can any one give me some hints?
|
|
|
|
|
Hi.
My app can be started with different command line parameters. Some of these may represent date values. So what I do is convert the string taken from the command line into a DateTime object using the Convert.ToDateTime() method.
What format should the string resemble in order to be sure that the conversion is ALWAYS possible and successful REGARDLESS of the local/language settings of the machine that runs the program?
Thank you.
|
|
|
|
|
blackjack2150 wrote: What format should the string resemble in order to be sure that the conversion is ALWAYS possible and successful REGARDLESS of the local/language settings of the machine that runs the program?
You can pass IFormatProvider as second argument of Convert.ToDateTime . Convert will then parse string according to that format, regardless of local settings.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
By telling the user what format to use
Some examples from DOS:
XCOPY
/D:m-d-y Copies files changed on or after the specified date.
SCHTASKS /CREATE
/SD startdate Specifies the first date on which the
task runs. The format is
"yyyy/mm/dd".
And of course you should require an ISO 8601-compliant format, like "YYYY-MM-DD".
|
|
|
|
|
blackjack2150 wrote: What format should the string resemble in order to be sure that the conversion is ALWAYS possible and successful REGARDLESS of the local/language settings of the machine that runs the program
You would want to use one of the ISO 8601 formats. If you just need the date portion it should be YYYY-MM-DD or YYYYMMDD . If you need the time portion as well it should be YYYY-MM-DDTHH:MM:SS or YYYYMMDDTHHMMSS (where T is the literal character "T").
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Dear Gurus,
Does enyone know how I can set Image dynamically to my Button Background and delete that image from my PC?
I use Image.FromFile(@"C:\myImage.png") in my
When I try to delete image Error message apears "File used by another programm".
Thanks.
Vas
|
|
|
|
|
Opening an image from a file, locks the file. If you copy that image to a new image, dispose of the old one, then you can delete it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|