Advertisement
Yassine_Abbani

skider

Sep 1st, 2021
1,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Runtime.InteropServices;
  11.  
  12. namespace GC_Panel
  13. {
  14.     public partial class SliderShow : UserControl
  15.     {
  16.         // Time to code
  17.         private Bitmap image1 = GC_Panel.Properties.Resources._1;
  18.         // image1 = image 1 in resources as sortcut of call
  19.         // GC_Panel are my namespace user yours
  20.         private Bitmap image2 = GC_Panel.Properties.Resources._2;
  21.         // image2 = image 2 in resources as sortcut of call
  22.         private Bitmap image3 = GC_Panel.Properties.Resources._3;
  23.         // image3 = image 3 in resources as sortcut of call
  24.         private Bitmap image4 = GC_Panel.Properties.Resources._4;
  25.         // image4 = image 4 in resources as sortcut of call
  26.  
  27.         private Bitmap btncheck = GC_Panel.Properties.Resources.radiobutton_checked;
  28.         private Bitmap btnnocheck = GC_Panel.Properties.Resources.radiobutton_no_checked;
  29.  
  30.  
  31.         public SliderShow()
  32.         {
  33.             InitializeComponent();
  34.         }
  35.                 public static class Util
  36.                 {
  37.                     public enum Effect { Roll, Slide, Center, Blend }
  38.  
  39.                     public static void Animate(Control ctl, Effect effect, int msec, int angle)
  40.                     {
  41.                         int flags = effmap[(int)effect];
  42.  
  43.                         if (ctl.Visible)
  44.                         {
  45.                             flags |= 0x10000; angle += 180;
  46.                         }
  47.                         else
  48.                         {
  49.                             if (ctl.TopLevelControl == ctl) flags |= 0x20000;
  50.                             else if (effect == Effect.Blend) throw new ArgumentException();
  51.                         }
  52.  
  53.                         flags |= dirmap[(angle % 360) / 45];
  54.                         bool ok = AnimateWindow(ctl.Handle, msec, flags);
  55.                         if (!ok) throw new Exception("Animation failed");
  56.                         ctl.Visible = !ctl.Visible;
  57.                     }
  58.  
  59.                     private static int[] dirmap = { 1, 5, 4, 6, 2, 10, 8, 9 };
  60.                     private static int[] effmap = { 0, 0x40000, 0x10, 0x80000 };
  61.  
  62.                     [DllImport("user32.dll")]
  63.                     private static extern bool AnimateWindow(IntPtr handle, int msec, int flags);
  64.                 }
  65.  
  66.  
  67.  
  68.         private void timer1_Tick(object sender, EventArgs e)
  69.         {
  70.             Wallpapers.Show();
  71.  
  72.             // call order now
  73.             if (Wallpapers.Image == image1)
  74.             {
  75.              
  76.                 Wallpapers.Image = image2;
  77.                 Btn2.Image = btncheck;
  78.                 Btn1.Image = btnnocheck;
  79.                 Btn3.Image = btnnocheck;
  80.                 Btn4.Image = btnnocheck;
  81.  
  82.                 // change image from image 1 into image2
  83.             }
  84.             else if (Wallpapers.Image == image2)
  85.             {
  86.                 // Util.Animate(Wallpapers, Util.Effect.Slide, 1800, 200);
  87.                 Wallpapers.Image = image3;
  88.                 // change image from image 2 into image3
  89.  
  90.                 Btn3.Image = btncheck;
  91.                 Btn2.Image = btnnocheck;
  92.                 Btn1.Image = btnnocheck;
  93.                 Btn4.Image = btnnocheck;
  94.             }
  95.             else if (Wallpapers.Image == image3)
  96.             {
  97.                 Wallpapers.Image = image4;
  98.  
  99.                 // change image from image 3 into image4
  100.  
  101.                 Btn4.Image = btncheck;
  102.                 Btn2.Image = btnnocheck;
  103.                 Btn3.Image = btnnocheck;
  104.                 Btn1.Image = btnnocheck;
  105.             }
  106.             else
  107.             {
  108.  
  109.                 Wallpapers.Image = image1;
  110.                 // back into first state image1
  111.                 Btn1.Image = btncheck;
  112.                 Btn2.Image = btnnocheck;
  113.                 Btn3.Image = btnnocheck;
  114.                 Btn4.Image = btnnocheck;
  115.             }
  116.         }
  117.  
  118.         private void Btn1_Click(object sender, EventArgs e)
  119.         {
  120.             Wallpapers.Image = image1;
  121.             Btn1.Image = btncheck;              
  122.                 Btn2.Image = btnnocheck;
  123.                 Btn3.Image = btnnocheck;
  124.                 Btn4.Image = btnnocheck;
  125.  
  126.         }
  127.  
  128.         private void Btn2_Click(object sender, EventArgs e)
  129.         {
  130.             Wallpapers.Image = image2;
  131.  
  132.  
  133.                 Btn2.Image = btncheck;
  134.                 Btn1.Image = btnnocheck;
  135.                 Btn3.Image = btnnocheck;
  136.                 Btn4.Image = btnnocheck;
  137.  
  138.         }
  139.  
  140.         private void Btn3_Click(object sender, EventArgs e)
  141.         {
  142.             Wallpapers.Image = image3;
  143.  
  144.  
  145.  
  146.                 Btn3.Image = btncheck;
  147.                 Btn2.Image = btnnocheck;
  148.                 Btn1.Image = btnnocheck;
  149.                 Btn4.Image = btnnocheck;
  150.  
  151.  
  152.         }
  153.  
  154.         private void Btn4_Click(object sender, EventArgs e)
  155.         {
  156.             Wallpapers.Image = image4;
  157.  
  158.  
  159.  
  160.                 Btn4.Image = btncheck;
  161.                 Btn2.Image = btnnocheck;
  162.                 Btn3.Image = btnnocheck;
  163.                 Btn1.Image = btnnocheck;
  164.  
  165.         }
  166.     }
  167. }
  168.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement