public PrintController(ArrowSet set) { NewSet(set); doc.PrintPage += printDocument_PrintPage; doc.EndPrint += printDocument_EndPrint; doc.PrinterSettings = settings; preview.Document = doc; print.Document = doc; }
public void LoadFromFile(ref ArrowSet data, string fileName) { try { OnLoad(LoadDataFromFile(ref data, fileName)); } catch (Exception ex) { OnLoad(ErrorMessageLoad + ex.Message); } }
public void SaveToFile(ArrowSet data, string fileName) { try { OnSave(SaveDataToFile(data, fileName)); } catch (Exception ex) { OnSave(ErrorMessageSave + ex.Message); } }
private string[] GetSummaryString(ArrowSet set, bool secondRow = false) { object s = set.GetSummary("Straightness", secondRow); return(new string[] { secondRow?string.Empty : "###", set.GetSummary("Grams", secondRow).ToString(), set.GetSummary("Grains", secondRow).ToString(), set.GetSummary("AMO", secondRow).ToString(), set.GetSummary("ASTM", secondRow).ToString(), s != null?s.ToString() : string.Empty }); }
private string LoadDataFromFile(ref ArrowSet set, string filename) { try { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read); set = (ArrowSet)formatter.Deserialize(stream); stream.Close(); return(null); } catch (Exception e) { return(e.Message); } }
private string SaveDataToFile(ArrowSet arrowSet, string filename) { try { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(filename, FileMode.Create, FileAccess.Write); formatter.Serialize(stream, arrowSet); stream.Close(); return(null); } catch (Exception e) { return(e.Message); } }
private void PrintArrowSetData(PrintPageEventArgs e, ArrowSet set, bool full, bool summary) { int x = 200; int xCellSpacing = 70; int y = 215; int lineSize = Details ? 590 : 390; if (full) { x = 100; xCellSpacing = 60; } var font_bold = new Font("Arial", 9, FontStyle.Bold); var font = new Font("Arial", 9, FontStyle.Regular); PrintDataRow(e, x, y, xCellSpacing, font_bold, GetHeaders(full)); y += 30; PrintLine(e, x, y - 9, x + lineSize, y - 9); int start = currentPage++ *maxEntriesPerPage; for (int i = start; i < set.Arrows.Length; i++) { if (i >= currentPage * maxEntriesPerPage) { e.HasMorePages = true; break; } PrintDataRow(e, x, y, xCellSpacing, font, GetDataString(set.Arrows[i], full)); y += cellSpacingY; } if (Summary) { PrintLine(e, x, y - 3, x + lineSize, y - 3); PrintDataRow(e, x, y + 5, xCellSpacing, font_bold, GetSummaryString(set)); PrintDataRow(e, x, y + 5 + cellSpacingY, xCellSpacing, font_bold, GetSummaryString(set, true)); } }
public void OnLoadHistory() { var dr = DialogResult.Yes; if (currentSet.ArrowCount > 0) { dr = MessageBox.Show( GlobalStrings.SerializerLoadWarning, GlobalStrings.SerializerLoadWarningHeader, MessageBoxButtons.YesNo, MessageBoxIcon.Information); } if (dr == DialogResult.Yes) { load.InitialDirectory = DataSerializer.SaveDirectory; load.Title = GlobalStrings.SerializerOpenFile; load.FileName = ""; load.Filter = DataSerializer.SaveFormat; if (load.ShowDialog() != DialogResult.Cancel) { ClearHistory(); var serializer = new DataSerializer(); serializer.LoadFailed += OnFailed; serializer.LoadSuccessful += OnLoadSuccessful; //TODO: refactor this later var set = new ArrowSet(); serializer.LoadFromFile(ref set, load.FileName); HistoryManager.instance.LoadSet(set); foreach (var arrow in currentSet.Arrows) { AddArrowToView(arrow); } } } }
private static Colors Read_Colors(Stream s, Flags flags, ColorOffsets offsets) { var colors = new Colors(); using (var br = new BinaryReader(s, Encoding.ASCII, true)) { // Top Solid #if SKIP_COLOR_NOT_SET if (flags.TopDrawType == TopDrawType.SolidColor || flags.TopDrawType == TopDrawType.SolidColorTexture) #endif { s.Position = offsets.TopBackground; var sevenBytes = flags.TopDrawType == TopDrawType.SolidColorTexture; colors.TopBackground = TopBackgroundSet.Read(br, sevenBytes); } #if SKIP_COLOR_NOT_SET else { colors.TopBackground = new TopBackgroundSet(); } #endif // Cursor #if SKIP_COLOR_NOT_SET if (flags.CursorColor) #endif { s.Position = offsets.Cursor; colors.Cursor = CursorSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.Cursor = new CursorSet(); } #endif // 3D Folder #if SKIP_COLOR_NOT_SET if (flags.FolderColor) #endif { s.Position = offsets.Folder; colors.Folder = FolderSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.Folder = new FolderSet(); } #endif // 3D File #if SKIP_COLOR_NOT_SET if (flags.FileColor) #endif { s.Position = offsets.File; colors.File = FileSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.File = new FileSet(); } #endif // Arrow Button #if SKIP_COLOR_NOT_SET if (flags.ArrowButtonColor) #endif { s.Position = offsets.ArrowButton; colors.ArrowButton = ArrowButtonSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.ArrowButton = new ArrowButtonSet(); } #endif // Arrows #if SKIP_COLOR_NOT_SET if (flags.ArrowColor) #endif { s.Position = offsets.Arrow; colors.Arrow = ArrowSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.Arrow = new ArrowSet(); } #endif // Open Button #if SKIP_COLOR_NOT_SET if (flags.OpenCloseColor) #endif { s.Position = offsets.Open; colors.Open = OpenCloseSet.Read(br); s.Position = offsets.Close; colors.Close = OpenCloseSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.Open = new OpenCloseSet(); colors.Close = new OpenCloseSet(); } #endif // Game Text #if SKIP_COLOR_NOT_SET if (flags.GameTextDrawType) #endif { s.Position = offsets.GameText; colors.GameText = GameTextSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.GameText = new GameTextSet(); } #endif // Bottom Solid #if SKIP_COLOR_NOT_SET if (flags.BottomBackgroundInnerColor) #endif { s.Position = offsets.BottomSolid; colors.BottomBackgroundInner = BottomBackgroundInnerSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.BottomBackgroundInner = new BottomBackgroundInnerSet(); } #endif // Bottom Outer #if SKIP_COLOR_NOT_SET if (flags.BottomBackgroundOuterColor) #endif { s.Position = offsets.BottomOuter; colors.BottomBackgroundOuter = BottomBackgroundOuterSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.BottomBackgroundOuter = new BottomBackgroundOuterSet(); } #endif // Folder BG #if SKIP_COLOR_NOT_SET if (flags.FolderBackgroundColor) #endif { s.Position = offsets.FolderBackground; colors.FolderBackground = BottomBackgroundInnerSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.FolderBackground = new BottomBackgroundInnerSet(); } #endif // Folder Arr #if SKIP_COLOR_NOT_SET if (flags.FolderArrowColor) #endif { s.Position = offsets.FolderArrow; colors.FolderArrow = FolderArrowSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.FolderArrow = new FolderArrowSet(); } #endif // Bottom Corner #if SKIP_COLOR_NOT_SET if (flags.BottomCornerButtonColor) #endif { s.Position = offsets.BottomCornerButton; colors.BottomCornerButton = BottomCorner.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.BottomCornerButton = new BottomCorner(); } #endif // Top Corner #if SKIP_COLOR_NOT_SET if (flags.TopCornerButtonColor) #endif { s.Position = offsets.TopCornerButton; colors.TopCornerButton = TopCornerSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.TopCornerButton = new TopCornerSet(); } #endif // Demo Text #if SKIP_COLOR_NOT_SET if (flags.DemoTextColor) #endif { s.Position = offsets.DemoText; colors.DemoText = DemoTextSet.Read(br); } #if SKIP_COLOR_NOT_SET else { colors.DemoText = new DemoTextSet(); } #endif } return(colors); }
public void NewSet(ArrowSet set) { this.set = set; }
public ArrowSetViewModel(ArrowSet model, string tag) : base(model, tag) { }
public DataConverter(ArrowSet arrowSet, DataGridView dataGrid) { this.arrowSet = arrowSet; this.dataGrid = dataGrid; }