public PracticalContentProcesser(int practicalID, IList <Autograph> autographs, PracticalItemProject project) { this.practicalID = practicalID; this.project = project; this.autographs = autographs; this.practicalManager = SingletonManager.Get <PracticalManager>(); }
private void OperateExcuted(object sender, ExecutedRoutedEventArgs e) { PracticalItemProject project = (PracticalItemProject)e.Parameter; PracticalOperate practicalOperate = new PracticalOperate(practicalItem, practicalItem.Autographs, practicalItem.ID, project); operateContainer.Content = practicalOperate; practicalOperate.OnBacked += PracticalOperate_OnBacked; projectContainer.Visibility = Visibility.Collapsed; operateContainer.Visibility = Visibility.Visible; }
private void LoadProcess(PracticalItem[] items) { if (!File.Exists(practicalProcessFileName)) { return; } XmlDocument document = new XmlDocument(); using (StringReader reader = new StringReader(UTF8Encoding.UTF8.GetString(File.ReadAllText(practicalProcessFileName).Split(' ').Select(item => Convert.ToByte(item)).ToArray()))) document.Load(reader); foreach (XmlNode practical in document.SelectSingleNode("process")) { int practicalId = Convert.ToInt32(practical.Attributes["id"].Value); PracticalItem practicalItem = items.SingleOrDefault(item => item.ID == practicalId); if (practicalItem == null) { continue; } foreach (XmlNode project in practical.ChildNodes) { int projectId = Convert.ToInt32(project.Attributes["id"].Value); PracticalItemProject projectItem = practicalItem.Projects.SingleOrDefault(item => item.ID == projectId); if (practicalItem == null) { continue; } projectItem.IsDone = ExistPract(practicalItem.ID) && Convert.ToBoolean(project.Attributes["hasdone"].Value); } practicalItem.UpdateState(); } }
public PracticalOperate(IHelper f2Helper, IList <Autograph> autographs, int practicalID, PracticalItemProject project) { this.f1Helper = project; this.f2Helper = f2Helper; this.isOpenDialog = false; this.keyboardHook = new KeyboardHook(); //this.keyboardHook.SetHook(); this.keyboardHook.OnKeyUp += KeyboardHook_OnKeyUp; Application.Current.Exit += Current_Exit; InitializeComponent(); if (!this.IsInDesignMode()) { contentProcesser = new PracticalContentProcesser(practicalID, autographs, project); container.SetBinding(Panel.DataContextProperty, new Binding(".") { Source = project }); practicalFilePath = contentProcesser.LoadContent(); } }
public PracticalItem[] GetAllPractical() { if (!File.Exists(templateFileName)) { throw new Exception("题库文件丢失。"); } FileStream fs = null; byte[] buffer = null; PracticalItem[] items = null; int[] practicalProjectCountArray = null; int[][] practicalProjectContentBufferLengthArray = null; int[][] practicalProjectF1BufferLengthArray = null; int[] practicalProjectF2BufferLengthArray = null; int[] practicalAutographCount = null; int[] practicalNameBufferLength = null; try { fs = new FileStream(templateFileName, FileMode.Open, FileAccess.Read); buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); items = new PracticalItem[BitConverter.ToInt32(buffer, 0)]; practicalProjectCountArray = new int[items.Length]; practicalProjectContentBufferLengthArray = new int[items.Length][]; practicalProjectF1BufferLengthArray = new int[items.Length][]; practicalProjectF2BufferLengthArray = new int[items.Length]; practicalNameBufferLength = new int[items.Length]; practicalAutographCount = new int[items.Length]; practicalContentBufferLength = new long[items.Length]; for (int i = 0; i < items.Length; i++) { items[i] = new PracticalItem(); } for (int i = 0; i < items.Length; i++) { buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); practicalAutographCount[i] = BitConverter.ToInt32(buffer, 0); } for (int i = 0; i < items.Length; i++) { buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); practicalProjectCountArray[i] = BitConverter.ToInt32(buffer, 0); practicalProjectContentBufferLengthArray[i] = new int[practicalProjectCountArray[i]]; practicalProjectF1BufferLengthArray[i] = new int[practicalProjectCountArray[i]]; } for (int i = 0; i < items.Length; i++) { for (int j = 0; j < practicalProjectCountArray[i]; j++) { PracticalItemProject project = new PracticalItemProject(); project.ID = j; items[i].Projects.Add(project); } } for (int i = 0; i < items.Length; i++) { for (int j = 0; j < practicalProjectCountArray[i]; j++) { buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); practicalProjectContentBufferLengthArray[i][j] = BitConverter.ToInt32(buffer, 0); } } for (int i = 0; i < items.Length; i++) { for (int j = 0; j < practicalProjectCountArray[i]; j++) { buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); practicalProjectF1BufferLengthArray[i][j] = BitConverter.ToInt32(buffer, 0); } } for (int i = 0; i < items.Length; i++) { buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); practicalProjectF2BufferLengthArray[i] = BitConverter.ToInt32(buffer, 0); } for (int i = 0; i < items.Length; i++) { buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); practicalNameBufferLength[i] = BitConverter.ToInt32(buffer, 0); } for (int i = 0; i < items.Length; i++) { buffer = new byte[sizeof(long)]; fs.Read(buffer, 0, buffer.Length); practicalContentBufferLength[i] = BitConverter.ToInt64(buffer, 0); } for (int i = 0; i < items.Length; i++) { for (int j = 0; j < practicalProjectCountArray[i]; j++) { buffer = new byte[practicalProjectContentBufferLengthArray[i][j]]; fs.Read(buffer, 0, buffer.Length); items[i].Projects[j].Name = UTF8Encoding.UTF8.GetString(buffer); } } for (int i = 0; i < items.Length; i++) { for (int j = 0; j < practicalProjectCountArray[i]; j++) { buffer = new byte[practicalProjectF1BufferLengthArray[i][j]]; fs.Read(buffer, 0, buffer.Length); items[i].Projects[j].HelperText = UTF8Encoding.UTF8.GetString(buffer); } } for (int i = 0; i < items.Length; i++) { buffer = new byte[practicalProjectF2BufferLengthArray[i]]; fs.Read(buffer, 0, buffer.Length); items[i].HelperText = UTF8Encoding.UTF8.GetString(buffer); } for (int i = 0; i < items.Length; i++) { for (int j = 0; j < practicalAutographCount[i]; j++) { Autograph autograph = new Autograph(); buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); buffer = new byte[BitConverter.ToInt32(buffer, 0)]; fs.Read(buffer, 0, buffer.Length); autograph.SheetName = UTF8Encoding.UTF8.GetString(buffer); buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); autograph.RowIndex = BitConverter.ToInt32(buffer, 0); buffer = new byte[sizeof(int)]; fs.Read(buffer, 0, buffer.Length); autograph.ColIndex = BitConverter.ToInt32(buffer, 0); items[i].Autographs.Add(autograph); } } for (int i = 0; i < items.Length; i++) { buffer = new byte[practicalNameBufferLength[i]]; fs.Read(buffer, 0, buffer.Length); items[i].ID = i; items[i].Name = UTF8Encoding.UTF8.GetString(buffer); } startIndex = fs.Position; practicalCount = items.Length; LoadProcess(items); } finally { if (fs != null) { fs.Dispose(); } } return(items); }