Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
CloudShow Manager
DisplayFusion
FileSeek
HashTools
LogFusion
Notepad Replacer
Online Base64 Decoder
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
TrayStatus
VoiceBot
WallpaperFusion
Display
Fusion
by Binary Fortress Software
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
Features
Free vs Pro
More
Screenshots
Scripted Functions (Macros)
Languages
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Purchase
Login / Register
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Copy WallpaperFusion Images
Return to DisplayFusion Scripted Functions (Macros)
Description
Archives your WallpaperFusion images.
Language
C#.net
Minimum Version
7.2.0+
Created By
Zeusthrax800254
Contributors
-
Date Created
Feb 9, 2015
Date Last Modified
Feb 9, 2015
Scripted Function (Macro) Code
Copy
Select All
using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; using System.Text.RegularExpressions; using System.Windows.Forms; public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { string sourcePath = GetSettingValue("CopyWallpaperSourcePath", Path.Combine("DisplayFusion", "Web Images"), false, false); string destinationPath = GetSettingValue("CopyWallpaperDestinationPath", string.Empty, true, false); foreach(string fileName in CopyWallpaper(sourcePath,destinationPath)) Process.Start(fileName); } public static IEnumerable<string> CopyWallpaper(string sourcePath, string destinationPath) { foreach (string file in Directory.GetFiles(sourcePath, "WallpaperFusion Image - *.jpg")) { foreach (Match match in Regex.Matches(file, @"WallpaperFusion Image - (?<WallpaperName>.*) (?<TimeStamp>\(.*\))(?<Extension>\.jpg)")) { if (match.Success && (match.Groups.Count > 2)) { string sourceFile = Path.Combine(sourcePath, file); string tempName = Path.Combine(destinationPath, string.Format("{0}{1}", Guid.NewGuid(), match.Groups["Extension"].Value)); File.Copy(sourceFile, tempName); KeyValuePair<DialogResult, string> result = GetDestinationFileName(destinationPath, match); if (result.Key == DialogResult.OK) { File.Copy(tempName, result.Value, true); File.Delete(tempName); yield return result.Value; } } } } } private static KeyValuePair<DialogResult, string> GetDestinationFileName(string destinationPath, Match match) { string destinationFileName = Path.Combine(destinationPath, string.Format("{0}{1}", match.Groups["WallpaperName"].Value, match.Groups["Extension"].Value)); if (File.Exists(destinationFileName)) { destinationFileName = Path.Combine(destinationPath, string.Format("{0} {1}{2}", match.Groups["WallpaperName"].Value, match.Groups["TimeStamp"].Value, match.Groups["Extension"].Value)); } if (File.Exists(destinationFileName)) { using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.AddExtension = true; dialog.InitialDirectory = destinationPath; dialog.Filter = "jpg (*.jpg)|*.jpg"; dialog.FileName = Path.GetFileName(destinationFileName); if (dialog.ShowDialog() != DialogResult.OK) return new KeyValuePair<DialogResult, string>(DialogResult.Abort, destinationFileName); destinationPath = dialog.FileName; } } return new KeyValuePair<DialogResult, string>(DialogResult.OK, destinationFileName); } private static string GetSettingValue(string key, string defaultPath, bool forceSelection, bool allowNew) { string value = BFS.ScriptSettings.ReadValue(key); if (string.IsNullOrEmpty(value)) { value = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), defaultPath); if (forceSelection || (!Directory.Exists(value))) value=GetFolderPathFromUser(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), allowNew); BFS.ScriptSettings.WriteValue(key, value); } return value; } private static string GetFolderPathFromUser(string sourcePath, bool allowNew) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "Select Directory for Source"; dialog.SelectedPath = sourcePath; dialog.ShowNewFolderButton = allowNew; if (dialog.ShowDialog() == DialogResult.OK) sourcePath = dialog.SelectedPath; return sourcePath; } } }