/// <summary>
        /// Shows form
        /// </summary>
        /// <param name="sf">Object which shows form</param>
        public static void Show(this IShowForm sf)
        {
            sf.ShowForm();
            Form form = sf.Form as Form;

            if (form == null)
            {
                return;
            }
            if (forms.Contains(form))
            {
                if (form.IsDisposed)
                {
                    forms.Remove(form);
                }
                return;
            }
            else
            {
                forms.Add(form);
                if (sf is IEnabled)
                {
                    IEnabled en = sf as IEnabled;
                    form.FormClosed += (object senrer, FormClosedEventArgs ev) =>
                    {
                        try
                        {
                            if (forms.Contains(form))
                            {
                                forms.Remove(form);
                            }
                            if (!en.Enabled)
                            {
                                en.Enabled = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            ex.ShowError(10);
                        }
                    };
                    if (en.Enabled)
                    {
                        en.Enabled = false;
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// 启用实体
 /// </summary>
 /// <param name="entity">实体</param>
 public static void Enabled(this IEnabled entity)
 {
     entity.IsEnabled = true;
 }
示例#3
0
 /// <summary>
 /// 禁用实体
 /// </summary>
 /// <param name="entity">实体</param>
 public static void Disabled(this IEnabled entity)
 {
     entity.IsEnabled = false;
 }