TheSwamp

Code Red => .NET => Topic started by: T.Willey on February 27, 2007, 04:14:05 PM

Title: Open drawing from listview
Post by: T.Willey on February 27, 2007, 04:14:05 PM
I'm trying to open up drawings from a list view.  I close the dialog, and then try to open them.  The drawing name gets passed, as I put in a message box to show this, but it keeps erroring out.  I'm have looked and tried many things, and none seem to work.  Any help is appreciated.

Here is the code I'm using.
Code: [Select]
void Button1Click(object sender, System.EventArgs e)
{
Close();
bool IsModel;
DocumentCollection DocCol = AcadApp.DocumentManager;
foreach (ListViewItem lvi in listView1.Items) {
ListViewItem.ListViewSubItemCollection lvsic = lvi.SubItems;
if (lvsic.Count > 1) {
try {
MessageBox.Show(lvsic[0].Text);
//Document tempDoc = DocCol.Open(lvsic[0].Text, true);
Document tempDoc = DocCol.Add(lvsic[0].Text);
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
StdScaleType ScaleType = (StdScaleType) Enum.Parse(typeof(StdScaleType), lvsic[4].Text, false);
MyPlottingPart(lvsic[1].Text, lvsic[2].Text, lvsic[3].Text, ScaleType, IsModel);
}
catch (System.Exception ex){
MessageBox.Show(ex.ToString());
}
}
}
}
Here are the picks of the two errors.
Title: Re: Open drawing from listview
Post by: Kerry on February 27, 2007, 04:35:34 PM
Whats on line 380 and 381 ??

What is your CommandMethod declaration ?


Title: Re: Open drawing from listview
Post by: T.Willey on February 27, 2007, 05:01:26 PM
Whats on line 380 and 381 ??

What is your CommandMethod declaration ?



Those are the two different calls to try and open a document.  I made it a session command.
Title: Re: Open drawing from listview
Post by: Alexander Rivilis on February 27, 2007, 05:48:15 PM
DocumentCollection.Open(dwgfileName) does not work when a modal dialog box is loaded (http://discussion.autodesk.com/thread.jspa?messageID=5463695)
Title: Re: Open drawing from listview
Post by: T.Willey on February 27, 2007, 05:59:25 PM
DocumentCollection.Open(dwgfileName) does not work when a modal dialog box is loaded (http://discussion.autodesk.com/thread.jspa?messageID=5463695)
Thank Alexander.  I saw that, but hoped something new has been found out.  So how would I do this?

I'm guessing that I would make an array of all the objects in the listview, then close the dialog, and then procress the array.  I will see what I can come up with.  Do I have to unload the dialog?  not just close it?

Off to do some more research.  :-)
Title: Re: Open drawing from listview
Post by: Glenn R on February 27, 2007, 06:07:57 PM
I see you've been inspired by my Script Writer thread piccy there Tim.

Something along these lines:

Code: [Select]
string [] drgs;
using (MyDlg dlg = new MyDlg())
{
    // Show dialog here
    drgs = dlg.SomeMethodToGetDrgs();
}
// Process drgs here...

Cheers,
Glenn.
Title: Re: Open drawing from listview
Post by: T.Willey on February 27, 2007, 06:47:01 PM
I see you've been inspired by my Script Writer thread piccy there Tim.
I likey you're piccy.  :-)

Something along these lines:

Code: [Select]
string [] drgs;
using (MyDlg dlg = new MyDlg())
{
    // Show dialog here
    drgs = dlg.SomeMethodToGetDrgs();
}
// Process drgs here...

Cheers,
Glenn.
I'm not sure I know how to do this.  I tried code like this, that uses the dispose of the dialog, but get the same error messages.  I will try and use the 'using' and see if I can figure it out.  I call the dialog box from within a 'doclock' call, will this work?  I even commented it out, and it still didn't work.
Code: [Select]
void Button1Click(object sender, System.EventArgs e)
{
bool IsModel;
DocumentCollection DocCol = AcadApp.DocumentManager;
ListView.ListViewItemCollection lvic = listView1.Items;
string[,] tempArray = new string[lvic.Count, 5];
int i = 0;
foreach (ListViewItem lvi in lvic) {
ListViewItem.ListViewSubItemCollection lvsic = lvi.SubItems;
for (int j = 0; j < lvsic.Count; j++) {
tempArray[i,j] = lvsic[j].Text;
}
++i;
}
Close();
Dispose();
for (i = 0; i < (tempArray.Length / 5); ++i) {
if (tempArray[i,1] != null) {
try {
MessageBox.Show(tempArray[i,0]);
Document tempDoc = DocCol.Open(tempArray[i,0], true);
//Document tempDoc = DocCol.Add(tempArray[i,0]);
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
StdScaleType ScaleType = (StdScaleType) Enum.Parse(typeof(StdScaleType), tempArray[i,4], false);
MyPlottingPart(tempArray[i,1], tempArray[i,2], tempArray[i,3], ScaleType, IsModel);
}
catch (System.Exception ex){
MessageBox.Show(ex.ToString());
}
}
}
}
Title: Re: Open drawing from listview
Post by: Glenn R on February 27, 2007, 06:55:47 PM
To use a few words that are bandied about at the moment - you have to de-couple your UI and business logic :)
In other words, move all your processing code OUT of the form.

