Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1
Paint EventHandler Off Form1 Paint EventHandler Off Form1
Paint EventHandler Off Form1
Go Back  Xtreme Visual Basic Talk > > > Paint EventHandler Off Form1


Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2013, 01:10 AM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default Paint EventHandler Off Form1


In the last couple of years I have slowly learned a few (and I do mean few) tricks here and there to work with multiple classes. One of the things that has eluded me is the ability to call an object event on the Form1 from a remote class.

As part of the solution AtmaWeapon offered in another thread, it contained a couple of lines of code that might contain the answer. I looked up the MSDN website and got a bit more of the puzzle, but I still can’t work out where the pieces of this jigsaw puzzle fit.

Code:
<SerializableAttribute><ComVisibleAttribute(True)> Public Delegate Sub EventHandler (sender As Object, e As EventArgs)

Public Class Counter
    Public Event ThresholdReached As EventHandler

    Protected Overridable Sub OnThresholdReached(e As EventArgs)
        RaiseEvent ThresholdReached(Me, e)
    End Sub 

End Class
Which I then changed to PaintEventArgs to suit the type of Event I want to handle (Paint.Refresh)

Code:
    <SerializableAttribute> <ComVisibleAttribute(True)> Public Delegate Sub EventHandler(sender As Object, e As PaintEventArgs)
    Public Event ThePaintEvent As EventHandler

    Public Overridable Sub OnThePaintEvent(sender As Object, e As PaintEventArgs)
        RaiseEvent ThePaintEvent(Form1.PictureBox1, e)
    End Sub
The trouble I keep running into is that once I can’t pass the arguments (sender As Object, e As PaintEventArgs) to the next class, or it requires a different set of arguments the wheels fall of my wagon.
I have put together a simple example with a PictureBox called PictureBox1 on Form1.

Just in case you can’t open the VB2012 project the complete code is here. There are no errors showing but it doesn’t work. I don’t really know how it is supposed to work, so I have no clue how to fix it.

Code:
Public Class Form1

    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim _lm As New LoadMe
        _lm.LoadThis()

    End Sub

End Class
Code:
Public Class LoadMe

    Private Property e As PaintEventArgs

    Public Sub LoadThis()

        Dim _pm As New PaintMe
        _pm.pbShape_Paint(Form1.PictureBox1, e)

    End Sub

End Class
Code:
Imports System.Runtime.InteropServices
Imports System.Drawing.Graphics

Public Class PaintMe

    <SerializableAttribute> <ComVisibleAttribute(True)> Public Delegate Sub EventHandler(sender As Object, e As PaintEventArgs)
    Public Event ThePaintEvent As EventHandler

    Public Overridable Sub OnThePaintEvent(sender As Object, e As PaintEventArgs)
        RaiseEvent ThePaintEvent(Form1.PictureBox1, e)
    End Sub

    Public Sub pbShape_Paint(sender As Object, e As PaintEventArgs) Handles Me.ThePaintEvent

        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        e.Graphics.DrawLine(Pens.Black, 10, 10, 10, 100)
        e.Graphics.DrawLine(Pens.Black, 10, 100, 100, 100)

    End Sub

End Class
Attached Files
File Type: zip PassThePaint.zip (16.5 KB, 1 views)
Reply With Quote
  #2  
Old 02-12-2013, 08:38 AM
AtmaWeapon's Avatar
AtmaWeaponPaint EventHandler Off Form1 AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Personally I think there is no reason to do this. I'll talk about it conceptually, then discuss what's wrong with your application because "never" isn't a word that often holds in programming.

In general, it is a poor design to call a method to raise an event on another class that isn't your base class. Events are raised to let unrelated classes know that something has happened. If you are in Z, you know A has happened in Y, and you want to do something in Z, just do the thing in Z directly.

For example, look at BackgroundWorker. To start it, you call RunWorkerAsync(). When you do that, it creates a RunWorkerEventArgs and raises its DoWork event on another thread. The handler does its work, and when it returns, the BackgroundWorker gathers information and creates a RunWorkerCompletedEventArgs, using that to raise its WorkerCompleted event. This implementation lets you handle just two events to use a BackgroundWorker and not worry about managing a thread. Imagine if instead, MS required you to create your own DoWorkEventArgs and raise DoWork yourself on a specific thread. The class would be useless; you may as well do the rest on your own.

There is never really a good reason to make an API that requires you to create the EventArgs for an event then pass it to a method in another class so that class can raise the event. But there *can* be a good reason to make a method that raises the event, and it'll come up as I talk about why your example doesn't work.

Basically, your code never creates a PaintEventArgs. So it's Nothing, and that causes a NullReferenceException. Note that to create one, you have to have a Graphics object for the surface on which you want to draw. This means you'll have to call CreateGraphics() on... something, but this is where I get confused. Since PaintMe isn't a Control it won't have CreateGraphics(). Same with LoadMe. Maybe you intend to send it a Graphics object from the PictureBox on Form1. But this makes me ask, "Why not just handle the PictureBox's Paint event and call Invalidate() when you want to redraw it?" If you do it that way, you don't have to worry about measuring invalidation rectangles or creating Graphics objects; Windows does it for you.

Painting code belongs in forms and controls. When looking at your form makes you shake your head and say, "What can I extract?", the things inside Paint events should be among the last. If you're painting on a specific control, you might opt to make a custom control with that drawing code inside. It can be acceptable to make a class that takes a Graphics object and draws some particular stuff on it. But I'd be willing to bet you've still got a lot of stuff that isn't drawing in that form and it's the least important thing to the form.

When you separate things, separate code. Events are strongly tied to the class that contains them, and the only thing that should be purposefully raising events in A is A or subclasses of A. Even in the instance of Control.Invalidate() it's rare I'm calling it on a class that isn't the current class.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 02-12-2013, 04:04 PM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default

Where do I start… I am so hopelessly lost in what I was trying to do I couldn’t see the exit sign anywhere. I caught the fringes of what you are saying, and the rest went over my head. So I will comment on what I think I understand.

“Basically, your code never creates a PaintEventArgs. So it's Nothing, and that causes a NullReferenceException. … This means you'll have to call CreateGraphics() on...”

Yes exactly this is why I have a method calling an event from a different class, because I tried all sorts of different ways to get something other than Nothing in the PaintEventArg, with no luck with any of them. I came up with several different ways but all of them produced Nothing. I knew I was doing the wrong thing but didn't know what the right thing was to change it.

Basically I was struggling to associate the Picturebox1 on Form1 with the PaintEventArg on PaintMe. I know I could create a picture box in code, but I was trying to associate a static object on Form1 from a different class more as an example than specifically needing to do it, so in the future when I am struggling to get code off of Form1 I could do it more gracefully.

I need both PaintEventArg to get e.graphics and associated pens etc, and I need to get access to the picture box as well. Where I think I was predominantly going wrong (still other areas are wrong but the worst wrong) is that I am trying to access an object that doesn’t have a Handle. Bear with me while I try to explain this… For controls like a combo box I have written code like this AddHandler guidePartNoCombo.SelectedIndexChanged, AddressOf cboGuidePartNo_SelectedIndexChanged and that gives me easy access to the control from other classes.

But because a Picture Box doesn’t have a Click event or a selected index Changed it is much harder to tap into a static object. I have moved a lot off the main form a sample of below.

Code:
 Private Sub cboYaxis_SIC(sender As Object, e As EventArgs) Handles cboYaxis.SelectedIndexChanged
        If blnFTT Then _mi.cboYAxis()
    End Sub

    Private Sub cboPercent_SIC(sender As Object, e As EventArgs) Handles cboPercent.SelectedIndexChanged
        If blnFTT Then _mi.cboPercent()
    End Sub

    Private Sub cboShapeLineThick_SIC(sender As Object, e As EventArgs) Handles cboShapeLineThick.SelectedIndexChanged
        If blnFTT Then _mi.cboShapeLineThick()
    End Sub

    Private Sub miShapeLineColour_Click(sender As Object, e As EventArgs) Handles miShapeLineColour.Click
        _mi.miShapeLineColour()
    End Sub

    Private Sub miShapeBackColour_Click(sender As Object, e As EventArgs) Handles miShapeBackColour.Click
        _mi.miShapeBackColour()
    End Sub
But I was trying to get all the paint related code off the main form as well. The second mistake I made is I think I should have returned to the main form and made the call to PaintMe from there rather than trying to make the call from LoadMe (not sure but you may have said that, or something like that in your response). While you probably view this as a complete failure, sometimes learning what not to do can be just as useful as what to do. I think I will return all the PaintMe code back to Form1, but I feel I am one step closer to learning how to get it to a separate class.

BTW what does Invalidate do?, I have never used it (despite trying it many times) but I could never find a laymans understanding of what it does. Im guess as the name suggests it resets something to clear or disables it but I just don’t know.
Reply With Quote
  #4  
Old 02-13-2013, 08:03 PM
hDC_0Paint EventHandler Off Form1 hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 559
Default Invalidate - forces Paint event to fire

Quote:
Originally Posted by CodeCruncher
BTW what does Invalidate do?, I have never used it (despite trying it many times) but
I could never find a layman’s understanding of what it does.
I’m guessing as the name suggests it resets something to clear or disables it but I just don’t know.
It forces a Paint event call to update the onscreen graphics.

The MSDN Control.Invalidate method page says it simply:
Quote:
Invalidates the entire surface of the control and causes the control to be redrawn.

Remarks:
Calling the Invalidate method does not force a synchronous paint; to force a synchronous paint, call the Update method after calling the Invalidate method.

When this method is called with no parameters, the entire client area is added to the update region.
The Form.Invalidate method is along similar lines but with a specified list of overloads.

Quote:
Originally Posted by CodeCruncher
I tried all sorts of different ways to get something other than Nothing in the PaintEventArg, with no luck with any of them.
Hmm..I sensing a very basic lack-of-depth in your understanding of "Graphics" and e.Graphics,
(as well as the "when and/or how" of using PaintEventArgs conceptually).

Did you ever take a read through of this BobPowell page:
When (and how) to use CreateGraphics

Personally I rarely use CreateGraphics but I am experienced in using off form backbuffers for rendering.

I see surfR2911 took the time in post#49 to explain things a little, but from your response in post#50 it looks like it didn't fully sink in:
Quote:
Light above head slowly flickers to life, like a fluoro light coming on….

If I took your multi object drawing and put it into the buffer, could I then access the buffered drawing co-ordinates
to get the left, right, top bottom points, so I could redraw it scaled to suit and
re-enter it back into the buffer for a one time draw?
The answer is yes
..and if you properly create / maintain a set of backbuffers you can redraw it as many times as you want.

Stop thinking about drawing on the form or a control.
Stop thinking about drawing on the computer monitor screen at all.
Even under VB6 there where things called memoryDCs.
They could be drawn on (using lines and text) quite easily.

You draw, render, and compose all graphics for all layers in memory.

Then only at the very end of the rending process/pipeline do you "flip" the memory image
to what you want to use in the gui thread (i.e. the painted form and it's painted controls).

I always keep the famous flip graphic bookmarked.

Did you read ever download the "_Mouse_events_rendered_in_class.zip" attachment from post#51 of the Viewer thread
and look at the code in the "Public Function Draw"?

Basically what happens:
1.) the Form_Mouse event is used to call Render() with the e As System.Windows.Forms.MouseEventArgs routed directly into the off form class
2.) Render() calls the Draw sub (off form)
3.) Me.Refresh() call the form's Paint event

