I have a 20x16 array of objects.
I need a way to iterate through the array and only consider few rows and few
columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be
considered in loop
Another time, I whould need only first 3 columns and last 4 rows to be
considered...
Anyhow, I will not have separate rows or columns in the same iteration...
So, never something like first 3 rows and last 2 rows... or first 2 columns
and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------ 20 1366
Not totally sure if this is what you want, I have not tested it, just
written in Notepad.
Const xSize As Integer = 20
Const ySize As Integer = 16
Dim Skips( xSize,ySize ) as Boolean
Dim MyObjects(xSize,ySize) as Object
Dim xCount As Integer = 0
Dim yCount As Integer = 0
'Setup All Skips to False
For yCount=0 to yMax-1 Step 1
For xCount=0 to yMax-1 Step1
Skips(xCount,yCount)=False
Next
Next
'Set up rows and cols to skip for example.
Skips(9,3) = Frue
For yCount=0 to ySize-1 Step 1
For xCount=0 to xSize-1 step 1
if Skips(xCount,yCount) Then
'Skip Action
Else
'Do Action
End If
Next
Next
Regards - OHM
Crirus wrote: I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
Regards - OHM# OneHandedMan{at}BTInternet{dot}com
* "Crirus" <Cr****@datagroup.ro> scripsit: I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
Store the indices in 2 arrays and loop through the arrays, get the
values in the 2 index arrays and access the value in the array.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi Crirus
Just like the others written in this mail and true pseudo my thought about
this
\\\
mySelectedArray as myarrayfunction("R",3,2)
function myarrayfunction (firstIs, rows,columns)
if firstis = "R" then
RowIndexStart = 0
RowIndexEnd = rows
ColIndexStart = coltable.length - (columns + 1)
ColIndexEnd = coltable.length - 1
else
RowIndexStart = rowtable.length - (rows + 1)
RowIndexEnd = rowtable.length - 1
ColIndexStart = 0
ConIndexEnd = columns
end if
///
And then a normal nested for next loop
Cor I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and
few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2
columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
-- Cheers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
The skip part is the tricky one here.. I want to implement it as dinamic as
it can be
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com> wrote in
message news:u9****************@TK2MSFTNGP11.phx.gbl... Not totally sure if this is what you want, I have not tested it, just written in Notepad.
Const xSize As Integer = 20 Const ySize As Integer = 16 Dim Skips( xSize,ySize ) as Boolean Dim MyObjects(xSize,ySize) as Object Dim xCount As Integer = 0 Dim yCount As Integer = 0
'Setup All Skips to False For yCount=0 to yMax-1 Step 1 For xCount=0 to yMax-1 Step1 Skips(xCount,yCount)=False Next Next
'Set up rows and cols to skip for example. Skips(9,3) = Frue
For yCount=0 to ySize-1 Step 1
For xCount=0 to xSize-1 step 1
if Skips(xCount,yCount) Then 'Skip Action Else 'Do Action End If
Next Next
Regards - OHM
Crirus wrote: I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
Regards - OHM# OneHandedMan{at}BTInternet{dot}com
can you add some pseudocode to explain?
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bs************@ID-208219.news.uni-berlin.de... * "Crirus" <Cr****@datagroup.ro> scripsit: I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and
few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to
be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same
iteration... So, never something like first 3 rows and last 2 rows... or first 2
columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
Store the indices in 2 arrays and loop through the arrays, get the values in the 2 index arrays and access the value in the array.
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet>
Still cant see the ideea!
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Cor" <no*@non.com> wrote in message
news:eT**************@TK2MSFTNGP09.phx.gbl... Hi Crirus
Just like the others written in this mail and true pseudo my thought about this \\\ mySelectedArray as myarrayfunction("R",3,2) function myarrayfunction (firstIs, rows,columns) if firstis = "R" then RowIndexStart = 0 RowIndexEnd = rows ColIndexStart = coltable.length - (columns + 1) ColIndexEnd = coltable.length - 1 else RowIndexStart = rowtable.length - (rows + 1) RowIndexEnd = rowtable.length - 1 ColIndexStart = 0 ConIndexEnd = columns end if /// And then a normal nested for next loop
Cor I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to
be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same
iteration... So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
-- Cheers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
To help you understand what I need I should tell you that I use that to draw
a bitmap on a control, and when I scroll the image, to redraw only the parts
new exposed...so I whould have to draw some rows and colls depending on
scroll directions
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Crirus" <Cr****@datagroup.ro> wrote in message
news:uy**************@tk2msftngp13.phx.gbl... I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and
few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2
columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
-- Cheers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
Hi Crirus Still cant see the ideea!
mySelectedArray as myarrayfunction("R",3,2)
You tell what is the first one the Row or the Column with an R or a whatever
You also tell the amount of rows and the amount of columns
That you do as a function
function myarrayfunction (firstIs, rows,columns)
if firstis = "R" then
' if it is row the startindex = 0 and the end index in this example 3
' the startindex for the columns = 14 and the end index 16
RowIndexStart = 0
RowIndexEnd = rows
ColIndexStart = coltable.length - (columns + 1)
ColIndexEnd = coltable.length - 1
else
RowIndexStart = rowtable.length - (rows + 1)
RowIndexEnd = rowtable.length - 1
ColIndexStart = 0
ConIndexEnd = columns
end if
for i = rowindexStart to rowIndexEnd
for y = colIndexStart to colIndexEnd
add to array
next
next
return array
Not that difficult I thought?
Cor
How about first 2 rows and first 3 columns?
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hi Crirus Still cant see the ideea! mySelectedArray as myarrayfunction("R",3,2) You tell what is the first one the Row or the Column with an R or a
whatever You also tell the amount of rows and the amount of columns That you do as a function function myarrayfunction (firstIs, rows,columns)
if firstis = "R" then ' if it is row the startindex = 0 and the end index in this example 3 ' the startindex for the columns = 14 and the end index 16 RowIndexStart = 0 RowIndexEnd = rows ColIndexStart = coltable.length - (columns + 1) ColIndexEnd = coltable.length - 1 else RowIndexStart = rowtable.length - (rows + 1) RowIndexEnd = rowtable.length - 1 ColIndexStart = 0 ConIndexEnd = columns end if
for i = rowindexStart to rowIndexEnd for y = colIndexStart to colIndexEnd add to array next next return array
Not that difficult I thought?
Cor
That you did not ask.
:-) How about first 2 rows and first 3 columns?
--
But than you need an extra parameter in the same context or something as
FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
LOL
I told you there can be any borders, not only first rows and last cols
I can have any borders but not rows only or cols only
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Cor" <no*@non.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl... That you did not ask.
:-)
How about first 2 rows and first 3 columns?
-- But than you need an extra parameter in the same context or something as FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
Cor & Crirus,
The only change I would recommend (to Cor's example) is to make the firstIs
parameter an Enum, either a Flags as I show or FF LF FC and LC as Cor
showed. Either way the Enum will give you intellisense on the allowed
values.
<Flags()> _
Public Enum Position
FirstRow = 0
LastRow = 1 ' Row value is either on (1) or off (0)
FirstColumn = 0
LastColumn = 2 ' Column value is either on (2) or off (0)
End Enum
function myarrayfunction (firstIs As Position, rows,columns)
If (firstIs And Position.LastRow) = Position.FirstRow Then
RowIndexStart = 0
RowIndexEnd = rows
Else
RowIndexStart = rowtable.length - (rows + 1)
RowIndexEnd = rowtable.length - 1
End If
If (firstIs And Position.LastColumn ) = Position.FirstColumnThen
ColIndexStart = 0
ConIndexEnd = columns
Else
ColIndexStart = coltable.length - (columns + 1)
ColIndexEnd = coltable.length - 1
End If
Then when you call it you can use
myarrayfunction (Position.FirstRow Or Position.FirstColumn , x, x)
myarrayfunction (Position.FirstRow Or Position.LastColumn, x, x)
myarrayfunction (Position.LastRow Or Position.FirstColumn , x, x)
myarrayfunction (Position.LastRow Or Position.LastColumn, x, x)
Hope this helps
Jay
"Cor" <no*@non.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl... That you did not ask.
:-)
How about first 2 rows and first 3 columns?
-- But than you need an extra parameter in the same context or something as FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
I do, actualy...
thanks
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Cor" <no*@non.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl... That you did not ask.
:-)
How about first 2 rows and first 3 columns?
-- But than you need an extra parameter in the same context or something as FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
yeah, thanks
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Cor & Crirus, The only change I would recommend (to Cor's example) is to make the
firstIs parameter an Enum, either a Flags as I show or FF LF FC and LC as Cor showed. Either way the Enum will give you intellisense on the allowed values.
<Flags()> _ Public Enum Position FirstRow = 0 LastRow = 1 ' Row value is either on (1) or off (0) FirstColumn = 0 LastColumn = 2 ' Column value is either on (2) or off (0) End Enum
function myarrayfunction (firstIs As Position, rows,columns) If (firstIs And Position.LastRow) = Position.FirstRow Then RowIndexStart = 0 RowIndexEnd = rows Else RowIndexStart = rowtable.length - (rows + 1) RowIndexEnd = rowtable.length - 1 End If
If (firstIs And Position.LastColumn ) = Position.FirstColumnThen ColIndexStart = 0 ConIndexEnd = columns Else ColIndexStart = coltable.length - (columns + 1) ColIndexEnd = coltable.length - 1 End If
Then when you call it you can use myarrayfunction (Position.FirstRow Or Position.FirstColumn , x, x) myarrayfunction (Position.FirstRow Or Position.LastColumn, x, x) myarrayfunction (Position.LastRow Or Position.FirstColumn , x, x) myarrayfunction (Position.LastRow Or Position.LastColumn, x, x)
Hope this helps Jay
"Cor" <no*@non.com> wrote in message news:uv**************@tk2msftngp13.phx.gbl... That you did not ask.
:-)
How about first 2 rows and first 3 columns?
-- But than you need an extra parameter in the same context or something as FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
Whats wrong with my Implementation ?
Crirus wrote: The skip part is the tricky one here.. I want to implement it as dinamic as it can be "One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com> wrote in message news:u9****************@TK2MSFTNGP11.phx.gbl... Not totally sure if this is what you want, I have not tested it, just written in Notepad.
Const xSize As Integer = 20 Const ySize As Integer = 16 Dim Skips( xSize,ySize ) as Boolean Dim MyObjects(xSize,ySize) as Object Dim xCount As Integer = 0 Dim yCount As Integer = 0
'Setup All Skips to False For yCount=0 to yMax-1 Step 1 For xCount=0 to yMax-1 Step1 Skips(xCount,yCount)=False Next Next
'Set up rows and cols to skip for example. Skips(9,3) = Frue
For yCount=0 to ySize-1 Step 1
For xCount=0 to xSize-1 step 1
if Skips(xCount,yCount) Then 'Skip Action Else 'Do Action End If
Next Next
Regards - OHM
Crirus wrote: I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
Regards - OHM# OneHandedMan{at}BTInternet{dot}com
Regards - OHM# OneHandedMan{at}BTInternet{dot}com
just now I figured out your ideea.. so you first set up the tiles in a
rectangle that I dont need to pick up, then just considering the rest?
I whould like more to minimise the for loops because this is gonna be a
speed optimisation and big loops just make it slower
Beside, I can have that rows and cols at any border.. so first 3 rows and
first 2 cols are my case either
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com> wrote in
message news:eR*************@TK2MSFTNGP11.phx.gbl... Whats wrong with my Implementation ?
Crirus wrote: The skip part is the tricky one here.. I want to implement it as dinamic as it can be "One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com> wrote in message news:u9****************@TK2MSFTNGP11.phx.gbl... Not totally sure if this is what you want, I have not tested it, just written in Notepad.
Const xSize As Integer = 20 Const ySize As Integer = 16 Dim Skips( xSize,ySize ) as Boolean Dim MyObjects(xSize,ySize) as Object Dim xCount As Integer = 0 Dim yCount As Integer = 0
'Setup All Skips to False For yCount=0 to yMax-1 Step 1 For xCount=0 to yMax-1 Step1 Skips(xCount,yCount)=False Next Next
'Set up rows and cols to skip for example. Skips(9,3) = Frue
For yCount=0 to ySize-1 Step 1
For xCount=0 to xSize-1 step 1
if Skips(xCount,yCount) Then 'Skip Action Else 'Do Action End If
Next Next
Regards - OHM
Crirus wrote: I have a 20x16 array of objects. I need a way to iterate through the array and only consider few rows and few columns.
To be clearer, sometimes I need only first 2 rows and last 3 columns to be considered in loop Another time, I whould need only first 3 columns and last 4 rows to be considered...
Anyhow, I will not have separate rows or columns in the same iteration... So, never something like first 3 rows and last 2 rows... or first 2 columns and last 3 columns
only rows and columns, at the beginning r at the end.
Any ideea how to implement that?
Regards - OHM# OneHandedMan{at}BTInternet{dot}com
Regards - OHM# OneHandedMan{at}BTInternet{dot}com
I still ned some help.. I'm not used to use flags...
I have 2 values X, Y that shows wich flags should be combined
so X>0 means FirstColumn and Y>0 means FirstRow
How to set does flags into a variable to state both X,Y positive or negative
values?
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Cor & Crirus, The only change I would recommend (to Cor's example) is to make the
firstIs parameter an Enum, either a Flags as I show or FF LF FC and LC as Cor showed. Either way the Enum will give you intellisense on the allowed values.
<Flags()> _ Public Enum Position FirstRow = 0 LastRow = 1 ' Row value is either on (1) or off (0) FirstColumn = 0 LastColumn = 2 ' Column value is either on (2) or off (0) End Enum
function myarrayfunction (firstIs As Position, rows,columns) If (firstIs And Position.LastRow) = Position.FirstRow Then RowIndexStart = 0 RowIndexEnd = rows Else RowIndexStart = rowtable.length - (rows + 1) RowIndexEnd = rowtable.length - 1 End If
If (firstIs And Position.LastColumn ) = Position.FirstColumnThen ColIndexStart = 0 ConIndexEnd = columns Else ColIndexStart = coltable.length - (columns + 1) ColIndexEnd = coltable.length - 1 End If
Then when you call it you can use myarrayfunction (Position.FirstRow Or Position.FirstColumn , x, x) myarrayfunction (Position.FirstRow Or Position.LastColumn, x, x) myarrayfunction (Position.LastRow Or Position.FirstColumn , x, x) myarrayfunction (Position.LastRow Or Position.LastColumn, x, x)
Hope this helps Jay
"Cor" <no*@non.com> wrote in message news:uv**************@tk2msftngp13.phx.gbl... That you did not ask.
:-)
How about first 2 rows and first 3 columns?
-- But than you need an extra parameter in the same context or something as FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
What can be wrong with the followings:
Consider only first if in draw function first
'In a Propery
If Value.X > 0 Then
redraw.direction = Position.FirstColumn
Else
redraw.direction = Position.LastColumn
End If
If Value.Y > 0 Then
redraw.direction = redraw.direction Or Position.FirstRow
Else
redraw.direction = redraw.direction Or Position.LastRow
End If
......
'in a draw function
If redraw.direction = Position.FirstColumn Or Position.FirstRow Then
DrawCroppedMap(redraw.cols, redraw.rows, cols - redraw.cols,
rows - redraw.rows, redraw.cols, redraw.rows)
DrawNewRowsAndCols(0, cols - 1, 0, redraw.rows - 1) 'draw
rows at top
DrawNewRowsAndCols(0, redraw.cols - 1, redraw.rows, rows -
1) 'draw remaining of cols at left
ElseIf redraw.direction = Position.LastColumn Or
Position.LastRow Then
'draw cropped here... not implemented yet IGNORE
DrawNewRowsAndCols(0, cols - 1, 0, redraw.rows - 1) 'draw
rows at top
DrawNewRowsAndCols(cols - 1 - redraw.cols, cols - 1,
redraw.rows, rows - 1) 'draw remaining of cols at right
ElseIf redraw.direction = Position.FirstColumn Or
Position.LastRow Then
'draw cropped here... not implemented yet IGNORE
DrawNewRowsAndCols(0, cols - 1, rows - 1 - redraw.rows,
rows - 1)
DrawNewRowsAndCols(0, redraw.cols - 1, 0, rows - 1 -
redraw.rows)
ElseIf redraw.direction = Position.LastColumn Or
Position.FirstRow Then
'draw cropped here... not implemented yet IGNORE
DrawNewRowsAndCols(0, cols - 1, rows - 1 - redraw.rows,
rows - 1)
DrawNewRowsAndCols(cols - 1 - redraw.cols, cols - 1, 0,
rows - 1 - redraw.rows) 'draw remaining cols at right
End If
........
Private Sub DrawNewRowsAndCols(ByVal xStart As Integer, ByVal xEnd As
Integer, ByVal yStart As Integer, ByVal yEnd As Integer)
For x As Integer = xStart To xEnd
For y As Integer = yStart To yEnd
grBuffer.DrawImage(GetCompleteTile(x, y), New Rectangle(x *
tile.Width, y * tile.Width, tile.Width, tile.Height), New Rectangle(0, 0,
tile.Width, tile.Height), GraphicsUnit.Pixel)
Next
Next
End Sub
Private Sub DrawCroppedMap(ByVal x As Integer, ByVal y As Integer, ByVal
width As Integer, ByVal height As Integer, ByVal newX As Integer, ByVal newY
As Integer)
Dim CropBuff As Bitmap = New Bitmap(bufferMap)
grBuffer.DrawImage(CropBuff, New Rectangle(newX * tile.Width, newY *
tile.Height, width * tile.Width, height * tile.Height), New Rectangle(x *
tile.Width, y * tile.Height, width * tile.Width, height * tile.Height),
GraphicsUnit.Pixel)
End Sub
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
Forget about it ... I figured out.... but no speed improvement...
--
Cheers,
Crirus
------------------------------
If work were a good thing, the boss would take it all from you
------------------------------
"Crirus" <Cr****@datagroup.ro> wrote in message
news:ud**************@tk2msftngp13.phx.gbl... What can be wrong with the followings: Consider only first if in draw function first
'In a Propery If Value.X > 0 Then redraw.direction = Position.FirstColumn Else redraw.direction = Position.LastColumn End If
If Value.Y > 0 Then redraw.direction = redraw.direction Or
Position.FirstRow Else redraw.direction = redraw.direction Or
Position.LastRow End If ..... 'in a draw function
If redraw.direction = Position.FirstColumn Or Position.FirstRow
Then DrawCroppedMap(redraw.cols, redraw.rows, cols -
redraw.cols, rows - redraw.rows, redraw.cols, redraw.rows) DrawNewRowsAndCols(0, cols - 1, 0, redraw.rows - 1) 'draw rows at top DrawNewRowsAndCols(0, redraw.cols - 1, redraw.rows, rows - 1) 'draw remaining of cols at left ElseIf redraw.direction = Position.LastColumn Or Position.LastRow Then 'draw cropped here... not implemented yet IGNORE DrawNewRowsAndCols(0, cols - 1, 0, redraw.rows - 1) 'draw rows at top DrawNewRowsAndCols(cols - 1 - redraw.cols, cols - 1, redraw.rows, rows - 1) 'draw remaining of cols at right ElseIf redraw.direction = Position.FirstColumn Or Position.LastRow Then 'draw cropped here... not implemented yet IGNORE DrawNewRowsAndCols(0, cols - 1, rows - 1 - redraw.rows, rows - 1) DrawNewRowsAndCols(0, redraw.cols - 1, 0, rows - 1 - redraw.rows) ElseIf redraw.direction = Position.LastColumn Or Position.FirstRow Then 'draw cropped here... not implemented yet IGNORE DrawNewRowsAndCols(0, cols - 1, rows - 1 - redraw.rows, rows - 1) DrawNewRowsAndCols(cols - 1 - redraw.cols, cols - 1, 0, rows - 1 - redraw.rows) 'draw remaining cols at right End If .......
Private Sub DrawNewRowsAndCols(ByVal xStart As Integer, ByVal xEnd As Integer, ByVal yStart As Integer, ByVal yEnd As Integer) For x As Integer = xStart To xEnd For y As Integer = yStart To yEnd grBuffer.DrawImage(GetCompleteTile(x, y), New Rectangle(x
* tile.Width, y * tile.Width, tile.Width, tile.Height), New Rectangle(0, 0, tile.Width, tile.Height), GraphicsUnit.Pixel) Next Next End Sub Private Sub DrawCroppedMap(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal newX As Integer, ByVal
newY As Integer) Dim CropBuff As Bitmap = New Bitmap(bufferMap) grBuffer.DrawImage(CropBuff, New Rectangle(newX * tile.Width, newY
* tile.Height, width * tile.Width, height * tile.Height), New Rectangle(x * tile.Width, y * tile.Height, width * tile.Width, height * tile.Height), GraphicsUnit.Pixel) End Sub -- Cheers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
Crirus,
As your other post suggests. If you already have the X & Y that "operate as
the flags" I would not bother with the flags, I would simply send in the x &
y values. (or two booleans where I compare the values. Which in many ways
simplify your code. I would use the Enum, where you just know that you need
those values, not based on other conditions (for example the sides of a
box).
function myarrayfunction (firstRow as Boolean, firstColumn As boolean,
rows,columns)
If firtRow Then
RowIndexStart = 0
RowIndexEnd = rows
Else
RowIndexStart = rowtable.length - (rows + 1)
RowIndexEnd = rowtable.length - 1
End If
If firstColumn Then
ColIndexStart = 0
ConIndexEnd = columns
Else
ColIndexStart = coltable.length - (columns + 1)
ColIndexEnd = coltable.length - 1
End If
Then when you call it you can use:
myarrayfunction (x > 0, y > 0, rows , columns )
I would still separate the check (x >0) from the process, as it makes the
process slightly clearer...
Hope this helps
Jay
"Crirus" <Cr****@datagroup.ro> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... I still ned some help.. I'm not used to use flags...
I have 2 values X, Y that shows wich flags should be combined
so X>0 means FirstColumn and Y>0 means FirstRow
How to set does flags into a variable to state both X,Y positive or
negative values?
-- Cheers, Crirus
------------------------------ If work were a good thing, the boss would take it all from you
------------------------------
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Cor & Crirus, The only change I would recommend (to Cor's example) is to make the firstIs parameter an Enum, either a Flags as I show or FF LF FC and LC as Cor showed. Either way the Enum will give you intellisense on the allowed values.
<Flags()> _ Public Enum Position FirstRow = 0 LastRow = 1 ' Row value is either on (1) or off (0) FirstColumn = 0 LastColumn = 2 ' Column value is either on (2) or off (0) End Enum
function myarrayfunction (firstIs As Position, rows,columns) If (firstIs And Position.LastRow) = Position.FirstRow Then RowIndexStart = 0 RowIndexEnd = rows Else RowIndexStart = rowtable.length - (rows + 1) RowIndexEnd = rowtable.length - 1 End If
If (firstIs And Position.LastColumn ) = Position.FirstColumnThen ColIndexStart = 0 ConIndexEnd = columns Else ColIndexStart = coltable.length - (columns + 1) ColIndexEnd = coltable.length - 1 End If
Then when you call it you can use myarrayfunction (Position.FirstRow Or Position.FirstColumn , x, x) myarrayfunction (Position.FirstRow Or Position.LastColumn, x, x) myarrayfunction (Position.LastRow Or Position.FirstColumn , x, x) myarrayfunction (Position.LastRow Or Position.LastColumn, x, x)
Hope this helps Jay
"Cor" <no*@non.com> wrote in message news:uv**************@tk2msftngp13.phx.gbl... That you did not ask.
:-)
> How about first 2 rows and first 3 columns? > > -- But than you need an extra parameter in the same context or something
as FF LF FC and LC and then I would do the test in a select case.
Do you understand it or would i write this in a example?
Cor
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bruce Whitehouse |
last post by:
This should be an easy one, but I'm not sure the best way to do it.
I've got a form, and when I click a button it starts looping through an
array. With each iteration of the array I want it to...
|
by: Tomás |
last post by:
Looking at the following function:
#include <cstddef>
#include <iostream>
template<typename T, std::size_t len>
void PrintOutStrings( const char* const (&Array) )
{
for (std::size_t i = 0;...
|
by: Sam Kong |
last post by:
Hello!
My question would not be very practical but just out of curiosity.
In JavaScript, Array is a subclass of Object.
Well maybe not exactly... but sort of...
For normal objects, you can...
|
by: Sathyaish |
last post by:
Can every problem that has an iterative solution also be expressed in
terms of a recursive solution?
I tried one example, and am in the process of trying out more examples,
increasing their...
|
by: TheRealDan |
last post by:
Hi all.
I'm having a problem with a special characters.
I have php script that reads from an xml file and writes to a mysql db.
It's a script called phptunest that I found on the net, although the...
|
by: zaeminkr |
last post by:
Hello.
I believed below two functions would have same performance.
However, I realized the second form of array iteration are found more
in many performance critical code like Microsoft CRT...
|
by: sanctus |
last post by:
I'm working on an existing code and don't understand what the following iteration iterates over:
rows = dim;
pagesize = dim*dim;
for(ix=1;ix<dim-1;ix++)
for(iy=1;iy<dim-1;iy++) ...
|
by: dannywebster |
last post by:
Hello all,
I have a dictionary of which i'm itervalues'ing through, and i'll be
performing some logic on a particular iteration when a condition is
met with trusty .startswith('foo'). I need to...
|
by: raghulvarma |
last post by:
I have got an unsorted integer variables stored in an array,Now if I need to do some operation in that array in which way I could tune in my for loop, By which way could I reduce the iteration of a...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |