private void OpenClick(object sender, RoutedEventArgs e) { if (IsSaved ? true : (MessageBox.Show("Current message collection is not saved. Continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)) { MessageOpenWindow mow = new MessageOpenWindow(); mow.Owner = this; if (mow.ShowDialog() == true) { if (mow.Type == 0) { Stream stream = File.Open(mow.Path, FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); Collection<MessageCollection> tmp = (Collection<MessageCollection>)bformatter.Deserialize(stream); stream.Close(); Lines = tmp[0]; Destinations = tmp[1]; Stops = tmp[2]; InitializeAll(); RefreshPreview(); } SaveFile = mow.Path; IsSaved = true; } } }
public MessageCollection(MessageCollection source) { DisplayType = source.DisplayType; Messages = new List<MessageStorage>(source.Messages); }
private void NewClick(object sender, RoutedEventArgs e) { if (IsSaved ? true : (MessageBox.Show("Current message collection is not saved. Continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)) { Lines = new MessageCollection("Lines", Settings.Default.MessageLinesCount); Destinations = new MessageCollection("Destinations", Settings.Default.MessageDestinationsCount); Stops = new MessageCollection("Stops", Settings.Default.MessageStopsCount); InitializeAll(); SaveFile = ""; IsSaved = false; } }
public Description(MessageCollection lines, MessageCollection destinations, MessageCollection stops) { CreationDate = System.Text.Encoding.ASCII.GetBytes(DateTime.Now.ToString("ddMMyyyy")); Comment = System.Text.Encoding.ASCII.GetBytes("VALDS & EKSELCOM RIGA LATVIA"); Revision = System.Text.Encoding.ASCII.GetBytes("REV 1.01"); string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\MyFaPixel\Config\Extra.txt"; if (File.Exists(path)) { StreamReader stream = new StreamReader(path); String str = stream.ReadLine(); stream.Close(); if (str.Length == (Extra.Length * 3 - 1)) for (int i = 0; i < Extra.Length; ++i) byte.TryParse(str.Substring(i * 3, 2), System.Globalization.NumberStyles.HexNumber, null, out Extra[i]); } GeneralFAT = new FAT(); FontFAT = new FAT(); LineFAT = new FAT(); DestinationFAT = new FAT(); StopFAT = new FAT(); Fonts = new List<Font>(); Lines = new List<Message>(1000); for (int i = 0; i < 1000; ++i) Lines.Add(null); Destinations = new List<Message>(1000); for (int i = 0; i < 1000; ++i) Destinations.Add(null); Stops = new List<Message>(2000); for (int i = 0; i < 2000; ++i) Stops.Add(null); Message tmpMessage; int tmpFont; foreach (MessageStorage message in lines.Messages) { if (message != null) { ++CountLine; tmpMessage = new Message(); foreach (PageStorage page in message.Pages) { if (page != null) { tmpFont = FontByName(page.Strings[0].Font); if (tmpFont < 0) { Fonts.Add(new Font(page.Strings[0].Font)); tmpFont = Fonts.Count - 1; } tmpMessage.Items.Add(new Page(tmpFont, page.Strings[0].Indent, page.Strings[0].X, page.Strings[0].Width, page.Strings[0].Shift, page.Strings[0].Text, Fonts[tmpFont].Ascii, message.Loop, 0)); } } LastLine = lines.Messages.IndexOf(message); Lines[LastLine] = tmpMessage; } } foreach (MessageStorage message in destinations.Messages) { if (message != null) { ++CountDestination; tmpMessage = new Message(); foreach (PageStorage page in message.Pages) { if (page != null) { tmpFont = FontByName(page.Strings[0].Font); if (tmpFont < 0) { Fonts.Add(new Font(page.Strings[0].Font)); tmpFont = Fonts.Count - 1; } tmpMessage.Items.Add(new Page(tmpFont, page.Strings[0].Indent, page.Strings[0].X, page.Strings[0].Width, page.Strings[0].Shift, page.Strings[0].Text, Fonts[tmpFont].Ascii, (tmpMessage.Items.Count > 0 ? message.Loop : false), (tmpMessage.Items.Count > 0 || message.Pages.Last() != null ? page.Time : 0))); } } LastDestination = destinations.Messages.IndexOf(message); Destinations[LastDestination] = tmpMessage; } } foreach (MessageStorage message in stops.Messages) { if (message != null) { ++CountStop; tmpMessage = new Message(); foreach (PageStorage page in message.Pages) { if (page != null) { tmpFont = FontByName(page.Strings[0].Font); if (tmpFont < 0) { Fonts.Add(new Font(page.Strings[0].Font)); tmpFont = Fonts.Count - 1; } tmpMessage.Items.Add(new Page(tmpFont, page.Strings[0].Indent, page.Strings[0].X, page.Strings[0].Width, page.Strings[0].Shift, page.Strings[0].Text, Fonts[tmpFont].Ascii, (tmpMessage.Items.Count > 0 ? message.Loop : false), (tmpMessage.Items.Count > 0 || message.Pages.Last() != null ? page.Time : 0))); } } LastStop = stops.Messages.IndexOf(message); Stops[LastStop] = tmpMessage; } } GeneralFAT.Addresses.Add(FileLength); FileLength += (UInt32)(Fonts.Count * 4); GeneralFAT.Addresses.Add(FileLength); FileLength += (UInt32)((LastLine + 1) * 4); GeneralFAT.Addresses.Add(FileLength); FileLength += (UInt32)((LastDestination + 1) * 4); GeneralFAT.Addresses.Add(FileLength); FileLength += (UInt32)((LastStop + 1) * 4); foreach (Font tmp in Fonts) { FontFAT.Addresses.Add(FileLength); FileLength += tmp.Weight; } foreach (Message tmp in Lines) { if (tmp != null) { LineFAT.Addresses.Add(FileLength); FileLength += tmp.Weight; if (Lines.IndexOf(tmp) == LastLine) break; } else LineFAT.Addresses.Add(0); } foreach (Message tmp in Destinations) { if (tmp != null) { DestinationFAT.Addresses.Add(FileLength); FileLength += tmp.Weight; if (Destinations.IndexOf(tmp) == LastDestination) break; } else DestinationFAT.Addresses.Add(0); } foreach (Message tmp in Stops) { if (tmp != null) { StopFAT.Addresses.Add(FileLength); FileLength += tmp.Weight; if (Stops.IndexOf(tmp) == LastStop) break; } else StopFAT.Addresses.Add(0); } }