For instance, in your command class, fire the dialog inside a using statement, then before the using scope is exited, extract the data you need and truck on...which is what I showed previously.

Cheers,
Glenn.
Title: Re: Open drawing from listview
Post by: Glenn R on February 27, 2007, 06:58:32 PM
Once you solve this, I can guess what your next question will be  :evil:
Title: Re: Open drawing from listview
Post by: T.Willey on February 27, 2007, 07:01:43 PM
To use a few words that are bandied about at the moment - you have to de-couple your UI and business logic :)
In other words, move all your processing code OUT of the form.

For instance, in your command class, fire the dialog inside a using statement, then before the using scope is exited, extract the data you need and truck on...which is what I showed previously.

Cheers,
Glenn.
Okay.. I think I can get it from here.  I thought once I disposed of it, I could do the stuff within.

Once you solve this, I can guess what your next question will be  :evil:
No more questions....  :angel:
Title: Re: Open drawing from listview
Post by: Glenn R on February 27, 2007, 07:10:33 PM
Riddle me this grasshopper: How can you dispose of the form from INSIDE one of it's button handlers?
Title: Re: Open drawing from listview
Post by: T.Willey on February 27, 2007, 07:20:28 PM
Riddle me this grasshopper: How can you dispose of the form from INSIDE one of it's button handlers?
Uh...... you can't.... I guess...... Okay I will code it like you said.... I'm getting an 'eLocking' error.. maybe that is the cause... be right back.....  Oh yea!! Thanks....
Title: Re: Open drawing from listview
Post by: Glenn R on February 27, 2007, 07:35:37 PM
You won't need to lock to do the open btw...
Title: Re: Open drawing from listview
Post by: T.Willey on February 27, 2007, 07:49:35 PM
You won't need to lock to do the open btw...
I'm having other issues now Glenn.  I will work on this tomorrow, as it is time to go home.  Thanks for you help, I don't know if I would have gotten this far today without it.   :-)
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 05:14:16 PM
So today I got it to open the drawings, print them (some times, this is the only erroring part now), and close the drawings.  I will post it when I get it complete enough to post.  The printing problems are wierd, and seem to have no rhyme or reason.

Off to study some more, and maybe understand the whole plotting thingy.  :-)
Thanks again!
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 06:08:28 PM
So how did you get it to open the drawings?
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 06:15:11 PM
So how did you get it to open the drawings?
I moved the open part outside the dialog call, like you said.  I got all the information I needed when closing the dialog, stored it in a global array, and use it outside of the dialog.  Then I used the 'open' method on the 'DocumentManager' (document collection) with the name of the file, and the bool value set to true, so it opens it as read only.

