/// <summary> /// Gets the current view settings for the specified user. /// </summary> /// <param name="listId"></param> /// <returns></returns> public ActionResult GetCurrent(int listId) { ListViewSettings lvs = null; using (AngularPatternsEntities context = new AngularPatternsEntities()) { UserActiveView userActiveView = context.UserActiveView.FirstOrDefault(x => x.UserId == userId && x.ListId == listId); if (userActiveView != null) { lvs = context.ListViewSettings.First(x => x.Id == userActiveView.ViewId); } else { // if there's no last view stored, try to load the default view for this user lvs = context.ListViewSettings.FirstOrDefault(x => x.ListId == listId && x.UserId == userId && x.IsDefault); if (lvs == null) { // if there's no default view for this user, try to load the default view for this user lvs = context.ListViewSettings.FirstOrDefault(x => x.ListId == listId && x.IsDefault && x.IsPublic); } } } ViewSettings viewSettings = null; if (lvs != null) { viewSettings = CreateFromListViewSetting(lvs); } return(Content(JsonConvert.SerializeObject(viewSettings), "application/json")); }
public ConnectySetings() { // Init the local Variables connectionSettings = new ConnectionSettings(); applicationSettings = new ApplicationSettings(); viewSettings = new ViewSettings(); }
/// <summary> /// Loads the layout from file. /// </summary> public void LoadLayoutFile() { var filePath = (!string.IsNullOrEmpty(this.layoutFilePath) && File.Exists(this.layoutFilePath)) ? this.layoutFilePath : this.standardLayoutFilePath; var viewSettingsSerializer = new XmlSerializer(typeof(ViewSettings)); var viewSettings = new ViewSettings(); using (var reader = File.Open(filePath, FileMode.Open)) { try { viewSettings = (ViewSettings)viewSettingsSerializer.Deserialize(reader); this.LayoutRoot = viewSettings.ClusterViewLayoutRoot; this.LayoutRoot.PropertyChanged += (o, e) => this.layoutUpdated = true; this.ClusterPlotViewModel.ClusterViewerSettings = viewSettings.ClusterViewerSettings; this.originalSettings = viewSettings.ClusterViewerSettings; } catch (InvalidCastException) { MessageBox.Show("Could not deserialize layout settings."); } } }
public ImagePanelControl1() { InitializeComponent(); DoubleBuffered = true; pix8 = new List <byte>(); pix16 = new List <ushort>(); pix24 = new List <byte>(); this.hScrollBar.Visible = false; this.vScrollBar.Visible = false; winMin = 0; winMax = 65535; ptWLDown = new Point(); changeValWidth = 0.5; changeValCentre = 20.0; rightMouseDown = false; imageAvailable = false; signed16Image = false; lut8 = new byte[256]; lut16 = new byte[65536]; viewSettings = ViewSettings.ZoomToFit; viewSettingsChanged = false; PerformResize(); }
public FormEditSettings(ViewSettings viewSettings) { InitializeComponent(); m_ViewSettings = viewSettings ?? throw new ArgumentNullException(nameof(viewSettings)); fillGuessSettingEdit.FillGuessSettings = viewSettings.FillGuessSettings; if (m_ViewSettings.LimitDuration == ViewSettings.DurationEnum.Unlimited) { domainUpDownTime.SelectedIndex = 4; } else if (m_ViewSettings.LimitDuration == ViewSettings.DurationEnum.TenSecond) { domainUpDownTime.SelectedIndex = 3; } else if (m_ViewSettings.LimitDuration == ViewSettings.DurationEnum.TwoSecond) { domainUpDownTime.SelectedIndex = 2; } else if (m_ViewSettings.LimitDuration == ViewSettings.DurationEnum.Second) { domainUpDownTime.SelectedIndex = 1; } else { domainUpDownTime.SelectedIndex = 0; } }
/// <summary> /// TBD /// </summary> /// <param name="system">TBD</param> /// <param name="config">TBD</param> public PersistenceSettings(ActorSystem system, Config config) : base(system, config) { View = new ViewSettings(config); AtLeastOnceDelivery = new AtLeastOnceDeliverySettings(config); Internal = new InternalSettings(config); }
private void LoadViewSettings() { if (currentDICOM == null) { return; } string seriesUID = currentDICOM.seriesInfo.seriesUID; if (savedViewSettings.ContainsKey(seriesUID)) { currentViewSettings = savedViewSettings [seriesUID]; } else { currentViewSettings = new ViewSettings { level = 0.5f, window = 1f, panX = 0f, panY = 0f, slice = 0, zoom = 1f, flipHorizontal = false, flipVertical = true }; } }
public void IsFalseIfUpdatedButOptedOut() { var settings = new ViewSettings { IsUpdated = true, EnableChangelog = false }; var vm = new UpdateViewModel(settings); Assert.False(vm.ShowChangelog); }
public void IsTrueIfUpdatedAndOptedIn() { var settings = new ViewSettings { IsUpdated = true, EnableChangelog = true }; var vm = new UpdateViewModel(settings); Assert.True(vm.ShowChangelog); }
public void IsFalseIfNotUpdated() { var settings = new ViewSettings { IsUpdated = false }; var vm = new UpdateViewModel(settings); Assert.False(vm.ShowChangelog); }
private void MigrateViewSettings() { var oldViewSettings = new ViewSettings(this.oldBlobCache); var newViewSettings = new ViewSettings(this.newBlobCache); this.MigrateSettingsStorage(oldViewSettings, newViewSettings); }
public UpdateViewModel(ViewSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); this.settings = settings; }
public ActionResult Settings(ViewSettings settings) { ActionResult result = new EmptyResult(); try { this.EntityContext.TryAttach(this.ActiveUser); UserEngage engage = this.GetUserEngage(this.ActiveUser); this.ActiveUser.Email = settings.Email; engage.Unsubscribe = settings.Engage.Unsubscribe; engage.Comment = settings.Engage.Comment; engage.ComicCreate = settings.Engage.ComicCreate; engage.ComicRemix = settings.Engage.ComicRemix; this.EntityContext.SaveChanges(); ViewSettings model = new ViewSettings(new ClientUserEngage(engage), this.ActiveUser.Email); model.Feedback = "Your changes have been saved."; result = this.View(model); } finally { this.EntityContext.TryDetach(this.ActiveUser); } return(result); }
/// <summary> /// Конструктор /// </summary> public FrmMain() { InitializeComponent(); exeDir = ""; configDir = ""; webAppDir = ""; commSettings = new CommSettings(); webSettings = new WebSettings(); viewSettings = new ViewSettings(); regKey = ""; loadedCommSettings = null; loadedWebSettings = null; loadedViewSettings = null; loadedRegKey = ""; commSettingsChanged = false; webSettingsChanged = false; viewSettingsChanged = false; regKeyChanged = false; showing = false; selViewSet = null; selViewInfo = null; }
/// <summary> /// Gets the view settings with the specified id. /// </summary> /// <param name="listId"></param> /// <returns></returns> public ActionResult GetViewById(int id) { using (AngularPatternsEntities context = new AngularPatternsEntities()) { ListViewSettings lvs = context.ListViewSettings.FirstOrDefault(x => x.Id == id); if (lvs == null) { throw new Exception("The view doesn't exist"); } UserActiveView userActiveView = context.UserActiveView.FirstOrDefault(x => x.UserId == userId && x.ListId == lvs.ListId); if (userActiveView != null) { context.UserActiveView.Remove(userActiveView); } // set this view as an active one userActiveView = new UserActiveView(); userActiveView.ListId = lvs.ListId; userActiveView.UserId = userId; userActiveView.ListViewSettings = lvs; context.UserActiveView.Add(userActiveView); context.SaveChanges(); ViewSettings viewSettings = CreateFromListViewSetting(lvs); return(Content(JsonConvert.SerializeObject(viewSettings), "application/json")); } }
public AppSettings(string[] args) { this.Edition = "Editor"; this.LicenseKeyRegistryRootPath = @"HKEY_CURRENT_USER\Software\AI\AITalkII"; this.LicenseKeyRegistryValueName = "edocesnecil"; this.LicenseFileName = "aitalk.lic"; this.AuthCode = ""; this.Timeout = 0x3e8; this.SoundBufferLatency = 50; this.SoundBufferLength = 4; this.Title = ""; this.SubTitle = ""; this.Version = AssemblyInfoGetter.Version; this.ComporateName = "株式会社エーアイ"; this.ComporateName2 = ""; this.Copyright = AssemblyInfoGetter.Copyright; this.ExpirationDateVisible = true; this.TitleView = new TitleViewSettings(); this.Function = new FunctionSettings(); this.NGWord = new NGWordSettings(); this.UserDic = new UserDicSettings(); this.Menu = new MenuSettings(); this.View = new ViewSettings(); if ((args.Length > 0) && ((args[0] == "--log") || (args[0] == "-l"))) { this.LogOutput |= LogOutoutMode.File; } }
private void ToggleAspectRatio() { if (_mPlayer != null) { ViewSettings setari = _info.Cam.Data.ViewSettings; bool aspectDefault = _mPlayer.AspectRatio == setari.AspectRatioDefault; _mPlayer.AspectRatio = (aspectDefault) ? // AspectRatio e Default setari.AspectRatioMode : // Mode 2 setari.AspectRatioDefault; // Default // Notificari optionale _form.btnRatio.Text = (aspectDefault) ? setari.AspectRatioDefault.ToString() : setari.AspectRatioMode.ToString(); _lblEventsShowCount = 10; _form.lblEvent.Text = @"Event: aspect ratio change from " + ((aspectDefault) ? (VlcUtils.AspectRatioToString(setari.AspectRatioDefault) + " to " + VlcUtils.AspectRatioToString(setari.AspectRatioMode)) : (VlcUtils.AspectRatioToString(setari.AspectRatioMode) + " to " + VlcUtils.AspectRatioToString(setari.AspectRatioDefault))); } else { _form.lblEvent.Text = @"No video, cannot change aspect ratio"; } }
public static void MapKeysToView(ViewSettings viewSettings, Object view , State state) { IDictionary<StateKeySettings, String> mapKeysProps = viewSettings.MapKeysProperties; foreach (KeyValuePair<StateKeySettings, String> key_property in mapKeysProps) { String keyName = key_property.Key.Name; String propertyName = key_property.Value; PropertyInfo propViewData = FindPropertyByName(view, propertyName); if (propViewData == null || propViewData.CanWrite == false) throw new Exception(string.Format("ExceptionIncorrectViewPropertyMapping: {0} - {1} - {2}." , viewSettings.Name, propertyName, keyName)); try { propViewData.SetValue(view, state[keyName], null); } catch (TargetInvocationException ex) { throw ex.InnerException; } } }
/// <summary> /// Initializes a new instance of the <see cref="FormMain" /> class. /// </summary> /// <param name="viewSettings">Default view Settings</param> public FormMain(ViewSettings viewSettings) { m_ViewSettings = viewSettings; InitializeComponent(); Text = AssemblyTitle; Logger.AddLog(loggerDisplay.AddLog); m_DetailControlLoader = new DetailControlLoader(detailControl); // add the not button not visible in designer to the detail control detailControl.AddToolStripItem(1, m_ToolStripButtonSettings); detailControl.AddToolStripItem(1, m_ToolStripButtonLoadFile); detailControl.AddToolStripItem(int.MaxValue, m_ToolStripButtonSource); detailControl.AddToolStripItem(int.MaxValue, m_ToolStripButtonAsText); detailControl.AddToolStripItem(int.MaxValue, m_ToolStripButtonShowLog); detailControl.BeforeFileStored += BeforeFileStored; detailControl.FileStored += FileStored; detailControl.HTMLStyle = m_ViewSettings.HTMLStyle; detailControl.MenuDown = m_ViewSettings.MenuDown; this.LoadWindowState(m_ViewSettings.WindowPosition); ShowTextPanel(true); m_ViewSettings.FillGuessSettings.PropertyChanged += AnyPropertyChangedReload; SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; m_SettingsChangedTimerChange.AutoReset = false; m_SettingsChangedTimerChange.Elapsed += async(sender, args) => await OpenDataReaderAsync(); m_SettingsChangedTimerChange.Stop(); }
public void ApplyViewSettings(bool bCheckOwnership) { if (_settings != EditorManager.ActiveView.CurrentViewSettings) { if (bCheckOwnership) { return; } _settings = (ViewSettings)EditorManager.ActiveView.CurrentViewSettings.Clone(); // it is important that we have our own pointer here } ViewSettings defaultS = EditorManager.ActiveView.DefaultViewSettings; _settings.NearClipDistance = (_fCustomNear > 0.0f) ? _fCustomNear : defaultS.NearClipDistance; _settings.FarClipDistance = (_fCustomFar > 0.0f) ? _fCustomFar : defaultS.FarClipDistance; _settings.FOV.X = (_fCustomFOV > 0.0f) ? _fCustomFOV : defaultS.FOV.X; EditorManager.ActiveView.SetViewSettings(_settings, false); if (_bApplyTimeOfDay) { EditorManager.RendererNodeManager.SetCurrentTime(_fCustomTimeOfDay); } EditorManager.ActiveView.UpdateView(false); }
private void InitializeView() { if (ViewSettings.TryGetValue(CurrentViewName, out var viewUrl)) { mainView.Src = viewUrl; } }
public ModelGroupItem(int id, ViewSettings viewSettings, ListBox listbox, List <ModelGroupItem> listGroupItem) { this.id = id; this.listbox = listbox; this.listGroupItem = listGroupItem; this.Status = MessageStatus.NotReady; }
private void btnCancel_Click(object sender, EventArgs e) { commSettings = loadedCommSettings.Clone(); viewSettings = loadedViewSettings.Clone(); regKey = loadedRegKey; SettingsToControls(); SetSettingsUnchanged(); }
public void OpenSettings() { ViewSettings viewSettings = new ViewSettings { Owner = _view }; viewSettings.ShowDialog(); }
public override void Initialize(TaskArgumentsHolder args, ViewSettings settings) { AddColumns(); AddRows(); SetColumnWidth(); MyController.SubscribeForChangesToPeople(new Client.EmployeeData.PersonRowChangeEventHandler(Person_PersonRowChanged)); }
public PersistenceSettings(ActorSystem system, Config config) : base(system, config) { Journal = new JournalSettings(config); View = new ViewSettings(config); GuaranteedDelivery = new GuaranteedDeliverySettings(config); Internal = new InternalSettings(config); }
static VirtualMediaHelper() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); ViewSettings settings = settingsManager.Load <ViewSettings>(); ShowVirtualSeriesMedia = settings.ShowVirtualSeriesMedia; ShowVirtualMovieMedia = settings.ShowVirtualMovieMedia; ShowVirtualAudioMedia = settings.ShowVirtualAudioMedia; }
public void SetsIsUpdatedToFalse() { var settings = new ViewSettings { IsUpdated = true }; var vm = new UpdateViewModel(settings); vm.ChangelogShown(); Assert.False(settings.IsUpdated); }
public void DisabledChangelogIfRequested() { var settings = new ViewSettings { IsUpdated = true, EnableChangelog = true }; var vm = new UpdateViewModel(settings) { DisableChangelog = true }; vm.ChangelogShown(); Assert.False(settings.EnableChangelog); }
private Texture2D mTexture; // A texture object to store the screenshot data (so we can delete it later) // Use the Configure method to update this component so that it conforms to the console's visual settings, // such as the font, font color, or font size public override void Configure(ViewSettings settings) { Caption.font = settings.Font; Caption.fontSize = settings.FontSize; Caption.color = settings.FontColor; // Make caption's height equal to the font height Caption.rectTransform.sizeDelta = new Vector2(Caption.rectTransform.sizeDelta.x, settings.FontSize); }
public override void Initialize(TaskArgumentsHolder args, ViewSettings settings) { ProductDS products = StoreController.GetCatalogProducts(); catalogGrid.DataSource = products; catalogGrid.DataMember = "product"; DataGridTableStyle style = new DataGridTableStyle(); style.ReadOnly = true; style.MappingName = "product"; PropertyDescriptorCollection descriptors = this.BindingContext[products, "product"].GetItemProperties(); DataGridColumnStyle productId = new DataGridTextBoxColumn(descriptors["ProductID"]); productId.MappingName = "ProductID"; productId.HeaderText = "Product ID"; productId.ReadOnly = true; style.GridColumnStyles.Add(productId); DataGridColumnStyle categoryID = new DataGridTextBoxColumn(descriptors["CategoryID"]); categoryID.MappingName = "CategoryID"; categoryID.HeaderText = "Category ID"; categoryID.ReadOnly = true; style.GridColumnStyles.Add(categoryID); DataGridColumnStyle modelNumber = new DataGridTextBoxColumn(descriptors["ModelNumber"]); modelNumber.MappingName = "ModelNumber"; modelNumber.HeaderText = "Model Number"; modelNumber.ReadOnly = true; style.GridColumnStyles.Add(modelNumber); DataGridColumnStyle modelName = new DataGridTextBoxColumn(descriptors["ModelName"]); modelName.MappingName = "ModelName"; modelName.HeaderText = "Model Name"; modelName.ReadOnly = true; style.GridColumnStyles.Add(modelName); DataGridColumnStyle unitCost = new DataGridTextBoxColumn(descriptors["UnitCost"], "c"); unitCost.MappingName = "UnitCost"; unitCost.HeaderText = "Unit Cost"; unitCost.ReadOnly = true; style.GridColumnStyles.Add(unitCost); DataGridColumnStyle description = new DataGridTextBoxColumn(descriptors["Description"]); description.MappingName = "Description"; description.HeaderText = "Description"; description.ReadOnly = true; style.GridColumnStyles.Add(description); catalogGrid.TableStyles.Add(style); }
public override void Save() { base.Save(); ViewSettings settings = SettingsManager.Load <ViewSettings>(); settings.ShowVirtualAudioMedia = _selected.Contains(0); settings.ShowVirtualMovieMedia = _selected.Contains(1); settings.ShowVirtualSeriesMedia = _selected.Contains(2); SettingsManager.Save(settings); }
public void SetsIsUpdatedToFalse() { var settings = new ViewSettings { IsUpdated = true }; using (var vm = new UpdateViewModel(settings)) { vm.DismissUpdateNotification(); } Assert.False(settings.IsUpdated); }
public MapperSettings() { Paths = new PathSettings(); UI = new UISettings(); View = new ViewSettings(); Performance = new PerformanceSettings(); Paths.DataDirs = new List<string>(); Paths.DataFiles = new List<string>(); }
internal void Execute(ViewSettings settings) { Telemetry.CommandExecuted("view", "path", _path); Table table = ReadTable(); ViewModel viewModel = Get(table, settings.expandCells, settings.displayMinWidth); new TViewType().Draw(viewModel, settings); }
private void LoadViewSettings(string stylename) { ViewSettings viewSettings = GridViewSettingsManager.LoadFromXML(Consts.DGSettingsPath + stylename); dataGridExtended.LoadSettings(viewSettings.dataGridStyle); DataViewSource.GroupDescriptions.Clear(); viewSettings.collectionViewSourceStyle.Apply(DataViewSource); }
public MapperSettings() { Paths = new PathSettings(); UI = new UISettings(); View = new ViewSettings(); Performance = new PerformanceSettings(); Paths.DataDirs = new List <string>(); Paths.DataFiles = new List <string>(); }
/// <summary> /// Устанавливает в вид Settings значения свойств из модели GroupItem /// </summary> /// <param name="Model"> Модель GroupItem </param> /// <param name="View"> Вид Settings</param> public static void SaveModel(ModelGroupItem model, ViewSettings view, ViewGroupItem viewGroupItem) { model.title = view.Title1.Text; model.message = view.Message.Text; model.hashTags = view.HashTags.Text; model.albumId = view.AlbumId.Text; model.groupId = view.GroupId.Text; model.path = view.Path.Text; model.color = view.Color.SelectedColor; model.SetStatus(); }
public void IsTrueIfUpdatedAndOptedIn() { var settings = new ViewSettings { IsUpdated = true, EnableChangelog = true }; using (var vm = new UpdateViewModel(settings)) { Assert.True(vm.ShowChangelog); } }
public UpdateViewModel(ViewSettings settings, IUpdateManager updateManager = null) { if (settings == null) throw new ArgumentNullException("settings"); this.settings = settings; this.updateManager = updateManager ?? new UpdateManager(AppInfo.UpdatePath, "Espera", FrameworkVersion.Net45); this.updateLock = new object(); this.CheckForUpdate = ReactiveCommand.CreateAsyncTask(_ => this.UpdateSilentlyAsync()); this.shouldRestart = this.settings.WhenAnyValue(x => x.IsUpdated) .ToProperty(this, x => x.ShouldRestart); this.Restart = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => UpdateManager.RestartApp())); Observable.Interval(TimeSpan.FromHours(2), RxApp.TaskpoolScheduler) .StartWith(0) // Trigger an initial update check .InvokeCommand(this.CheckForUpdate); }
/// <summary> /// Overloaded. Starts open navigation beginning with the first view. /// </summary> /// <param name="firstView">The name of the first view.</param> /// <param name="args">Additional navigation arguments.</param> public void StartTask(string firstView, TaskArgumentsHolder args) { SetState(CreateState()); string startViewName = null; if (!string.IsNullOrEmpty(CurrentState.CurrentView)) { startViewName = CurrentState.CurrentView; _startView = UIPConfiguration.Config.GetViewSettingsFromName(CurrentState.CurrentView); } else if (!string.IsNullOrEmpty(firstView)) { startViewName = firstView; _startView = UIPConfiguration.Config.GetViewSettingsFromName(firstView); } if (_startView == null) throw new Exception(string.Format("ExceptionViewConfigNotFound: {0}.", startViewName)); StartTask(args); }
protected virtual void redirectToNextView(string previousView, ViewSettings viewSettings, String queryParams) { try { // когда последний параметр = true, то система не всегда ведет себя корректно // //if( previousView == null ) // HttpContext.Current.Response.Redirect( HttpContext.Current.Request.ApplicationPath // + "/" + viewSettings.Type + queryParams, true); //else HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type + queryParams, false); //HttpContext.Current.Response.Redirect( // ApplicationPath.GetFullVirtualPath(viewSettings.Type + queryParams), false); } catch (System.Threading.ThreadAbortException) { } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { this.DeviceWatcher = new CurrentSensorDeviceWatcher(); object sensorRegistryData = null; if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.TryGetValue("SensorRegistry", out sensorRegistryData)) { this.SensorRegistry = SensorRegistry.DeserializeOrDefault(sensorRegistryData as string ?? ""); } else { this.SensorRegistry = new SensorRegistry(); } this.PowerDistribution = new PowerDistribution(this.SensorRegistry); this.PowerDistributionLogger = new PowerDistributionLogger(this.PowerDistribution); this.ViewSettings = new ViewSettings(); ApplicationView.GetForCurrentView().TryResizeView(new Size(800, 480)); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
public void Initialize(Vector2i viewDistance, TerrainContext terrainContext) { this.terrainContext = terrainContext; areasAlwaysVisibleWithinDistance = Area.Size.X * 2; view = new ViewSettings(viewDistance); AreaCollection = new AreaCollection(); AreaCache = new AreaCacheCollection(); areaRange = new AreaRange(); viewDistanceAreaRange = new AreaRange(); visibilityQueue = new VisibilityQueue(terrainContext); Statistics = new TerrainVisibilityStatistics(this, AreaCache); SpawnPointHelper = new AreaSpawnPointHelper(terrainContext); Logger.RegisterLogLevelsFor<TerrainVisibility>(Logger.LogLevels.Adaptive); }
public ImagePanelControl() { InitializeComponent(); DoubleBuffered = true; pix8 = new List<byte>(); pix16 = new List<ushort>(); pix24 = new List<byte>(); this.hScrollBar.Visible = false; this.vScrollBar.Visible = false; winMin = 0; winMax = 65535; ptWLDown = new Point(); changeValWidth = 0.5; changeValCentre = 20.0; rightMouseDown = false; imageAvailable = false; signed16Image = false; lut8 = new byte[256]; lut16 = new byte[65536]; viewSettings = ViewSettings.ZoomToFit; viewSettingsChanged = false; PerformResize(); }
public void ApplyViewSettings(bool bCheckOwnership) { if (_settings != EditorManager.ActiveView.CurrentViewSettings) { if (bCheckOwnership) return; _settings = (ViewSettings)EditorManager.ActiveView.CurrentViewSettings.Clone(); // it is important that we have our own pointer here } ViewSettings defaultS = EditorManager.ActiveView.DefaultViewSettings; _settings.NearClipDistance = (_fCustomNear > 0.0f) ? _fCustomNear : defaultS.NearClipDistance; _settings.FarClipDistance = (_fCustomFar > 0.0f) ? _fCustomFar : defaultS.FarClipDistance; _settings.FOV.X = (_fCustomFOV > 0.0f) ? _fCustomFOV : defaultS.FOV.X; EditorManager.ActiveView.SetViewSettings(_settings, false); EditorManager.ActiveView.UpdateView(false); }
/// <summary> /// Returns true if a layout manager is expected. Returns false if no layout manager was specified for a particular view. /// </summary> /// <param name="viewSettings">The configuration of a specific view.</param> /// <returns></returns> private bool ViewExpectsLayoutManager(ViewSettings viewSettings) { return (viewSettings.LayoutManager != null && viewSettings.LayoutManager.Length > 0); }
/// <summary> /// Initializes the WebFormView. /// </summary> /// <param name="args">The initialization arguments.</param> /// <param name="settings">The settings for the view.</param> public virtual void Initialize(TaskArgumentsHolder args, ViewSettings settings) { }
public ShellViewModel(Library library, ViewSettings viewSettings, CoreSettings coreSettings, IWindowManager windowManager, MobileApiInfo mobileApiInfo) { this.library = library; this.ViewSettings = viewSettings; this.coreSettings = coreSettings; this.disposable = new CompositeDisposable(); this.UpdateViewModel = new UpdateViewModel(viewSettings); this.library.Initialize(); this.accessToken = this.library.LocalAccessControl.RegisterLocalAccessToken(); this.library.CurrentPlaylistChanged.Subscribe(x => this.RaisePropertyChanged("CurrentPlaylist")); this.canChangeTime = this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockTime)) .ToProperty(this, x => x.CanChangeTime); this.canChangeVolume = this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockVolume)) .ToProperty(this, x => x.CanChangeVolume); this.canAlterPlaylist = this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlaylist)) .ToProperty(this, x => x.CanAlterPlaylist); this.showVotes = this.coreSettings.WhenAnyValue(x => x.EnableVotingSystem) .CombineLatest(mobileApiInfo.ConnectedClientCount, (enableVoting, connectedClients) => enableVoting && connectedClients > 0) .ToProperty(this, x => x.ShowVotes); this.isAdmin = this.library.LocalAccessControl.ObserveAccessPermission(this.accessToken) .Select(x => x == AccessPermission.Admin) .ToProperty(this, x => x.IsAdmin); this.NextSongCommand = this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause)) .CombineLatest(this.library.CanPlayNextSong, (x1, x2) => x1 && x2) .ToCommand(); this.NextSongCommand.RegisterAsyncTask(_ => this.library.PlayNextSongAsync(this.accessToken)); this.PreviousSongCommand = this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause)) .CombineLatest(this.library.CanPlayPreviousSong, (x1, x2) => x1 && x2) .ToCommand(); this.PreviousSongCommand.RegisterAsyncTask(_ => this.library.PlayPreviousSongAsync(this.accessToken)); if (!this.library.Playlists.Any()) { this.library.AddAndSwitchToPlaylist(this.GetNewPlaylistName(), this.accessToken); } else { this.library.SwitchToPlaylist(this.library.Playlists.First(), this.accessToken); } this.SettingsViewModel = new SettingsViewModel(this.library, this.ViewSettings, this.coreSettings, windowManager, this.accessToken, mobileApiInfo); this.LocalViewModel = new LocalViewModel(this.library, this.ViewSettings, this.coreSettings, accessToken); this.YoutubeViewModel = new YoutubeViewModel(this.library, this.ViewSettings, this.coreSettings, accessToken); this.SoundCloudViewModel = new SoundCloudViewModel(this.library, accessToken, this.coreSettings, this.ViewSettings); this.DirectYoutubeViewModel = new DirectYoutubeViewModel(this.library, accessToken); Observable.Interval(TimeSpan.FromMilliseconds(300), RxApp.TaskpoolScheduler) .Where(_ => this.RemainingPlaylistTimeout > TimeSpan.Zero) .Subscribe(x => this.RaisePropertyChanged("RemainingPlaylistTimeout")) .DisposeWith(this.disposable); this.currentSongSource = this.WhenAnyValue(x => x.IsLocal, x => x.IsYoutube, x => x.IsSoundCloud, (local, youtube, soundcloud) => { if (local) { return (ISongSourceViewModel)this.LocalViewModel; } if (youtube) { return this.YoutubeViewModel; } if (soundcloud) { return this.SoundCloudViewModel; } return this.LocalViewModel; }) .ToProperty(this, x => x.CurrentSongSource, null, ImmediateScheduler.Instance); this.displayTimeoutWarning = Observable.Merge(this.LocalViewModel.TimeoutWarning, this.YoutubeViewModel.TimeoutWarning, this.DirectYoutubeViewModel.TimeoutWarning, this.SoundCloudViewModel.TimeoutWarning) .SelectMany(x => new[] { true, false }.ToObservable()) .ToProperty(this, x => x.DisplayTimeoutWarning); this.showPlaylistTimeout = this.WhenAnyValue(x => x.IsAdmin) .CombineLatest(this.WhenAnyValue(x => x.SettingsViewModel.EnablePlaylistTimeout), (isAdmin, enableTimeout) => !isAdmin && enableTimeout) .ToProperty(this, x => x.ShowPlaylistTimeout); this.MuteCommand = new ReactiveCommand(this.WhenAnyValue(x => x.IsAdmin)); this.MuteCommand.Subscribe(x => this.Volume = 0); this.UnMuteCommand = new ReactiveCommand(this.WhenAnyValue(x => x.IsAdmin)); this.UnMuteCommand.Subscribe(x => this.Volume = 1); this.canModifyWindow = this.HasAccess(this.ViewSettings.WhenAnyValue(x => x.LockWindow)) .ToProperty(this, x => x.CanModifyWindow); this.isPlaying = this.library.PlaybackState .Select(x => x == AudioPlayerState.Playing) .ToProperty(this, x => x.IsPlaying); this.currentTime = this.library.CurrentPlaybackTime .StartWith(TimeSpan.Zero) .Select(x => x.FormatAdaptive()) .ToProperty(this, x => x.CurrentTime); this.currentSeconds = this.library.CurrentPlaybackTime .Select(x => (int)x.TotalSeconds) .ToProperty(this, x => x.CurrentSeconds); this.totalTime = this.library.TotalTime .Select(x => x.FormatAdaptive()) .ToProperty(this, x => x.TotalTime); this.totalSeconds = this.library.TotalTime .Select(x => (int)x.TotalSeconds) .ToProperty(this, x => x.TotalSeconds); this.volume = this.library.WhenAnyValue(x => x.Volume, x => (double)x) .ToProperty(this, x => x.Volume); this.AddPlaylistCommand = new ReactiveCommand(this.WhenAnyValue(x => x.CanAlterPlaylist)); this.AddPlaylistCommand.Subscribe(x => this.AddPlaylist()); this.Playlists = this.library.Playlists.CreateDerivedCollection(this.CreatePlaylistViewModel); this.Playlists.ItemsRemoved.Subscribe(x => x.Dispose()); this.ShowSettingsCommand = new ReactiveCommand(); this.ShowSettingsCommand.Subscribe(x => this.SettingsViewModel.HandleSettings()); this.ShufflePlaylistCommand = new ReactiveCommand(this.WhenAnyValue(x => x.CanAlterPlaylist)); this.ShufflePlaylistCommand.Subscribe(x => this.library.ShufflePlaylist(this.accessToken)); this.PlayCommand = new ReactiveCommand(this.WhenAnyValue(x => x.SelectedPlaylistEntries) .CombineLatest(this.WhenAnyValue(x => x.IsAdmin), this.coreSettings.WhenAnyValue(x => x.LockPlayPause), this.library.LoadedSong, this.library.PlaybackState, (selectedPlaylistEntries, isAdmin, lockPlayPause, loadedSong, playBackState) => // The admin can always play, but if we are in party mode, we have to check // whether it is allowed to play (isAdmin || !lockPlayPause) && // If exactly one song is selected, the command can be executed (selectedPlaylistEntries != null && selectedPlaylistEntries.Count() == 1 || // If the current song is paused, the command can be executed (loadedSong != null || playBackState == AudioPlayerState.Paused)))); this.PlayCommand.SelectMany(async x => { if (await this.library.PlaybackState.FirstAsync() == AudioPlayerState.Paused || await this.library.LoadedSong.FirstAsync() != null) { await this.library.ContinueSongAsync(this.accessToken); } else { await this.library.PlaySongAsync(this.SelectedPlaylistEntries.First().Index, this.accessToken); } return Unit.Default; }).Subscribe(); this.PlayOverrideCommand = this.WhenAnyValue(x => x.SelectedPlaylistEntries) .CombineLatest(this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause)), (selectedPlaylistEntries, hasAccess) => hasAccess && (selectedPlaylistEntries != null && selectedPlaylistEntries.Count() == 1)) .ToCommand(); this.PlayOverrideCommand.RegisterAsyncTask(_ => this.library.PlaySongAsync(this.SelectedPlaylistEntries.First().Index, this.accessToken)); // The default play command differs whether we are in party mode or not and depends on // the selected setting in administrator mode and the song source. // // In party mode, it is always "Add To Playlist", in administrator mode we look at the // value that the song source returns this.defaultPlaybackCommand = this.WhenAnyValue(x => x.CurrentSongSource, x => x.IsAdmin, (songSource, isAdmin) => !isAdmin || songSource.DefaultPlaybackAction == DefaultPlaybackAction.AddToPlaylist ? songSource.AddToPlaylistCommand : songSource.PlayNowCommand) .ToProperty(this, x => x.DefaultPlaybackCommand); this.PauseCommand = this.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause)) .CombineLatest(this.isPlaying, (hasAccess, isPlaying) => hasAccess && isPlaying) .ToCommand(); this.PauseCommand.RegisterAsyncTask(_ => this.library.PauseSongAsync(this.accessToken)); var pauseOrContinueCommand = this.WhenAnyValue(x => x.IsPlaying) .Select(x => x ? this.PauseCommand : this.PlayCommand).Publish(null); pauseOrContinueCommand.Connect(); this.PauseContinueCommand = pauseOrContinueCommand.Select(x => x.CanExecuteObservable).Switch().ToCommand(); this.PauseContinueCommand.SelectMany(async _ => await pauseOrContinueCommand.FirstAsync()).Subscribe(x => x.Execute(null)); this.EditPlaylistNameCommand = this.WhenAnyValue(x => x.CanAlterPlaylist, x => x.CurrentPlaylist, (x1, x2) => x1 && !x2.Model.IsTemporary) .ToCommand(); this.EditPlaylistNameCommand.Subscribe(x => this.CurrentPlaylist.EditName = true); this.RemovePlaylistCommand = this.WhenAnyValue(x => x.CurrentEditedPlaylist, x => x.CurrentPlaylist, x => x.CanAlterPlaylist, (currentEditedPlaylist, currentPlaylist, canAlterPlaylist) => (currentEditedPlaylist != null || currentPlaylist != null) && canAlterPlaylist) .ToCommand(); this.RemovePlaylistCommand.Subscribe(x => this.RemoveCurrentPlaylist()); this.RemoveSelectedPlaylistEntriesCommand = this.WhenAnyValue(x => x.SelectedPlaylistEntries, x => x.CanAlterPlaylist, (selectedPlaylistEntries, canAlterPlaylist) => selectedPlaylistEntries != null && selectedPlaylistEntries.Any() && canAlterPlaylist) .ToCommand(); this.RemoveSelectedPlaylistEntriesCommand.Subscribe(x => this.library.RemoveFromPlaylist(this.SelectedPlaylistEntries.Select(entry => entry.Index), this.accessToken)); // We re-evaluate the selected entries after each up or down move here, because WPF // doesn't send us proper updates about the selection var reEvaluateSelectedPlaylistEntry = new Subject<Unit>(); this.MovePlaylistSongUpCommand = this.WhenAnyValue(x => x.SelectedPlaylistEntries) .Merge(reEvaluateSelectedPlaylistEntry.Select(_ => this.SelectedPlaylistEntries)) .Select(x => x != null && x.Count() == 1 && x.First().Index > 0) .CombineLatest(this.WhenAnyValue(x => x.CanAlterPlaylist), (canMoveUp, canAlterPlaylist) => canMoveUp && canAlterPlaylist) .ToCommand(); this.MovePlaylistSongUpCommand.Subscribe(_ => { int index = this.SelectedPlaylistEntries.First().Index; this.library.MovePlaylistSong(index, index - 1, this.accessToken); reEvaluateSelectedPlaylistEntry.OnNext(Unit.Default); }); this.MovePlaylistSongDownCommand = this.WhenAnyValue(x => x.SelectedPlaylistEntries) .Merge(reEvaluateSelectedPlaylistEntry.Select(_ => this.SelectedPlaylistEntries)) .Select(x => x != null && x.Count() == 1 && x.First().Index < this.CurrentPlaylist.Songs.Count - 1) .CombineLatest(this.WhenAnyValue(x => x.CanAlterPlaylist), (canMoveDown, canAlterPlaylist) => canMoveDown && canAlterPlaylist) .ToCommand(); this.MovePlaylistSongDownCommand.Subscribe(_ => { int index = this.SelectedPlaylistEntries.First().Index; this.library.MovePlaylistSong(index, index + 1, this.accessToken); reEvaluateSelectedPlaylistEntry.OnNext(Unit.Default); }); this.MovePlaylistSongCommand = this.WhenAnyValue(x => x.SelectedPlaylistEntries) .Merge(reEvaluateSelectedPlaylistEntry.Select(_ => this.SelectedPlaylistEntries)) .Select(x => x != null && x.Count() == 1) .CombineLatest(this.WhenAnyValue(x => x.CanAlterPlaylist), (canMoveUp, canAlterPlaylist) => canMoveUp && canAlterPlaylist) .ToCommand(); this.MovePlaylistSongCommand.Subscribe(x => { int fromIndex = this.SelectedPlaylistEntries.First().Index; int toIndex = (int?)x ?? this.CurrentPlaylist.Songs.Last().Index + 1; // If we move a song from the front of the playlist to the back, we want it move be // in front of the target song if (fromIndex < toIndex) { toIndex--; } this.library.MovePlaylistSong(fromIndex, toIndex, this.accessToken); reEvaluateSelectedPlaylistEntry.OnNext(Unit.Default); }); this.IsLocal = true; }
public ShellViewModel(Library library, ViewSettings viewSettings, CoreSettings coreSettings, IWindowManager windowManager, MobileApiInfo mobileApiInfo) { this.library = library; this.ViewSettings = viewSettings; this.coreSettings = coreSettings; this.disposable = new CompositeDisposable(); this.UpdateViewModel = new UpdateViewModel(viewSettings); this.library.Initialize(); this.accessToken = this.library.LocalAccessControl.RegisterLocalAccessToken(); this.library.WhenAnyValue(x => x.CurrentPlaylist).Subscribe(x => this.RaisePropertyChanged("CurrentPlaylist")); this.canChangeTime = this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockTime), this.accessToken) .ToProperty(this, x => x.CanChangeTime); this.canChangeVolume = this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockVolume), this.accessToken) .ToProperty(this, x => x.CanChangeVolume); this.canAlterPlaylist = this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlaylist), this.accessToken) .ToProperty(this, x => x.CanAlterPlaylist); this.showVotes = this.library.RemoteAccessControl.WhenAnyValue(x => x.IsGuestSystemReallyEnabled) .CombineLatest(mobileApiInfo.ConnectedClientCount, (enableGuestSystem, connectedClients) => enableGuestSystem && connectedClients > 0) .ToProperty(this, x => x.ShowVotes); mobileApiInfo.VideoPlayerToggleRequest.Subscribe(_ => this.ShowVideoPlayer = !this.ShowVideoPlayer); this.isAdmin = this.library.LocalAccessControl.ObserveAccessPermission(this.accessToken) .Select(x => x == AccessPermission.Admin) .ToProperty(this, x => x.IsAdmin); this.NextSongCommand = ReactiveCommand.CreateAsyncTask(this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause), this.accessToken) .CombineLatest(this.library.WhenAnyValue(x => x.CurrentPlaylist.CanPlayNextSong), (x1, x2) => x1 && x2) .ObserveOn(RxApp.MainThreadScheduler), _ => this.library.PlayNextSongAsync(this.accessToken)); this.PreviousSongCommand = ReactiveCommand.CreateAsyncTask(this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause), this.accessToken) .CombineLatest(this.library.WhenAnyValue(x => x.CurrentPlaylist.CanPlayPreviousSong), (x1, x2) => x1 && x2) .ObserveOn(RxApp.MainThreadScheduler), _ => this.library.PlayPreviousSongAsync(this.accessToken)); if (!this.library.Playlists.Any()) { this.library.AddAndSwitchToPlaylist(this.GetNewPlaylistName(), this.accessToken); } else { this.library.SwitchToPlaylist(this.library.Playlists.First(), this.accessToken); } this.SettingsViewModel = new SettingsViewModel(this.library, this.ViewSettings, this.coreSettings, windowManager, this.accessToken, mobileApiInfo); this.LocalViewModel = new LocalViewModel(this.library, this.ViewSettings, this.coreSettings, accessToken); this.YoutubeViewModel = new YoutubeViewModel(this.library, this.ViewSettings, this.coreSettings, accessToken); this.SoundCloudViewModel = new SoundCloudViewModel(this.library, accessToken, this.coreSettings, this.ViewSettings); this.DirectYoutubeViewModel = new DirectYoutubeViewModel(this.library, this.coreSettings, accessToken); this.currentSongSource = this.WhenAnyValue(x => x.IsLocal, x => x.IsYoutube, x => x.IsSoundCloud, (local, youtube, soundcloud) => { if (local) { return (ISongSourceViewModel)this.LocalViewModel; } if (youtube) { return this.YoutubeViewModel; } if (soundcloud) { return this.SoundCloudViewModel; } return this.LocalViewModel; }) .ToProperty(this, x => x.CurrentSongSource, null, ImmediateScheduler.Instance); this.MuteCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsAdmin)); this.MuteCommand.Subscribe(x => this.Volume = 0); this.UnMuteCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsAdmin)); this.UnMuteCommand.Subscribe(x => this.Volume = 1); this.canModifyWindow = this.library.LocalAccessControl.HasAccess(this.ViewSettings.WhenAnyValue(x => x.LockWindow), this.accessToken) .ToProperty(this, x => x.CanModifyWindow); this.isPlaying = this.library.PlaybackState .Select(x => x == AudioPlayerState.Playing) .ObserveOn(RxApp.MainThreadScheduler) .ToProperty(this, x => x.IsPlaying); this.currentTime = this.library.CurrentPlaybackTime .StartWith(TimeSpan.Zero) .Select(x => x.FormatAdaptive()) .ToProperty(this, x => x.CurrentTime); this.currentSeconds = this.library.CurrentPlaybackTime .Select(x => (int)x.TotalSeconds) .ToProperty(this, x => x.CurrentSeconds); this.totalTime = this.library.TotalTime .Select(x => x.FormatAdaptive()) .ToProperty(this, x => x.TotalTime); this.totalSeconds = this.library.TotalTime .Select(x => (int)x.TotalSeconds) .ToProperty(this, x => x.TotalSeconds); this.volume = this.library.WhenAnyValue(x => x.Volume, x => (double)x) .ToProperty(this, x => x.Volume); this.AddPlaylistCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanAlterPlaylist)); this.AddPlaylistCommand.Subscribe(x => this.AddPlaylist()); this.Playlists = this.library.Playlists.CreateDerivedCollection(this.CreatePlaylistViewModel, x => x.Dispose()); this.ShowSettingsCommand = ReactiveCommand.Create(); this.ShowSettingsCommand.Subscribe(x => this.SettingsViewModel.HandleSettings()); this.ShufflePlaylistCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanAlterPlaylist)); this.ShufflePlaylistCommand.Subscribe(x => this.library.ShufflePlaylist(this.accessToken)); IObservable<bool> canPlay = this.WhenAnyValue(x => x.CurrentPlaylist.SelectedEntries) .CombineLatest(this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause), this.accessToken), this.library.LoadedSong, this.library.PlaybackState, (selectedPlaylistEntries, hasPlayAccess, loadedSong, playBackState) => // The admin can always play, but if we are in party mode, we have to check // whether it is allowed to play hasPlayAccess && // If exactly one song is selected, the command can be executed (selectedPlaylistEntries != null && selectedPlaylistEntries.Count() == 1 || // If the current song is paused, the command can be executed (loadedSong != null || playBackState == AudioPlayerState.Paused))); this.PlayCommand = ReactiveCommand.CreateAsyncTask(canPlay, async _ => { if (await this.library.PlaybackState.FirstAsync() == AudioPlayerState.Paused || await this.library.LoadedSong.FirstAsync() != null) { await this.library.ContinueSongAsync(this.accessToken); } else { await this.library.PlaySongAsync(this.CurrentPlaylist.SelectedEntries.First().Index, this.accessToken); } }); this.PlayOverrideCommand = ReactiveCommand.CreateAsyncTask(this.WhenAnyValue(x => x.CurrentPlaylist.SelectedEntries) .CombineLatest(this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause), this.accessToken), (selectedPlaylistEntries, hasAccess) => hasAccess && (selectedPlaylistEntries != null && selectedPlaylistEntries.Count() == 1)), _ => this.library.PlaySongAsync(this.CurrentPlaylist.SelectedEntries.First().Index, this.accessToken)); this.PauseCommand = ReactiveCommand.CreateAsyncTask(this.library.LocalAccessControl.HasAccess(this.coreSettings.WhenAnyValue(x => x.LockPlayPause), this.accessToken) .CombineLatest(this.WhenAnyValue(x => x.IsPlaying), (hasAccess, isPlaying) => hasAccess && isPlaying), _ => this.library.PauseSongAsync(this.accessToken)); var pauseOrContinueCommand = this.WhenAnyValue(x => x.IsPlaying) .Select(x => x ? this.PauseCommand : this.PlayCommand).Publish(null); pauseOrContinueCommand.Connect(); this.PauseContinueCommand = ReactiveCommand.CreateAsyncTask( pauseOrContinueCommand.Select(x => x.CanExecuteObservable).Switch().ObserveOn(RxApp.MainThreadScheduler), async _ => { IReactiveCommand<Unit> command = await pauseOrContinueCommand.FirstAsync(); await command.ExecuteAsync(); }); this.EditPlaylistNameCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanAlterPlaylist, x => x.CurrentPlaylist, (x1, x2) => x1 && !x2.Model.IsTemporary)); this.EditPlaylistNameCommand.Subscribe(x => this.CurrentPlaylist.EditName = true); this.RemovePlaylistCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CurrentEditedPlaylist, x => x.CurrentPlaylist, x => x.CanAlterPlaylist, (currentEditedPlaylist, currentPlaylist, canAlterPlaylist) => (currentEditedPlaylist != null || currentPlaylist != null) && canAlterPlaylist)); this.RemovePlaylistCommand.Subscribe(x => this.RemoveCurrentPlaylist()); this.IsLocal = true; }
public SettingsViewModel(Library library, ViewSettings viewSettings, CoreSettings coreSettings, IWindowManager windowManager, Guid accessToken, MobileApiInfo mobileApiInfo) { if (library == null) Throw.ArgumentNullException(() => library); if (viewSettings == null) Throw.ArgumentNullException(() => viewSettings); if (coreSettings == null) Throw.ArgumentNullException(() => coreSettings); if (mobileApiInfo == null) throw new ArgumentNullException("mobileApiInfo"); this.library = library; this.viewSettings = viewSettings; this.coreSettings = coreSettings; this.windowManager = windowManager; this.accessToken = accessToken; this.canCreateAdmin = this .WhenAnyValue(x => x.CreationPassword, x => !string.IsNullOrWhiteSpace(x) && !this.isAdminCreated) .ToProperty(this, x => x.CanCreateAdmin); this.CreateAdminCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanCreateAdmin), ImmediateScheduler.Instance); // Immediate execution, because we set the password to an empty string afterwards this.CreateAdminCommand.Subscribe(p => { this.library.LocalAccessControl.SetLocalPassword(this.accessToken, this.CreationPassword); this.isAdminCreated = true; }); this.ChangeToPartyCommand = ReactiveCommand.Create(this.CreateAdminCommand.Select(x => true).StartWith(false)); this.ChangeToPartyCommand.Subscribe(p => { this.library.LocalAccessControl.DowngradeLocalAccess(this.accessToken); this.ShowSettings = false; }); this.canLogin = this.WhenAnyValue(x => x.LoginPassword, x => !string.IsNullOrWhiteSpace(x)) .ToProperty(this, x => x.CanLogin); this.LoginCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanLogin), ImmediateScheduler.Instance); // Immediate execution, because we set the password to an empty string afterwards this.LoginCommand.Subscribe(p => { try { this.library.LocalAccessControl.UpgradeLocalAccess(this.accessToken, this.LoginPassword); this.IsWrongPassword = false; this.ShowLogin = false; this.ShowSettings = true; } catch (WrongPasswordException) { this.IsWrongPassword = true; } }); this.OpenLinkCommand = ReactiveCommand.Create(); this.OpenLinkCommand.Cast<string>().Subscribe(x => { try { Process.Start(x); } catch (Win32Exception ex) { this.Log().ErrorException(String.Format("Could not open link {0}", x), ex); } }); this.ReportBugCommand = ReactiveCommand.Create(); this.ReportBugCommand.Subscribe(p => this.windowManager.ShowWindow(new BugReportViewModel())); this.ChangeAccentColorCommand = ReactiveCommand.Create(); this.ChangeAccentColorCommand.Subscribe(x => this.viewSettings.AccentColor = (string)x); this.ChangeAppThemeCommand = ReactiveCommand.Create(); this.ChangeAppThemeCommand.Subscribe(x => this.viewSettings.AppTheme = (string)x); this.UpdateLibraryCommand = ReactiveCommand.Create(this.library.WhenAnyValue(x => x.IsUpdating, x => !x) .ObserveOn(RxApp.MainThreadScheduler) .CombineLatest(this.library.WhenAnyValue(x => x.SongSourcePath).Select(x => !String.IsNullOrEmpty(x)), (x1, x2) => x1 && x2)); this.UpdateLibraryCommand.Subscribe(_ => this.library.UpdateNow()); this.librarySource = this.library.WhenAnyValue(x => x.SongSourcePath) .ToProperty(this, x => x.LibrarySource); this.port = this.coreSettings.Port; this.ChangePortCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Port, NetworkHelpers.IsPortValid)); this.ChangePortCommand.Subscribe(_ => this.coreSettings.Port = this.Port); this.remoteControlPassword = this.coreSettings.RemoteControlPassword; this.ChangeRemoteControlPasswordCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.RemoteControlPassword) .Select(x => !String.IsNullOrWhiteSpace(x))); this.ChangeRemoteControlPasswordCommand.Subscribe(x => this.library.RemoteAccessControl.SetRemotePassword(this.accessToken, this.RemoteControlPassword)); this.showRemoteControlPasswordError = this.WhenAnyValue(x => x.RemoteControlPassword, x => x.LockRemoteControl, (password, lockRemoteControl) => String.IsNullOrWhiteSpace(password) && lockRemoteControl) .ToProperty(this, x => x.ShowRemoteControlPasswordError); this.isRemoteAccessReallyLocked = this.library.RemoteAccessControl.WhenAnyValue(x => x.IsRemoteAccessReallyLocked) .ToProperty(this, x => x.IsRemoteAccessReallyLocked); this.isPortOccupied = mobileApiInfo.IsPortOccupied.ToProperty(this, x => x.IsPortOccupied); this.enableChangelog = this.viewSettings.WhenAnyValue(x => x.EnableChangelog) .ToProperty(this, x => x.EnableChangelog); this.defaultPlaybackEngine = this.coreSettings.WhenAnyValue(x => x.DefaultPlaybackEngine) .ToProperty(this, x => x.DefaultPlaybackEngine); }
private void LoadViews(XmlNode configNode, IFormatProvider formatProvider) { ObjectTypeSettings typedObject; //Get the configured views foreach( XmlNode viewNode in configNode.SelectNodes(NodeViewXPath)) { typedObject = new ViewSettings(viewNode, formatProvider); if (!_viewByNameCollection.ContainsKey(typedObject.Name)) { _viewByNameCollection.Add(typedObject.Name, typedObject); } else throw new Exception(string.Format("ExceptionViewSettingAlreadyConfigured {0}.", typedObject.Name)); } }