Advertisement
SilentLamy

4 rotating cube GI puzzle simulation

Jul 24th, 2021 (edited)
4,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 7.14 KB | None | 0 0
  1. [Front]
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head runat="server">
  4.     <title></title>
  5.     <style>
  6.         .none{background:#ff0000}
  7.         .success{background:#00ff21}
  8.         .btn{
  9.             display:block;
  10.             margin:0;
  11.             padding:0;
  12.             width:100%;
  13.         }
  14.         .col-c{
  15.             width:100px;
  16.         }
  17.     </style>
  18. </head>
  19. <body>
  20.     <form id="form1" runat="server">
  21.         <asp:ScriptManager ID="sc1" runat="server"></asp:ScriptManager>
  22.         <div>
  23.             <asp:UpdatePanel ID="upnl" runat="server" UpdateMode="Always">
  24.                 <ContentTemplate>
  25.                     <table style="border-collapse:collapse;" border="1">
  26.                         <tr>
  27.                             <td class="col-c"><asp:TextBox ID="tx1" runat="server" Text="0" AutoPostBack="true" OnTextChanged="tx1_TextChanged"></asp:TextBox></td>
  28.                             <td class="col-c"><asp:Button ID="bt1" runat="server" OnClick="bt1_Click" CssClass="btn" /></td>
  29.                             <td>&nbsp;</td>
  30.                             <td class="col-c"><asp:TextBox ID="tx2" runat="server" Text="0" AutoPostBack="true" OnTextChanged="tx1_TextChanged"></asp:TextBox></td>
  31.                             <td class="col-c"><asp:Button ID="bt2" runat="server" OnClick="bt2_Click" CssClass="btn" /></td>
  32.                         </tr>
  33.                         <tr>
  34.                             <td colspan="2">&nbsp;</td>
  35.                             <td style="width:50px">
  36.                                 <asp:PlaceHolder ID="ph1" runat="server" />
  37.                             </td>
  38.                             <td colspan="2">&nbsp;</td>
  39.                         </tr>
  40.                         <tr>
  41.                             <td><asp:TextBox ID="tx3" runat="server" Text="0" AutoPostBack="true" OnTextChanged="tx1_TextChanged"></asp:TextBox></td>
  42.                             <td><asp:Button ID="bt3" runat="server" OnClick="bt3_Click"  CssClass="btn" /></td>
  43.                             <td>&nbsp;</td>
  44.                             <td><asp:TextBox ID="tx4" runat="server" Text="0" AutoPostBack="true" OnTextChanged="tx1_TextChanged"></asp:TextBox></td>
  45.                             <td><asp:Button ID="bt4" runat="server" OnClick="bt4_Click"  CssClass="btn" /></td>
  46.                         </tr>
  47.                         <tr>
  48.                             <td colspan="5">
  49.                                 <asp:TextBox ID="result" runat="server" TextMode="MultiLine" Width="100%" Height="30px" style="resize:none;display:block" />
  50.                             </td>
  51.                         </tr>
  52.                         <tr>
  53.                             <td colspan="5"><asp:Button ID="clear" runat="server" Text="clear" OnClick="clear_Click" CssClass="btn" /></td>
  54.                         </tr>
  55.                     </table>
  56.                 </ContentTemplate>
  57.             </asp:UpdatePanel>
  58.         </div>
  59.     </form>
  60. </body>
  61. </html>
  62. [C# Code-Behind]
  63. protected void Page_Load(object sender, EventArgs e)
  64.         {
  65.             if (!IsPostBack)
  66.             {
  67.                 result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  68.             }
  69.         }
  70.  
  71.         protected void bt1_Click(object sender, EventArgs e)
  72.         {
  73.  
  74.             tx1.Text = check_result(Convert.ToInt32(tx1.Text) + 1);
  75.             tx2.Text = check_result(Convert.ToInt32(tx2.Text) + 1);
  76.             tx3.Text = check_result(Convert.ToInt32(tx3.Text) + 1);
  77.             result.Text = result.Text + "(1)";
  78.             result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  79.         }
  80.  
  81.         protected void bt2_Click(object sender, EventArgs e)
  82.         {
  83.             tx1.Text = check_result(Convert.ToInt32(tx1.Text) + 1);
  84.             tx2.Text = check_result(Convert.ToInt32(tx2.Text) + 1);
  85.             tx4.Text = check_result(Convert.ToInt32(tx4.Text) + 1);
  86.             result.Text = result.Text + "(2)";
  87.             result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  88.         }
  89.  
  90.         protected void bt3_Click(object sender, EventArgs e)
  91.         {
  92.             tx1.Text = check_result(Convert.ToInt32(tx1.Text) + 1);
  93.             tx3.Text = check_result(Convert.ToInt32(tx3.Text) + 1);
  94.             tx4.Text = check_result(Convert.ToInt32(tx4.Text) + 1);
  95.             result.Text = result.Text + "(3)";
  96.             result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  97.         }
  98.  
  99.         protected void bt4_Click(object sender, EventArgs e)
  100.         {
  101.             tx2.Text = check_result(Convert.ToInt32(tx2.Text) + 1);
  102.             tx3.Text = check_result(Convert.ToInt32(tx3.Text) + 1);
  103.             tx4.Text = check_result(Convert.ToInt32(tx4.Text) + 1);
  104.             result.Text = result.Text + "(4)";
  105.             result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  106.         }
  107.         private void result_show(int n1, int n2, int n3, int n4)
  108.         {
  109.             ph1.Controls.Clear();
  110.             if(n1 == 0)
  111.             {
  112.                 if(n2 == 0)
  113.                 {
  114.                     if(n3 == 0)
  115.                     {
  116.                         if (n4 == 0)
  117.                         {
  118.                             ph1.Controls.Add(new Literal { Text = "<div class='success'>&nbsp;</div>" });
  119.                         }
  120.                         else
  121.                         {
  122.                             ph1.Controls.Add(new Literal { Text = "<div class='none'>&nbsp;</div>" });
  123.                         }
  124.                     }
  125.                     else
  126.                     {
  127.                         ph1.Controls.Add(new Literal { Text = "<div class='none'>&nbsp;</div>" });
  128.                     }
  129.                 }
  130.                 else
  131.                 {
  132.                     ph1.Controls.Add(new Literal { Text = "<div class='none'>&nbsp;</div>" });
  133.                 }
  134.             }
  135.             else
  136.             {
  137.                 ph1.Controls.Add(new Literal { Text = "<div class='none'>&nbsp;</div>" });
  138.             }
  139.         }
  140.         private string check_result(int num_sample)
  141.         {
  142.             int result = 0;
  143.             if(num_sample== 4)
  144.             {
  145.                 result = 0;
  146.             }
  147.             else
  148.             {
  149.                 result = num_sample;
  150.             }
  151.             return result.ToString();
  152.         }
  153.  
  154.         protected void clear_Click(object sender, EventArgs e)
  155.         {
  156.             tx1.Text = "0";
  157.             tx2.Text = "0";
  158.             tx3.Text = "0";
  159.             tx4.Text = "0";
  160.             result.Text = string.Empty;
  161.             result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  162.         }
  163.  
  164.         protected void tx1_TextChanged(object sender, EventArgs e)
  165.         {
  166.             result_show(Convert.ToInt32(tx1.Text), Convert.ToInt32(tx2.Text), Convert.ToInt32(tx3.Text), Convert.ToInt32(tx4.Text));
  167.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement