Пример #1
0
        /// <summary>
        /// 子窗体关闭事件
        /// </summary>
        void childForm_Closed(object sender, EventArgs e)
        {
            FlushMemory();
            childForm = null;
            ConfirmMessageBox mb = new ConfirmMessageBox("系统提示", "主窗体中子窗体关闭事件触发了", true, false, "确定", "取消");

            mb.ShowDialog();
        }
Пример #2
0
        ///// <summary>
        ///// 窗体构造函数
        ///// </summary>
        //private void InitForm()
        //{
        //    bool first = true;
        //    for (int i = 0; i < 9; i++)
        //    {
        //        ClientInfo model = new ClientInfo()
        //        {
        //            ClientId = "00" + (i + 1).ToString(),
        //            ClientName = (i + 1) + "号衡器",
        //            Weight = rd.Next(27500, 30000).ToString(),
        //            State = first ? "1" : "2",
        //            IsRedLight = first,
        //            IsGreenLight = !first
        //        };
        //        models.Add(model);
        //        first = !first;
        //    }
        //    this.ItemsControl.ItemsSource = models;
        //    this.ItemsControl.Items.Refresh();
        //}

        ///// <summary>
        ///// 指定的计时器间隔已过去而且计时器处于启用状态时发生
        ///// </summary>
        //void timer_Tick(object sender, EventArgs e)
        //{
        //    List<ClientInfo> Dt = this.ItemsControl.ItemsSource as List<ClientInfo>;
        //    if (Dt!=null&&Dt.Count>0)
        //    {
        //        var ls = (from r in Dt where r.ClientId == "00" + rd.Next(1, 9) select r).ToList();
        //        if (ls!=null&&ls.Count>0)
        //        {
        //            ls.First().IsGreenLight = !ls.First().IsGreenLight;
        //            ls.First().IsRedLight = !ls.First().IsRedLight;
        //            ls.First().State = ls.First().IsRedLight ? "1" : "2";
        //            ls.First().Weight = rd.Next(27500, 30000).ToString();
        //        }
        //    }
        //    this.ItemsControl.Items.Refresh();
        //}

        private void OpenChildFormBtn_Click(object sender, RoutedEventArgs e)
        {
            childForm         = new TestChildForm();
            childForm.Closed += childForm_Closed;
            childForm.ShowDialog();
        }