Esempio n. 1
0
 //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"));
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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
        }
Esempio n. 4
0
 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")
     });
 }
Esempio n. 5
0
 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")
     });
 }
Esempio n. 6
0
    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
            });
        }
    }