public static void SaveRound(REWRound rr, ProjFileStream pfs) { pfs.WriteString(rr.roundName); for (int i = 0; i < rr.WordsCount; i++) { pfs.WriteString(rr.words[i]); pfs.WriteBool(rr.states[i]); } }
private void WriteFont(Font fnt, Color cl, ProjFileStream pfs) { pfs.WriteString(fnt.Name); pfs.WriteFloat(fnt.Size); pfs.WriteInt((int)fnt.Style); pfs.WriteInt((int)fnt.Unit); pfs.WriteByte(fnt.GdiCharSet); pfs.WriteBool(fnt.GdiVerticalFont); pfs.WriteColor(cl); }
private Font ReadFont(ProjFileStream pfs, ref Color col) { string name = pfs.ReadString(); float size = pfs.ReadFloat(); FontStyle fs = (FontStyle)pfs.ReadInt(); GraphicsUnit gu = (GraphicsUnit)pfs.ReadInt(); byte cs = pfs.ReadByte(); bool vf = pfs.ReadBool(); col = pfs.ReadColor(); return(new System.Drawing.Font(name, size, fs, gu, cs, vf)); }
private void SaveProject() { ProjFileStream pfs = new ProjFileStream(filename, FileMode.Create, FileAccess.Write); WriteFont(visFont, visCol, pfs); // Видимый шрифт WriteFont(unvFont, unvCol, pfs); // Невидимый шрифт pfs.WriteInt(WordCount); // Количество слов. Должно совпадать при загрузке! pfs.WriteInt(listBox1.Items.Count); // Количество заданий for (int i = 0; i < listBox1.Items.Count; i++) { REWRound.SaveRound((REWRound)listBox1.Items[i], pfs); } pfs.Close(); Saved = true; }
public static REWRound LoadRound(ProjFileStream pfs, int fileCount, int maxCount) { string name = pfs.ReadString(); REWRound rr = new REWRound(name, maxCount); for (int i = 0; i < fileCount; i++) { string wrd = pfs.ReadString(); bool stt = pfs.ReadBool(); if (i < maxCount) { rr.SetAt(wrd, stt, i); } } return(rr); }
private void OpenProject() { listBox1.Items.Clear(); wf.ClearForm(); pf.ClearForm(); ProjFileStream pfs = new ProjFileStream(filename, FileMode.Open, FileAccess.Read); // Видимый шрифт visFont = ReadFont(pfs, ref visCol); wf.VisFont = visFont; pf.VisFont = visFont; wf.VisColor = visCol; pf.VisColor = visCol; // Невидимый шрифт unvFont = ReadFont(pfs, ref unvCol); wf.UnvFont = unvFont; pf.UnvFont = unvFont; wf.UnvColor = unvCol; pf.UnvColor = unvCol; // Количество слов. Должно совпадать! int localWC = pfs.ReadInt(); // Количество заданий int localCNT = pfs.ReadInt(); roundCounter = localCNT; for (int i = 0; i < localCNT; i++) { listBox1.Items.Add(REWRound.LoadRound(pfs, localWC, WordCount)); } if (listBox1.Items.Count > 0) { listBox1.SelectedIndex = 0; } pfs.Close(); Saved = true; }