123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using XHZB.Model;
- using Common.ZB;
- using XHZB.Desktop.Utils;
- using Common.system;
- using System.Windows.Media.Animation;
- using System.Threading;
-
- namespace XHZB.Desktop
- {
-
-
-
- public partial class ToolbarWindow : Window
- {
- #region 字段
-
-
-
- internal double pwidth = SystemParameters.PrimaryScreenWidth;
-
-
-
- internal double pHeight = SystemParameters.PrimaryScreenHeight;
-
-
-
- internal ToolbarModel pageData = new ToolbarModel();
-
-
-
- private bool heibanshow = false;
- #endregion
-
- #region 初始化
- public ToolbarWindow()
- {
- InitializeComponent();
-
- txbName.Text = APP.LoginUser.username;
-
- heiban_btn.Click += Heiban_btn_Click;
- pizhu_btn.Click += Pizhu_btn_Click;
- Topmost = true;
- Left = pwidth - 300;
- Top = (pHeight - 568) / 2;
-
- pageData.menuList.Add(new ToolbarMenu()
- {
- Name = "个人空间",
- Pic = "../Images/ToolBar/我的备课@2x.png"
- });
- pageData.menuList.Add(new ToolbarMenu()
- {
- Name = "直播",
- Pic = "../Images/ToolBar/直播@2x.png"
- });
- pageData.menuList.Add(new ToolbarMenu()
- {
- Name = "抢答点名",
- Pic = "../Images/ToolBar/抢答@2x.png"
- });
- pageData.menuList.Add(new ToolbarMenu()
- {
- Name = "课堂工具",
- Pic = "../Images/ToolBar/黑板01@2x.png"
- });
- pageData.menuList.Add(new ToolbarMenu()
- {
- Name = "本节考勤",
- Pic = "../Images/ToolBar/本节考勤01@2x.png"
- });
- pageData.menuList.Add(new ToolbarMenu()
- {
- Name = "结束课堂",
- Pic = "../Images/ToolBar/下课@2x.png"
- });
-
- DataContext = pageData;
- }
- #endregion
-
- #region 事件
-
-
-
-
-
- private void toolbar_item_Click(object sender, RoutedEventArgs e)
- {
- int clickindex = 0;
- List<Button> buttons = VTHelper.FindChilds<Button>(toolbar_list, "toolbar_item");
- for (int i = 0; i < buttons.Count; i++)
- {
- if (buttons[i] == sender)
- {
- clickindex = i;
- break;
- }
- }
- ToolbarMenu item = pageData.menuList[clickindex];
- if (clickindex == 0)
- {
- try
- {
-
- if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
- {
- APP.W_UserCenterWindow.Focus();
- }
- else
- {
- APP.W_UserCenterWindow = new UserCenterWindow();
- APP.W_UserCenterWindow.Show();
- APP.W_UserCenterWindow.Closed += UserCenterWindow_Closed;
- }
-
- }
- catch (Exception ex)
- {
-
-
- LogHelper.WriteErrLog("【个人空间(toolbar_item_Click)" + ex.Message, ex);
- }
- }
- else if (clickindex == 1)
- {
-
- pageData.tongping = !pageData.tongping;
- if (pageData.tongping)
- {
-
- pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
- pageData.menuList[1].Name = "正在直播";
-
- if(APP.W_CameraWindow==null)
- {
- APP.W_CameraWindow = new CameraWindow();
- APP.W_CameraWindow.Topmost = true;
- APP.W_CameraWindow.Left = pwidth - 300;
- APP.W_CameraWindow.Top = 0;
- }
- APP.W_CameraWindow.Show();
- }
- else
- {
-
- pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
- pageData.menuList[1].Name = "直播";
- APP.W_CameraWindow.Hide();
- }
- }
- else if (clickindex == 2)
- {
-
- try
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (APP.W_RollCallWindow == null)
- {
- APP.W_RollCallWindow = new RollCallWindow();
-
- }
- else
- {
-
- }
- APP.W_RollCallWindow.Owner = this;
-
-
- APP.W_RollCallWindow.Show();
- }
- catch (Exception ex)
- {
-
-
- LogHelper.WriteErrLog("【抢答点名(toolbar_item_Click)" + ex.Message, ex);
- }
- }
- else if (clickindex == 3)
- {
- try
- {
- heibanshow = !heibanshow;
- List<DependencyObject> list = new List<DependencyObject>
- {
- heiban_btn,
- pizhu_btn
- };
-
-
-
-
-
-
-
-
-
-
- hideOrShow(heibanshow, ketangTool, list);
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【课堂工具(toolbar_item_Click)" + ex.Message, ex);
- }
- }
- else if (clickindex == 4)
- {
-
- try
- {
- showKaoqin();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
- }
- }
- else if (clickindex == 5)
- {
- if (MessageWindow.Show("是否结束课堂?", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
- {
- closeAction();
- }
- }
- }
-
-
-
-
-
- private void UserCenterWindow_Closed(object sender, EventArgs e)
- {
- APP.W_UserCenterWindow = null;
-
- }
-
-
-
- private void showKaoqin()
- {
-
-
-
-
-
-
-
-
-
- try
- {
- #region 关闭冲突页面
-
-
-
-
-
-
-
-
-
-
- #endregion 关闭冲突页面
-
- if (APP.W_AttendanceWindow == null)
- {
- APP.W_AttendanceWindow = new AttendanceWindow
- {
- Owner = this
- };
-
- }
- else
- {
-
- }
-
- APP.W_AttendanceWindow.Show();
- }
- catch (Exception ex)
- {
-
-
- LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
- }
-
- }
-
-
-
-
-
- private void Heiban_btn_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- heibanshow = !heibanshow;
-
- #region 关闭冲突页面
-
-
-
- #endregion 关闭冲突页面
-
- List<DependencyObject> list = new List<DependencyObject>
- {
- heiban_btn,
- pizhu_btn
- };
- hideOrShow(heibanshow, ketangTool, list);
- if (APP.W_ZBlackboardWindow == null)
- {
- APP.W_ZBlackboardWindow = new ZBlackboardWindow
- {
- Topmost = true,
- Width = pwidth,
- Height = pHeight,
- Left = 0,
- Top = 0,
- Owner = this
- };
-
- }
-
- APP.W_ZBlackboardWindow.ShowDialog();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【黑板(Heiban_btn_Click)" + ex.Message, ex);
- }
- }
-
-
-
-
-
- private void Pizhu_btn_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- heibanshow = !heibanshow;
-
- #region 关闭冲突页面
-
-
-
- #endregion 关闭冲突页面
-
- List<DependencyObject> list = new List<DependencyObject>
- {
- heiban_btn,
- pizhu_btn
- };
- hideOrShow(heibanshow, ketangTool, list);
- if (APP.W_PracticeWindow == null)
- {
- APP.W_PracticeWindow = new PracticeWindow();
- APP.W_PracticeWindow.click_closeClick += PracticeWin_click_closeClick;
- APP.W_PracticeWindow.Topmost = true;
- APP.W_PracticeWindow.Width = pwidth;
- APP.W_PracticeWindow.Height = pHeight;
- APP.W_PracticeWindow.Left = 0;
- APP.W_PracticeWindow.Top = 0;
-
- APP.W_PracticeWindow.Unloaded += PracticeWin_Unloaded;
- }
- APP.W_PracticeWindow.Owner = this;
- Hide();
- addimage();
-
- APP.W_PracticeWindow.ShowDialog();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【批注(Pizhu_btn_Click)" + ex.Message, ex);
- }
- }
-
-
-
- private void addimage()
- {
- string ImagePath = ImageHelper.GetTempImagePath();
- ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), ImagePath,false,out BitmapImage bitmapImage,-1);
- APP.W_PracticeWindow.addImage(ImagePath);
- }
-
-
-
- private void PracticeWin_click_closeClick()
- {
- APP.W_PracticeWindow = null;
- }
-
-
-
-
-
- private void PracticeWin_Unloaded(object sender, RoutedEventArgs e)
- {
- Show();
- }
-
-
-
- private void closeAction()
- {
-
-
- try
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Dispatcher.Invoke(new Action(() =>
- {
- System.Environment.Exit(0);
- }));
-
- }
- catch (Exception ex)
- {
-
- LogHelper.WriteErrLog("【ToolbarWindow】(closeAction)" + ex.Message, ex);
- }
-
-
- }
-
-
-
-
-
-
- private void hideOrShow(bool toolShow, DependencyObject target, List<DependencyObject> contentList)
- {
- Storyboard story = new Storyboard();
- DoubleAnimation da = new DoubleAnimation();
- if (toolShow)
- {
- da.From = 0;
- da.To = 173;
- }
- else
- {
- da.From = 173.0;
- da.To = 0.0;
- }
-
-
- da.AutoReverse = false;
-
-
- da.Duration = new Duration(TimeSpan.FromSeconds(0.3));
- Storyboard.SetTarget(da, target);
- Storyboard.SetTargetProperty(da, new PropertyPath("Width"));
- story.Children.Add(da);
-
- foreach (DependencyObject item in contentList)
- {
- DoubleAnimation da2 = new DoubleAnimation();
- if (toolShow)
- {
- da2.From = 0;
- da2.To = 1.0;
- }
- else
- {
- da2.From = 1.0;
- da2.To = 0.0;
- }
- da2.Duration = new Duration(TimeSpan.FromSeconds(0.1));
- Storyboard.SetTarget(da2, item);
- Storyboard.SetTargetProperty(da2, new PropertyPath("Opacity"));
- story.Children.Add(da2);
- }
-
- story.Begin();
- }
-
-
-
-
-
-
- private void hideOrShowToolbar(bool toolShow, DependencyObject target, List<DependencyObject> contentList)
- {
- if (txbName.Visibility == Visibility.Visible)
- {
- txbName.Visibility = Visibility.Collapsed;
-
-
-
-
- }
- else
- {
- txbName.Visibility = Visibility.Visible;
-
-
-
-
- }
-
- Storyboard story = new Storyboard();
- DoubleAnimation da = new DoubleAnimation();
- if (toolShow)
- {
- da.From = 0;
- da.To = 670;
- }
- else
- {
- da.From = 670;
- da.To = 0.0;
- }
-
-
- da.AutoReverse = false;
-
-
- da.Duration = new Duration(TimeSpan.FromSeconds(0.3));
- Storyboard.SetTarget(da, target);
- Storyboard.SetTargetProperty(da, new PropertyPath("Height"));
- story.Children.Add(da);
-
- foreach (DependencyObject item in contentList)
- {
- DoubleAnimation da2 = new DoubleAnimation();
- if (toolShow)
- {
- da2.From = 0;
- da2.To = 1.0;
- }
- else
- {
- da2.From = 1.0;
- da2.To = 0.0;
- }
- da2.Duration = new Duration(TimeSpan.FromSeconds(0.1));
- Storyboard.SetTarget(da2, item);
- Storyboard.SetTargetProperty(da2, new PropertyPath("Opacity"));
- story.Children.Add(da2);
- }
-
- story.Begin();
- }
- private void toolbar_win_Closed(object sender, EventArgs e)
- {
-
- }
-
- private void toolbar_win_ContentRendered(object sender, EventArgs e)
- {
-
- }
-
- private void toolbar_win_Loaded(object sender, RoutedEventArgs e)
- {
-
- }
-
- private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
- {
-
- }
- private int time = NumUtil.unixTime();
- private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- int temptime = NumUtil.unixTime();
- if (temptime - time < 1)
- {
- pageData.IsOpen = !pageData.IsOpen;
-
- List<DependencyObject> list = new List<DependencyObject>
- {
- toolbar_list
- };
-
- hideOrShowToolbar(pageData.IsOpen, toolbar, list);
-
- if (!pageData.IsOpen)
- {
- if (heibanshow)
- {
- List<DependencyObject> list3 = new List<DependencyObject>();
- heibanshow = false;
- list3.Add(heiban_btn);
- list3.Add(pizhu_btn);
- hideOrShow(heibanshow, ketangTool, list3);
- }
- }
- }
- }
-
-
-
-
-
- private void Rectangle_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- {
- DragMove();
- }
- }
- #endregion
- }
-
-
-
- public class ToolbarModel : NotifyModel
- {
- public ObservableCollection<ToolbarMenu> menuList { get; set; }
-
- internal bool _tongping = false;
-
- public bool tongping
- {
- get => _tongping;
- set { _tongping = value; OnPropertyChanged("tongping"); }
- }
-
- internal bool _IsOpen = true;
-
- public bool IsOpen
- {
- get => _IsOpen;
- set { _IsOpen = value; OnPropertyChanged("IsOpen"); }
- }
-
- public ToolbarModel()
- {
- menuList = new ObservableCollection<ToolbarMenu>();
- }
- }
-
-
-
-
- public class ToolbarMenu : NotifyModel
- {
- internal string _name;
-
- public string Name
- {
- get => _name;
- set { _name = value; OnPropertyChanged("Name"); }
- }
-
- internal string _Pic;
-
- public string Pic
- {
- get => _Pic;
- set { _Pic = value; OnPropertyChanged("Pic"); }
- }
- }
- }
|