Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: C sharp file creation at specified time. Pin
Nicholas Marty17-Oct-14 4:32
professionalNicholas Marty17-Oct-14 4:32 
GeneralRe: C sharp file creation at specified time. Pin
kanswal7718-Oct-14 17:38
kanswal7718-Oct-14 17:38 
GeneralRe: C sharp file creation at specified time. Pin
Dave Kreskowiak17-Oct-14 4:35
mveDave Kreskowiak17-Oct-14 4:35 
Question[c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046716-Oct-14 22:32
Member 1116046716-Oct-14 22:32 
AnswerRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 0:01
mveRichard MacCutchan17-Oct-14 0:01 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 0:15
Member 1116046717-Oct-14 0:15 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 2:12
mveRichard MacCutchan17-Oct-14 2:12 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 17:32
Member 1116046717-Oct-14 17:32 
Thank a lot for the reply! I think I have some grasp of it now, but am having some trouble visualising it. I asked a friend for some advice, according to him,

Quote:
the trick to getting it to work is dividing the square numbers in even rows by 6 and the remainder is the column number of that square number, then for the odd row's you just get the remainder of them but depending on what the remainder is, will determine what column they are, like if(squarenum % 6 == 0) then column is 5
and to find the row numbers you just use division by 6 aswell, like each 6 times you go through the loop go up(or down) a row


I think I understand what I have to do, just not really sure how. For example, how can I find the "even rows".

Funny thing is, I love puzzles like this, but this just has me completly stumped!

Again, thanks a lot for the replies guys.

EDIT:

OKAY! so I decided just to do it the long way, but I really want to know if there is a way to do it in less code. Here is my solution, any/all input would be very much appreciated!

C#
/// <summary>
       /// For a given square number, tells you the corresponding row and column numbers.
       /// Pre:  none.
       /// Post: returns the row and column numbers, via "out" parameters.
       /// </summary>
       /// <param name="squareNumber">The input square number.</param>
       /// <param name="rowNumber">The output row number.</param>
       /// <param name="columnNumber">The output column number.</param>
       private static void MapSquareNumToScreenRowAndColumn(int squareNumber, out int rowNumber, out int columnNumber){

           // ######################## Add more code to this method and replace the next two lines by something more sensible.  ###############################
           rowNumber = 0; // Use 0 to make the compiler happy for now.
           columnNumber = 0; // Use 0 to make the compiler happy for now.

           columnNumber = squareNumber % 6;
           rowNumber = squareNumber/6;

           //switch statement for assigning column values to odd rows
           int remainder = squareNumber%6;
           switch (remainder){
               case 0:
                   columnNumber = 5;
                   break;
               case 1:
                   columnNumber = 4;
                   break;
               case 2:
                   columnNumber = 3;
                   break;
               case 3:
                   columnNumber = 2;
                   break;
               case 4:
                   columnNumber = 1;
                   break;
               case 5:
                   columnNumber = 0;
                   break;

           }

           if (squareNumber >=0 && squareNumber <= 5){
               rowNumber = 6;
               columnNumber = squareNumber%6;

           }

           if (squareNumber >=6 && squareNumber <= 11){
               rowNumber = 5;
           }

           if (squareNumber >=12 && squareNumber <= 17){
               rowNumber = 4;
               columnNumber = squareNumber%6;
           }
           if (squareNumber >=18 && squareNumber <= 23){
               rowNumber = 3;

           }
           if (squareNumber >= 24 && squareNumber <= 29){
               rowNumber = 2;
               columnNumber = squareNumber%6;

           }
           if (squareNumber >= 30 && squareNumber <= 35){
               rowNumber = 1;

           }
           if (squareNumber >= 36 && squareNumber <= 41){
               rowNumber = 0;
               columnNumber = squareNumber % 6;
           }


       }//end MapSquareNumToScreenRowAndColumn


modified 18-Oct-14 0:55am.

GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 21:10
mveRichard MacCutchan17-Oct-14 21:10 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Member 1116046717-Oct-14 22:27
Member 1116046717-Oct-14 22:27 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan18-Oct-14 4:02
mveRichard MacCutchan18-Oct-14 4:02 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
BillWoodruff17-Oct-14 21:39
professionalBillWoodruff17-Oct-14 21:39 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
BillWoodruff17-Oct-14 0:38
professionalBillWoodruff17-Oct-14 0:38 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 2:15
mveRichard MacCutchan17-Oct-14 2:15 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
BillWoodruff17-Oct-14 2:45
professionalBillWoodruff17-Oct-14 2:45 
GeneralRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
Richard MacCutchan17-Oct-14 2:56
mveRichard MacCutchan17-Oct-14 2:56 
AnswerRe: [c#]Place objects in tablelayoutpanel cells in specific order Pin
BillWoodruff17-Oct-14 0:25
professionalBillWoodruff17-Oct-14 0:25 
QuestionPlay/Pause/Stop media through ASIO driver using C# Pin
Praveen Raghuvanshi16-Oct-14 18:16
professionalPraveen Raghuvanshi16-Oct-14 18:16 
AnswerRe: Play/Pause/Stop media through ASIO driver using C# Pin
Brisingr Aerowing17-Oct-14 10:08
professionalBrisingr Aerowing17-Oct-14 10:08 
GeneralRe: Play/Pause/Stop media through ASIO driver using C# Pin
Praveen Raghuvanshi26-Oct-14 7:37
professionalPraveen Raghuvanshi26-Oct-14 7:37 
Questionanother Func-enstein weirdness : and yet another bad example of MS documentation PinPopular
BillWoodruff16-Oct-14 11:38
professionalBillWoodruff16-Oct-14 11:38 
AnswerRe: another Func-enstein weirdness : and yet another bad example of MS documentation Pin
Gerry Schmitz16-Oct-14 17:43
mveGerry Schmitz16-Oct-14 17:43 
AnswerRe: another Func-enstein weirdness : and yet another bad example of MS documentation Pin
OriginalGriff16-Oct-14 19:27
mveOriginalGriff16-Oct-14 19:27 
AnswerRe: another Func-enstein weirdness : and yet another bad example of MS documentation Pin
Richard Deeming17-Oct-14 5:28
mveRichard Deeming17-Oct-14 5:28 
Questionnecessity to cast return value to nullable in lambda expression ? Pin
BillWoodruff16-Oct-14 7:25
professionalBillWoodruff16-Oct-14 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.