Hello All,
I have an app that I started some time ago, and it has come back to the forefront of priorities. The app, in part, is based on the RS Flow Chart sample. There are many objects (rectangles) drawn and positioned at start up. They are moved about the screen using a timer to scroll them. This all works perfectly.
Now, I have to change one or more of the rectangles fill color. Using the sample, I tried adding a button with this code:
If FlowChartCanvas.Nodes(2).myColor =RGB(250, 0, 250) Then
FlowChartCanvas.Nodes(2).myColor = RGB(0,255,255) //&cFF000000
Else
FlowChartCanvas.Nodes(2).myColor =RGB(250, 0, 250)
End If
FlowChartCanvas.Invalidate(False)
That works perfectly.
This is the code from the sample that draws the rectangles:
Dim theX, theY, w As Integer
Dim n As Node
n = Nodes(num)
off.Graphics.ForeColor = n.myColor
Select Case n.shape
Case 0 // circle/oval
off.Graphics.FillOval(n.x, n.y, n.Width, n.Height)
Case 1 // rectangle
off.Graphics.FillRect(n.x, n.y, n.width, n.height)
End Select
If SelNode = num Then
off.Graphics.ForeColor = RGB(250, 0, 0)
Else
off.Graphics.ForeColor = nodeColor
End If
Select Case n.shape
Case 0 //circle/oval
off.Graphics.DrawOval(n.x, n.y, n.width, n.height)
Case 1 //rectangle
off.Graphics.DrawRect(n.x, n.y, n.width, n.height)
End Select
off.Graphics.ForeColor = nodeColor
off.Graphics.TextFont = myFont
theX = n.x + n.width/2 - off.Graphics.StringWidth(n.name)/2
theY = n.y + n.height/2 + off.Graphics.TextHeight/2
off.Graphics.DrawString(n.name, theX, theY)
If editMode And SelNode = num Then
w = 6
off.Graphics.ForeColor = RGB(0, 0, 0)
off.Graphics.FillRect(n.x-w/2, n.y-w/2, w, w)
off.Graphics.FillRect(n.x-w/2, n.y+n.height-w/2, w, w)
off.Graphics.FillRect(n.x+n.width-w/2, n.y-w/2, w, w)
off.Graphics.FillRect(n.x+n.width-w/2, n.y+n.height-w/2, w, w)
End If
Next, I switched over to the real app, and tried doing the same thing. No go. I even disabled the timer for the scrolling thinking the scroll forcing the paint event was getting in the way. No change.
I checked the code, and for the most part, it appears to match. I even removed all code other than to draw the fill and it still will not change!
This is the my modified code that draws the rectangles:
dim thex,they,w as integer
dim n as clsUnit //node
n=nodes(num)
off.graphics.forecolor=n.mycolor
Select Case n.shape //FILL Of object
Case 0 //circle/oval
off.graphics.filloval n.x,n.y,n.width,n.height
Case 1 //rectangle
off.graphics.fillrect n.x,n.y,n.width,n.height
End Select
// if UpdatingColor = True Then Return
//******************* Border Around Unit ***********************//
if selnode=num then //FORECOLOR
off.graphics.forecolor=rgb(250,0,0)
NodeSelectedIndicated = True
else
off.graphics.forecolor=nodecolor
end if
//Draw the border for each unit object
If App.GraphiXSiteDefaults.DrawBorder <> "N" Then
num = num
End iF
Select Case n.shape //OUTLINE of Object
Case 0 //circle/oval
off.graphics.drawoval n.x,n.y,n.width,n.height
Case 1 //rectangle
off.graphics.drawrect n.x,n.y,n.width,n.height
End Select
//******************* Border Around Unit ***********************//
//******************* Unit Text ***********************//
off.graphics.forecolor=nodecolor //Text Color
off.graphics.textfont=myfont
thex=n.x+n.width/2-off.graphics.stringwidth(n.name)/2
they=n.y+n.height/2+off.graphics.textheight/2
off.graphics.drawstring n.name,thex,they
if num <> 35 then
if editmode and selnode=num then
w=6
off.graphics.forecolor=rgb(0,0,0)
off.graphics.fillrect n.x-w/2,n.y-w/2,w,w
off.graphics.fillrect n.x-w/2,n.y+n.height-w/2,w,w
off.graphics.fillrect n.x+n.width-w/2,n.y-w/2,w,w
off.graphics.fillrect n.x+n.width-w/2,n.y+n.height-w/2,w,w
end if
End If
//******************* Unit Text ***********************//
The project is a decent size, but not yet huge. However it would be too large I think, to post here. While I know this makes it a LOT tougher to provide help, if anyone has any ideas, I would really appreciate the input! Spent all day today, with no progress at all…
Thanks all,
Tim