So you could actually comment out Render() in the Form MouseMove event and
just directly call Me.Refresh (which also forces a Paint event call like Invalidate):
Quote:
Code:
Private Sub Form1_MouseMove(ByVal sender As Object, _
             ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    If blnTracking = True Then
      mainCube.MouseX = e.X
      mainCube.MouseY = e.Y
    Else
      mainCube.MouseX = 0
      mainCube.MouseY = 0
    End If
    'Render()
    Me.Refresh()
End Sub
..then add a Form Paint event with the following code:
Quote:
Code:
Private Sub Form1_Paint(ByVal sender As Object, _
              ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    Me.BackgroundImage = mainCube.Draw(drawOrigin)
End Sub
So Form MouseMove transmits user input (mouse location) directly into the off form Draw sub which "flips" (paints)
both the checkerboard background and the drawing of the mouse location coordinates onto the form using
a created-at-runtime "Graphics" tied to a memory image backbuffer.

It could just as easily be painted to a picturebox (or any other control) as it paints the form.

This is a huge conceptual leap over anything you could find in the MSDN examples.
Note: No PaintEventArgs had to be passed around (either on form or off form).

Part of the "magic" is also happening in the "Private Function getDrawingBounds()",
(that does rect-style "framing" for the left, right, top bottom points),
so don't forget to study (and understand) what's happening there as well.

The painting in that example could be a little less flickery if you "focused" the class code more on just rendering and less on 3D math stuff,
as well as making sure you only "invalidated" the part of the form that actually needed to be refreshed
(in order to clear the previously drawn mouse x y text coordinate graphics and prevent blit smearing);
instead of the forcing the whole form background to re-drawn/re-painted.
passel's QuickSpaceInvaders example shows how to do selective invalidation.

Anyway..understanding these things helps you if you are doing customdraw for a control,
or rendering 3D points/line project to 2D or a thousand other things
you can do with the Graphics object in VB.Net.

I'm also tempted to go have you read about hWnds and hDCs (so you could get back to Windows graphics basics),
but that's probably too old school so I just leave it there..

Last edited by hDC_0; 02-13-2013 at 08:34 PM.
Reply With Quote
  #5  
Old 02-13-2013, 08:34 PM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default

Thanks hDC_0 there is quite a lot to digest there. Currently I am going back through my code as per AtmaWeapon's suggegstion and just trying to make it more object orientated.

Half the problem is I am constanly trying to code while I am tired and sometimes things just don't sink in or are more diffacult than they need to be.

For example I tried to make a class that loads everything up instead of grouping the stuff that needs to loaded with the controls that it is loading, i.e setting a label for button in one class, and setting the click actions in another.

I am without a doubt bouncing from class to class without need, I need to slow down my thinking and write the code around the object and not worry so much which class it is in.

I haven't given up on the idea of trying to put it into memory before drawing, I just need to get some order back in the code. I need to defrag my head first.

Last edited by CodeCruncher; 02-13-2013 at 08:40 PM.
Reply With Quote
  #6  
Old 02-14-2013, 09:13 AM
AtmaWeapon's Avatar
AtmaWeaponPaint EventHandler Off Form1 AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Be careful with the whole "making things more object-oriented" thing. It can burn you, particularly when you're new to it.

I just wasted a whole day on a project starting from the object model and working backwards. Turned out it was a heck of a lot easier to start with a bunch of lists and dictionaries, then build the object model out of that.

Building proper object-oriented programs right is a lifetime goal. The best thing to focus on at first is "it works". Then, ask yourself, "What parts are hard to work with?" Those are the most important places to focus on refactoring. Things that are simple and work shouldn't be touched. I've had to learn and relearn this over the course of 10 years XD
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #7  
Old 02-14-2013, 03:14 PM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default

I started with VB6 back in the mid to late 90’s and I have been trying to get more OO ever since. Back then I used to write massive all in one statements with numerous GoTo’s on the main form. With large time gaps and bad memory I often have to relearn everything all over again. I feel like my skills are slowly increasing, but sometimes I forget the most basic fundamentals and it takes me a while to get back up to speed. At times I have looked back at code I have written and blown my own mind that I ever knew enough to write such code. If memory serves me right I think it was you many years ago that suggested I start to write code based around the object. I have been trying to make it a habit ever since, but occasionally I slip back into that VB6 linear statement code.

So last night I had a rethink about how I should have this working…
First I am setting the menu items by calling SetMenuItems() from the form load event.

Code:
    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        If Not System.IO.File.Exists(mySets.FilePath) Then
            Dim ofdFile As New OpenFileDialog()
            ofdFile.Filter = "3D Studio|*.3ds"
            If (ofdFile.ShowDialog() = Windows.Forms.DialogResult.OK) Then
                mySets.FilePath = ofdFile.FileName.ToString
                mySets.Save()
            Else
                MsgBox("  A required database file has not been selected." & vbNewLine & _
                       "  Without it the program can not continue to load." & vbNewLine & _
                       "  The program will now close.", vbCritical, "Missing Database")
            End If
        Else
            blnFTT = True
            _mi.SetMenuItems()
            Dim _i3ds As New Import3DS
            _i3ds.SetImport3DS()
            Dim _si As New ScreenItems
            _si.SetScreenItems()
		…..
Then I am setting each item individually… (I could put them all SetMenuItems as they will only be used once, but trying to avoid clumping non related code)
Code:
    Public Sub SetMenuItems()

        SetFileName()
        SetXaxis()
        SetYaxis()
        SetScreenPercent()
        SetShapeLineColour()
        SetShapeLineWidth()
        SetShapeBackColour()
        SetShapePointColour()
        SetShapeCornerColour()
        SetGraphLineColour()
        SetGraphLineWidth()
        SetGraphBackColour()
        SetFormForeColour()
        SetFormBackColour()

    End Sub

    Private Sub SetFileName()
        Dim splitedStr As String() = mySets.FilePath.Split(New [Char]() {"\"c})
        Main.miFileName.Text = "File Name: " & splitedStr(splitedStr.Length - 1).Substring(0, splitedStr(splitedStr.Length - 1).Length - 4)
    End Sub

    Private Sub SetXaxis()
        xTheta = CDbl(Main.cboXaxis.Items(mySets.Xaxis))
        Main.cboXaxis.SelectedIndex = mySets.Xaxis
    End Sub

    Private Sub SetYaxis()
        yTheta = CDbl(Main.cboYaxis.Items(mySets.Yaxis))
        Main.cboYaxis.SelectedIndex = mySets.Yaxis
    End Sub
Setting the SelectedIndex makes a call back to the main form and is promptly ignored as this is the FTT (first time through)
Code:
    Private Sub cboXaxis_SIC(sender As Object, e As EventArgs) Handles cboXaxis.SelectedIndexChanged
        If Not blnFTT Then _mi.cboXAxis()
    End Sub

    Private Sub cboYaxis_SIC(sender As Object, e As EventArgs) Handles cboYaxis.SelectedIndexChanged
        If Not blnFTT Then _mi.cboYAxis()
    End Sub

    Private Sub cboPercent_SIC(sender As Object, e As EventArgs) Handles cboPercent.SelectedIndexChanged
        If Not blnFTT Then _mi.cboPercent()
    End Sub
Once the application starts (and blnFTT is set to False) those same combo boxes work with the MenuItems class (_mi) to change as required.
Code:
    Public Sub cboXAxis()

        If CDbl(Main.cboXaxis.SelectedItem) <> xTheta Then
            xTheta = CDbl(Main.cboXaxis.SelectedItem)
            mySets.Xaxis = CByte(Main.cboXaxis.SelectedIndex)
            mySets.Save()
            Main.pbShape.Refresh()
        End If

    End Sub

    Public Sub cboYAxis()

        If CDbl(Main.cboYaxis.SelectedItem) <> yTheta Then
            yTheta = CDbl(Main.cboYaxis.SelectedItem)
            mySets.Yaxis = CByte(Main.cboYaxis.SelectedIndex)
            mySets.Save()
            Main.pbShape.Refresh()
        End If

    End Sub
Instead of hopping from class to class like I was before, I am trying to alternate between main and only one other class at a time, the stupid thing is I have done this so many times before in other code, I don’t know why I keep forgetting to keep it simple.

So now I have my combo boxes on the main form just to trigger the event, and all the menu item changes taking place in the MenuItem class keeping everything simple and running sweet, then I do the exact same thing for the file import and so on.

Last edited by CodeCruncher; 02-14-2013 at 03:26 PM.
Reply With Quote
  #8  
Old 02-19-2013, 01:48 AM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default

I have sorted out the main issue I started the thread for, and have updated the original thread with a new version of the software Intersecting lines

I still need to get the graphic part sorted out but will continue trying to get that sorted in the other thread.

Thanks for everyones help, I still have a lot to implement.
Reply With Quote
  #9  
Old 02-19-2013, 07:29 PM
hDC_0Paint EventHandler Off Form1 hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 559
Default Project goals and following OOP prinicpals..

Quote:
Originally Posted by CodeCruncher
I started with VB6 back in the mid to late 90’s and I have been trying to get more OO ever since.
There is sometimes a tradeoff in trying to do "pure" OOP and that tradeoff can be about performance.

I worked on some (PVM) parallel virtual machine code, written in C++ and designed to run a rendering farm
on a distributed processing HPCC (High Performance Computing Cluster).

My first coding attempt was very careful in following the design OOP principles of abstraction, encapsulation, polymorphism, and inheritance.

Everything worked but it took over 16 hours to render a certain test animated sequence.

Needless to say I began to profile things to figure out which piece of code needed to be tweaked.

The result - just about every part of it was equally slow.

I started over..totally forgetting about OOP and just coding the most efficient way I knew how.
It was full of C malloc hacks but it rendered the same sequence in under 3 seconds!

So I went back and looked carefully at the poor performance OOP version.

Slowly (after hours and hours of studying the code),
I realized that multiple inheritance and polymorphism was hiding (masking) a lot of bad recursion looping.

I encapsulated the good performance code and added some structured exception handling (it wasn't stable under load).
Then I redesigned the master control module (to have better real time control over the threading) and called it good.

The performance on the final code was still under 5 seconds
and I've reused the hack-ish code from that project a couple of other times

Clients have been pleased with the performance.
Thankfully they've never asked to take a close look at the source for the "helper" dlls.

I'm not saying that OOP principles are not a good goal to keep in mind.
Just try to make sure it's not the only goal "in the mix" when it comes to coding a project.

Last edited by hDC_0; 02-19-2013 at 07:36 PM.
Reply With Quote
  #10  
Old 02-19-2013, 08:30 PM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default

I sort of strayed from complete OO to a cross between it and logical chunks of information. If you take a look at the new classes I created, I have gone for a more functional grouping.

Would appreciate you taking a look at the code to see if it can be tweaked any better...

I have a gut feeling there are a couple of variables "Public xTheta, yTheta As Double" that should be in their own class. Don't ask me why it's just a feeling. Quite some time ago while trying to make a Space Invaders game Atmaweapon tried to point me in the direction of putting just variables into classes, and as hard as I tried to understand why I just couldn't get it.

My brain just couldn't fathom having variables by themselves, and I kept writting code in the class, but in this project which is largely based on SurfR2911 graphics code, he has a few classes with just variables in it, and for some strange reason I half understand why they are there, it's kind of like it makes a new object of like minded variables.
Reply With Quote
  #11  
Old 02-19-2013, 09:40 PM
hDC_0Paint EventHandler Off Form1 hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 559
Default Goals?

Quote:
Originally Posted by CodeCruncher
Would appreciate you taking a look at the code to see if it can be tweaked any better...
Are you talking about your Baffle Step Calculator (versions 1 thru 4) in the Intersecting lines thread?

I have looked at the BSC attachments (and I'm sure a number of other forum members have, at very least, been following the thread).

The question I have (and that may be of interest to others trying to follow the thread):
Quote:
What are you trying (at this point) to accomplish in "exploring" surfR2911's complex wireframe code example?
I don't recall seeing any recent (revised?) kind of mission/thread statement like:
"My end goal in exploring 3D graphics in VB.Net is to..." or
"I'm trying to achieve the following end result...
Towards that end I need the code to do suchandsuch but I have traced the inability to do so to the following code.."

..or in short: "Where is the Intersecting Lines thread going?"

If you are just "exploring" code (with an eye toward learning) that's fine,
but if there is an "end point" (where you can say "Once I achieve the following the thread will be resolved.."),
it would be interesting knowing what exactly that endpoint would be.

Without knowing what you are really trying to do it's a mystery what might not be happening
or what revisions are needed to guide you along a "path" going in that direction..
Reply With Quote
  #12  
Old 02-19-2013, 10:40 PM
CodeCruncher CodeCruncher is offline
Junior Contributor
 
Join Date: Jul 2006
Posts: 355
Default

The problem with a goals list, is the moment you say I am trying do a list of things it will get so complicated that I won’t be able to follow all the advice, or worse miss some.

Most of where I am headed is completely unchartered waters for me, so I am trying to contain opening up the box too wide and losing a sense of where I am going. That why I posted the class issue in a different thread as it wasn’t really part of this project, but it makes it far easier to work with.

But to give you a high level overview of what needs to be done:

Step 1.
Now that I have the 3D object working fairly ok, the next step is to work out how to buffer it to memory, so I can manipulate it and draw it in a non-flickered way. Found this to get started http://msdn.microsoft.com/en-us/libr...dgraphics.aspx

I don’t have any problems with a single object, but when I load a multi object file I need to work out how to look at each of the objects as if they were one big object, so I can keep the percentage of screen usage working properly. Before I was doing this with a second Paintbox refresh, but that is as subtle as a sledgehammer (ok to get going) and doesn’t work with my current code.

Step 2.
I want to be able to pick certain points on the screen using the mouse and place dots on the screen (undetermined amount of dots). Currently the way the code stands by changing the index in the Vertex list box it picks different points, I want to be able to do that in reverse so I can remove the Vertex list box off the form.

Step 3.
Once I do the above I can actually get back to the original question. I will have a point of origin (say a yellow dot) and several corner dots (say blue dots) I then want to work out how to measure multiple distances from the point of origin to numerous points on the surrounding lines. There are already some suggestions back at the beginning of the thread, and I have a few ideas of my own, but I don’t want to focus on it yet for fear of getting confused.

SurfR2311 kindly provided some code which I probably could never write (I probably could if I had several years to nut it out) but it took what I thought was possible to a whole new level, When I asked the original question I was looking at a 2D drawing entered by text boxes, so the issue was more one of straight forward measurement, so I need to do step 1 and 2 before I can return to the original problem I had.

I feel confident I can get this done as long as I don’t get overwhelmed by trying to spread myself too thin.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1 Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1 Paint EventHandler Off Form1
Paint EventHandler Off Form1
Paint EventHandler Off Form1
 
Paint EventHandler Off Form1
Paint EventHandler Off Form1
 
-->