示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (openFileDialog2.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            string filename  = openFileDialog2.FileName;
            string filename1 = openFileDialog2.SafeFileName;
            string dir       = Path.GetDirectoryName(openFileDialog2.FileName);

            //MessageBox.Show(Path.GetDirectoryName(openFileDialog1.FileName));
            textBox12.Text = filename;

            string     fullPath = Application.StartupPath.ToString();
            INIManager manager  = new INIManager(fullPath + "\\my.ini");

            manager.WritePrivateString("main", "path2", filename);
            manager.WritePrivateString("main", "filename2", filename1);
            manager.WritePrivateString("main", "dir2", dir);
            GlobalVars.dir2        = dir;
            GlobalVars.pathreload2 = filename;
            GlobalVars.filename2   = filename1;
            //MessageBox.Show(filename+" без "+ filename1);
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (IsNull(textBox1) || IsNull(textBox2) || IsNull(folderBrowserDialog1.SelectedPath))
            {
                DialogManager.showDialogError("Empty Fields.");
                return;
            }

            INIManager ini = new INIManager(iniName);

            ini.WritePrivateString("Enter", "ServerName", textBox1.Text);
            ini.WritePrivateString("Enter", "DataBaseName", textBox2.Text);
            ini.WritePrivateString("Enter", "Path", folderBrowserDialog1.SelectedPath);

            if (SQLWorker.IsCreate(textBox1.Text, textBox2.Text))
            {
                sqlWorker = new SQLWorker(textBox1.Text, textBox2.Text);

                if (checkBox1.Checked)
                {
                    DataViewPage form1 = new DataViewPage(sqlWorker);
                    form1.Show();
                }
                else
                {
                    DialogManager.showDialogInfo("Sucsess! You can close window.");
                }
            }
            else
            {
                if (DialogManager.showDialogYesNo("Data Base or Server not found. Create new Data Base?"))
                {
                    if (!creater())
                    {
                        DialogManager.showDialogError("Error creating database. Try Again.");
                        if (!SQLWorker.delDB(textBox1.Text, textBox2.Text))
                        {
                            DialogManager.showDialogError("Error cleaning data.");
                        }
                        return;
                    }
                    else
                    {
                        sqlWorker = new SQLWorker(textBox1.Text, textBox2.Text);

                        if (checkBox1.Checked)
                        {
                            DataViewPage form1 = new DataViewPage(sqlWorker);
                            form1.Show();
                        }
                        else
                        {
                            DialogManager.showDialogInfo("Sucsess! You can close window.");
                        }
                    }
                }
            }
        }
示例#3
0
 public void unzip()
 {
     try
     {
         Process psiw;
         psiw = Process.Start("cmd", @"/c taskkill /f /im informer.exe");
         psiw.Close();
         System.Threading.Thread.Sleep(2000);
         //string startPath = @"D:\YandexDisk\dev.sanekxxx4.ru\c#\launcher_informer\launcher_informer\bin\Debug\";
         string zipPath     = @"bin.zip";
         string extractPath = @"bin\" + GlobalVars.version;
         //ZipFile.CreateFromDirectory(startPath, zipPath);
         DirectoryInfo directoryinfo = new DirectoryInfo(extractPath);
         if (directoryinfo.Exists)
         {
             directoryinfo.Delete(true);
         }
         ZipFile.ExtractToDirectory(zipPath, extractPath);
         label1.Text = "Разархивация!";
         copy();
         string     fullPath = Application.StartupPath.ToString();
         INIManager manager  = new INIManager(fullPath + "\\my.ini");
         manager.WritePrivateString("main", "version", GlobalVars.version);
         Process.Start("informer.exe");
     }
     catch (Exception ex)
     {
         LogFile Log = new LogFile("error_launcher");
         Log.writeLogLine(ex.Message + " unzip");
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            INIManager manager = new INIManager("C:\\my.ini");

            string name = manager.GetPrivateString("main", "name");

            Console.WriteLine(name);

            manager.WritePrivateString("Василий", "возраст", "21");
        }
        private void SaveUserSettings(string appFileName)
        {
            WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            bool             hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);

            miAddUniversityMember.Enabled    = hasAdministrativeRight ? true : false;
            miRemoveUniversityMember.Enabled = hasAdministrativeRight ? true : false;

            miAddGroupMember.Enabled    = hasAdministrativeRight ? true : false;
            miRemoveGroupMember.Enabled = hasAdministrativeRight ? true : false;

            INIManager iniManager = new INIManager(appFileName);

            iniManager.WritePrivateString("miUniversity", "Enabled", miUniversity.Enabled.ToString());
            iniManager.WritePrivateString("miGroup", "Enabled", miGroup.Enabled.ToString());

            iniManager.WritePrivateString("miAddUniversityMember", "Enabled",
                                          miAddUniversityMember.Enabled.ToString());
            iniManager.WritePrivateString("miRemoveUniversityMember", "Enabled",
                                          miRemoveUniversityMember.Enabled.ToString());

            iniManager.WritePrivateString("miAddGroupMember", "Enabled",
                                          miAddGroupMember.Enabled.ToString());
            iniManager.WritePrivateString("miRemoveGroupMember", "Enabled",
                                          miRemoveGroupMember.Enabled.ToString());
        }
