diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index 5bed76f..8e31c48 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -48,7 +48,7 @@ namespace Reseter2 this.Close(); } - + InitializeComponent(); checkControl1.updateCheck += CheckControl1_updateCheck; flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ; @@ -60,6 +60,7 @@ namespace Reseter2 treeView1.Nodes.AddRange(WordsList.ListNodes()); + treeView1.SelectedNode. //treeView1.MouseCaptureChanged.; tabControl1.SelectedIndex = 1; diff --git a/Reseter2/Reseter2.csproj b/Reseter2/Reseter2.csproj index 1ae37f9..b87b271 100644 --- a/Reseter2/Reseter2.csproj +++ b/Reseter2/Reseter2.csproj @@ -75,6 +75,7 @@ + @@ -92,6 +93,7 @@ Component + Form diff --git a/Reseter2/Setting/SGlobalSetting.cs b/Reseter2/Setting/SGlobalSetting.cs new file mode 100644 index 0000000..bd39de2 --- /dev/null +++ b/Reseter2/Setting/SGlobalSetting.cs @@ -0,0 +1,76 @@ +using Reseter2.Words; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using System.Security.Policy; +using System.Text; +using System.Threading.Tasks; + +namespace Reseter2.Setting +{ + [Serializable] + internal static class SGlobalSetting + { + public static SettingHistory settingHistory + public static SettingWords settingWords = new SettingWords(); + + public static void LoadSetting() + { + + } + + public static bool Load(string path) + { + BinaryFormatter binaryFormatter = new BinaryFormatter(); + FileStream file = null; + try + { + file = new FileStream(path, FileMode.Open); + WordsList.MainCategory = (WordsCategory)binaryFormatter.Deserialize(file); + file.Close(); + file.Dispose(); + return true; + } + catch + { + return false; + } + + } + + private static object Clone(object input) + { + object output; + BinaryFormatter binaryFormatter = new BinaryFormatter(); + MemoryStream Memory = new MemoryStream(); + binaryFormatter.Serialize(Memory, input); + Memory.Position = 0; + if (input is WordsCategory) settingWords.HashSumm(Memory); + Memory.Position = 0; + output = binaryFormatter.Deserialize(Memory); + Memory.Dispose(); + Memory.Close(); + + return output; + } + + public static WordsCategory Clone(WordsCategory input) + { + return (WordsCategory)Clone((object)input); + } + + public static IComp Clone(IComp input) + { + return (IComp)Clone((object)input); + } + + public static void Save() + { + + } + + + } +} diff --git a/Reseter2/Setting/SettingWords.cs b/Reseter2/Setting/SettingWords.cs new file mode 100644 index 0000000..d523839 --- /dev/null +++ b/Reseter2/Setting/SettingWords.cs @@ -0,0 +1,41 @@ +using Reseter2.Words; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using System.Security.Cryptography; +using System.Security.Policy; +using System.Text; +using System.Threading.Tasks; +using static System.Net.WebRequestMethods; + +namespace Reseter2.Setting +{ + [Serializable] + internal class SettingWords + { + public string PathBase { get; set; } + [NonSerialized] + private MD5 Hash = MD5.Create(); + [NonSerialized] + private byte[] hash; + public SettingWords() + { + PathBase = "base.dat"; + } + + public SettingWords(string pathBase) + { + PathBase = pathBase; + } + + public void HashSumm(MemoryStream memory) + { + hash = Hash.ComputeHash(memory); + } + + + + } +} \ No newline at end of file diff --git a/Reseter2/Words/BilderWords.cs b/Reseter2/Words/BilderWords.cs index 6c3913d..cf9059b 100644 --- a/Reseter2/Words/BilderWords.cs +++ b/Reseter2/Words/BilderWords.cs @@ -1,4 +1,5 @@ using Reseter2.History; +using Reseter2.Setting; using System; using System.Collections.Generic; using System.ComponentModel; @@ -36,39 +37,16 @@ namespace Reseter2.Words public BilderWords(IComp comp) { LoadForm(); - BinaryFormatter binaryFormatter = new BinaryFormatter(); - MemoryStream memory = new MemoryStream(); - binaryFormatter.Serialize(memory, comp); - memory.Position = 0; - CompId compId = (CompId)binaryFormatter.Deserialize(memory); - memory.Close(); - memory.Dispose(); - //TreeNode treeNode = new TreeNode(); - WordsComp item = new WordsComp(compId); - WordsList.AddItem(item, ChangeCategory); - - + CompId compId = (CompId)SGlobalSetting.Clone(comp); + WordsComp item = new WordsComp(compId); + WordsList.AddItem(item, ChangeCategory); treeView1.Nodes.AddRange(WordsList.ListNodes(ChangeCategory)); - //treeNode.ImageIndex = 1; - //treeNode.Text = item.NameNode(); - //treeNode.Tag = item; - //treeView1.Nodes.Add(treeNode); } private void LoadForm() { - BinaryFormatter binaryFormatter = new BinaryFormatter(); - MemoryStream Memory = new MemoryStream(); - binaryFormatter.Serialize(Memory, WordsList.MainCategory); - Memory.Position = 0; - hash = Hash.ComputeHash(Memory); - Memory.Position = 0; - ChangeCategory = (WordsCategory)binaryFormatter.Deserialize(Memory); - Memory.Dispose(); - Memory.Close(); - + ChangeCategory = SGlobalSetting.Clone(WordsList.MainCategory); InitializeComponent(); - cb_create.Items.Add("Категория"); cb_create.Items.Add("Компьютер"); cb_create.SelectedIndex = 0; @@ -76,9 +54,6 @@ namespace Reseter2.Words treeView1.DragEnter += new DragEventHandler(TreeView1_DragEnter); treeView1.DragOver += new DragEventHandler(TreeView1_DragOver); treeView1.DragDrop += new DragEventHandler(TreeView1_DragDrop); - - - this.DialogResult = DialogResult.Abort; } private void TreeView1_ItemDrag(object sender, ItemDragEventArgs e) { @@ -87,7 +62,6 @@ namespace Reseter2.Words { DoDragDrop(e.Item, DragDropEffects.Move); } - //throw new NotImplementedException(); } private void TreeView1_DragEnter(object sender, DragEventArgs e)