public string ResolveUri(string relativeFileName, string appPath = "~/content/widgets/", string lang = "") { var relativePath = (appPath.EndsWith("/") ? appPath : (appPath + "/")) + InstalledPath.Replace("\\", "/") + "/"; if (!relativeFileName.StartsWith("http://") && !relativeFileName.StartsWith("ftp://") && !relativeFileName.StartsWith("https://") && !relativeFileName.StartsWith("~")) { if (!string.IsNullOrEmpty(lang) && !this.DefaultLocale.Equals(lang, StringComparison.OrdinalIgnoreCase)) { var supports = string.IsNullOrEmpty(this.Locales) ? Locales.Split(',') : new string[0]; if (supports.Length > 0 && supports.Contains(lang)) { return(relativePath + "locales/" + lang + "/" + relativeFileName); } } return(relativePath + relativeFileName); } return(relativeFileName); }
public ApplicationViewModel(ApplicationManager manager, InstalledApplication app) { _app = app; DisplayName = app.ObserveProperty(x => x.DisplayName).ToReactiveProperty(); Definition = app.ObserveProperty(x => x.Definition).ToReactiveProperty(); DeveloperName = app.ObserveProperty(x => x.DeveloperName).ToReactiveProperty(); InstalledPath = app.ObserveProperty(x => x.InstalledPath).ToReactiveProperty(); IsApplicationMissing = InstalledPath.Select(path => !File.Exists(path)).ToReactiveProperty(); var currentVersion = app.ObserveProperty(x => x.ApplicationVersion).ToReactiveProperty(); Version = currentVersion.Where(x => x != null) .Select(x => x.ToString()) .ToReactiveProperty(); Image64 = InstalledPath.Select(x => GetIcon(x, 64)).ToReactiveProperty(); Image128 = InstalledPath.Select(x => GetIcon(x, 128)).ToReactiveProperty(); Latest = app.ObserveProperty(x => x.Latest).ToReactiveProperty(); HasUpdate = Latest.Select(x => x != null).ToReactiveProperty(); HasUpdateMessage = HasUpdate.Select(x => x ? "最新版があります" : "お使いのバージョンは最新です").ToReactiveProperty(); LatestVersion = Latest.CombineLatest(currentVersion, (latest, current) => latest != null ? latest.Version : current) .Where(x => x != null) .Select(x => x.ToString()) .ToReactiveProperty(); ReleaseNote = Latest.Select(x => x != null ? x.ReleaseNote : "更新情報はありません。") .ToReactiveProperty(); ExecuteCommand = new ReactiveCommand(app.ObserveProperty(x => x.CanExecute)); ExecuteCommand.Subscribe(_ => { app.ExecuteAsync(); }); UpdateCommand = new ReactiveCommand(Latest.Select(x => x != null)); UpdateCommand.Subscribe(async _ => { var res = await Messenger.GetResponse(new AsyncConfirmationMessage { MessageKey = "Confirm", Caption = "確認", Text = app.UpdateConfirmationMessage }).Response; if (res != true) { return; } await app.UpdateAsync(); Messenger.Raise(new AsyncInformationMessage { MessageKey = "Close" }); Messenger.Raise(new AsyncInformationMessage { MessageKey = "Information", Caption = "完了", Text = "アップデートが完了しました。" }); }); RemoveCommand = new ReactiveCommand(app.ObserveProperty(x => x.CanRemove)); RemoveCommand.Subscribe(async _ => { var res = await Messenger.GetResponse(new AsyncConfirmationMessage { MessageKey = "Confirm", Caption = "確認", Text = "アプリケーションの登録を削除してもよろしいですか?(アプリケーション自体は削除されません)" }).Response; if (res != true) { return; } await manager.RemoveApplicationAsync(app); Messenger.Raise(new AsyncInformationMessage { MessageKey = "Close" }); }); }