Changeable pen

Discussion in 'Questions (Windows Mobile)' started by neilnapier, Nov 25, 2007.

  1. neilnapier

    neilnapier Active Member Licensed User

    I have been working on a Burning Sand PPPC Program (that is on the program forum) and I am stuck with quite a few problems. Could anyone help me to figure out how to sort this peice of coding:

    Code:
    Sub BurningSand_MouseMove (x,y)
    If circle.Enabled = true Then
    If blnDRAG = 1 Then
          
    If ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
             BurningSand.FCircle(x, y, PenSize, DrawColor, F) 
    'Filled circle
             
             
    Else if Circle2.Enabled = true Then
          
    If   blnDRAG = 1 Then
          
    If ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
             BurningSand.ForeLayer = 
    True
             BurningSand.FCircle(x, y, PenSize, DrawColor) 
    ' circle
             End if
             
    End if
             
    End if
             
    End if
             
    End if
    End Sub
    The problem is I am trying to get a choice of either having a filled circle or a normal circle as a pen, using buttons to choose. However i can't figure out how to do it.

    Could someone please help me,

    neilnapier
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should set the ForeLayer property only once (you could do it in Sub App_Start).
    I think that you've confused the If...End If blocks.
    Code:
    Sub BurningSand_MouseMove (x,y)
        
    If circle.Enabled = true Then
            
    If blnDRAG = 1 AND ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
                BurningSand.FCircle(x, y, PenSize, DrawColor, F) 
    'Filled circle
            End If
        
    Else If Circle2.Enabled = true Then
            
    If blnDRAG = 1 AND ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
                BurningSand.FCircle(x, y, PenSize, DrawColor) 
    ' circle
            End If
        
    End If
    End Sub
     
  3. neilnapier

    neilnapier Active Member Licensed User

    Thanks but it still doesn't work... The circle and Circle2 are both buttons and so I wasn't sure if the enable thing would work with it. So It might have something to do with them...
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The Button.Enabled property doesn't indicate whether the user pressed on this button or not.
    Maybe you should use two RadioBtns and then check the RadioBtn.Checked property.
     
  5. neilnapier

    neilnapier Active Member Licensed User

    That wouldn't work as it is an image button... I am trying to get it to look like the desktop version as much as possible. Is there a way that it would be possible... I could upload the whole file if you want so you can actually test to see what is wrong with it?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please upload the file.
     
  7. neilnapier

    neilnapier Active Member Licensed User

    Ok... here it is!
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The solution is to use a global variable (I've named it filled):
    Code:
    Sub Globals
        blnDRAG = 
    0
        MinX = 
    30
        MaxX = BurningSand.Width - 
    33
        MinY = 
    25
        MaxY = Burningsand.Height - 
    45
        PenSize = 
    2
        DrawColor = Rgb(
    80,0,0)
        filled = 
    true
    End Sub

    Sub circle_Click
        filled = 
    true
    End Sub

    Sub Circle2_Click
        filled = 
    false
    End Sub

    Sub BurningSand_MouseMove (x,y)
        
    If blnDRAG = 1 AND ((x > MinX) AND (x < MaxX)) AND ((y > MinY) AND (y < MaxY)) Then
            
    If filled Then
                BurningSand.FCircle(x, y, PenSize, DrawColor, F) 
    'Filled circle
            Else
                BurningSand.FCircle(x, y, PenSize, DrawColor) 
    ' circle
            End If
        
    End If
    End Sub
    Note that for boolean values you can just write: If filled then (instead of If filled = true then).
     
  9. neilnapier

    neilnapier Active Member Licensed User

    Thanks!!! That really helped a lot!

    I have a few other questions however...

    Is it possible to add a FPS counter to my program (frames per secend)

    Would it be possible to have it so that each of the pixels that you draw move down the forelayer at a set speed (like a liquid) or up (like a gas)

    Is there a way that I could have a indecator that is at the bottom that states which colour the cursor is going to create (or a name that the colour has been named (ie Water for blue)

    Anyway thanks again Erel. When I release the updated version then I will put you in the thanks section.
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    There are no built-in methods for these features.
    You will need to implement them.
    About the color, you could draw a circle or some other figure with the selected color.
     
  11. neilnapier

    neilnapier Active Member Licensed User

    But would there be a way using something like...

    Code:
    Do
    Something.Top = Something.Top + 
    1
    Loop
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    You could use this code with an Image control.
    But it is not suitable for your application.
     
  13. neilnapier

    neilnapier Active Member Licensed User

    I have updated my page in Open Source. I have 4 different pens now.

    Erel do you have any idea how I would possibly be able to make a liquid or gas. I was thinking perhaps using the the FErase function along with having something like x, y + 1, so that it moves but I'm not entirely sure how I would do this.
     
Loading...