示例#6
0
 private void checkBox8_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox8.Checked)
     {
         string     fullPath = Application.StartupPath.ToString();
         INIManager manager  = new INIManager(fullPath + "\\my.ini");
         manager.WritePrivateString("main", "internet_r", "1");
         GlobalVars.internet_r = "1";
     }
     else
     {
         string     fullPath = Application.StartupPath.ToString();
         INIManager manager  = new INIManager(fullPath + "\\my.ini");
         manager.WritePrivateString("main", "internet_r", "0");
         GlobalVars.internet_r = "0";
     }
 }
示例#7
0
        private void CheckBoxTempMax_CheckedChanged(object sender, EventArgs e)
        {
            if (cbTempMaxGPU.Checked)
            {
                manager.WritePrivateString("main", "reboot_temp_max", "1");

                ZeroingOut();
            }
            else
            {
                manager.WritePrivateString("main", "reboot_temp_max", "0");
            }
        }
示例#8
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            /*
             * const string userRoot = "HKEY_CURRENT_USER";
             * const string subkey = "Software\\AVR_log";
             * const string keyName = userRoot + "\\" + subkey;
             * bool NeedRestart = false;
             *
             * try
             * {
             *  if (config.hostMySQL != edhostMySQL.Text)
             *  {
             *      Registry.SetValue(keyName, "hostMySQL", edhostMySQL.Text);
             *      NeedRestart = true;
             *  }
             *
             *  if (config.dbMySQL != eddbMySQL.Text)
             *  {
             *      Registry.SetValue(keyName, "dbMySQL", eddbMySQL.Text);
             *      NeedRestart = true;
             *  }
             *
             *  if (config.ExportPath != edExportPath.Text)
             *  {
             *      Registry.SetValue(keyName, "ExportPath", edExportPath.Text);
             *      NeedRestart = true;
             *  }
             *  if (config.UpdatePath != edUpdatePath.Text)
             *  {
             *      Registry.SetValue(keyName, "UpdatePath", edUpdatePath.Text);
             *      NeedRestart = true;
             *  }
             *  if (config.Timer / 1000 != edTimer.Value)
             *  {
             *      config.Timer = (int)edTimer.Value * 1000;
             *      Registry.SetValue(keyName, "Timer", config.Timer);
             *  }
             *  if (config.CheckStartUpdate != checkStartUpdate.Checked)
             *  {
             *      if (checkStartUpdate.Checked) Registry.SetValue(keyName, "CheckUpdate", "true");
             *      else Registry.SetValue(keyName, "CheckUpdate", "false");
             *
             *  }
             *
             *
             * }
             * finally
             * {
             *  if (NeedRestart) MessageBox.Show("Настройки успешно сохранены, но изменения встыпят в силу только при следующем запуске программы.");
             *  else MessageBox.Show("Настройки успешно сохранены.");
             *  this.DialogResult = DialogResult.OK;
             *  this.Hide();
             * }*/
            bool NeedRestart = false;

            try
            {
                INIManager manager = new INIManager(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "AVR_log.ini"));
                if (Config.hostMySQL != edhostMySQL.Text)
                {
                    manager.WritePrivateString("main", "hostMySQL", edhostMySQL.Text);
                    NeedRestart = true;
                }

                if (Config.dbMySQL != eddbMySQL.Text)
                {
                    manager.WritePrivateString("main", "dbMySQL", eddbMySQL.Text);
                    NeedRestart = true;
                }

                if (Config.ExportPath != edExportPath.Text)
                {
                    manager.WritePrivateString("main", "ExportPath", edExportPath.Text);
                    Config.ExportPath = edExportPath.Text;
                }
                if (Config.UpdatePath != edUpdatePath.Text)
                {
                    manager.WritePrivateString("main", "UpdatePath", edUpdatePath.Text);
                    NeedRestart = true;
                }
                if (Config.Timer / 1000 != edTimer.Value)
                {
                    Config.Timer = (int)edTimer.Value * 1000;
                    manager.WritePrivateString("main", "Timer", Config.Timer.ToString());
                }
                if (Config.CheckStartUpdate != checkStartUpdate.Checked)
                {
                    if (checkStartUpdate.Checked)
                    {
                        manager.WritePrivateString("main", "CheckUpdate", "true");
                    }
                    else
                    {
                        manager.WritePrivateString("main", "CheckUpdate", "false");
                    }
                    Config.CheckStartUpdate = checkStartUpdate.Checked;
                }

                if (Config.Sortvl10 != edSortvl10.Text)
                {
                    manager.WritePrivateString("main", "Sortvl10", edSortvl10.Text);
                    Config.Sortvl10 = edSortvl10.Text;
                    NeedRestart     = true;
                }

                if (Config.Sortvl04 != edSortvl04.Text)
                {
                    manager.WritePrivateString("main", "Sortvl04", edSortvl04.Text);
                    Config.Sortvl04 = edSortvl04.Text;
                    NeedRestart     = true;
                }

                if (Config.UserCanRenameFeeder != cbUserCanRenameFeeder.Checked)
                {
                    if (cbUserCanRenameFeeder.Checked)
                    {
                        manager.WritePrivateString("main", "UserCanRenameFeeder", "true");
                    }
                    else
                    {
                        manager.WritePrivateString("main", "UserCanRenameFeeder", "false");
                    }
                    Config.UserCanRenameFeeder = cbUserCanRenameFeeder.Checked;
                }
            }
            finally
            {
                if (NeedRestart)
                {
                    MessageBox.Show("Настройки успешно сохранены, но изменения встыпят в силу только при следующем запуске программы.");
                }
                else
                {
                    MessageBox.Show("Настройки успешно сохранены.");
                }
                this.DialogResult = DialogResult.OK;
                this.Hide();
            }
        }
示例#9
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string     fullPath = Application.StartupPath.ToString();
         INIManager manager  = new INIManager(fullPath + "\\my.ini");
         string     max      = textBox1.Text;
         string     min      = textBox2.Text;
         string     t_max    = textBox7.Text;
         string     t_min    = textBox8.Text;
         //string pool = textBox9.Text;
         //string wallet = textBox4.Text;
         string t_start   = comboBox2.Text;
         string r_min     = textBox5.Text;
         string rt_min    = textBox11.Text;
         string fan_max   = textBox4.Text;
         string fan_min   = textBox6.Text;
         string t_fan_max = textBox9.Text;
         string t_fan_min = textBox10.Text;
         string clock1    = textBox13.Text;
         // string t_inet = textBox17.Text;
         // manager.WritePrivateString("main", "t_inet", t_inet);
         // GlobalVars.t_inet = Convert.ToInt32(t_inet);
         manager.WritePrivateString("main", "clock", clock1);
         GlobalVars.clock1 = Convert.ToInt32(clock1);
         string t_clock = textBox14.Text;
         manager.WritePrivateString("main", "t_clock", t_clock);
         GlobalVars.t_clock = Convert.ToInt32(t_clock);
         string memory = textBox15.Text;
         manager.WritePrivateString("main", "memory", memory);
         GlobalVars.memory = Convert.ToInt32(memory);
         string t_memory = textBox16.Text;
         manager.WritePrivateString("main", "t_memory", t_memory);
         GlobalVars.t_memory = Convert.ToInt32(t_memory);
         manager.WritePrivateString("main", "t_fan_max", t_fan_max);
         GlobalVars.t_fan_max = Convert.ToInt32(t_fan_max);
         manager.WritePrivateString("main", "t_fan_min", t_fan_min);
         GlobalVars.t_fan_min = Convert.ToInt32(t_fan_min);
         manager.WritePrivateString("main", "fan_max", fan_max);
         GlobalVars.fan_max = Convert.ToInt32(fan_max);
         manager.WritePrivateString("main", "fan_min", fan_min);
         GlobalVars.fan_min = Convert.ToInt32(fan_min);
         manager.WritePrivateString("main", "max", max);
         GlobalVars.max = Convert.ToInt32(max);
         manager.WritePrivateString("main", "min", min);
         GlobalVars.min = Convert.ToInt32(min);
         manager.WritePrivateString("main", "t_min", t_min);
         GlobalVars.t_min = Convert.ToInt32(t_min);
         manager.WritePrivateString("main", "t_max", t_max);
         GlobalVars.t_max = Convert.ToInt32(t_max);
         // manager.WritePrivateString("main", "pool", pool);
         //  manager.WritePrivateString("main", "wallet", wallet);
         GlobalVars.t_start = Convert.ToInt32(t_start);
         manager.WritePrivateString("main", "t_start", t_start);
         manager.WritePrivateString("main", "r_min", r_min);
         manager.WritePrivateString("main", "rt_min", rt_min);
         ini();
         Hide();
     }
     catch (Exception ex)
     {
         LogFile Log = new LogFile("error");
         Log.writeLogLine(ex.Message);
     }
 }