After a test, it doesn't work correctly if I cancel the dialog, so I'm going to have to change something, but that is not my main concern right now.  Right now it is the plotting that I can't seem to figure anything out on.  I'm reading the ARX help files, but they are not helping.  :ugly:

I seem to be not using my 'PlotEngine' correctly.

My search continues.......
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 06:21:29 PM
After a test, it doesn't work correctly if I cancel the dialog, so I'm going to have to change something, but that is not my main concern right now. 
Fixed!  :-)
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 06:23:52 PM
You're using the DocumentCollection's Open method...could you post the relevant snip of code please.
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 06:34:30 PM
You're using the DocumentCollection's Open method...could you post the relevant snip of code please.
Sure.  'PlottingArray' holds all the info for my plotting right now.
Code: [Select]
try {
tempDoc = DocCol.Open(PlottingArray[i,0], true);
using (DocumentLock DocLock = tempDoc.LockDocument()) {
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
if (PlottingArray[i,5] != null) LastPlot = true;
StdScaleType ScaleType = (StdScaleType) Enum.Parse(typeof(StdScaleType), PlottingArray[i,4], false);
MyPlottingPart(PlottingArray[i,1], PlottingArray[i,2], PlottingArray[i,3], ScaleType, IsModel, LastPlot);
}
}
catch (System.Exception ex){
MessageBox.Show(ex.ToString());
}
finally {
if (tempDoc != null) tempDoc.CloseAndDiscard();
}
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 06:37:54 PM
What is 'DocCol' Tim? ie How is it declared/defined?
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 06:42:56 PM
What is 'DocCol' Tim? ie How is it declared/defined?
It is defined in the main program portion of the code that is called by the command name.  If you want I can post that whole portion, but didn't think it was needed....... well I will post it, as it is almost all posted above.
Code: [Select]
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
DocumentCollection DocCol = AcadApp.DocumentManager;
Code: [Select]
[CommandMethod("MyPlot", CommandFlags.Session)]
public void MethodCall () {
DialogResult dr;
using (MyPlot modalForm = new MyPlot()) {
dr = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(modalForm);
}
if (dr == DialogResult.OK) {
bool IsModel;
bool LastPlot = false;
Document tempDoc = null;
DocumentCollection DocCol = AcadApp.DocumentManager;
for (int i = 0; i < (PlottingArray.Length / 6); ++i) {
if (PlottingArray[i,1] != null) {
try {
tempDoc = DocCol.Open(PlottingArray[i,0], true);
using (DocumentLock DocLock = tempDoc.LockDocument()) {
if (string.Compare("Model", LayoutManager.Current.CurrentLayout) == 0) {
IsModel = true;
}
else IsModel = false;
if (PlottingArray[i,5] != null) LastPlot = true;
StdScaleType ScaleType = (StdScaleType) Enum.Parse(typeof(StdScaleType), PlottingArray[i,4], false);
MyPlottingPart(PlottingArray[i,1], PlottingArray[i,2], PlottingArray[i,3], ScaleType, IsModel, LastPlot);
}
}
catch (System.Exception ex){
MessageBox.Show(ex.ToString());
}
finally {
if (tempDoc != null) tempDoc.CloseAndDiscard();
}
}
}
}
}

Edit:  I had to lock the document while trying to plot it.  Before I locked it, it wouldn't work at all.
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 06:47:13 PM
Tim,

Immediately after this line:
Code: [Select]
tempDoc = DocCol.Open(PlottingArray[i,0], true);

can you put in a MessageBox call and spit up the the name of MdiActiveDocument please?
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 06:58:54 PM
Tim,

Immediately after this line:
Code: [Select]
tempDoc = DocCol.Open(PlottingArray[i,0], true);

can you put in a MessageBox call and spit up the the name of MdiActiveDocument please?
It showed the name of the drawing I selected to plot, not the one it was called from.  It even plotted it.  :-)
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 07:04:44 PM
What happened when you didn't lock it?

The reason I ask is this. I tried using your open approach first and it wouldn't work because the Open method is asynchronous - meaning the line of code executes, then it trucks on and doesn't wait for the drawing to finish opening. So this approach went out the door very quickly. I then settled on COM to open the drgs, but always wanted a better way. Then Alexander Rivilis posted a bit of code here on using P/INVOKE to get access to a synchronous open method.

I don't lock the drawing to plot though, whereas you do...
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 07:08:06 PM
What happened when you didn't lock it?

The reason I ask is this. I tried using your open approach first and it wouldn't work because the Open method is asynchronous - meaning the line of code executes, then it trucks on and doesn't wait for the drawing to finish opening. So this approach went out the door very quickly. I then settled on COM to open the drgs, but always wanted a better way. Then Alexander Rivilis posted a bit of code here on using P/INVOKE to get access to a synchronous open method.

I don't lock the drawing to plot though, whereas you do...
When I didn't lock the drawings, it would act like it was plotting, but then nothing would show up at the plotter.  I mean the window for the plot progress dialog would show, but it wouldn't ACTUALLY plot anything.  Once I added in the dock locking, it plots.  I don't understand it really, just reading in the ARX files made me think it would work.
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 07:08:52 PM
Actually, after looking through my plot function, I do in fact lock the document to plot it...sorry.

I'm still intrigued as to why your open is working though........hmmmm......
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 07:09:46 PM
Can you post the project, or a stripped down one if you like please Tim...I want to step it...
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 07:14:27 PM
Actually, after looking through my plot function, I do in fact lock the document to plot it...sorry.

I'm still intrigued as to why your open is working though........hmmmm......
Thats fine with me.  I'm still learning, so questioning why I do things is not bad for me.  It makes me think why I did it that way.  :-)

Can you post the project, or a stripped down one if you like please Tim...I want to step it...
I can post the whole thing.  I will just use a file instead of the code window though.  I'm on '06 and using .Net 1.1.  I had to change the ext to 'txt', so I think you can just change it back.
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 07:18:02 PM
Thanks for that...looking at it now...hang a sec...
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 07:30:35 PM
Since I have two global arrays, should I clear them at the end of the code?  I mean I know they are only global when the program is called, but I was just thinking I should clear (make them null) at the end of the code.
I was thinking something like
Code: [Select]
Array.Clear(PlottingArray, 0, PlottingArray.Length);
Array.Clear(ScaleValueArray, 0, ScaleValueArray.Length);
Title: Re: Open drawing from listview
Post by: Glenn R on February 28, 2007, 07:37:47 PM
You can never be too tidy in my opinion. That looks ok for clearing the arrays.

After a bit of fiddling, I managed to get it to open drawings, but the plot was failing...no biggy yet as it's early days.
It does indeed seem to open the drawings correctly...I'll keep playing.

Thanks Tim.
Title: Re: Open drawing from listview
Post by: T.Willey on February 28, 2007, 07:43:32 PM
You can never be too tidy in my opinion. That looks ok for clearing the arrays.

After a bit of fiddling, I managed to get it to open drawings, but the plot was failing...no biggy yet as it's early days.
It does indeed seem to open the drawings correctly...I'll keep playing.

Thanks Tim.
Thanks Glenn for helping me on this one.  I'm going home now, but look forward to seeing what you suggest tomorrow, as I don't have Acad installed at home right now, so I can't play there.
Title: Re: Open drawing from listview
Post by: Kerry on February 28, 2007, 08:14:51 PM
Just flying past ...

To me, there are several of learning, 2 of which I think of as "by example" and "by heuristic"
... this is a great eample of the latter.

The others , cause I know 'someone' will ask, are "by rote" , "in your sleep" . "by algorithm" and "for desperation" .. there are probably more ...  :lol:
Title: Re: Open drawing from listview
Post by: Kerry on February 28, 2007, 09:15:51 PM
.. "by heuristic"

.. by that I mean concentrating on ‘how’ to solve problems or where/how to look for answers rather than the “answer” itself.

If you read that after a couple of beers it sounds better :lol:
Title: Re: Open drawing from listview
Post by: T.Willey on March 01, 2007, 02:27:11 PM
So I changed my error message to this.
Code: [Select]
catch (System.Exception ex) {
Autodesk.AutoCAD.Runtime.Exception AcadEr = ex as Autodesk.AutoCAD.Runtime.Exception;
if (AcadEr !=null) MessageBox.Show(AcadEr.ErrorStatus.ToString());
else MessageBox.Show(ex.ToString());
}
And found out the issue is that there is  a background plot inprogress, so I figure I either have to turn that off background plotting, or put in a loop to wait for it.  I think I will try and code it so that it will not plot in the background.  Will be back.
Title: Re: Open drawing from listview
Post by: T.Willey on March 01, 2007, 03:13:07 PM
So changing the system variable 'backgroundplot' worked.  Here is the code I added to the start of the 'MyPlotPart' sub
Code: [Select]
object OldBkGdPlt = AcadApp.GetSystemVariable("BackGroundPlot");
AcadApp.SetSystemVariable("BackGroundPlot", 0);
Then at the very end of the same sub, I added
Code: [Select]
AcadApp.SetSystemVariable("BackGroundPlot", OldBkGdPlt);
It seems to have sent them, but they are stuck in my printer right now spooling.

This doesn't look good.  I may have to change this again...... be back after some more testing...
Title: Re: Open drawing from listview
Post by: T.Willey on March 01, 2007, 03:48:56 PM
This does not work for me and my printer.  It will spool until 48 bytes, and the it will stop spooling, so I need to wait for the background plot to finish before going to the next drawing.

Off to see how to do that.
Title: Re: Open drawing from listview
Post by: Glenn R on March 01, 2007, 06:14:07 PM
You must explicitly turn backgroundplot OFF...that's the very first thing I do.

Also, your catch clause, whilst technically correct if a not the best way. Look up exception handing in a C# book if you have one handy and tell me what you find. A hint - you can have more than one...
Title: Re: Open drawing from listview
Post by: T.Willey on March 01, 2007, 06:35:35 PM
You must explicitly turn backgroundplot OFF...that's the very first thing I do.
If I do, they don't get printed, as they just stay in the printer spooling for hours on a small drawing.  I will try again soon, just don't want to hold up the netword printer for myself.  :-)

Also, your catch clause, whilst technically correct if a not the best way. Look up exception handing in a C# book if you have one handy and tell me what you find. A hint - you can have more than one...
I don't have one at all.  I read all my stuff online.  I know you can have more that one, I just didn't see how to code for specific Acad ones.  I tried a couple of ways, and they just wouldn't compile.  I think I might know how to do it now, but am trying to find a way to sort of pause the plotting until the background plot is done.  Haven't gotten a good way yet.  I tried a cheap little 'while' loop that would do nothing until Acad said the plot was done.  Something like
Code: [Select]
while (PlotFactory.ProcessPlotState != 0) {}It worked, but it takes so long for it to plot even small drawings.  There has to be a better way, I just haven't found it yet.  Thanks again for your help on this Glenn.  I really appreciate it.
Title: Re: Open drawing from listview
Post by: Glenn R on March 01, 2007, 06:43:56 PM
As far as I'm aware, you HAVE to turn backgrounplot off - all sorts of ussues arise if you do not.
Title: Re: Open drawing from listview
Post by: T.Willey on March 01, 2007, 07:01:09 PM
As far as I'm aware, you HAVE to turn backgrounplot off - all sorts of ussues arise if you do not.
Okay it seems to work when I turn backgroundplot off.  The first one is the only one that takes some time.  I guess I was in too much of a rush.

