/// <summary> /// 添加入群须知 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hyper_Link_Click(object sender, RoutedEventArgs e) { try { if (this.DataContext is ChatViewModel cvm && cvm.TargetVM is GroupViewModel) { GroupViewModel gvm = (this.DataContext as ChatViewModel).TargetVM as GroupViewModel; GroupViewModel gvm1 = AppData.MainMV.GroupListVM.Items.ToList().FirstOrDefault(x => x.ID == gvm.ID); GroupModel groupModel = gvm1.Model as GroupModel; GroupNotice gnTice = gvm1.AllNotice.FirstOrDefault(x => x.NoticeTitle == "入群须知"); if (gnTice != null) { AppData.MainMV.TipMessage = "已添加入群须知"; return; } else { App.Current.Dispatcher.Invoke(new Action(() => { GroupModel gm = (cvm.TargetVM as GroupViewModel).Model as GroupModel; GroupNotice gn = new GroupNotice() { NoticeTitle = "入群须知", GroupId = gm.ID, GroupName = gm.DisplayName, NoticeReleTime = DateTime.Now, IsCanOperate = true, NoticeType = 1 }; if (!gvm.IsCreator) { gn.IsCanOperate = false; } GroupNoticeWindow gnw = new GroupNoticeWindow(gn, "添加入群须知"); gnw.txb_Title.IsEnabled = false; gnw.Owner = App.Current.MainWindow; gnw.ShowDialog(); })); } } } catch (Exception ex) { MessageBox.ShowDialogBox(ex.Message); } }
/// <summary> /// 添加普通群公告 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bd_AddNotice_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (this.DataContext is ChatViewModel cvm && cvm.TargetVM is GroupViewModel) { GroupModel gm = (cvm.TargetVM as GroupViewModel).Model as GroupModel; GroupNotice gn = new GroupNotice() { GroupId = gm.ID, GroupName = gm.DisplayName, NoticeReleTime = DateTime.Now, IsCanOperate = true, NoticeType = 0 }; GroupNoticeWindow gnw = new GroupNoticeWindow(gn); gnw.Owner = App.Current.MainWindow; gnw.ShowDialog(); } }