Ejemplo n.º 1
0
        public Alarm(AlarmStruct alarm)
        {
            InitializeComponent();

            alarmStruct = alarm;

            alarmStruct      = alarm;
            Label_Title.Text = alarmStruct.Title;
            Label_Body.Text  = alarmStruct.Body;

            if (alarm.BackColor != Color.Empty)
            {
                Panel_Main.BackColor = alarmStruct.BackColor;
            }

            if (alarm.ImagePath != string.Empty && new FileInfo(alarm.ImagePath).Exists)
            {
                try
                {
                    Picture_Image.Image = Image.FromFile(alarmStruct.ImagePath);
                    Label_Title.Size    = new Size(Label_Title.Size.Width - Picture_Image.Size.Width - 10, Label_Title.Size.Height);
                    Label_Body.Size     = new Size(Label_Body.Size.Width - Picture_Image.Size.Width - 10, Label_Body.Size.Height);
                }
                catch (Exception)
                {
                }
            }

            if (alarm.BorderStyle != Picture_Image.BorderStyle)
            {
                Picture_Image.BorderStyle = alarmStruct.BorderStyle;
            }

            Timer.Start();
        }
Ejemplo n.º 2
0
        public void Add(AlarmStruct alarmStruct)
        {
            Alarm alarm = new Alarm(alarmStruct);

            alarm.LifeTimeEnd += Remove;
            AlamList.Add(alarm);
            try
            {
                Form.Controls.Add(alarm);

                ChangeFormSize();
                ChangeDeskLocation();
                ChangeControlLocation();
            }
            catch (Exception)
            {
                Form.Invoke(new MethodInvoker(() =>
                {
                    Form.Controls.Add(alarm);

                    ChangeFormSize();
                    ChangeDeskLocation();
                    ChangeControlLocation();
                }));
            }
        }
Ejemplo n.º 3
0
        private void Remove(object sender, AlarmStruct AlamStruct)
        {
            AlamList.Remove(sender as Alarm);

            try
            {
                ChangeFormSize();
                ChangeDeskLocation();
                ChangeControlLocation();

                (sender as Control).Dispose();
            }
            catch (Exception)
            {
                Form.Invoke(new MethodInvoker(() =>
                {
                    ChangeFormSize();
                    ChangeDeskLocation();
                    ChangeControlLocation();

                    (sender as Control).Dispose();
                }));
            }
        }
Ejemplo n.º 4
0
 private void OnLifeTimeEnd(AlarmStruct alarmStruct)
 {
     LifeTimeEnd?.Invoke(this, alarmStruct);
 }