I still can't get the specific Acad errors to complie.  Do I have to get the base one, and then test each one?  It seems like that is the case in my searches.

Edit: This is how I did it.
Code: [Select]
catch (Autodesk.AutoCAD.Runtime.Exception AcadEr) {
MessageBox.Show(AcadEr.Message);
}
catch (System.Exception ex){
MessageBox.Show(ex.Message);
}
Title: Re: Open drawing from listview
Post by: Glenn R on March 01, 2007, 07:20:29 PM
Good - that's better.

Now, in your adesk catch clause, you could put in a switch statement and switch on the ErroStatus for example...
Title: Re: Open drawing from listview
Post by: T.Willey on March 01, 2007, 07:45:15 PM
Good - that's better.

Now, in your adesk catch clause, you could put in a switch statement and switch on the ErroStatus for example...
Ah... I will have to read up on 'switch'... I think they are like 'cond' in lisp but not sure.  Now I have to make my dialog look purddy, as it seems to work correctly now with all your help.  Thanks again.  I will look into this other stuff tomorrow as time permits.
Title: Re: Open drawing from listview
Post by: Glenn R on March 01, 2007, 08:18:21 PM
Yes, a switch is essentially like a lisp cond.

I strongly suggest you get some training in .NET or at the very least, get a few good books. For C# I would recommend 'Pro C# 2005 and the .NET 2.0 Platform', by Andrew Troelsen, published by Apress.

Cheers,
Glenn.
Title: Re: Open drawing from listview
Post by: Kerry on March 01, 2007, 09:02:32 PM
............  get a few good books. For C# I would recommend 'Pro C# 2005 and the .NET 2.0 Platform', by Andrew Troelsen, published by Apress.

Cheers,
Glenn.

Yes, it's brilliant ! ... and heavy :-)
Title: Re: Open drawing from listview
Post by: Paul Richardson on March 02, 2007, 07:23:52 AM
............  get a few good books. For C# I would recommend 'Pro C# 2005 and the .NET 2.0 Platform', by Andrew Troelsen, published by Apress.

Cheers,
Glenn.

Yes, it's brilliant ! ... and heavy :-)

Agreed! Also C++/CLI and Pro ASP.net in C# 2005 are great from Apress.
Title: Re: Open drawing from listview
Post by: T.Willey on March 02, 2007, 11:21:39 AM
............  get a few good books. For C# I would recommend 'Pro C# 2005 and the .NET 2.0 Platform', by Andrew Troelsen, published by Apress.

Cheers,
Glenn.

Yes, it's brilliant ! ... and heavy :-)

Agreed! Also C++/CLI and Pro ASP.net in C# 2005 are great from Apress.
Thanks Glenn, Kerry and Paul.  Maybe I will have to check it out.  I have one in pdf format that I was reading, but got bored.  Now I use it for reference when I can't figure something out, or I can't find it on MSDN.  The pdf is called 'Ecma-334' and I think Luis recomended it.
Title: Re: Open drawing from listview
Post by: T.Willey on March 02, 2007, 03:04:57 PM
It's working the way I want it to now!  8-)

Thanks again Glenn!

I just noticed that I should make one more button to remove the plotting setup, so if you pick one by mistake it will remove the settings so it won't plot.  But here is a piccy.  I'm not sure if I will keep it with all the different columns, but it's nice to see right now.

Edit:  If anyone wants I can post the code as is now.
Edit:  Updated piccy and updated code to allow for the removal of plot settings, which is the button is shown in the new pic.
Title: Re: Open drawing from listview
Post by: Kerry on March 02, 2007, 07:09:09 PM
.........  The pdf is called 'Ecma-334' ....

