Ejemplo n.º 1
0
 public void SaveSettings()
 {
     settings = new AppSettings(GetBufferSize(), GetCheck(), GetSet());
     if (GetSet() == SettingsSaveMethod.Registry) { SaveSettingsInRegistry(settings); if (CheckINI()) File.Delete(Environment.CurrentDirectory + "\\Settings.ini"); }
     else if (GetSet() == SettingsSaveMethod.INI) { SaveSettingsInFile(settings); if (RegAccess.CheckRegistry()) RegAccess.CleanRegistry(); }
     else { SaveSettingsInRegistry(settings); if (CheckINI()) File.Delete(Environment.CurrentDirectory + "\\Settings.ini"); }
 }
Ejemplo n.º 2
0
        public AppSettings GetSettings()
        {
            if (File.Exists(Environment.CurrentDirectory + "\\Settings.ini")){ GetSettingsFromFile(); }
            else if (RegAccess.CheckRegistry()) { settings = RegAccess.GetSettingsFromRegistry(); }
            else { settings = new AppSettings(8192, CheckSumMethod.CRC32, SettingsSaveMethod.Registry); }

            return settings;
        }
Ejemplo n.º 3
0
        public void ShowForm(int param, AppSettings settings=null)
        {
            //Update values according to the settings recieved
            this.settings = settings; this.buffer = (long)settings.Buffer;
            this.checkCode = (int)settings.CheckSumType; labelHashType.Text = "(" + settings.CheckSumType.ToString() + ")";
            this.Show();

            if (param == 1) //File Split
            { browseButton.Enabled = buttonCalcMD5.Enabled = groupBox1.Enabled = true; tabMain.SelectedTab = tabSplitFile; tabJoinFiles.Dispose(); comboBoxFileSize.SelectedIndex = 0; }
            else if (param == 2) // File Join
            { buttonJoinSplitFiles.Enabled = progressBarFileJoin.Enabled = true; tabMain.SelectedTab = tabJoinFiles; tabSplitFile.Dispose(); }
            else if (param == 3) // Folder Split/Join Form
            {
                tabJoinFiles.Dispose();
                labelSelect.Text = "Select the Folder whose contents are to be Split..."; lSize.Text = "Total Files Size:";
                infoHeaderLabel.Text = "Folder Details and Set Split Options";
                fileSizeLabel.Location = new Point(160, fileSizeLabel.Location.Y); tabSplitFile.Text = "SPLIT FOLDER CONTENTS";
                lChecksum.Visible = buttonCalcMD5.Visible = false; buttonSplitFile.Location = new Point(230, 316); buttonSplitFile.Size = new Size(226, 33);
                buttonSplitFile.Text = "SPLIT FOLDER CONTENTS"; IsFolder = true; browseButton.Enabled = true; labelHashType.Visible = false;
                browseButton_Click(null, null); groupBox1.Enabled = true;
            }
        }
Ejemplo n.º 4
0
 private void SettingsForm_Load(object sender, EventArgs e)
 {
     settings = GetSettings();
     checkedListBoxBuffer.SetItemChecked((int)(Math.Log((settings.Buffer / 8192),2)), true);
     checkedListBoxFilecheck.SetItemChecked((int)settings.CheckSumType - 1, true);
     checkedListBoxSettingsave.SetItemChecked((int)settings.SettingsSaveType - 1, true);
 }
Ejemplo n.º 5
0
 private void SaveSettingsInRegistry(AppSettings settings)
 {
     RegAccess.SaveSettingsinRegistry(settings);
 }
Ejemplo n.º 6
0
 private void SaveSettingsInFile(AppSettings settings)
 {
     using (Stream output = File.Create(Environment.CurrentDirectory + "\\Settings.ini"))
     {
         BinaryFormatter formatter = new BinaryFormatter();
         formatter.Serialize(output, settings);
     }
 }
Ejemplo n.º 7
0
 private void GetSettingsFromFile()
 {
     using (Stream input = File.Open(Environment.CurrentDirectory + "\\Settings.ini", FileMode.Open, FileAccess.Read))
     {
         BinaryFormatter formatter = new BinaryFormatter();
         settings = (AppSettings)formatter.Deserialize(input);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets Settings from Windows Registry and returns the settings
        /// </summary>
        /// <returns>AppSettings object containing the settings data</returns>
        public static AppSettings GetSettingsFromRegistry()
        {
            AppSettings settings; int buffer; CheckSumMethod check; SettingsSaveMethod set;
            try
            {
                using (sysreg = Registry.CurrentUser.OpenSubKey("Software\\SplitterViP"))
                {
                    buffer = int.Parse((string)sysreg.GetValue("Buffer Size",8192));
                    check = (CheckSumMethod)int.Parse((string)sysreg.GetValue("Checksum Method", "CRC32"));
                    set = (SettingsSaveMethod)int.Parse((string)sysreg.GetValue("Settings Save Method", "Registry"));
                    settings = new AppSettings(buffer, check, set);
                }

            }
            catch (System.ArgumentNullException Exp)
            {
                MessageBox.Show(Exp.Message, "Registry Access Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                settings = null;
            }

            return settings;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Saves Settings in Windows Registry corresponding to the data passed
 /// </summary>
 /// <param name="settings">AppSettings object containing all the settings data</param>
 public static void SaveSettingsinRegistry(AppSettings settings)
 {
     using (sysreg = Registry.CurrentUser.CreateSubKey("Software\\SplitterViP"))
     {
         sysreg.SetValue("Buffer Size", settings.Buffer.ToString(), RegistryValueKind.String);
         sysreg.SetValue("Checksum Method", ((int)settings.CheckSumType).ToString(), RegistryValueKind.String);
         sysreg.SetValue("Settings Save Method",((int) settings.SettingsSaveType).ToString(), RegistryValueKind.String);
     }
 }