static public BcProject FromFile(string filename) { FileStream fs = new FileStream(filename, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); BcProject project = (BcProject)bf.Deserialize(fs); fs.Close(); return(project); }
private void saveProjectAsToolStripMenuItem_Click(object sender, EventArgs e) { try { BcProject project = BcProject.FromFile((string)lbProjects.SelectedItem); if (saveFileDialog1.ShowDialog() != DialogResult.OK) { return; } project.Save(saveFileDialog1.FileName); AddToProjectList(saveFileDialog1.FileName); } catch { MessageBox.Show("Cannot save project", "File write error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { try { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } foreach (string s in openFileDialog1.FileNames) { BcProject project = BcProject.FromFile(s); AddToProjectList(s); } } catch { MessageBox.Show("Cannot open project", "File read error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public BcPrintDocument(AxBarCodeWiz bc, BcProject project) { this.bc = bc; DefaultPageSettings = project.pageSettings; table = project.table; data = project.data; project.state.ApplyState(bc); xDist = project.layout.xDist; yDist = project.layout.yDist; title = project.layout.title; titleFont = project.layout.titleFont; printTitleOnce = project.layout.printTitleOnce; bs = new BindingSource(); bs.DataSource = table; bs.Sort = data.sort; MarginsConverter mc = new MarginsConverter(); xDist = (float)PrinterUnitConvert.Convert(xDist * 10, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display); yDist = (float)PrinterUnitConvert.Convert(yDist * 10, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display); }
private void lbProjects_SelectedIndexChanged(object sender, EventArgs e) { try { string filename = (string)lbProjects.SelectedItem; if (filename != prevName) { if (TryToSaveChanges() == DialogResult.Cancel) { lbProjects.SelectedItem = prevName; return; } hasChanges = false; prevName = filename; prCur = BcProject.FromFile(filename); BcPrintDocument doc = new BcPrintDocument(bc, prCur); ppc.Document = doc; ppc.InvalidatePreview(); ppc.Select(); } else { //if (hasChanges == false) // return; BcPrintDocument doc = new BcPrintDocument(bc, prCur); ppc.Document = doc; ppc.InvalidatePreview(); ppc.Select(); } } catch { prCur = null; RemoveFromProjectList((string)lbProjects.SelectedItem); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { string filename = "Project.bcp"; BcSource source = BcSource.Workers; decimal plantId = -1; RewDataSet.BarcodeDataTable table = null; BarcodeData data = null; BarcodeState state = null; BcLayout layout = null; int i = 0; do { DialogResult res = DialogResult.None; switch (i) { case 0: saveFileDialog1.FileName = filename; res = saveFileDialog1.ShowDialog(); filename = saveFileDialog1.FileName; break; case 1: DataSourceForm dForm = new DataSourceForm(source, plantId, connection, DialogMode.Master); res = dForm.ShowDialog(); source = dForm.GetSource(out plantId); break; case 2: switch (source) { case BcSource.Workers: WorkFilterForm fWork = new WorkFilterForm(connection, table, plantId, DialogMode.Master); res = fWork.ShowDialog(); table = fWork.GetTable(); break; case BcSource.Defects: DefFilterForm fDef = new DefFilterForm(connection, table, plantId, DialogMode.Master); res = fDef.ShowDialog(); table = fDef.GetTable(); break; case BcSource.Repairs: RepFilterForm fRep = new RepFilterForm(connection, table, plantId, DialogMode.Master); res = fRep.ShowDialog(); table = fRep.GetTable(); break; } break; case 3: BarcodeDataForm fData = new BarcodeDataForm(data, DialogMode.Master); res = fData.ShowDialog(); data = fData.GetData(); break; case 4: BarcodeStateForm fState = new BarcodeStateForm(state, DialogMode.Master); res = fState.ShowDialog(); state = fState.GetState(); break; case 5: LayoutForm fLayout = new LayoutForm(layout, DialogMode.Master); res = fLayout.ShowDialog(); layout = fLayout.GetLayout(); break; } switch (res) { case DialogResult.Cancel: return; case DialogResult.OK: i++; break; case DialogResult.Retry: i--; break; } }while (i < 6); BcProject project = new BcProject(source, plantId, table, data, state, layout, new PageSettings()); try { project.Save(filename); } catch { MessageBox.Show("Cannot write file", "Save error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } hasChanges = false; AddToProjectList(filename); }