Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2013
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.36 KB | None | 0 0
  1. public partial class NotificationCenterWindow : UserControl
  2.     {
  3.         int x = 5;
  4.         int y = 10;
  5.         char[] arr;
  6.         public NotificationCenterWindow()
  7.         {
  8.             InitializeComponent();
  9.            
  10.         }
  11.  
  12.         public void messages(List<string> list_msg) // создание панелей для сообщений.
  13.         {
  14.             for (int i = 0; i < list_msg.Count; i++)
  15.             {
  16.  
  17.                 Panel panel = new Panel();
  18.                 panel.Name = "pan"+i.ToString();
  19.                 TextBox textBox1 = new TextBox();
  20.                 TextBox textBox2 = new TextBox();
  21.                 TextBox textBox3 = new TextBox();
  22.                 panel.Width = 308;
  23.                 panel.BackColor = Color.Bisque;
  24.                 panel.Location = new Point(x, y);
  25.  
  26.                 panel.Controls.Add(textBox1);
  27.                 textBox1.Size = new System.Drawing.Size(90, 10);
  28.                 textBox1.Location = new Point(10, 10);
  29.                 textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
  30.                 textBox1.BackColor = Color.Bisque;
  31.  
  32.                 panel.Controls.Add(textBox2);
  33.                 textBox2.Location = new Point(200, 10);
  34.                 textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
  35.                 textBox2.BackColor = Color.Bisque;
  36.                 textBox2.TextAlign = HorizontalAlignment.Right;
  37.                 textBox2.Anchor = AnchorStyles.Right;
  38.  
  39.                 panel.Controls.Add(textBox3);
  40.                 textBox3.Location = new Point(10, 30);
  41.                 textBox3.BorderStyle = System.Windows.Forms.BorderStyle.None;
  42.                 textBox3.BackColor = Color.Bisque;
  43.                 textBox3.MaximumSize = new System.Drawing.Size(292, 100);
  44.                 textBox3.Size = new System.Drawing.Size(292, 60);
  45.                 textBox3.Multiline = true;
  46.                 textBox3.Anchor = AnchorStyles.Right | AnchorStyles.Left;
  47.  
  48.                 Button delButt = new Button();
  49.                 delButt.Size = new System.Drawing.Size(12, 12);
  50.                 delButt.Location = new Point(292, 2);
  51.                 delButt.Anchor = AnchorStyles.Right;
  52.                 Bitmap bmp = new Bitmap(Properties.Resources.close);
  53.                 delButt.BackgroundImage = bmp;
  54.  
  55.                 panel.MouseHover += (sender, e) =>
  56.                 {
  57.                     textBox2.Hide();
  58.                     panel.Controls.Add(delButt);
  59.                     delButt.Show();
  60.                 };
  61.  
  62.                 panel.MouseLeave += (sender, e) =>
  63.                 {
  64.                     textBox2.Show();
  65.                 };
  66.  
  67.  
  68.                 panel1.Controls.Add(panel);
  69.                 panel.Anchor = AnchorStyles.Left | AnchorStyles.Right;
  70.                 y += 120;
  71.  
  72.  
  73.                 string[] out_info = list_msg[i].Split('|');
  74.                 textBox1.Text = out_info[1];
  75.                 textBox2.Text = out_info[2];
  76.                
  77.                 arr = out_info[3].ToCharArray(); // если в сообщении больше 120 символов - обрезаем и добавляем "..."
  78.                 for (int j = 0; j < 120; j++) {
  79.                     textBox3.Text += arr[j].ToString();
  80.                 }
  81.                 if (arr.Length > 120) {
  82.                     textBox3.Text += "...";
  83.                 }
  84.                
  85.             }
  86.         }
  87.  
  88.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement