public static PrefSound[] GetList(bool allowDefault)
        {
            List<PrefSound> list = new List<PrefSound>();
            if (allowDefault) list.Add(Default);
            list.Add(None);

            // read available sounds from C:\WINDOWS\Media
            string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
            string windowsPath = System.IO.Path.GetDirectoryName(systemPath);
            string mediaPath = System.IO.Path.Combine(windowsPath, "Media");
            if (System.IO.Directory.Exists(mediaPath))
            {
                System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(mediaPath);
                System.IO.FileInfo[] files = d.GetFiles("*.wav");
                foreach (System.IO.FileInfo file in files)
                {
                    PrefSound ps = new PrefSound(true, file.Name, file.FullName);
                    list.Add(ps);
                }
            }

            PrefSound[] arr = list.ToArray();
            list.Clear();
            list = null;
            return arr;
        }
        public virtual bool ShouldPlaySound(PrefSound defaultSound, out string soundFile)

        {
            soundFile = null;

            if (this.preferences.PrefSound.IsDefault)

            {
                if (defaultSound != null)

                {
                    if (defaultSound.PlaySound.HasValue && defaultSound.PlaySound.Value)

                    {
                        soundFile = defaultSound.SoundFile;

                        return(true);
                    }
                }
            }

            else

            {
                if (this.preferences.PrefSound.PlaySound.HasValue && this.preferences.PrefSound.PlaySound.Value)

                {
                    soundFile = this.preferences.PrefSound.SoundFile;

                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public static PrefSound[] GetList(bool allowDefault)
        {
            List <PrefSound> list = new List <PrefSound>();

            if (allowDefault)
            {
                list.Add(Default);
            }
            list.Add(None);

            // read available sounds from C:\WINDOWS\Media
            string systemPath  = Environment.GetFolderPath(Environment.SpecialFolder.System);
            string windowsPath = System.IO.Path.GetDirectoryName(systemPath);
            string mediaPath   = System.IO.Path.Combine(windowsPath, "Media");

            if (System.IO.Directory.Exists(mediaPath))
            {
                System.IO.DirectoryInfo d     = new System.IO.DirectoryInfo(mediaPath);
                System.IO.FileInfo[]    files = d.GetFiles("*.wav");
                foreach (System.IO.FileInfo file in files)
                {
                    PrefSound ps = new PrefSound(true, file.Name, file.FullName);
                    list.Add(ps);
                }
            }

            PrefSound[] arr = list.ToArray();
            list.Clear();
            list = null;
            return(arr);
        }
Пример #4
0
        public override bool Equals(object obj)
        {
            PrefSound s = obj as PrefSound;

            if (s != null)
            {
                return(this.Name == s.ActualName);
            }
            else
            {
                return(base.Equals(obj));
            }
        }
Пример #5
0
 internal static PrefSound FromFilePath(string filePath)
 {
     try
     {
         if (!String.IsNullOrEmpty(filePath))
         {
             System.IO.FileInfo file = new System.IO.FileInfo(filePath);
             PrefSound          ps   = new PrefSound(true, file.Name, file.FullName);
             return(ps);
         }
     }
     catch
     {
     }
     return(PrefSound.None);
 }
Пример #6
0
 private void LoadMiscPrefs()
 {
     // default sound
     string defaultSoundPath = Properties.Settings.Default.DefaultSound;
     PrefSound ps = PrefSound.FromFilePath(defaultSoundPath);
     this.growlDefaultSound = ps;
 }
 public virtual bool ShouldPlaySound(PrefSound defaultSound, out string soundFile)
 {
     soundFile = null;
     if (this.preferences.PrefSound.IsDefault)
     {
         if (defaultSound != null)
         {
             if (defaultSound.PlaySound.HasValue && defaultSound.PlaySound.Value)
             {
                 soundFile = defaultSound.SoundFile;
                 return true;
             }
         }
     }
     else
     {
         if (this.preferences.PrefSound.PlaySound.HasValue && this.preferences.PrefSound.PlaySound.Value)
         {
             soundFile = this.preferences.PrefSound.SoundFile;
             return true;
         }
     }
     return false;
 }
 internal static PrefSound FromFilePath(string filePath)
 {
     try
     {
         if (!String.IsNullOrEmpty(filePath))
         {
             System.IO.FileInfo file = new System.IO.FileInfo(filePath);
             PrefSound ps = new PrefSound(true, file.Name, file.FullName);
             return ps;
         }
     }
     catch
     {
     }
     return PrefSound.None;
 }