That's pretty dry reading :-)  Hope you found a hyperlinked version.
Title: Re: Open drawing from listview
Post by: Kerry on March 02, 2007, 07:12:14 PM
......
Edit:  If anyone wants I can post the code as is now.

Yep, go for it !  .. and update it as you progress


Edit:  Updated piccy and updated code ....

I missed something I think

Looks like you're having fun Tim .. wish I had time to play.
Title: Re: Open drawing from listview
Post by: T.Willey on March 02, 2007, 07:27:57 PM
......
Edit:  If anyone wants I can post the code as is now.

Yep, go for it !  .. and update it as you progress
Okay.  Attached is a txt file of the cs code.


Edit:  Updated piccy and updated code ....

I missed something I think

Looks like you're having fun Tim .. wish I had time to play.

You didn't miss anything, I was just saying that the new button works correctly.  That is the updated code I was talking about.  Sorry for the confusion.  Yes it is fun.  I just wish I had more understanding RIGHT NOW so that I could code anything.  :roll:

On a side note:  If anyone knows why the 'centered' option doesn't work all the time, I would love to hear it.  It worked sometimes on all plots, then it wouldn't work on all plots but the first one, so that is why it is commented out in the code.
Title: Re: Open drawing from listview
Post by: Kerry on March 02, 2007, 07:36:41 PM

Okay.  Attached is a txt file of the cs code.

...  Yes it is fun.  I just wish I had more understanding RIGHT NOW so that I could code anything.  :roll:


Thanks for the file Tim, that may encourage others to become involved.

.... yeah, the 'RIGHT NOW' thingie applies to me as well. Having a sense of adventure helps I think :-)
 
Title: Re: Open drawing from listview
Post by: Glenn R on March 02, 2007, 08:39:01 PM
Tim,

2 things LEAPT out at me concerning your code:

1. You better start naming controls quick smart!
2. General code structure needs improving.

One thing I hate is long indentation. For example:
If this,
    If this
        If this

etc.

I prefer this:
If !This
    bail.

Next statement.

However, this is just personal preference I suppose...keep at it...AND GET THE BOOKS mentioned.
I don't doubt you got bored with the technical spec...as KErry said - dry reading.



Title: Re: Open drawing from listview
Post by: Glenn R on March 03, 2007, 03:23:16 AM
Another excellent book, for WinForms in particular, is Erik Brown's 'Windows Froms Programming with C#' or the second edition, 'Windows Forms in Action', both by Manning publications.
Title: Re: Open drawing from listview
Post by: T.Willey on March 05, 2007, 11:50:21 AM
1. You better start naming controls quick smart!
Yea I noticed this already when I went from 'listBox' to 'comboBox'.  I had to change them all, but I still didn't name them.  :-D

2. General code structure needs improving.
Yea.  I think this is lack of experience.  I notice that in my coding style with Lisp.  It got easier to write and read with experience.

However, this is just personal ...AND GET THE BOOKS mentioned.
I don't doubt you got bored with the technical spec...as KErry said - dry reading.
Maybe I can get my work to pay for a couple of books, even though I'm hired as a draft person and not a programmer.  Doesn't hurt to try.

Another excellent book, for WinForms in particular, is Erik Brown's 'Windows Froms Programming with C#' or the second edition, 'Windows Forms in Action', both by Manning publications.
I'll check this one out also.  Thanks again.
Title: Re: Open drawing from listview
Post by: T.Willey on March 05, 2007, 01:27:24 PM
..... For C# I would recommend 'Pro C# 2005 and the .NET 2.0 Platform', by Andrew Troelsen, published by Apress.
Found link to pdf version here. (http://meidianto.blogspot.com/2007/02/pro-c-2005-and-net-20-platform-third.html)  I mean it is a large pdf (1000+ pages), so a hard copy might be better.