TheSwamp

Code Red => .NET => Topic started by: Glenn R on October 15, 2007, 09:19:35 PM

Title: Some Code Snippety goodness
Post by: Glenn R on October 15, 2007, 09:19:35 PM
Have at it lads and lasses (http://msdn2.microsoft.com/en-us/vstudio/aa718338.aspx)  :-D
Title: Re: Some Code Snippety goodness
Post by: Bryco on October 15, 2007, 11:36:40 PM
I use this one a bit
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>
        isZero
      </Title>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>dNum</ID>
          <ToolTip>Check if number is close enough to zero.</ToolTip>
          <Default>1.0</Default>
        </Literal>
        <Literal Editable="false">
          <ID>MathClass</ID>
          <Function>SimpleTypeName(System.Math)</Function>
        </Literal>
      </Declarations>   
     
      <Code Language="CSharp">
        <![CDATA[if ($MathClass$.Abs($dNum$ )<1.0e-8){$dNum$=0;}]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

I guess all I needed to post was
<![CDATA[if ($MathClass$.Abs($dNum$ )<1.0e-8){$dNum$=0;}]]>
Title: Re: Some Code Snippety goodness
Post by: Glenn R on October 15, 2007, 11:53:25 PM
How's the C# coming along Bryce?
Title: Re: Some Code Snippety goodness
Post by: Glenn R on October 15, 2007, 11:53:47 PM
Or was it VB.net...?
Title: Re: Some Code Snippety goodness
Post by: Kerry on October 16, 2007, 12:59:25 AM
Or was it VB.net...?

I use this one a bit
...........  I guess all I needed to post was
<![CDATA[if ($MathClass$.Abs($dNum$ )<1.0e-8)  {    $dNum$=0     ;}    ]]>

correct the first time I'd guess :-)
Title: Re: Some Code Snippety goodness
Post by: Bryco on October 16, 2007, 01:12:43 AM
It is C#, but it is still an uphill battle. I think vb.net would have been easier for me as it so much closer to vba, way easier to convert code.  But now that I've gone this far I do see some of the points you and others make for it being a better language. A big help was finding the sites that offer VB.net and C# comparison.
Until then I was spending 2 hours searching for how to use something small like select case and then how to use more than one item in the case call.
 switch (sOwner)
                {
                    case "Ms":      whereas  I am used to  case "Ms","ModelSpace"  etc

I spent more than a day trying to get an arc to do what I wanted. And even after doing it in vba then transferring into C# again it took an hour to see what I had done wrong.
It is quite a shocker to get points in Ucs. Anyway I did get to pick 3 points anywhere and draw an arc through those points and since the arc is in any plane that took quite a few functions to be converted to achieve. I then realised that adding that to an arc jig was stupid so the arc jig is really quite simple. Damn it's good to whine.  Anyway I'm still working through adding ents. Polylines are next and that's going to take a bit of work. At least the math is all there for the taking (although I still need to test it all out. Part of trying to find the problem with the Arcs , involved comparing  CrossProduct w/ my CrossProduct function.), the curve class is awesome.
   After the ents, I may concentrate on the parts that C# does that vba can't. Wipeout is a start then some viewport action. I figure I have about a year to convert the vba before vista hits our shop, so I'm taking it a bit at a time.
 Without the support on this site I would definately given up a while a go. Perhaps in a couple of months I'll see a return that is better than the merely having to learn it as vba is dying.It really takes a long time to check your code.

Title: Re: Some Code Snippety goodness
Post by: Glenn R on October 16, 2007, 01:25:16 AM
Keep at it mate; you'll get there. I told you there was some really good points to the language, that I and others prefer over VB and I am glad you're starting to see them.

BTW, regarding the switch:
Code: [Select]
switch (someString)
{
    case "Ms":
    case "Modelspace":
        // Do some interesting black magic here
        break;
    default:
        break;
}

You can 'fall through' groups of labels.

Title: Re: Some Code Snippety goodness
Post by: Kerry on October 17, 2007, 01:43:13 AM

....and ;

Visual Studio 2008 Training Videos
Quote
Ready to learn about all the ways that Visual Studio 2008 will make you more productive? Check out the training videos below. This page will be updated with new clips, so keep an eye out for updates.
http://msdn2.microsoft.com/en-us/vstudio/bb655906.aspx
Title: Re: Some Code Snippety goodness
Post by: Glenn R on October 17, 2007, 02:26:44 AM
Good find there Kerry.
Title: Re: Some Code Snippety goodness
Post by: Bryco on October 17, 2007, 10:52:15 AM
Kerry are you using the 2008?
Title: Re: Some Code Snippety goodness
Post by: Kerry on October 17, 2007, 05:06:34 PM

Bryco,
Not yet ...

I'm just doing some preparation for picking up C# again ... haven't played for ages.
Title: Re: Some Code Snippety goodness
Post by: Bryco on October 17, 2007, 06:09:41 PM
I've always meant to ask you if
a)you have converted all your lisp and are running your programs from C#,
b) You write all the new stuff in C#
c) You still write in lisp first
d) Mix it up.
Title: Re: Some Code Snippety goodness
Post by: Kerry on October 17, 2007, 06:19:26 PM

I have not converted code ... and don't intend converting ... 

New code will be C# (generally),
except for on the fly stuff, which will be VLisp.
I don't use vb, so not an issue.

I won't be writing in lisp first .. I want to learn to think in curley brackets, not paren's (as much as I DO like parenthesis )





Title: Re: Some Code Snippety goodness
Post by: Glenn R on October 17, 2007, 07:36:50 PM
as much as I DO like parenthesis

You're sick and twisted Kerry...or a masochist :)
Title: Re: Some Code Snippety goodness
Post by: Kerry on October 17, 2007, 07:53:41 PM
as much as I DO like parenthesis

You're sick and twisted Kerry...or a masochist :)

All 3 is a possibility ...
Title: Re: Some Code Snippety goodness
Post by: Glenn R on October 17, 2007, 07:54:54 PM
 :lmao: