Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
            {
                openFileDialog1.Filter = "JSON Settings(*.json)|*.json|All files(*.*)|*.*";
                if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                string strSettings = System.IO.File.ReadAllText(openFileDialog1.FileName);
                settings = JsonConvert.DeserializeObject <DataSettings>(strSettings);
                System.IO.File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\CustomStatus\Settings.json", strSettings);
                main.settings = this.settings;

                main.listBox1.Items.Clear();
                foreach (var Date in settings.Dates)
                {
                    main.listBox1.Items.Add(Date.Name);
                }

                this.Close();
            }
        }
Пример #2
0
        private void ProxySettings_Load(object sender, EventArgs e)
        {
            settings = JsonConvert.DeserializeObject <DataSettings>(File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                                                                                     + @"\CustomStatus\Settings.json"));
            switch (settings.UseProxy)
            {
            case 0:
                radioButton3.Checked = true;
                break;

            case 1:
                radioButton2.Checked = true;
                break;

            case 2:
                radioButton1.Checked = true;
                break;
            }
            richTextBox1.Clear();
            foreach (var proxy in settings.Proxies)
            {
                richTextBox1.Text += proxy + "\n";
            }
        }
Пример #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            richTextBox1.BackColor = this.BackColor;
            if (!Directory.Exists(appData + @"\CustomStatus"))
            {
                Directory.CreateDirectory(appData + @"\CustomStatus");
            }
            else if (!File.Exists(appData + @"\CustomStatus\Settings.json"))
            {
                File.WriteAllText(appData + @"\CustomStatus\Settings.json", "{\"Dates\":[], \"UseProxy\": 0, \"Proxies\":[]}");
            }

            if (!String.IsNullOrEmpty(Properties.Settings.Default.RuCaptcha))
            {
                toolStripMenuItem2.Text = Properties.Settings.Default.RuCaptcha;
            }

            settings = JsonConvert.DeserializeObject <DataSettings>(File.ReadAllText(appData + @"\CustomStatus\Settings.json"));

            if (!String.IsNullOrEmpty(Properties.Settings.Default.VkToken) && Properties.Settings.Default.VkUserId != 0)
            {
                try
                {
                    vkapi.Authorize(new VkNet.Model.ApiAuthParams()
                    {
                        AccessToken = Properties.Settings.Default.VkToken, UserId = Properties.Settings.Default.VkUserId, ApplicationId = 2685278
                    });
                    vkapi.Utils.ResolveScreenName("durov");
                    label10.Text      = "В работе";
                    label10.ForeColor = Color.Green;
                    AddLog("[ВКонтакте] Бот успешно запущен!");

                    Task.Factory.StartNew(() => { VkStatus(); });
                }
                catch (Exception ex)
                {
                    label10.Text      = "Отключено";
                    label10.ForeColor = Color.Red;
                    AddLog("[ВКонтакте] Не удалось запустить бота: " + ex.Message);
                }
            }
            else
            {
                label10.Text      = "Отключено";
                label10.ForeColor = Color.Red;
            }
            if (Properties.Settings.Default.UseDSRP)
            {
                try
                {
                    StartDSActivity();
                    label11.Text      = "В работе";
                    label11.ForeColor = Color.Green;
                }
                catch (Exception ex)
                {
                    label11.Text      = "Отключено";
                    label11.ForeColor = Color.Red;
                    AddLog("[Discord] Не удалось запустить бота: " + ex.Message);
                }
            }
            else
            {
                label11.Text      = "Отключено";
                label11.ForeColor = Color.Red;
            }
            if (label10.ForeColor == Color.Green || label11.ForeColor == Color.Green)
            {
                button10.Text = "Остановить бота";
            }
            else
            {
                button10.Text = "Запустить бота";
            }
            if (Properties.YGRPC.Default.UseRPC && Properties.YGRPC.Default.ClientStartMode == 1)
            {
                if (!Directory.Exists("Discord-RPC-Extension") || !File.Exists(@"Discord-RPC-Extension\server_win.exe"))
                {
                    MessageBox.Show("Файл server_win.exe не найден", "CustomStatus");
                    Properties.YGRPC.Default.ClientStartMode = 2;
                    Properties.YGRPC.Default.Save();
                }
                else
                {
                    ProcessStartInfo procInfo = new ProcessStartInfo();
                    procInfo.FileName = @"Discord-RPC-Extension\server_win.exe";
                    winServer         = new Process {
                        StartInfo = procInfo
                    };
                    winServer.Start();
                }
            }
        }
Пример #4
0
 public Importer(Form1 main)
 {
     InitializeComponent();
     this.main = main;
     settings  = main.settings;
 }