public SettingsView(SettingsViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; this._viewModel = viewModel; }
public MainWindowViewModel() { ApplicationMessageService = new ApplicationMessageServiceViewModel(); CompositeDisposable.Add(ApplicationMessageService); SettingsViewModel = new SettingsViewModel(); CompositeDisposable.Add(SettingsViewModel); }
public void BindToViewModel(SettingsViewModel model) { viewModel = model; var settings = viewModel.GetDataSource(); txtCurrentCustomerNumber.Text = settings["numbers.customer.customer_number"].Value; }
public Design() { Main = new MainViewModel( new DesignLocationService(), new DesignNavigationService(), new DesignMapService(), new DesignPluginSettings(), new MapSearchRequest() ); Settings = new SettingsViewModel( new DesignPluginSettings() ); Main.OnNavigatedTo(); Settings.OnNavigatedTo(); }
/// <summary> /// Initializes a new instance of the <see cref="Settings"/> class. /// </summary> public Settings(ObservableCollection<ProjectViewModel> projects) { this.projects = projects; InitializeComponent(); model = new SettingsViewModel(projects); DataContext = model; }
public SettingsView(SettingsViewModel viewModel) { InitializeComponent(); _viewModel = viewModel; this.DataContext = _viewModel; romPaths.Content = new RomPathsView(viewModel.RomPathsViewModel); smsInput.Content = new SmsInputView(viewModel.SmsInputViewModel, viewModel.InputManager); }
public Design() { About = new AboutViewModel( new DesignBrowserService(), new DesignEmailService(), new DesignAppRatingService() ); Main = new MainViewModel( new DesignNavigationService(), new DesignPluginLoader(), new DesignMainSettings(), new DesignTileService() ); Settings = new SettingsViewModel( new DesignMainSettings(), new DesignCredentialsStorage(), new DesignTileService() ); About.OnNavigatedTo(); Main.OnNavigatedTo(); Settings.OnNavigatedTo(); }
private void OnNavBarButtonClick(object sender, EventArgs e) { if(core.WindowManager.ExistsWindow<ISettingsView>()) { core.WindowManager.BringWindowToFront<ISettingsView>(); } else { var view = SettingFactories.SettingsViewFactory.CreateSettingsView(); SettingsViewModel viewModel = new SettingsViewModel(view); core.WindowManager.RegisterWindow(view); } }
public Design() { AddStation = new AddStationViewModel( new DesignTransportService(), new DesignLocationService(), new DesignNavigationService(), new DesignPluginSettings() ); Main = new MainViewModel( new DesignTransportService(), new DesignPluginSettings(), new DesignNavigationService(), new DesignLocationService() ); Settings = new SettingsViewModel( new DesignPluginSettings() ); AddStation.OnNavigatedToAsync(); Main.OnNavigatedToAsync(); Settings.OnNavigatedTo(); }
public Settings() { InitializeComponent(); DataContext = settings = new SettingsViewModel(); var promptWith = ((LanguageCollection)App.Current.Resources["LanguageCodes"]).ToList(); promptWith.Insert(0, new LanguageViewModel { Code = "$term", Description = "Prompt with terms" }); promptWith.Insert(1, new LanguageViewModel { Code = "$definition", Description = "Prompt with definitions" }); promptWithLanguages.ItemsSource = promptWith; }
public SettingsWindow() { InitializeComponent(); vm = new SettingsViewModel(); vm.Settings = Settings.Default; vm.FontNames = Fonts.SystemFontFamilies.Select(f => f.Source).OrderBy(f => f).ToList(); this.DataContext = vm; this.settingsCopy = SimpleMapper.Map<Settings, Settings>(Settings.Default); }
void Awake() { if (null == model) { model = gameObject.GetComponent<SettingsViewModel>(); } if (null == model) { throw new MissingComponentException(); } }
public Design() { About = new AboutViewModel( new DesignBrowserService(), new DesignEmailService(), new DesignRatingService() ); Main = new MainViewModel( new DesignNavigationService(), new DesignServerAccess(), new DesignPluginLoader(), new DesignMainSettings(), new DesignTileService(), new ViewPluginRequest() ); Settings = new SettingsViewModel( new DesignMainSettings(), new DesignAuthenticator(), new DesignNavigationService(), new DesignAuthenticationService(), new DesignCredentialsStorage(), new DesignTileService() ); About.OnNavigatedTo(); Main.OnNavigatedToAsync(); Settings.OnNavigatedTo(); }
public OptionWindowViewModel() { SettingsViewModel = new SettingsViewModel(); CompositeDisposable.Add(SettingsViewModel); CompositeDisposable.Add(new PropertyChangedEventListener(SettingsViewModel, (sender, e) => { if (e.PropertyName == "CustomTweetSaveFolder" || e.PropertyName == "SaveTweetWhenDelete") RaisePropertyChanged(() => IsEnabledTweetSaveFolderSelector); })); GlobalizationServiceViewModel = new GlobalizationServiceViewModel(); CompositeDisposable.Add(GlobalizationServiceViewModel); }
public void Initaize() { if (null == viewModel) { browser = container.Resolve<QueryViewModel>(); viewModel = container.Resolve<SettingsViewModel>(); viewModel.Model = model; viewModel.EditDownloadDir = new DelegateCommand(SettingsEditDownloadDir); viewModel.ChangeAvatar = new DelegateCommand(ChangeAvatar); viewModel.ResetInterface = new DelegateCommand(ResetInterface); viewModel.DisplayQuickStart = new DelegateCommand(DisplayQuickStart); } }
public ComposeWindowViewModel() { SettingsViewModel = new SettingsViewModel(); CompositeDisposable.Add(SettingsViewModel); Media = new ObservableSynchronizedCollection<UploadMediaInfoViewModel>(); CompositeDisposable.Add(new CollectionChangedEventListener(Media, (sender, e) => { RaisePropertyChanged(() => IsMediaAttached); RaisePropertyChanged(() => CharCountLeft); TweetCommand.RaiseCanExecuteChanged(); })); }
public MainWindow() { _mainViewModel = new PlayerViewModel(); _setViewModel = new SettingsViewModel(); _viewer = new MediaViewer(_setViewModel, _mainViewModel.Controller); _set = new SettingsOverview(_setViewModel); _set.Visibility = Visibility.Hidden; InitializeComponent(); this.Loaded += MainWindow_Loaded; this.Closing += MainWindow_Closing; this.KeyUp += MainWindow_KeyUp; App.Dispatch = this.Dispatcher; _viewer.Visibility = Visibility.Visible; }
public Design() { var foodService = new DesignFoodService(); var meal = foodService.GetMenusAsync( null, CancellationToken.None ).Result.Menu[0].Meals[0]; Main = new MainViewModel( new DesignDataCache(), new DesignNavigationService(), new DesignFoodService(), new DesignCredentialsStorage(), new DesignPluginSettings() ); Rating = new RatingViewModel( new DesignFoodService(), new DesignNavigationService(), new DesignDeviceIdentifier(), meal ); Settings = new SettingsViewModel( new DesignPluginSettings() ); Main.OnNavigatedToAsync(); Rating.OnNavigatedToAsync(); Settings.OnNavigatedTo(); }
public ShellViewModel( GameViewModel gameView, ControlsViewModel controlsView, MessageViewModel messageView, RecordsViewModel recordsView, SettingsViewModel settingsView, UserViewModel userView) { GameView = gameView; ControlsView = controlsView; MessageView = messageView; RecordsView = recordsView; SettingsView = settingsView; UserView = userView; SetTitle(); IsUserActive = true; }
public ActionResult UpdateName(SettingsViewModel model) { if (!this.ModelState.IsValid) { return new HttpNotFoundResult(); } var app = this.apps.GetMyApps(this.User.Identity.GetUserId()) .FirstOrDefault(x => x.Id == model.Id); if (app == null) { return new HttpNotFoundResult(); } app.Name = model.Name; this.apps.Update(app); return this.Json(model.Name); }
protected void FinishInit() { Current = this; _listingFilter = new NSFWListingFilter(); if (IsInDesignMode) { _initializationBlob = new InitializationBlob { Settings = new Dictionary<string, string>(), NSFWFilter = new Dictionary<string, bool>() }; } else { OfflineService = new OfflineService(); _initializationBlob = OfflineService.LoadInitializationBlob(""); } Settings = new Model.Settings(_initializationBlob.Settings); SettingsHub = new SettingsViewModel(Settings); RedditUserState = _initializationBlob.DefaultUser ?? new UserState(); SnooStreamViewModel.ActivityManager.OAuth = SnooStreamViewModel.RedditUserState != null && SnooStreamViewModel.RedditUserState.OAuth != null ? JsonConvert.SerializeObject(SnooStreamViewModel.RedditUserState) : ""; SnooStreamViewModel.ActivityManager.CanStore = SnooStreamViewModel.RedditUserState != null && SnooStreamViewModel.RedditUserState.IsDefault; NotificationService = new Common.NotificationService(); CaptchaProvider = new CaptchaService(); RedditService = new Reddit(_listingFilter, RedditUserState, OfflineService, CaptchaProvider, "3m9rQtBinOg_rA", null, "http://www.google.com"); Login = new LoginViewModel(); _listingFilter.Initialize(Settings, OfflineService, RedditService, _initializationBlob.NSFWFilter); CommandDispatcher = new CommandDispatcher(); SubredditRiver = new SubredditRiverViewModel(_initializationBlob.Subreddits); SelfStream = new SelfStreamViewModel(); ModStream = new ModStreamViewModel(); NavMenu = new NavMenu(Enumerable.Empty<LinkRiverViewModel>(), this); MessengerInstance.Register<UserLoggedInMessage>(this, OnUserLoggedIn); if (RedditUserState.Username != null) { SelfUser = new AboutUserViewModel(RedditUserState.Username); } }
public void TestDeviceConnectStatus() { var settings = SettingsManager(); var status = StatusManager(); SettingsViewModel target = new SettingsViewModel(settings.Object, status.Object); string actual = null; target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { actual = e.PropertyName; }; settings.SetupGet(s => s.DeviceConnectStatusKey).Returns(TestKey); target.DeviceConnectStatus = new Status() { Key = TestKey }; ; settings.VerifySet(s => s.DeviceConnectStatusKey = TestKey); Assert.AreEqual(TestKey, target.DeviceConnectStatus.Key); Assert.AreEqual("DeviceConnectStatus", actual); }
public ApplicationController(Lazy<ShellViewModel> shellViewModelLazy, Lazy<SettingsViewModel> settingsViewModelLazy, Lazy<AboutViewModel> aboutViewModelLazy, Lazy<HelpViewModel> helpViewModelLazy, Lazy<LogViewModel> logViewModelLazy, Lazy<ShellService> shellServiceLazy, CompositionContainer compositionContainer, Lazy<IAccountAuthenticationService> accountAuthenticationServiceLazy, IShellController shellController, Lazy<SystemTrayNotifierViewModel> lazySystemTrayNotifierViewModel, IGuiInteractionService guiInteractionService, ILogController logController) { //ViewModels _shellViewModel = shellViewModelLazy.Value; _settingsViewModel = settingsViewModelLazy.Value; _aboutViewModel = aboutViewModelLazy.Value; _helpViewModel = helpViewModelLazy.Value; _logViewModel = logViewModelLazy.Value; _systemTrayNotifierViewModel = lazySystemTrayNotifierViewModel.Value; //Commands _shellViewModel.Closing += ShellViewModelClosing; _exitCommand = new DelegateCommand(Close); //Services AccountAuthenticationService = accountAuthenticationServiceLazy.Value; _shellService = shellServiceLazy.Value; _shellService.ShellView = _shellViewModel.View; _shellService.SettingsView = _settingsViewModel.View; _shellService.AboutView = _aboutViewModel.View; _shellService.HelpView = _helpViewModel.View; _shellService.LogView = _logViewModel.View; _shellController = shellController; _guiInteractionService = guiInteractionService; _logController = logController; if (_shellViewModel.IsSettingsVisible) { _settingsViewModel.Load(); } }
public void TestDeviceConnectNotification() { var settings = SettingsManager(); var status = StatusManager(); settings.SetupGet(s => s.DeviceConnectNotification).Returns(true); SettingsViewModel target = new SettingsViewModel(settings.Object, status.Object); string actual = null; target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { actual = e.PropertyName; }; Assert.AreEqual(true, target.DeviceConnectNotification); target.DeviceConnectNotification = false; settings.VerifySet(s => s.DeviceConnectNotification = false); Assert.AreEqual("DeviceConnectNotification", actual); }
public Design() { var eventsService = new DesignEventsService(); var result = eventsService.GetEventPoolAsync( null, CancellationToken.None ).Result; var pool = result.Pool; pool.Items = result.ChildrenItems.Values.ToArray(); var itemRequest = new ViewEventItemRequest( 0, true ); CategoryFilter = new CategoryFilterViewModel( new DesignPluginSettings(), pool ); EventItem = new EventItemViewModel( new DesignDataCache(), new DesignNavigationService(), new DesignBrowserService(), new DesignEventsService(), new DesignPluginSettings(), itemRequest ); EventPool = new EventPoolViewModel( new DesignDataCache(), new DesignNavigationService(), new DesignEventsService(), new DesignPluginSettings(), new DesignEmailPrompt(), new DesignCodeScanner(), -1 ); Settings = new SettingsViewModel( new DesignPluginSettings() ); TagFilter = new TagFilterViewModel( new DesignPluginSettings(), pool ); CategoryFilter.OnNavigatedTo(); EventItem.OnNavigatedToAsync(); EventPool.OnNavigatedToAsync(); Settings.OnNavigatedTo(); TagFilter.OnNavigatedTo(); }
public SettingsView(SettingsViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }
protected override void Init(Bundle savedInstanceState) { ViewModel = AndroidViewModelLocator.Settings; }
public TransformEditViewModelWPF(SettingsViewModel vmSettings, MDictionaryEdit itemEdit) : base(vmSettings, itemEdit) { }
private void RefreshCategories(SettingsViewModel obj) => RefreshCategories();
protected override async void OnActivated(IActivatedEventArgs args) { Logger.Info("App activated"); // Window management if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); rootFrame.CacheSize = 1; Window.Current.Content = rootFrame; } var currentView = SystemNavigationManager.GetForCurrentView(); switch (args.Kind) { case ActivationKind.Protocol: var eventArgs = args as ProtocolActivatedEventArgs; if (eventArgs.Uri.AbsoluteUri == "files-uwp:") { rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo()); } else { var parsedArgs = eventArgs.Uri.Query.TrimStart('?').Split('='); var unescapedValue = Uri.UnescapeDataString(parsedArgs[1]); switch (parsedArgs[0]) { case "tab": rootFrame.Navigate(typeof(MainPage), TabItemArguments.Deserialize(unescapedValue), new SuppressNavigationTransitionInfo()); break; case "folder": rootFrame.Navigate(typeof(MainPage), unescapedValue, new SuppressNavigationTransitionInfo()); break; } } // Ensure the current window is active. Window.Current.Activate(); Window.Current.CoreWindow.Activated += CoreWindow_Activated; return; case ActivationKind.CommandLineLaunch: var cmdLineArgs = args as CommandLineActivatedEventArgs; var operation = cmdLineArgs.Operation; var cmdLineString = operation.Arguments; var activationPath = operation.CurrentDirectoryPath; var parsedCommands = CommandLineParser.ParseUntrustedCommands(cmdLineString); if (parsedCommands != null && parsedCommands.Count > 0) { foreach (var command in parsedCommands) { switch (command.Type) { case ParsedCommandType.OpenDirectory: rootFrame.Navigate(typeof(MainPage), command.Payload, new SuppressNavigationTransitionInfo()); // Ensure the current window is active. Window.Current.Activate(); Window.Current.CoreWindow.Activated += CoreWindow_Activated; return; case ParsedCommandType.OpenPath: try { var det = await StorageFolder.GetFolderFromPathAsync(command.Payload); rootFrame.Navigate(typeof(MainPage), command.Payload, new SuppressNavigationTransitionInfo()); // Ensure the current window is active. Window.Current.Activate(); Window.Current.CoreWindow.Activated += CoreWindow_Activated; return; } catch (System.IO.FileNotFoundException ex) { //Not a folder Debug.WriteLine($"File not found exception App.xaml.cs\\OnActivated with message: {ex.Message}"); } catch (Exception ex) { Debug.WriteLine($"Exception in App.xaml.cs\\OnActivated with message: {ex.Message}"); } break; case ParsedCommandType.Unknown: rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo()); // Ensure the current window is active. Window.Current.Activate(); Window.Current.CoreWindow.Activated += CoreWindow_Activated; return; } } } break; case ActivationKind.ToastNotification: var eventArgsForNotification = args as ToastNotificationActivatedEventArgs; if (eventArgsForNotification.Argument == "report") { // Launch the URI and open log files location //SettingsViewModel.OpenLogLocation(); SettingsViewModel.ReportIssueOnGitHub(); } break; } rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo()); // Ensure the current window is active. Window.Current.Activate(); Window.Current.CoreWindow.Activated += CoreWindow_Activated; }
public ActionResult Settings(SettingsViewModel model) { return View(model); }
private void RefreshTransactions(SettingsViewModel obj) => RefreshTransactions();
public SettingsPage() { InitializeComponent(); BindingContext = new SettingsViewModel(); }
private void ApplicationBarIconButton_Click(object sender, EventArgs e) { SettingsViewModel.SaveSettingsFile(); NavigationService.GoBack(); }
/// <summary> /// Initializes a new instance of the <see cref="ShellViewModel" /> class. /// </summary> /// <param name="container">The container.</param> /// <param name="settingsService">The settings service.</param> /// <param name="settingsViewModel">The settings view model.</param> /// <param name="eventAggregator">The event aggregator.</param> public ShellViewModel(SimpleContainer container, SettingsService settingsService, SettingsViewModel settingsViewModel, IEventAggregator eventAggregator) { this._eventAggregator = eventAggregator; this._settingsService = settingsService; this._container = container; this._settingsViewModel = settingsViewModel; this.WaitForPoe(); this.StartWithWindows = File.Exists(this.ShortcutFilePath); this.ShowInTaskBar = true; if (settingsService.FirstLaunch) { if (this.StartWithWindows) { // RefreshShortcut File.Delete(this.ShortcutFilePath); this.CreateLink(); } settingsService.FirstLaunch = false; this._showUpdateSuccess = true; settingsService.Save(); Process.Start("https://github.com/C1rdec/Poe-Lurker/releases/latest"); } this._eventAggregator.Subscribe(this); }
/// <summary> /// Called when the scan updates. /// </summary> /// <param name="cancellationToken">The cancellation token for handling canceled tasks.</param> protected override void OnUpdate(CancellationToken cancellationToken) { Int32 processedPages = 0; Boolean hasRelativeConstraint = this.ScanConstraintManager.HasRelativeConstraint(); // Determine if we need to increment both current and previous value pointers, or just current value pointers PointerIncrementMode pointerIncrementMode = hasRelativeConstraint ? PointerIncrementMode.ValuesOnly : PointerIncrementMode.CurrentOnly; cancellationToken.ThrowIfCancellationRequested(); // Enforce each value constraint foreach (ScanConstraint scanConstraint in this.ScanConstraintManager) { this.Snapshot.SetAllValidBits(false); Parallel.ForEach( this.Snapshot.Cast <SnapshotRegion>(), SettingsViewModel.GetInstance().ParallelSettingsFullCpu, (region) => { // Check for canceled scan if (cancellationToken.IsCancellationRequested) { return; } // Ignore region if it requires current & previous values, but we cannot find them if (hasRelativeConstraint && !region.CanCompare()) { return; } for (IEnumerator <SnapshotElementIterator> enumerator = region.IterateElements(pointerIncrementMode, scanConstraint.Constraint, scanConstraint.ConstraintValue); enumerator.MoveNext();) { SnapshotElementIterator element = enumerator.Current; // Perform the comparison based on the current scan constraint if (element.Compare()) { element.SetValid(true); } } //// End foreach Element lock (this.ProgressLock) { processedPages++; // Limit how often we update the progress if (processedPages % 10 == 0) { this.UpdateProgress(processedPages / this.ScanConstraintManager.Count(), this.Snapshot.RegionCount, canFinalize: false); } } }); //// End foreach Region // Exit if canceled cancellationToken.ThrowIfCancellationRequested(); } //// End foreach Constraint }
protected override async void OnAppearing() { _viewModel = new SettingsViewModel() { Title = AppTranslations.Page_Title_Settings }; var permissionTrackErrors = await _settingService.GetSettingValueAsync(SettingKeys.PermissionTrackErrors); var notifyWhenStatusNotRespond = await _settingService.GetSettingValueAsync(SettingKeys.NotifyWhenStatusNotRespond); var darkModeEnabled = await _settingService.GetSettingValueAsync(SettingKeys.DarkModeEnabled); _viewModel.StatusRequestUrl = await _settingService.GetSettingValueAsync(SettingKeys.StatusRequestUrl);; if (permissionTrackErrors == "1") { _viewModel.PermissionTrackErrors = true; } if (notifyWhenStatusNotRespond == "1") { _viewModel.NotifyWhenStatusNotRespond = true; } if (darkModeEnabled == "1") { _viewModel.DarkModeEnabled = true; } #region GadgetSortingSetting // TODO: Fix this static stuff... var allEnumTypes = new List <GadgetSortingTypes> { GadgetSortingTypes.ByCreationAsc, GadgetSortingTypes.ByCreationDesc, GadgetSortingTypes.ByNameAsc, GadgetSortingTypes.ByNameDesc, GadgetSortingTypes.ByLocationAsc, GadgetSortingTypes.ByLocationDesc, GadgetSortingTypes.ByTemperatureDesc, GadgetSortingTypes.ByTemperatureAsc }; var gadgetSortingOptions = (allEnumTypes.Select(enumType => GetGadgetSortingTypeName(enumType))).ToList(); _pckGadgetSortingType.ItemsSource = gadgetSortingOptions; var currentGadgetSorting = await _settingService.GetSettingValueAsync(SettingKeys.GadgetSortingType); int.TryParse(currentGadgetSorting, out int gadgetSortingId); _pckGadgetSortingType.SelectedIndex = gadgetSortingId - 1; #endregion #region WebRequestTimeoutSetting var timeoutSettingOptions = new List <string>(); for (int i = 1; i < 20; i++) { timeoutSettingOptions.Add($"{i} " + AppTranslations.Page_Settings_Setting_Timeout_Measurement); } _pckTimeoutSetting.ItemsSource = timeoutSettingOptions; var requestTimeoutInSeconds = await _settingService.GetSettingValueAsync(SettingKeys.RequestTimeoutInSeconds); int.TryParse(requestTimeoutInSeconds, out int requestTimeout); _pckTimeoutSetting.SelectedIndex = requestTimeout - 1; #endregion BindingContext = _viewModel; }
public LeftSideBarModel() { Settings = new SettingsViewModel(); adminUserModel = new AdminUserModel(); }
public MainViewModel(SettingsViewModel settingsViewModel) { Settings = settingsViewModel; }
/// <summary> /// Event fired when the stream commands need to be update. /// </summary> private void OnUpdate() { if (!this.IsConnected) { return; } try { lock (this.VoteLock) { if (!this.IsConnected || !BrowseViewModel.GetInstance().IsLoggedIn) { return; } AccessTokens accessTokens = SettingsViewModel.GetInstance().AccessTokens; IEnumerable <CheatVotes> cheatVotes = SqualrApi.GetStreamActivationIds(accessTokens.AccessToken); IEnumerable <Cheat> candidateCheats = LibraryViewModel.GetInstance().CheatsInLibrary; if (candidateCheats == null || this.PreviousCheatVotes == null || cheatVotes == null || this.PreviousCheatVotes.Count() != cheatVotes.Count()) { this.PreviousCheatVotes = cheatVotes; return; } // Get cheat IDs to activate based on increased vote counts IEnumerable <Int32> cheatIdsToActivate = cheatVotes .Join( this.PreviousCheatVotes, currentVote => currentVote.CheatId, previousVote => previousVote.CheatId, (currentVote, previousVote) => new { cheatId = currentVote.CheatId, currentCount = currentVote.VoteCount, previousCount = previousVote.VoteCount }) .Where(combinedVote => combinedVote.currentCount != combinedVote.previousCount) .Select(combinedVote => combinedVote.cheatId); // Add in new votes with no previous vote count cheatIdsToActivate = cheatVotes .Select(vote => vote.CheatId) .Except(this.PreviousCheatVotes.Select(vote => vote.CheatId)) .Concat(cheatIdsToActivate) .Distinct(); IEnumerable <Cheat> projectItemsToActivate = cheatIdsToActivate .Join( candidateCheats, cheatId => cheatId, projectItem => projectItem?.CheatId, (cheatId, projectItem) => projectItem); IEnumerable <Cheat> projectItemsToDeactivate = cheatVotes .Join( candidateCheats, cheatVote => cheatVote.CheatId, projectItem => projectItem?.CheatId, (cheatId, projectItem) => projectItem) .Except(projectItemsToActivate); // Handle activations projectItemsToActivate.ForEach(item => { item.IsActivated = true; // Reset duration always item.Duration = 0.0f; }); // Notify which project items were activated such that Squalr can update the stream overlay if (projectItemsToActivate.Count() > 0) { Task.Run(() => { IEnumerable <Cheat> activatedProjectItems = candidateCheats .Select(item => item) .Where(item => !item.IsStreamDisabled) .Where(item => item.IsActivated); IEnumerable <OverlayMeta> overlayMeta = activatedProjectItems .Select(item => new OverlayMeta(item.CheatId, item.Cooldown, item.Duration)); if (overlayMeta.Count() > 0) { try { SqualrApi.UpdateOverlayMeta(accessTokens.AccessToken, overlayMeta.ToArray()); } catch (Exception ex) { OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error updating overlay cooldowns and durations", ex); } } }); } this.PreviousCheatVotes = cheatVotes; } } catch (Exception ex) { OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Warn, "Error fetching activated cheats", ex); } }
public App() { // Set custom Flags (mostly experimental ones) //Device.SetFlags(new[] { // "", //}); Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjE5ODY0QDMxMzcyZTM0MmUzMFJ6YjhtVjhjYnRRdlZOSC9yK0lGcmFTd09PT1dnVHhWcGxhUGNxeXk3ajA9"); InitializeComponent(); if (!Current.Properties.ContainsKey(Constants.UserName)) { Current.Properties[Constants.UserName] = "Novo Usuário"; } if (!Current.Properties.ContainsKey(Constants.OrganizationName)) { Current.Properties[Constants.OrganizationName] = "Nova Organização"; } if (!Current.Properties.ContainsKey(Constants.FontSize)) { Current.Properties[Constants.FontSize] = "14"; } if (!Current.Properties.ContainsKey(Constants.FontFamily)) { Current.Properties[Constants.FontFamily] = "Times New Roman"; } if (!Current.Properties.ContainsKey(Constants.MarginLeft)) { Current.Properties[Constants.MarginLeft] = "3"; } if (!Current.Properties.ContainsKey(Constants.MarginTop)) { Current.Properties[Constants.MarginTop] = "2"; } if (!Current.Properties.ContainsKey(Constants.MarginRight)) { Current.Properties[Constants.MarginRight] = "3"; } if (!Current.Properties.ContainsKey(Constants.MarginBottom)) { Current.Properties[Constants.MarginBottom] = "2"; } if (!Current.Properties.ContainsKey(Constants.Version)) { Current.Properties[Constants.Version] = "0"; } if (!Current.Properties.ContainsKey(Constants.SelectedMinuteImage)) { Current.Properties[Constants.SelectedMinuteImage] = "0"; } Current.SavePropertiesAsync(); // ViewModels homeViewModel = new HomeViewModel(); aboutViewModel = new AboutViewModel(); settingsViewModel = new SettingsViewModel(); minuteViewModel = new MinuteViewModel(); MainPage = new AppShell { }.Standard(); var version = App.Current.Properties[Constants.Version]?.ToString(); if (version != "v13") { Current.Properties[Constants.Version] = "v13"; Current.SavePropertiesAsync(); Application.Current.MainPage.DisplayAlert("Versão 13", "Olá!\r\n\r\nEsta é a versão 13 do PRO Atas. As principais mudanças são:\r\n\r\n- Agora é possível mudar a imagem do cabeçalho da ata em 'Configurações';\r\n- Página 'Sobre Mim' acrescentada;\r\n- Performance do aplicativo substancialmente melhorada;\r\n- Melhorias gerais na experiência de uso;\r\n- Alguns bugs foram corrigidos;\r\n\r\nEste aplicativo é desenvolvido por Raelson por iniciativa própria. Caso precise entrar em contato, enviar e-mail para [email protected]", "Legal!"); } }
/// <summary> /// Creates an instance of the given type. /// </summary> /// <param name="requestedType"></param> /// <returns></returns> /// <remarks> /// Every object in the composite root should be instantiates before returning the requested type. /// Otherwise, classes may not work correctly with each other, if they use an indirect way of communicating /// such as through events. /// </remarks> private object CreateInstance(Type requestedType) { MetroWindow metroWindow = Application.Current.MainWindow as MetroWindow; App app = Application.Current as App; LibraryUpdater libraryUpdater = new LibraryUpdater(); DialogCoordinator dialogCoordinator = new DialogCoordinator(); Persister persister = new Persister(); UpdateEliteAPI updateEliteAPI = new UpdateEliteAPI(libraryUpdater, dialogCoordinator, EventMessenger); SelectCharacter selectCharacterRequest = new SelectCharacter(EventMessenger, metroWindow); SelectAbilityRequestHandler selectAbilityRequestHandler = new SelectAbilityRequestHandler(metroWindow); BattlesViewModel battlesViewModel = new BattlesViewModel(); FollowViewModel followViewModel = new FollowViewModel(); IgnoredViewModel ignoredViewModel = new IgnoredViewModel(); LogViewModel logViewModel = new LogViewModel(); SelectProcessViewModel selectProcessViewModel = new SelectProcessViewModel(new SelectProcessDialog()); RestingViewModel restingViewModel = new RestingViewModel(); RoutesViewModel routesViewModel = new RoutesViewModel(); SettingsViewModel settingsViewModel = new SettingsViewModel(); TargetingViewModel targetingViewModel = new TargetingViewModel(); TargetsViewModel targetsViewModel = new TargetsViewModel(); TabViewModels tabViewModels = new TabViewModels(new List <IViewModel>() { battlesViewModel, targetingViewModel, restingViewModel, routesViewModel, followViewModel, logViewModel, settingsViewModel, }); MainViewModel mainViewModel = new MainViewModel(tabViewModels); MasterViewModel masterViewModel = new MasterViewModel(mainViewModel, EventMessenger); if (requestedType == typeof(EventMessenger)) { return(EventMessenger); } if (requestedType == typeof(App)) { return(app); } if (requestedType == typeof(LibraryUpdater)) { return(libraryUpdater); } if (requestedType == typeof(SelectCharacter)) { return(selectCharacterRequest); } if (requestedType == typeof(SelectAbilityRequestHandler)) { return(selectAbilityRequestHandler); } if (requestedType == typeof(IDialogCoordinator)) { return(dialogCoordinator); } if (requestedType == typeof(IPersister)) { return(persister); } if (requestedType == typeof(UpdateEliteAPI)) { return(updateEliteAPI); } if (requestedType == typeof(BattlesViewModel)) { return(battlesViewModel); } if (requestedType == typeof(FollowViewModel)) { return(followViewModel); } if (requestedType == typeof(IgnoredViewModel)) { return(ignoredViewModel); } if (requestedType == typeof(LogViewModel)) { return(logViewModel); } if (requestedType == typeof(TabViewModels)) { return(tabViewModels); } if (requestedType == typeof(MainViewModel)) { return(mainViewModel); } if (requestedType == typeof(MasterViewModel)) { return(masterViewModel); } if (requestedType == typeof(SelectProcessViewModel)) { return(selectProcessViewModel); } if (requestedType == typeof(RestingViewModel)) { return(restingViewModel); } if (requestedType == typeof(RoutesViewModel)) { return(routesViewModel); } if (requestedType == typeof(SettingsViewModel)) { return(settingsViewModel); } if (requestedType == typeof(TargetingViewModel)) { return(targetingViewModel); } if (requestedType == typeof(TargetsViewModel)) { return(targetsViewModel); } throw new InvalidOperationException($"Could not create instance of requested type {requestedType.Name}"); }
public SettingsWindow() { InitializeComponent(); DataContext = new SettingsViewModel(); }
/// <summary> /// Logs the user out. /// </summary> private void Logout() { SettingsViewModel.GetInstance().AccessTokens = null; Settings.Default.Save(); this.Navigate(NavigationPage.Login); }
public SettingsPage() { this.InitializeComponent(); ViewModel = new SettingsViewModel(); }
//---------------------------------save list data after edit--------------------------------------// public static void Save(SettingsViewModel settingviewmodel) { try { RemindersEntities Entities = new RemindersEntities(); string BirthDayEmailTextKey = SettingsKeys.BirthDayEmailTextKey(); string AnniversaryEmailTextKey = SettingsKeys.AnniversaryEmailTextKey(); string BirthdayReminderKey = SettingsKeys.BirthdayReminderKey(); string AnniversaryReminderKey = SettingsKeys.AnniversaryReminderKey(); string EventReminderKey = SettingsKeys.EventReminderKey(); string SendBirthdayKey = SettingsKeys.SendBirthdayKey(); string SendAnniversaryKey = SettingsKeys.SendAnniversaryKey(); string SendEventKey = SettingsKeys.SendEventKey(); string UpComingReminderKey = SettingsKeys.UpComingReminderKey(); string EmailAdminKey = SettingsKeys.EmailAdminKey(); string EmailSenderKey = SettingsKeys.EmailSenderKey(); string PasswordSenderKey = SettingsKeys.PasswordSenderKey(); string smtpaddressKey = SettingsKeys.smtpaddressKey(); string portnumberKey = SettingsKeys.portnumberKey(); var set0 = Entities.Settings.Where(x => x.Key == BirthDayEmailTextKey).FirstOrDefault(); set0.Values = settingviewmodel.settingsView.BirthDayEmailText; set0.Description = settingviewmodel.settingsView.BirthDayEmailText; set0.CreatedOn = DateTime.Now; var set1 = Entities.Settings.Where(x => x.Key == AnniversaryEmailTextKey).FirstOrDefault(); set1.Values = settingviewmodel.settingsView.AnniversaryEmailText; set1.Description = settingviewmodel.settingsView.AnniversaryEmailText; set1.CreatedOn = DateTime.Now; var set2 = Entities.Settings.Where(x => x.Key == BirthdayReminderKey).FirstOrDefault(); set2.Values = settingviewmodel.BirthdayReminderID.ToString(); var Lookup2 = Entities.Lookups.Find(settingviewmodel.BirthdayReminderID); set2.Description = Lookup2.Description.ToString(); set2.CreatedOn = DateTime.Now; var set3 = Entities.Settings.Where(x => x.Key == AnniversaryReminderKey).FirstOrDefault(); set3.Values = settingviewmodel.AnniversaryReminderID.ToString(); var Lookup3 = Entities.Lookups.Find(settingviewmodel.AnniversaryReminderID); set3.Description = Lookup3.Description.ToString(); set3.CreatedOn = DateTime.Now; var set4 = Entities.Settings.Where(x => x.Key == EventReminderKey).FirstOrDefault(); set4.Values = settingviewmodel.EventReminderID.ToString(); var Lookup4 = Entities.Lookups.Find(settingviewmodel.EventReminderID); set4.Description = Lookup4.Description.ToString(); set4.CreatedOn = DateTime.Now; var set5 = Entities.Settings.Where(x => x.Key == SendBirthdayKey).FirstOrDefault(); set5.Values = settingviewmodel.SendBirthdayID.ToString(); var Lookup5 = Entities.Lookups.Find(settingviewmodel.SendBirthdayID); set5.Description = Lookup5.Description.ToString(); set5.CreatedOn = DateTime.Now; var set6 = Entities.Settings.Where(x => x.Key == SendAnniversaryKey).FirstOrDefault(); set6.Values = settingviewmodel.SendAnniversaryID.ToString(); var Lookup6 = Entities.Lookups.Find(settingviewmodel.SendAnniversaryID); set6.Description = Lookup6.Description.ToString(); set6.CreatedOn = DateTime.Now; var set7 = Entities.Settings.Where(x => x.Key == SendEventKey).FirstOrDefault(); set7.Values = settingviewmodel.SendEventID.ToString(); var Lookup7 = Entities.Lookups.Find(settingviewmodel.SendEventID); set7.Description = Lookup7.Description.ToString(); set7.CreatedOn = DateTime.Now; var set8 = Entities.Settings.Where(x => x.Key == UpComingReminderKey).FirstOrDefault(); set8.Values = settingviewmodel.UpComingReminderID.ToString(); var Lookup8 = Entities.Lookups.Find(settingviewmodel.UpComingReminderID); set8.Description = Lookup8.Description.ToString(); set8.CreatedOn = DateTime.Now; var set15 = Entities.Settings.Where(x => x.Key == EmailAdminKey).FirstOrDefault(); set15.Values = settingviewmodel.settingsView.EmailAdmin.ToString(); set15.Description = settingviewmodel.settingsView.EmailAdmin.ToString(); set15.CreatedOn = DateTime.Now; Entities.SaveChanges(); } catch (Exception ex) { throw ex; } }
protected override void OnDisappearing() { base.OnDisappearing(); viewModel = null; BindingContext = null; }
/* TODO: Disabled Login components due to php backend not functioning on modapi.cc * protected void ShowLoginLoader() * { * Dispatcher.Invoke(delegate * { * LoginButton.Visibility = Visibility.Collapsed; * LoginLoader.Visibility = Visibility.Visible; * LoggedIn.Visibility = Visibility.Collapsed; * }); * } * * protected void ShowLoginUser(WebService.User user) * { * Dispatcher.Invoke(delegate * { * LoginButton.Visibility = Visibility.Collapsed; * LoginLoader.Visibility = Visibility.Collapsed; * LoggedIn.Visibility = Visibility.Visible; * UserAvatarLoader.Visibility = Visibility.Visible; * Console.WriteLine(user.Usergroup); * Usergroup.SetResourceReference(TextBlock.TextProperty, "Lang.UserGroup." + user.Usergroup); * Username.Text = user.Username; * user.OnAvatarChange = AvatarChange; * user.LoadAvatar(); * }); * } * * protected void AvatarChange() * { * Dispatcher.Invoke(delegate * { * UserAvatarLoader.Visibility = Visibility.Collapsed; * var avatar = new BitmapImage(); * avatar.BeginInit(); * if (WebService.CurrentUser.Avatar == null) * { * avatar.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/noAvatar.png"); * } * else * { * avatar.StreamSource = WebService.CurrentUser.Avatar; * } * avatar.CacheOption = BitmapCacheOption.OnLoad; * avatar.EndInit(); * UserAvatar.Source = avatar; * UserAvatar.InvalidateProperty(Image.SourceProperty); * }); * } * * protected void ShowLoginError(int id, string text) * { * Dispatcher.Invoke(delegate * { * ShowLogin(); * var win = new LoginWindow("Lang.Windows.Login", true); * win.ShowSubWindow(); * }); * } * * protected void ShowLogin() * { * Dispatcher.Invoke(delegate * { * LoginButton.Visibility = Visibility.Visible; * LoginLoader.Visibility = Visibility.Collapsed; * LoggedIn.Visibility = Visibility.Collapsed; * }); * } */ public MainWindow() { //System.Console.WriteLine("AAA"); if (Configuration.Languages["en"] != null) { App.Instance.Resources.MergedDictionaries.Add(Configuration.Languages["en"].Resource); } InitializeComponent(); Instance = this; /* TODO: Disabled Login components due to php backend not functioning on modapi.cc * WebService.OnDoLogin = ShowLoginLoader; * WebService.OnLogin = ShowLoginUser; * WebService.OnLoginError = ShowLoginError; * WebService.OnLogout = ShowLogin; */ WebService.Initialize(); foreach (var langCode in Languages) { var newItem = new ComboBoxItem { Style = Application.Current.FindResource("ComboBoxItem") as Style, DataContext = langCode }; LanguageItems.Add(langCode, newItem); var panel = new StackPanel { Orientation = Orientation.Horizontal }; var image = new Image { Height = 20 }; var source = new BitmapImage(); source.BeginInit(); source.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Lang_" + langCode + ".png"); source.EndInit(); image.Source = source; image.Margin = new Thickness(0, 0, 5, 0); panel.Children.Add(image); var label = new TextBlock { FontSize = 16 }; label.SetResourceReference(TextBlock.TextProperty, "Lang.Languages." + langCode); panel.Children.Add(label); newItem.Content = panel; DevelopmentLanguageSelector.Items.Add(newItem); } FirstSetup = Configuration.GetString("SetupDone").ToLower() != "true"; if (FirstSetup) { var win = new FirstSetup("Lang.Windows.FirstSetup"); win.ShowSubWindow(); win.Show(); } else { FirstSetupDone(); } Configuration.OnLanguageChanged += LanguageChanged; foreach (var language in Configuration.Languages.Values) { AddLanguage(language); } SettingsVm = new SettingsViewModel(); Settings.DataContext = SettingsVm; //LanguageSelector.SelectedIndex = Configuration.Languages.Values.ToList().IndexOf(Configuration.CurrentLanguage); foreach (var tab in GuiConfiguration.Tabs) { var newTab = new IconTabItem(); var style = App.Instance.Resources["TopTab"] as Style; newTab.Style = style; try { var image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconName); image.EndInit(); newTab.IconSource = image; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \"" + tab.IconName + "\".", Debug.Type.Warning); } try { var imageSelected = new BitmapImage(); imageSelected.BeginInit(); imageSelected.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconSelectedName); imageSelected.EndInit(); newTab.SelectedIconSource = imageSelected; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \"" + tab.IconSelectedName + "\".", Debug.Type.Warning); } newTab.SetResourceReference(IconTabItem.LabelProperty, tab.LangPath + ".Tab"); var newPanel = (IPanel)Activator.CreateInstance(tab.ComponentType); newTab.Content = newPanel; Debug.Log("MainWindow", "Added tab of type \"" + tab.TypeName + "\"."); newPanel.SetTab(tab); Panels.Add(newPanel); Tabs.Items.Add(newTab); } Timer = new DispatcherTimer(); Timer.Tick += GuiTick; Timer.Interval = new TimeSpan((long)(GuiDeltaTime * 10000000)); Timer.Start(); LanguageChanged(); SettingsVm.Changed(); }
public void TestSettingsViewModelCreation() { var vm = new SettingsViewModel(); Assert.NotNull(vm); }
/// <summary> /// Called when the scan updates. /// </summary> protected override void OnUpdate() { Int32 processedPages = 0; // Read memory to get current values Parallel.ForEach( this.Snapshot.Cast <Object>(), SettingsViewModel.GetInstance().ParallelSettings, (regionObject) => { SnapshotRegion region = regionObject as SnapshotRegion; Boolean readSuccess; region.ReadAllRegionMemory(out readSuccess, keepValues: true); if (!readSuccess) { region.SetAllValidBits(false); return; } // Ignore region if it requires current & previous values, but we cannot find them if (this.ScanConstraintManager.HasRelativeConstraint() && !region.CanCompare()) { region.SetAllValidBits(false); return; } foreach (SnapshotElementRef element in region) { // Enforce each value constraint on the element foreach (ScanConstraint scanConstraint in this.ScanConstraintManager) { switch (scanConstraint.Constraint) { case ConstraintsEnum.Unchanged: if (!element.Unchanged()) { element.SetValid(false); } break; case ConstraintsEnum.Changed: if (!element.Changed()) { element.SetValid(false); } break; case ConstraintsEnum.Increased: if (!element.Increased()) { element.SetValid(false); } break; case ConstraintsEnum.Decreased: if (!element.Decreased()) { element.SetValid(false); } break; case ConstraintsEnum.IncreasedByX: if (!element.IncreasedByValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.DecreasedByX: if (!element.DecreasedByValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.Equal: if (!element.EqualToValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.NotEqual: if (!element.NotEqualToValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.GreaterThan: if (!element.GreaterThanValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.GreaterThanOrEqual: if (!element.GreaterThanOrEqualToValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.LessThan: if (!element.LessThanValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.LessThanOrEqual: if (!element.LessThanOrEqualToValue(scanConstraint.ConstraintValue)) { element.SetValid(false); } break; case ConstraintsEnum.NotScientificNotation: if (element.IsScientificNotation()) { element.SetValid(false); } break; } } //// End foreach Constraint } //// End foreach Element lock (this.ProgressLock) { processedPages++; this.UpdateProgress(processedPages, this.Snapshot.GetRegionCount()); } }); //// End foreach Region base.OnUpdate(); }
public void TestInitialize() { settingsStoreMock = new SettingsStoreMock(); viewModel = new SettingsViewModel(settingsStoreMock, new TestAnalytics()); testObject = new PrivateObject(viewModel); }
public SettingsView(SettingsViewModel viewModel) { InitializeComponent(); this.BindingContext = viewModel; }
public CalendarController(SettingsViewModel settingsViewModel, CalendarViewModel calendarViewModel) { SettingsViewModel = settingsViewModel; CalendarViewModel = calendarViewModel; }
public SettingsView(bool needRestart) { InitializeComponent(); DataContext = new SettingsViewModel(needRestart); }
private void SettingDialogCommandExcute() { var settingDialogView = container.GetExportedValue<ISettingDialogView>(); var settingsView = container.GetExportedValue<ISettingsView>(); var proxyService = this.proxyController.ProxyService; this.dataController.TimerStop(); SettingsViewModel settingsViewModel = new SettingsViewModel(settingsView, proxyService, Settings.Default.TeamMembers); settingsViewModel.ActiveProxy = proxyService.ActiveProxy.ProxyName; settingsViewModel.UserName = Settings.Default.UserName; settingsViewModel.RefreshMinutes = Settings.Default.AutoQueryMinutes; settingsViewModel.IsFilterCreatedBy = Settings.Default.IsFilterCreatedBy; settingsViewModel.FilterStatusValues = Settings.Default.FilterStatusValues; settingsViewModel.FloatingWindowOpacity = Settings.Default.FloatingWindowOpacity; SettingDialogViewModel settingDialog = new SettingDialogViewModel(settingDialogView, proxyService, this.messageService, settingsViewModel); bool? result = settingDialog.ShowDialog(this.floatingViewModel.View); if (result == true) { proxyService.ActiveProxy = proxyService.Proxies.First(x => x.ProxyName == settingsViewModel.ActiveProxy); Settings.Default.ActiveProxy = settingsViewModel.ActiveProxy; Settings.Default.UserName = settingsViewModel.UserName; Settings.Default.AutoQueryMinutes = settingsViewModel.RefreshMinutes; Settings.Default.TeamMembers = settingsViewModel.TeamMembersString; Settings.Default.IsFilterCreatedBy = settingsViewModel.IsFilterCreatedBy; Settings.Default.FilterStatusValues = settingsViewModel.FilterStatusValues; Settings.Default.FloatingWindowOpacity = settingsViewModel.FloatingWindowOpacity; Settings.Default.Save(); } this.dataController.TimerStart(); floatingViewModel.Opacity = Settings.Default.FloatingWindowOpacity; }
private void OnSettingsClosed(object sender, EventArgs e) { _settingsViewModel.Closed -= OnSettingsClosed; _settingsViewModel = null; _settingsWindowId = null; }
public MainWindow() { //System.Console.WriteLine("AAA"); if (Configuration.Languages["en"] != null) App.Instance.Resources.MergedDictionaries.Add(Configuration.Languages["en"].Resource); InitializeComponent(); Instance = this; ModAPI.Utils.WebService.OnDoLogin = ShowLoginLoader; ModAPI.Utils.WebService.OnLogin = ShowLoginUser; ModAPI.Utils.WebService.OnLoginError = ShowLoginError; ModAPI.Utils.WebService.OnLogout = ShowLogin; ModAPI.Utils.WebService.Initialize(); foreach (string LangCode in Languages) { ComboBoxItem newItem = new ComboBoxItem(); newItem.Style = Application.Current.FindResource("ComboBoxItem") as Style; newItem.DataContext = LangCode; LanguageItems.Add(LangCode, newItem); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; Image image = new Image(); image.Height = 20; BitmapImage source = new BitmapImage(); source.BeginInit(); source.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Lang_"+LangCode+".png"); source.EndInit(); image.Source = source; image.Margin = new Thickness(0,0,5,0); panel.Children.Add(image); TextBlock label = new TextBlock(); label.SetResourceReference(TextBlock.TextProperty, "Lang.Languages." + LangCode); panel.Children.Add(label); newItem.Content = panel; DevelopmentLanguageSelector.Items.Add(newItem); } FirstSetup = Configuration.GetString("SetupDone").ToLower() != "true"; if (FirstSetup) { ModAPI.Windows.SubWindows.FirstSetup win = new ModAPI.Windows.SubWindows.FirstSetup("Lang.Windows.FirstSetup"); win.ShowSubWindow(); win.Show(); } else { FirstSetupDone(); } Configuration.OnLanguageChanged += LanguageChanged; foreach (Configuration.Language language in Configuration.Languages.Values) { AddLanguage(language); } SettingsVM = new SettingsViewModel(); Settings.DataContext = SettingsVM; //LanguageSelector.SelectedIndex = Configuration.Languages.Values.ToList().IndexOf(Configuration.CurrentLanguage); foreach (GUIConfiguration.Tab tab in GUIConfiguration.Tabs) { IconTabItem newTab = new IconTabItem(); Style style = App.Instance.Resources["TopTab"] as Style; newTab.Style = style; try { BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconName); image.EndInit(); newTab.IconSource = image; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \""+tab.IconName+"\".", Debug.Type.WARNING); } try { BitmapImage imageSelected = new BitmapImage(); imageSelected.BeginInit(); imageSelected.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/" + tab.IconSelectedName); imageSelected.EndInit(); newTab.SelectedIconSource = imageSelected; } catch (Exception e) { Debug.Log("MainWindow", "Couldn't find the icon \"" + tab.IconSelectedName + "\".", Debug.Type.WARNING); } newTab.SetResourceReference(IconTabItem.LabelProperty, tab.LangPath + ".Tab"); IPanel newPanel = (IPanel)Activator.CreateInstance(tab.ComponentType); newTab.Content = newPanel; Debug.Log("MainWindow", "Added tab of type \"" + tab.TypeName + "\"."); newPanel.SetTab(tab); Panels.Add(newPanel); Tabs.Items.Add(newTab); } Timer = new DispatcherTimer(); Timer.Tick += new EventHandler(GUITick); Timer.Interval = new TimeSpan((long) (GUIDeltaTime * 10000000)); Timer.Start(); LanguageChanged(); SettingsVM.Changed(); }
public JsonResult SettingSave(SettingsViewModel model) { Response response; try { List <string> keyList = new List <string> { Settings.KeyContractYear, Settings.KeyBaseSalary, Settings.KeyYearAddedRate, Settings.KeyBranchPersonelHourlyPayment, Settings.KeyBranchPersonelOverTime, Settings.KeyBranchPersonelMission, Settings.KeyBranchPersonelMonthlyWorkingHour, Settings.KeySuperVisorHourlyPayment, Settings.KeySuperVisorOverTime, Settings.KeySuperVisorMission, Settings.KeySuperVisorMonthlyWorkingHour, Settings.KeyOfficeHourlyPayment, Settings.KeyOfficeOverTime, Settings.KeyOfficeMission, Settings.KeyOfficeMonthlyWorkingHour }; using (var db = new KiaGalleryContext()) { List <Settings> settings = db.Settings.Where(x => keyList.Any(y => y == x.Key)).ToList(); settings.Single(x => x.Key == Settings.KeyContractYear).Value = model.contractYear; settings.Single(x => x.Key == Settings.KeyBaseSalary).Value = model.baseSalary; settings.Single(x => x.Key == Settings.KeyYearAddedRate).Value = model.yearAddedRate; settings.Single(x => x.Key == Settings.KeyBranchPersonelHourlyPayment).Value = model.branchPersonelHourlyPayment; settings.Single(x => x.Key == Settings.KeyBranchPersonelOverTime).Value = model.branchPersonelOverTime; settings.Single(x => x.Key == Settings.KeyBranchPersonelMission).Value = model.branchPersonelMission; settings.Single(x => x.Key == Settings.KeyBranchPersonelMonthlyWorkingHour).Value = model.branchPersonelMonthlyWorkingHour; settings.Single(x => x.Key == Settings.KeySuperVisorHourlyPayment).Value = model.superVisorHourlyPayment; settings.Single(x => x.Key == Settings.KeySuperVisorOverTime).Value = model.superVisorOverTime; settings.Single(x => x.Key == Settings.KeySuperVisorMission).Value = model.superVisorMission; settings.Single(x => x.Key == Settings.KeySuperVisorMonthlyWorkingHour).Value = model.superVisorMonthlyWorkingHour; settings.Single(x => x.Key == Settings.KeyOfficeHourlyPayment).Value = model.officeHourlyPayment; settings.Single(x => x.Key == Settings.KeyOfficeOverTime).Value = model.officeOverTime; settings.Single(x => x.Key == Settings.KeyOfficeMission).Value = model.officeMission; settings.Single(x => x.Key == Settings.KeyOfficeMonthlyWorkingHour).Value = model.officeMonthlyWorkingHour; Settings year = settings.SingleOrDefault(x => x.Key == Settings.KeyContractYear); if (year != null) { year.Value = model.contractYear; year.CreateUserId = GetAuthenticatedUserId(); year.ModifyUserId = GetAuthenticatedUserId(); year.CreateDate = DateTime.Now; year.ModifyDate = DateTime.Now; year.Ip = Request.UserHostAddress; } else { db.Settings.Add(new Model.Context.Settings() { Key = Model.Context.Settings.KeyContractYear, Value = model.contractYear, CreateUserId = GetAuthenticatedUserId(), ModifyUserId = GetAuthenticatedUserId(), CreateDate = DateTime.Now, ModifyDate = DateTime.Now, Ip = Request.UserHostAddress }); } db.SaveChanges(); } response = new Response() { status = 200, message = "اطلاعات با موفقیت ثبت شد." }; } catch (Exception ex) { response = Core.GetExceptionResponse(ex); } return(Json(response, JsonRequestBehavior.AllowGet)); }
public MainViewModel(ConnectionViewModel connectionViewModel, SettingsViewModel settingsViewModel) { SettingsViewModel = settingsViewModel; ConnectionViewModel = connectionViewModel; }
protected override void OnAppearing() { base.OnAppearing(); viewModel = new SettingsViewModel(); BindingContext = viewModel; }