private void btnCairoBackgroundFileBrowse_Click(object sender, RoutedEventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog { Filter = GetImageFilter() }) { if (dlg.SafeShowDialog() == System.Windows.Forms.DialogResult.OK) { txtCairoBackgroundPath.Text = dlg.FileName; Settings.Instance.CairoBackgroundImagePath = dlg.FileName; } } }
private void btnWindowsBackgroundFileBrowse_Click(object sender, RoutedEventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog { Filter = GetImageFilter() }) { if (dlg.SafeShowDialog() == System.Windows.Forms.DialogResult.OK) { txtWindowsBackgroundPath.Text = dlg.FileName; Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", dlg.FileName); NativeMethods.SystemParametersInfo(NativeMethods.SPI.SETDESKWALLPAPER, 0, dlg.FileName, (NativeMethods.SPIF.UPDATEINIFILE | NativeMethods.SPIF.SENDWININICHANGE)); } } }
private void btnCairoVideoFileBrowse_Click(object sender, RoutedEventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog { Filter = GetVideoFilter() }) { if (dlg.SafeShowDialog() == System.Windows.Forms.DialogResult.OK) { if (Path.GetExtension(dlg.FileName) == ".zip") { string[] exts = new[] { ".wmv", ".3g2", ".3gp", ".3gp2", ".3gpp", ".amv", ".asf", ".avi", ".bin", ".cue", ".divx", ".dv", ".flv", ".gxf", ".iso", ".m1v", ".m2v", ".m2t", ".m2ts", ".m4v", ".mkv", ".mov", ".mp2", ".mp2v", ".mp4", ".mp4v", ".mpa", ".mpe", ".mpeg", ".mpeg1", ".mpeg2", ".mpeg4", ".mpg", ".mpv2", ".mts", ".nsv", ".nuv", ".ogg", ".ogm", ".ogv", ".ogx", ".ps", ".rec", ".rm", ".rmvb", ".tod", ".ts", ".tts", ".vob", ".vro", ".webm", ".wmv" }; FileInfo fileInfo = new FileInfo(dlg.FileName); string extractPath = fileInfo.FullName.Remove((fileInfo.FullName.Length - fileInfo.Extension.Length), fileInfo.Extension.Length); if (Directory.Exists(extractPath) && MessageBox.Show("Path already exists, overwrite?", "DreamScene", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { Directory.Delete(extractPath, true); } if (!Directory.Exists(extractPath)) { ZipFile.ExtractToDirectory(dlg.FileName, extractPath); } string file = Directory.GetFiles(extractPath).FirstOrDefault(f => exts.Contains(Path.GetExtension(f))); if (!string.IsNullOrWhiteSpace(file)) { dlg.FileName = file; } } txtCairoVideoBackgroundPath.Text = dlg.FileName; Settings.Instance.CairoBackgroundVideoPath = dlg.FileName; } } }