public ActionResult UploadControl(UploadType type, string key, string title) { var model = new UploadControlViewModel { Type = (int)type, Key = key }; if (!string.IsNullOrEmpty(title)) { model.Title = title; } return(PartialView("_UploadControl", model)); }
public static string UploadControl(this HtmlHelper helper, UploadType type, string key, string title) { var model = new UploadControlViewModel { Type = (int)type, Key = key }; if (!string.IsNullOrEmpty(title)) { model.Title = title; } helper.RenderPartial("_UploadControl", model); return(null); }
private void Init() { SettingsManager.Instance.Load(); LanguagesManager.Instance.SetCurrentLanguage(SettingsManager.Instance.UseLanguage); { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "Service"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _serviceManager = new ServiceManager(configPath, AmoebaEnvironment.Config.Cache.BlocksPath, BufferManager.Instance); _serviceManager.Load(); { var locations = new List <Location>(); using (var reader = new StreamReader("Locations.txt")) { string line; while ((line = reader.ReadLine()) != null) { locations.Add(AmoebaConverter.FromLocationString(line)); } } _serviceManager.SetCloudLocations(locations); } if (_serviceManager.Config.Core.Download.BasePath == null) { lock (_serviceManager.LockObject) { var oldConfig = _serviceManager.Config; _serviceManager.SetConfig(new ServiceConfig(new CoreConfig(oldConfig.Core.Network, new DownloadConfig(AmoebaEnvironment.Paths.DownloadsPath)), oldConfig.Connection, oldConfig.Message)); } } } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "Control", "Message"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _messageManager = new MessageManager(configPath, _serviceManager); _messageManager.Load(); } { this.Title = SettingsManager.Instance.AccountInfo.ObserveProperty(n => n.DigitalSignature) .Select(n => $"Amoeba {AmoebaEnvironment.Version} - {n.ToString()}").ToReactiveProperty().AddTo(_disposable); this.RelationCommand = new ReactiveCommand().AddTo(_disposable); this.RelationCommand.Subscribe(() => this.Relation()).AddTo(_disposable); this.OptionsCommand = new ReactiveCommand().AddTo(_disposable); this.OptionsCommand.Subscribe(() => this.Options()).AddTo(_disposable); this.CheckBlocksCommand = new ReactiveCommand().AddTo(_disposable); this.CheckBlocksCommand.Subscribe(() => this.CheckBlocks()).AddTo(_disposable); this.LanguageCommand = new ReactiveCommand <string>().AddTo(_disposable); this.LanguageCommand.Subscribe((n) => LanguagesManager.Instance.SetCurrentLanguage(n)).AddTo(_disposable); this.WebsiteCommand = new ReactiveCommand().AddTo(_disposable); this.WebsiteCommand.Subscribe(() => this.Website()).AddTo(_disposable); this.VersionCommand = new ReactiveCommand().AddTo(_disposable); this.VersionCommand.Subscribe(() => this.Version()).AddTo(_disposable); this.IsProgressDialogOpen = new ReactiveProperty <bool>().AddTo(_disposable); this.ReceivingSpeed = new ReactiveProperty <decimal>().AddTo(_disposable); this.SendingSpeed = new ReactiveProperty <decimal>().AddTo(_disposable); this.WindowSettings = new ReactiveProperty <WindowSettings>().AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigPath, "View", "MainWindow"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); this.WindowSettings.Value = _settings.Load(nameof(WindowSettings), () => new WindowSettings()); this.DynamicOptions.SetProperties(_settings.Load(nameof(DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); } { this.CloudControlViewModel = new CloudControlViewModel(_serviceManager, _dialogService); this.ChatControlViewModel = new ChatControlViewModel(_serviceManager, _messageManager, _dialogService); this.StoreControlViewModel = new StoreControlViewModel(_serviceManager, _dialogService); this.StorePublishControlViewModel = new UploadControlViewModel(_serviceManager, _dialogService); this.SearchControlViewModel = new SearchControlViewModel(_serviceManager, _messageManager, _dialogService); this.DownloadControlViewModel = new DownloadControlViewModel(_serviceManager, _dialogService); this.UploadControlViewModel = new UploadControlViewModel(_serviceManager, _dialogService); } { _watchManager = new WatchManager(_serviceManager, _dialogService); } { Backup.Instance.SaveEvent += this.Save; } this.Setting_TrafficView(); }
private void Init() { SettingsManager.Instance.Load(); LanguagesManager.Instance.SetCurrentLanguage(SettingsManager.Instance.UseLanguage); { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigDirectoryPath, "Service"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _amoebaInterfaceManager = new AmoebaInterfaceManager(); { var info = UriUtils.Parse(AmoebaEnvironment.Config.Communication.TargetUri); var endpoint = new IPEndPoint(IPAddress.Parse(info.GetValue <string>("Address")), info.GetValue <int>("Port")); _amoebaInterfaceManager.Connect(endpoint, CancellationToken.None); _amoebaInterfaceManager.Load(); } if (_amoebaInterfaceManager.Config.Core.Download.BasePath == null) { lock (_amoebaInterfaceManager.LockObject) { var oldConfig = _amoebaInterfaceManager.Config; _amoebaInterfaceManager.SetConfig(new ServiceConfig(new CoreConfig(oldConfig.Core.Network, new DownloadConfig(AmoebaEnvironment.Paths.DownloadsDirectoryPath, oldConfig.Core.Download.ProtectedPercentage)), oldConfig.Connection, oldConfig.Message)); } } } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigDirectoryPath, "Control", "Message"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _messageManager = new MessageManager(configPath, _amoebaInterfaceManager); _messageManager.Load(); } { this.Title = SettingsManager.Instance.AccountSetting.ObserveProperty(n => n.DigitalSignature) .Select(n => $"Amoeba {AmoebaEnvironment.Version} - {n.ToString()}").ToReadOnlyReactiveProperty().AddTo(_disposable); this.RelationCommand = new ReactiveCommand().AddTo(_disposable); this.RelationCommand.Subscribe(() => this.Relation()).AddTo(_disposable); this.OptionsCommand = new ReactiveCommand().AddTo(_disposable); this.OptionsCommand.Subscribe(() => this.Options()).AddTo(_disposable); this.CheckBlocksCommand = new ReactiveCommand().AddTo(_disposable); this.CheckBlocksCommand.Subscribe(() => this.CheckBlocks()).AddTo(_disposable); this.LanguageCommand = new ReactiveCommand <string>().AddTo(_disposable); this.LanguageCommand.Subscribe((n) => LanguagesManager.Instance.SetCurrentLanguage(n)).AddTo(_disposable); this.WebsiteCommand = new ReactiveCommand().AddTo(_disposable); this.WebsiteCommand.Subscribe(() => this.Website()).AddTo(_disposable); this.VersionCommand = new ReactiveCommand().AddTo(_disposable); this.VersionCommand.Subscribe(() => this.Version()).AddTo(_disposable); this.IsProgressDialogOpen = new ReactiveProperty <bool>().AddTo(_disposable); this.ReceivingSpeed = new ReactiveProperty <decimal>().AddTo(_disposable); this.SendingSpeed = new ReactiveProperty <decimal>().AddTo(_disposable); this.WindowSettings = new ReactiveProperty <WindowSettings>().AddTo(_disposable); } { string configPath = Path.Combine(AmoebaEnvironment.Paths.ConfigDirectoryPath, "View", "MainWindow"); if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } _settings = new Settings(configPath); int version = _settings.Load("Version", () => 0); bool isInitialized = _settings.Load("IsInitialized", () => false); this.WindowSettings.Value = _settings.Load(nameof(this.WindowSettings), () => new WindowSettings()); this.DynamicOptions.SetProperties(_settings.Load(nameof(this.DynamicOptions), () => Array.Empty <DynamicOptions.DynamicPropertyInfo>())); if (!isInitialized) { var cloudUri = @"https://alliance-network.cloud/amoeba/locations.php"; if (_dialogService.ShowDialog($"Are you sure you want to connect to \"{cloudUri}\"?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes) { try { using (var httpClient = new HttpClient()) using (var response = httpClient.GetAsync(cloudUri).Result) using (var stream = response.Content.ReadAsStreamAsync().Result) { var list = new List <Location>(); foreach (var line in JsonUtils.Load <IEnumerable <string> >(stream)) { try { list.Add(AmoebaConverter.FromLocationString(line)); } catch (Exception) { } } _amoebaInterfaceManager.SetCloudLocations(list); } } catch (Exception) { } } } } { this.CloudControlViewModel = new CloudControlViewModel(_amoebaInterfaceManager, _dialogService); this.ChatControlViewModel = new ChatControlViewModel(_amoebaInterfaceManager, _messageManager, _dialogService); this.StoreControlViewModel = new StoreControlViewModel(_amoebaInterfaceManager, _dialogService); this.StorePublishControlViewModel = new UploadControlViewModel(_amoebaInterfaceManager, _dialogService); this.SearchControlViewModel = new SearchControlViewModel(_amoebaInterfaceManager, _messageManager, _dialogService); this.DownloadControlViewModel = new DownloadControlViewModel(_amoebaInterfaceManager, _dialogService); this.UploadControlViewModel = new UploadControlViewModel(_amoebaInterfaceManager, _dialogService); } { _watchManager = new WatchManager(_amoebaInterfaceManager, _dialogService); } { EventHooks.Instance.SaveEvent += this.Save; } this.Setting_TrafficView(); }