void save(object obj) { ChooseClassHourWindow window = obj as ChooseClassHourWindow; foreach (var c in this.Courses) { if (c.IsChecked) { if (window.Courses == null) { window.Courses = new List <UICourse>(); } if (window.Courses.Any(cc => cc.ID == c.ID)) { window.Courses.Remove(window.Courses.Find(cc => cc.ID == c.ID)); } window.Courses.Add(c); } } window.IsSave = true; // 清除选中状态 this.Courses.ForEach(c => c.IsChecked = false); this.ShowDialog("提示信息", "保存成功", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None); }
void cancel(object obj) { ChooseClassHourWindow window = obj as ChooseClassHourWindow; if (this.Courses.Count(c => c.IsChecked) > 0) { if (window.Courses == null) { window.Courses = new List <UICourse>(); } foreach (var c in this.Courses) { if (c.IsChecked) { if (window.Courses.Any(cc => cc.ID == c.ID)) { window.Courses.Remove(window.Courses.Find(cc => cc.ID == c.ID)); } window.Courses.Add(c); } } } window.DialogResult = window.IsSave; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.win = ((OSKernel.Presentation.Arranging.Administrative.Dialog.ChooseClassHourWindow)(target)); return; case 2: this.dg = ((System.Windows.Controls.DataGrid)(target)); return; } this._contentLoaded = true; }