//Handle UnauthorizedAccessException public static void HandleUnauthorizedAccessException(UnauthorizedAccessException ex) { CustomMessageBox.Error( ex.Message.Contains("The process cannot access the file") ? LangProvider.GetLang("FileIsInUse") : LangProvider.GetLang("UnauthorizedAccess"), LangProvider.GetLang("ExceptionOccurred")); }
public MainViewModel(DataService dataService) { Messenger.Default.Register <object>(this, MessageToken.LoadShowContent, obj => { if (SubContent is IDisposable disposable) { disposable.Dispose(); } SubContent = obj; }); Messenger.Default.Register <object>(this, MessageToken.ClearLeftSelected, obj => { DemoItemCurrent = null; foreach (var item in DemoInfoList) { item.SelectedIndex = -1; } }); Messenger.Default.Register <object>(this, MessageToken.LangUpdated, obj => { if (DemoItemCurrent == null) { return; } ContentTitle = LangProvider.GetLang(DemoItemCurrent.Name); }); DataList = dataService.GetDemoDataList(); DemoInfoList = dataService.GetDemoInfo(); }
public MainViewModel(DataService dataService) { _dataService = dataService; Messenger.Default.Register <object>(this, MessageToken.LoadShowContent, obj => { if (SubContent is IDisposable disposable) { disposable.Dispose(); } SubContent = obj; }, true); Messenger.Default.Register <object>(this, MessageToken.ClearLeftSelected, obj => { DemoItemCurrent = null; foreach (var item in DemoInfoCollection) { item.SelectedIndex = -1; } }); Messenger.Default.Register <object>(this, MessageToken.LangUpdated, obj => { if (DemoItemCurrent == null) { return; } ContentTitle = LangProvider.GetLang(DemoItemCurrent.Name); }); DemoInfoCollection = new ObservableCollection <DemoInfoModel>(); #if NET40 Task.Factory.StartNew(() => { DataList = dataService.GetDemoDataList(); foreach (var item in dataService.GetDemoInfo()) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { DemoInfoCollection.Add(item); }), DispatcherPriority.ApplicationIdle); } }); #else Task.Run(() => { DataList = dataService.GetDemoDataList(); foreach (var item in dataService.GetDemoInfo()) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { DemoInfoCollection.Add(item); }), DispatcherPriority.ApplicationIdle); } }); #endif }
public static MessageBoxInfo Info(string messageBoxText, string caption) { return(new MessageBoxInfo { Message = messageBoxText, Caption = caption, Button = MessageBoxButton.OK, IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.InfoGeometry, ConfirmContent = LangProvider.GetLang("OK") }); }
public static MessageBoxInfo Ask(string messageBoxText, string caption) { return(new MessageBoxInfo { Message = messageBoxText, Caption = caption, Button = MessageBoxButton.YesNo, IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.AskGeometry, YesContent = LangProvider.GetLang("Confirm"), NoContent = LangProvider.GetLang("Cancel") }); }
public static async void CheckForUpdate(bool onlyShowIfUpdateAvailable = false) { if (ApplicationHelper.IsConnectedToInternet()) { var ver = await UpdateHelper.CheckUpdateAsync("DineshSolanki", "FoliCon"); if (ver.IsExistNewVersion) { var info = new GrowlInfo { Message = LangProvider.GetLang("NewVersionFound").Format(ver.TagName, ver.Changelog.Replace("\\n", Environment.NewLine)), ConfirmStr = LangProvider.GetLang("UpdateNow"), CancelStr = LangProvider.GetLang("Ignore"), ShowDateTime = false, ActionBeforeClose = isConfirmed => { if (isConfirmed) { StartProcess(ver.ReleaseUrl); } return(true); } }; Growl.AskGlobal(info); } else { if (onlyShowIfUpdateAvailable is not false) { return; } var info = new GrowlInfo { Message = LangProvider.GetLang("ThisIsLatestVersion"), ShowDateTime = false, StaysOpen = false }; Growl.InfoGlobal(info); } } else { Growl.ErrorGlobal(new GrowlInfo { Message = LangProvider.GetLang("NetworkNotAvailable"), ShowDateTime = false }); } }