예제 #1
0
파일: Form1.cs 프로젝트: iamapi/MtgoxTrader
 public Form1()
 {
     InitializeComponent();
     InitializeData();
     InitializeControl();
     LoadSettings(null, null);
     MtGoxConfig = new Config();
     mtgoxV0 = new MtGoxAPIV0();
 }
예제 #2
0
        public static void SaveToFile(Config config, string fileName)
        {
            using (MemoryStream memStream = new MemoryStream())
            {
                DataContractSerializer serializer = new DataContractSerializer(typeof(Config));
                serializer.WriteObject(memStream, config);

                // Encrypt the memory stream.
                byte[] encryptedData = Encryption.EncryptData(memStream.ToArray());

                using (FileStream stream =
                    new FileStream(fileName, FileMode.Create))
                {
                    stream.Write(encryptedData, 0, encryptedData.Length);
                }
            }
        }
예제 #3
0
        public static Config LoadFromFile(string fileName)
        {
            Config config = new Config();
            byte[] fileContents = File.ReadAllBytes(fileName);

            byte[] decryptedData = Encryption.DecryptData(fileContents);

            using (MemoryStream stream = new MemoryStream())
            {
                stream.Write(decryptedData, 0, decryptedData.Length);

                stream.Position = 0;

                DataContractSerializer serializer = new DataContractSerializer(typeof(Config));

                config = (Config)serializer.ReadObject(stream);
            }
            return config;
        }
예제 #4
0
        private void showContent()
        {
            MtGoxConfig = new Config();
            try
            {
                MtGoxConfig = ConfigHelper.LoadFromFile(this.configrFullPath);
                this.txtKey.Text = MtGoxConfig.Key;
                this.txtSecret.Text = MtGoxConfig.Secret;
                this.comboCurrency.SelectedItem = MtGoxConfig.Currency;
            }
            catch(Exception e)
            {

            }
        }