Exemple #1
0
        private void addPresetButton_Click(object sender, EventArgs e) ////Кнопка добавления присета
        {
            try
            {
                addPresetButton.Enabled = false;
                double num = 0.0;
                if (PresetTextBox.Text != "" && GetApiTextBox.Text != "" && CountApiTextBox2.Text != "" && double.TryParse(CountApiTextBox2.Text, out num) && double.TryParse(GetApiTextBox.Text, out num))
                {
                    PresetGroupList TempPreset = new PresetGroupList();
                    TempPreset.Name = PresetTextBox.Text;
                    if (IfUserCheckBoxADD.Checked)
                    {
                        if (int.Parse(CountApiTextBox2.Text) < 100)
                        {
                            TempPreset.DoneAPI = "https://api.vk.com/method/wall.get.xml?owner_id=" + int.Parse(GetApiTextBox.Text.Trim().Replace(" ", string.Empty)) + "&count=" + int.Parse(CountApiTextBox2.Text.Trim().Replace(" ", string.Empty));
                        }
                        else
                        {
                            TempPreset.DoneAPI = "https://api.vk.com/method/wall.get.xml?owner_id=" + int.Parse(GetApiTextBox.Text.Trim().Replace(" ", string.Empty)) + "&count=100";
                        }
                    }
                    else
                    {
                        if (int.Parse(CountApiTextBox2.Text) < 100)
                        {
                            TempPreset.DoneAPI = "https://api.vk.com/method/wall.get.xml?owner_id=-" + int.Parse(GetApiTextBox.Text.Trim().Replace(" ", string.Empty)) + "&count=" + int.Parse(CountApiTextBox2.Text.Trim().Replace(" ", string.Empty));
                        }
                        else
                        {
                            TempPreset.DoneAPI = "https://api.vk.com/method/wall.get.xml?owner_id=-" + int.Parse(GetApiTextBox.Text.Trim().Replace(" ", string.Empty)) + "&count=100";
                        }
                    }

                    ListPreset.Add(TempPreset);
                    SaveFillPreset();
                    GoodLabel.Text          = "Добавлено: " + TempPreset.Name;
                    addPresetButton.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Введите правильные данные!");
                } addPresetButton.Enabled = true;
            }
            catch { MessageBox.Show("Ошибка"); }
        }
Exemple #2
0
        public Form1(string[] args)
        {
            InitializeComponent();

            //Аргументы из вне
            if (args.Length != 0)
            {
                paramid = args[0];
                paramc  = args[1];
            }
            else
            {
                paramid          = "-35193970";
                paramc           = "100";
                metroLabel3.Text = "Group: Perception of music";
            }
            getapi = "https://api.vk.com/method/wall.get.xml?owner_id=" + paramid + "&count=" + paramc; //создание запроса
            notifyIcon1.ContextMenuStrip = metroContextMenu1;
            LoadMusic(getapi);
            listBox1.Focus();
            namedir = "Perception of music";


            ////Первый запуск\Загрузка настр
            try ////загрузка настр
            {
                XmlSerializer ser  = new XmlSerializer(typeof(List <PresetGroupList>));
                string        path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\PM Music\Preset.cfg";
                FileStream    file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
                ListPreset = (List <PresetGroupList>)ser.Deserialize(file);
                file.Close();
            }
            catch {
                ////Создание стандарт настр
                try
                {
                    PresetGroupList DefPreset0 = new PresetGroupList();
                    PresetGroupList DefPreset1 = new PresetGroupList();

                    DefPreset0.Name = "Perception of music";
                    DefPreset1.Name = "Music for coding";

                    DefPreset0.DoneAPI = "https://api.vk.com/method/wall.get.xml?owner_id=-35193970&count=100";
                    DefPreset1.DoneAPI = "https://api.vk.com/method/wall.get.xml?owner_id=-74779558&count=100";

                    ListPreset.Add(DefPreset0);
                    ListPreset.Add(DefPreset1);

                    XmlSerializer ser  = new XmlSerializer(typeof(List <PresetGroupList>));
                    string        path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\PM Music\Preset.cfg";
                    Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\PM Music\");
                    FileStream file = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
                    ser.Serialize(file, ListPreset);
                    file.Close();
                }
                catch { }
            }

            for (int i = 0; i < ListPreset.Count; i++)
            {
                GroupComboBox1.Items.Add(ListPreset[i].Name);
                DelComboBox.Items.Add(ListPreset[i].Name);
            }
        }