Revision 4d70073b trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
b/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs | ||
---|---|---|
40 | 40 |
using System.ComponentModel.Composition; |
41 | 41 |
using System.IO; |
42 | 42 |
using System.Net; |
43 |
using System.Reflection; |
|
44 | 43 |
using System.Windows; |
45 | 44 |
using System.Windows.Forms; |
46 | 45 |
using Caliburn.Micro; |
47 |
using IWshRuntimeLibrary; |
|
48 | 46 |
using Pithos.Client.WPF.Configuration; |
49 |
using Pithos.Client.WPF.Preferences; |
|
50 | 47 |
using Pithos.Client.WPF.SelectiveSynch; |
51 | 48 |
using Pithos.Core; |
52 | 49 |
using Pithos.Interfaces; |
53 |
using File = System.IO.File; |
|
50 |
using System; |
|
51 |
using System.Linq; |
|
54 | 52 |
using Screen = Caliburn.Micro.Screen; |
55 | 53 |
|
56 |
namespace Pithos.Client.WPF |
|
54 |
namespace Pithos.Client.WPF.Preferences
|
|
57 | 55 |
{ |
58 |
using System; |
|
59 |
using System.Linq; |
|
60 |
using System.Threading.Tasks; |
|
61 |
|
|
62 | 56 |
/// <summary> |
63 | 57 |
/// TODO: Update summary. |
64 | 58 |
/// </summary> |
... | ... | |
92 | 86 |
|
93 | 87 |
public bool StartOnSystemStartup { get; set; } |
94 | 88 |
|
95 |
private static void CreateShortcut(string shortcutPath) |
|
96 |
{ |
|
97 |
//TODO: ###THROWS PERMISSIONS ERROR### |
|
98 |
var wshShell = new WshShellClass(); |
|
99 |
var shortcut = (IWshRuntimeLibrary.IWshShortcut) wshShell.CreateShortcut( |
|
100 |
shortcutPath); |
|
101 |
|
|
102 |
var exePath = Assembly.GetExecutingAssembly().Location; |
|
103 |
shortcut.TargetPath = exePath; |
|
104 |
shortcut.WorkingDirectory = Path.GetDirectoryName(exePath); |
|
105 |
shortcut.Description = "Pithos"; |
|
106 |
shortcut.Save(); |
|
107 |
} |
|
108 |
|
|
109 | 89 |
public ShellViewModel Shell { get; set; } |
110 | 90 |
//ShellExtensionController _extensionController=new ShellExtensionController(); |
111 | 91 |
|
... | ... | |
226 | 206 |
NotifyOfPropertyChange(()=>Settings); |
227 | 207 |
} |
228 | 208 |
|
229 |
private void SetStartupMode() |
|
230 |
{ |
|
231 |
if (StartOnSystemStartup && !File.Exists(_shortcutPath)) |
|
232 |
{ |
|
233 |
CreateShortcut(_shortcutPath); |
|
234 |
} |
|
235 |
else if (!StartOnSystemStartup && File.Exists(_shortcutPath)) |
|
236 |
{ |
|
237 |
if (File.Exists(_shortcutPath)) |
|
238 |
File.Delete(_shortcutPath); |
|
239 |
} |
|
240 |
} |
|
241 |
|
|
242 | 209 |
/* public void ChangePithosFolder() |
243 | 210 |
{ |
244 | 211 |
var browser = new FolderBrowserDialog(); |
Also available in: Unified diff