//read all bool ReadAll() { try { //when existence if (File.Exists("KeyboardAllStrings.asd")) { //clear KeyboardAllStrings.Clear(); KeyboardAllImage.Clear(); KeyboardAllConjunctionMatrix.Clear(); /* String Tem = File.ReadAllText("KeyboardAllStrings.asd"); * if (Tem.Length > 0) * { * for (int i = 0; i < Tem.Length; i++) * { * KeyboardAllStrings.Add(Tem[i].ToString()); * } * } * else * { * bool Do = CreateString(); * if (!Do) * return false; * }*/ //serilized Refrigtz.TakeRoot tr = new Refrigtz.TakeRoot(); AllKeyboardOfWorld t = tr.Load("KeyboardAllStrings.asd"); this.KeyboardAllConjunctionMatrix = t.KeyboardAllConjunctionMatrix; this.KeyboardAllConjunctionMatrixList = t.KeyboardAllConjunctionMatrixList; this.KeyboardAllImage = t.KeyboardAllImage; this.KeyboardAllStrings = t.KeyboardAllStrings; } else//others retiurn unsuccessfull { return(false); } } catch (Exception t) { //when unsuccessfull return false return(false); } //return true return(true); }
//Savle all bool SaveAll() { try { //when file dos not exist if (!File.Exists("KeyboardAllStrings.asd")) { /* lock (KeyboardAllStrings) * { * for (int i = 0; i < KeyboardAllStrings.Count; i++) * { * File.AppendAllText("KeyboardAllStrings.asd", KeyboardAllStrings[i]); * } * }*/ //serialized on take root if (this.KeyboardAllImage.Count > 0) { Refrigtz.TakeRoot t = new Refrigtz.TakeRoot(); t.Save(this, "KeyboardAllStrings.asd"); } } else //delete and serilized take root { File.Delete("KeyboardAllStrings.asd"); if (this.KeyboardAllImage.Count > 0) { Refrigtz.TakeRoot t = new Refrigtz.TakeRoot(); t.Save(this, "KeyboardAllStrings.asd"); } } } catch (Exception t) { //System.Windows.Forms.MessageBox.Show("Fatual Error!" + t.ToString()); return false; } return(true); }