示例#10
0
        private void BtSaveClick(object sender, EventArgs e)
        {
            try
            {
                manager.WritePrivateString("main", "temp_max", tbTempMax.Text);
                GlobalVars.temp_max = Convert.ToInt32(tbTempMax.Text);
                manager.WritePrivateString("main", "time_temp_max", tbTempMaxSec.Text);
                GlobalVars.time_temp_max = Convert.ToInt32(tbTempMaxSec.Text);

                manager.WritePrivateString("main", "temp_min", tbTempMin.Text);
                GlobalVars.temp_min = Convert.ToInt32(tbTempMin.Text);
                manager.WritePrivateString("main", "time_temp_min", tbTempMinSec.Text);
                GlobalVars.time_temp_min = Convert.ToInt32(tbTempMinSec.Text);

                manager.WritePrivateString("main", "fan_max", tbFanMax.Text);
                GlobalVars.fan_max = Convert.ToInt32(tbFanMax.Text);
                manager.WritePrivateString("main", "time_fan_max", tbFanMaxSec.Text);
                GlobalVars.time_fan_max = Convert.ToInt32(tbFanMaxSec.Text);

                manager.WritePrivateString("main", "fan_min", tbFanMin.Text);
                GlobalVars.fan_min = Convert.ToInt32(tbFanMin.Text);
                manager.WritePrivateString("main", "time_fan_min", tbFanMinSec.Text);
                GlobalVars.time_fan_min = Convert.ToInt32(tbFanMinSec.Text);

                manager.WritePrivateString("main", "reload_temp_min_file", tbReloadTempFile.Text);
                GlobalVars.reload_temp_min_file = Convert.ToInt32(tbReloadTempFile.Text);
                manager.WritePrivateString("main", "reload_time_min_file", tbReloadFileSec.Text);
                GlobalVars.reload_time_min_file = Convert.ToInt32(tbReloadFileSec.Text);

                manager.WritePrivateString("main", "clock", tbClockMin.Text);
                GlobalVars.core_clock = Convert.ToInt32(tbClockMin.Text);
                manager.WritePrivateString("main", "time_clock", tbClockMinSec.Text);
                GlobalVars.time_clock = Convert.ToInt32(tbClockMinSec.Text);

                manager.WritePrivateString("main", "memory", tbMemoryMin.Text);
                GlobalVars.memory = Convert.ToInt32(tbMemoryMin.Text);
                manager.WritePrivateString("main", "time_memory", tbMemoryMinSec.Text);
                GlobalVars.time_memory = Convert.ToInt32(tbMemoryMinSec.Text);

                manager.WritePrivateString("main", "count_GPU", tbCountGPU.Text);
                GlobalVars.count_GPU = Convert.ToInt32(tbCountGPU.Text);
                manager.WritePrivateString("main", "time_count_GPU", tbCountGPUSec.Text);
                GlobalVars.time_count_GPU = Convert.ToInt32(tbCountGPUSec.Text);

                manager.WritePrivateString("main", "load_GPU", tbLoadGPU.Text);
                GlobalVars.load_GPU = Convert.ToInt32(tbLoadGPU.Text);
                manager.WritePrivateString("main", "time_load_GPU", tbLoadGPUSec.Text);
                GlobalVars.time_load_GPU = Convert.ToInt32(tbLoadGPUSec.Text);

                manager.WritePrivateString("main", "time_internet", tbInternetOffSec.Text);
                GlobalVars.time_internet = Convert.ToInt32(tbInternetOffSec.Text);

                manager.WritePrivateString("main", "time_start", combTimeStart.Text);
                GlobalVars.time_start = Convert.ToInt32(combTimeStart.Text);



                ZeroingOut();

                this.Close();
            }
            catch (Exception ex)
            {
                _errors.writeLogLine(ex.Message, "error_settings");
                MessageBox.Show("Значения не могут быть пустыми");
            }
        }