コード例 #1
0
 private void RenameButton_Click(object sender, EventArgs e)
 {
     if (CharListView.SelectedItems.Count > 0)
     {
         ListViewItem item = CharListView.SelectedItems[0];
         if (item.Tag != null)
         {
             AddForm add = new AddForm(item.Text, "Введите новое имя.");
             add.ShowDialog(this);
             if (Configer.Tmp != "" && Configer.Tmp != item.Text)
             {
                 if (File.Exists(Path.Combine(Path.Combine(_profile.Name, item.Tag.ToString()), Configer.Tmp) + ".wav"))
                 {
                     MessageBox.Show("Звук с таким именем уже существует.");
                     return;
                 }
                 File.Move(Path.Combine(Path.Combine(_profile.Name, item.Tag.ToString()), item.Text) + ".wav",
                           Path.Combine(Path.Combine(_profile.Name, item.Tag.ToString()), Configer.Tmp) + ".wav");
                 Configer.LoadProfile(_profile, _profile.Name);
                 item.Text        = Configer.Tmp;
                 item.ToolTipText = item.Text;
                 CharListView.Sort();
             }
         }
     }
 }
コード例 #2
0
 private void AddProfile_Click(object sender, EventArgs e)
 {
     try
     {
         AddForm add = new AddForm("профиль0");
         add.ShowDialog(this);
         string name = Configer.Tmp;
         if (name == "")
         {
             return;
         }
         if (Directory.Exists(name))
         {
             MessageBox.Show("Профиль уже существует.");
             return;
         }
         if (MessageBox.Show(string.Format("Создать профиль '{0}'?",
                                           name), "", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             Directory.CreateDirectory(name);
             foreach (string s in _profile.SpecififcSoundTypes)
             {
                 Directory.CreateDirectory(Path.Combine(name, s));
             }
             ProfileComboBox.SelectedIndex = ProfileComboBox.Items.Add(name);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Невозможно создать профиль: " + ex.Message);
     }
 }
コード例 #3
0
        void SoundEditor_SaveEvent(object sender, SaveWavEventArgs e)
        {
            bool   added = false;
            string path  = "";

            // new sound adding.
            if (e.wavInfo.name == "")
            {
                AddForm add = new AddForm("музыка" + _profile.GetSpecificSoundsByType("музыка").Length);
                add.ShowDialog(this);
                if (Configer.Tmp != "")
                {
                    _profile.AddSound("музыка", Configer.Tmp, e.wavInfo.bytes);
                    if (CharBox.SelectedItem.ToString() == "музыка")
                    {
                        fillSpecificMediaList("музыка");
                        ListViewItem item = CharListView.Items.Find(Configer.Tmp, false)[0];
                        //item.Selected = true;
                        item.ToolTipText = item.Text;
                        added            = true;
                        path             = "музыка\\" + Configer.Tmp;
                        //CharListView.Focus();
                    }
                }
            }
            else
            {
                if (MessageBox.Show("Заменить звук " + e.wavInfo.name + "?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    string [] name = e.wavInfo.name.Split(new char[] { '\\' });
                    path = name[0];
                    // general sound
                    if (name.Length == 1)
                    {
                        _profile.AddSound(name[0], e.wavInfo.bytes);
                    }
                    else
                    {
                        _profile.AddSound(name[0], name[1], e.wavInfo.bytes);
                        path += "\\" + name[1];;
                    }
                    added = true;
                }
            }
            if (added)
            {
                // store bytes to disk
                path = _profile.Name + "\\" + path + ".wav";
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                FileStream s = File.Create(path);
                s.Write(e.wavInfo.bytes, 0, e.wavInfo.bytes.Length);
                s.Close();
            }
            // e.wavInfo.
        }
コード例 #4
0
        private void AddSoundButton_Click(object sender, EventArgs e)
        {
            string  type = CharBox.SelectedItem.ToString();
            AddForm add  = new AddForm(type + CharListView.Items.Count.ToString());

            add.ShowDialog(this);
            string name = Configer.Tmp;

            if (name != "")
            {
                _profile.AddSound(type, Configer.Tmp, null);
                if (record(name, type))
                {
                    fillSpecificMediaList(type);
                    ListViewItem item = CharListView.Items.Find(name, false)[0];
                    item.Selected    = true;
                    item.ToolTipText = item.Text;
                    CharListView.Focus();
                }
            }
        }