Example #1
0
        public override async Task Initialize()
        {
            Analytics.TrackEvent(GetType().Name);
            LoggingService.Trace("Navigated to MapViewModel");

            MapTheme = _preferences.Get(UserSettingsKeys.MapTheme, nameof(MapThemeEnum.GoogleLight)) switch
            {
                nameof(MapThemeEnum.Enlightened) => MapThemeEnum.Enlightened,
                nameof(MapThemeEnum.IntelDefault) => MapThemeEnum.IntelDefault,
                nameof(MapThemeEnum.RedIntel) => MapThemeEnum.RedIntel,
                _ => MapThemeEnum.GoogleLight
            };

            MapType = _preferences.Get(UserSettingsKeys.MapType, nameof(MapType.Street)) switch
            {
                nameof(MapType.Street) => MapType.Street,
                nameof(MapType.Hybrid) => MapType.Hybrid,
                _ => MapType.Street
            };

            IsStylingAvailable = MapType == MapType.Street;

            await base.Initialize();

            IsLocationAvailable = await CheckAndAskForLocationPermissions();
        }
Example #2
0
        bool GnomeBuildLaunchers()
        {
            IPreferences prefs = DockServices.Preferences.Get("/desktop/gnome/applications");

            // browser
            string browser = prefs.Get <string> ("browser/exec", "");
            // terminal
            string terminal = prefs.Get <string> ("terminal/exec", "");
            // calendar
            string calendar = prefs.Get <string> ("calendar/exec", "");
            // media
            string media = prefs.Get <string> ("media/exec", "");

            if (string.IsNullOrEmpty(browser) && string.IsNullOrEmpty(terminal) &&
                string.IsNullOrEmpty(calendar) && string.IsNullOrEmpty(media))
            {
                return(false);
            }

            Launchers = new[] {
                DockServices.DesktopItems.DesktopItemsFromExec(browser).FirstOrDefault(),
                DockServices.DesktopItems.DesktopItemsFromExec(terminal).FirstOrDefault(),
                DockServices.DesktopItems.DesktopItemsFromExec(calendar).FirstOrDefault(),
                DockServices.DesktopItems.DesktopItemsFromExec(media).FirstOrDefault(),
            }.Where(s => s != null).Select(s => s.Path);

            return(true);
        }
Example #3
0
        private static void ValidatePreferences(IPreferences preferences)
        {
            // MessageLevel
            var level = preferences.Get <LoggerLevel>(Preference.MessageLevel);

            if (level < LoggerLevel.Info)
            {
                level = LoggerLevel.Info;
            }
            else if (level > LoggerLevel.Debug)
            {
                level = LoggerLevel.Debug;
            }
            preferences.Set(Preference.MessageLevel, level);

            const int defaultInterval     = 15;
            var       clientRetrievalTask = preferences.Get <Preferences.Data.ClientRetrievalTask>(Preference.ClientRetrievalTask);

            if (!Core.Client.ClientScheduledTasks.ValidateInterval(clientRetrievalTask.Interval))
            {
                clientRetrievalTask.Interval = defaultInterval;
                preferences.Set(Preference.ClientRetrievalTask, clientRetrievalTask);
            }
            var webGenerationTask = preferences.Get <Preferences.Data.WebGenerationTask>(Preference.WebGenerationTask);

            if (!Core.Client.ClientScheduledTasks.ValidateInterval(webGenerationTask.Interval))
            {
                webGenerationTask.Interval = defaultInterval;
                preferences.Set(Preference.WebGenerationTask, webGenerationTask);
            }
        }
Example #4
0
 static TimerMainDockItem()
 {
     defaultTimer   = (uint)prefs.Get <int> ("DefaultTimer", 60);
     autoStart      = prefs.Get <bool> ("AutoStartTimers", false);
     autoDismiss    = prefs.Get <bool> ("AutoDismissTimers", false);
     dismissOnClick = prefs.Get <bool> ("DismissOnClick", true);
 }
Example #5
0
        public override async void Prepare()
        {
            base.Prepare();

            var appEnvironnement = _preferences.Get(ApplicationSettingsConstants.AppEnvironnement, "unknown_env");
            var appVersion       = _versionTracking.CurrentVersion;

            DisplayVersion = appEnvironnement != "unknown_env" ? $"{appEnvironnement} - v{appVersion}" : $"v{appVersion}";
            LoggedUser     = _userSettingsService.GetIngressName();

            var selectedOpId = _preferences.Get(UserSettingsKeys.SelectedOp, string.Empty);

            if (!string.IsNullOrWhiteSpace(selectedOpId))
            {
                var op = await _operationsDatabase.GetOperationModel(selectedOpId);

                SelectedOpName = op == null ? "ERROR loading OP" : op.Name;
            }

            if (_preferences.Get(UserSettingsKeys.LiveLocationSharingEnabled, false))
            {
                _isLiveLocationSharingEnabled = true;
                _messenger.Publish(new LiveGeolocationTrackingMessage(this, Action.Start));
                await RaisePropertyChanged(() => IsLiveLocationSharingEnabled);
            }
        }
Example #6
0
 public DockyItem()
 {
     Indicator = ActivityIndicator.Single;
     HoverText = prefs.Get <string> ("HoverText", "Docky");
     Icon      = "docky";
     HueShift  = Hue;
 }
 public override void Load()
 {
     ApplicationPath  = Preferences.Get <string>(Preference.ApplicationPath);
     CssFile          = Preferences.Get <string>(Preference.CssFile);
     OverviewXsltPath = Preferences.Get <string>(Preference.WebOverview);
     SummaryXsltPath  = Preferences.Get <string>(Preference.WebSummary);
     SlotXsltPath     = Preferences.Get <string>(Preference.WebSlot);
 }
Example #8
0
        public HtmlBuilderResult Build(XmlBuilderResult xmlBuilderResult, string path)
        {
            var cssFileName = Preferences.Get <string>(Preference.CssFile);

            var cssFile          = CopyCssFile(path, cssFileName);
            var slotSummaryFiles = EnumerateSlotSummaryFiles(xmlBuilderResult.SlotSummaryFile, path, cssFileName).ToList();
            var slotDetailFiles  = EnumerateSlotDetailFiles(xmlBuilderResult.SlotDetailFiles, path, cssFileName).ToList();

            return(new HtmlBuilderResult(cssFile, slotSummaryFiles, slotDetailFiles));
        }
Example #9
0
        public void MigrateOldPreferences()
        {
            var soberDate     = _preferences.Get(PreferenceConstants.SoberDate, DateTime.Today);
            var notifsEnabled = _preferences.Get(PreferenceConstants.NotificationsEnabled, false);
            var notifTime     = _preferences.Get(PreferenceConstants.NotificationTime, DateTime.MinValue);

            Set(PreferenceConstants.SoberDate, soberDate);
            Set(PreferenceConstants.NotificationsEnabled, notifsEnabled);
            Set(PreferenceConstants.NotificationTime, notifTime);

            _preferences.Clear();
        }
        public override void Start()
        {
            base.Start();

            LoggingService.Trace("Starting SplashScreenViewModel");
            Analytics.TrackEvent(GetType().Name);

            AppEnvironnement = _preferences.Get(ApplicationSettingsConstants.AppEnvironnement, "unknown_env");
            var appVersion = _versionTracking.CurrentVersion;

            DisplayVersion = AppEnvironnement != "unknown_env" ? $"{AppEnvironnement} - v{appVersion}" : $"v{appVersion}";
        }
Example #11
0
        private void LoadPreferences()
        {
            string authToken = preferences.Get(PreferencesKeys.AuthTokenKey);

            if (authToken == null || authToken.Trim() == "")
            {
                Logger.Debug("Rtm: Not authorized");
                isAuthorized = false;
            }
            else
            {
                Logger.Debug("Rtm: Authorized");
                isAuthorized = true;
            }
        }
        public ControllerActionPageViewModel(
            INavigationService navigationService,
            ITranslationService translationService,
            ICreationManager creationManager,
            IDeviceManager deviceManager,
            IDialogService dialogService,
            IPreferences preferences,
            NavigationParameters parameters)
            : base(navigationService, translationService)
        {
            _creationManager = creationManager;
            _deviceManager   = deviceManager;
            _dialogService   = dialogService;
            _preferences     = preferences;

            ControllerAction = parameters.Get <ControllerAction>("controlleraction", null);
            ControllerEvent  = parameters.Get <ControllerEvent>("controllerevent", null) ?? ControllerAction?.ControllerEvent;

            var device = _deviceManager.GetDeviceById(ControllerAction?.DeviceId);

            if (ControllerAction != null && device != null)
            {
                SelectedDevice             = device;
                Action.Channel             = ControllerAction.Channel;
                Action.IsInvert            = ControllerAction.IsInvert;
                Action.ChannelOutputType   = ControllerAction.ChannelOutputType;
                Action.MaxServoAngle       = ControllerAction.MaxServoAngle;
                Action.ButtonType          = ControllerAction.ButtonType;
                Action.AxisType            = ControllerAction.AxisType;
                Action.AxisCharacteristic  = ControllerAction.AxisCharacteristic;
                Action.MaxOutputPercent    = ControllerAction.MaxOutputPercent;
                Action.AxisDeadZonePercent = ControllerAction.AxisDeadZonePercent;
                Action.ServoBaseAngle      = ControllerAction.ServoBaseAngle;
                Action.StepperAngle        = ControllerAction.StepperAngle;
                Action.SequenceName        = ControllerAction.SequenceName;
            }
            else
            {
                var lastSelectedDeviceId = _preferences.Get <string>("LastSelectedDeviceId", null, "com.scn.BrickController2.ControllerActionPage");
                SelectedDevice             = _deviceManager.GetDeviceById(lastSelectedDeviceId) ?? _deviceManager.Devices.FirstOrDefault();
                Action.Channel             = 0;
                Action.IsInvert            = false;
                Action.ChannelOutputType   = ChannelOutputType.NormalMotor;
                Action.MaxServoAngle       = 90;
                Action.ButtonType          = ControllerButtonType.Normal;
                Action.AxisType            = ControllerAxisType.Normal;
                Action.AxisCharacteristic  = ControllerAxisCharacteristic.Linear;
                Action.MaxOutputPercent    = 100;
                Action.AxisDeadZonePercent = 0;
                Action.ServoBaseAngle      = 0;
                Action.StepperAngle        = 90;
                Action.SequenceName        = string.Empty;
            }

            SaveControllerActionCommand   = new SafeCommand(async() => await SaveControllerActionAsync(), () => SelectedDevice != null);
            DeleteControllerActionCommand = new SafeCommand(async() => await DeleteControllerActionAsync());
            OpenDeviceDetailsCommand      = new SafeCommand(async() => await OpenDeviceDetailsAsync(), () => SelectedDevice != null);
            OpenChannelSetupCommand       = new SafeCommand(async() => await OpenChannelSetupAsync(), () => SelectedDevice != null);
            OpenSequenceEditorCommand     = new SafeCommand(async() => await OpenSequenceEditorAsync());
        }
Example #13
0
        public Helper(File file)
        {
            File    = file;
            IsUser  = file.Path.StartsWith(HelperService.UserDir.Path);
            enabled = prefs.Get <bool> (prefs.SanitizeKey(File.Basename), false);

            GLib.File DataFile;
            if (IsUser)
            {
                DataFile = HelperService.UserMetaDir;
            }
            else if (file.Path.StartsWith(HelperService.SysDir.Path))
            {
                DataFile = HelperService.SysMetaDir;
            }
            else
            {
                DataFile = HelperService.SysLocalMetaDir;
            }

            DataFile = DataFile.GetChild(File.Basename + ".info");

            if (DataFile.Exists)
            {
                Data = new HelperMetadata(DataFile);
            }

            if (Enabled)
            {
                Start();
            }
        }
Example #14
0
        public RecentFilesProvider(IPreferences prefs)
        {
            NumRecentDocs = prefs.Get <int> ("NumRecentDocs", 7);

            RefreshRecentDocs();
            Gtk.RecentManager.Default.Changed += delegate { RefreshRecentDocs(); };
        }
Example #15
0
        public ICollection <Protein> GetProteins(IProgress <ProgressInfo> progress)
        {
            var requestUri   = new Uri(_preferences.Get <string>(Preference.ProjectDownloadUrl));
            var webOperation = WebOperation.Create(requestUri);

            if (progress != null)
            {
                webOperation.ProgressChanged += (sender, e) =>
                {
                    int    progressPercentage = Convert.ToInt32(e.Length / (double)e.TotalLength * 100);
                    string message            = $"Downloading {e.Length} of {e.TotalLength} bytes...";
                    progress.Report(new ProgressInfo(progressPercentage, message));
                };
            }
            webOperation.WebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
            webOperation.WebRequest.Proxy       = WebProxyFactory.Create(_preferences);
            using (var stream = new MemoryStream())
            {
                webOperation.Download(stream);
                stream.Position = 0;

                var serializer = new ProjectSummaryJsonDeserializer();
                return(serializer.Deserialize(stream));
            }
        }
		public RecentFilesProvider (IPreferences prefs)
		{
			NumRecentDocs = prefs.Get<int> ("NumRecentDocs", 7);
			
			RefreshRecentDocs ();
			Gtk.RecentManager.Default.Changed += delegate { RefreshRecentDocs (); };
		}
Example #17
0
        static SystemServices()
        {
            prefs = Services.Preferences.Get <SystemServicesConfig> ();

            // load user services
            string services = prefs.Get(PrefsServicesKey, "");

            if (string.IsNullOrEmpty(services))
            {
                // load default list
                userServices = new List <string> (DefaultUserServices);
            }
            else
            {
                userServices = new List <string> (services.Split());
            }

            // find directory with scripts
            foreach (string dir in ServiceDirectories)
            {
                if (Directory.Exists(dir))
                {
                    servicesDirectory = dir;
                    break;
                }
            }

            if (string.IsNullOrEmpty(servicesDirectory))
            {
                Log.Error("err: Sevices.FindServicesDirectory - not found dir with scripts");
            }
        }
Example #18
0
        public RecentDocumentsItem() : base(new RecentFilesProvider(prefs), prefs)
        {
            AlwaysShowRecent = prefs.Get <bool> ("AlwaysShowRecent", false);

            Provider.ItemsChanged += HandleItemsChanged;
            CurrentItemChanged    += HandleCurrentItemChanged;
        }
Example #19
0
 public static async Task <string> GetStringDecrypted(this IPreferences self, string key, string defaultValue, string password)
 {
     if (await self.ContainsKey(key))
     {
         return((await self.Get <string>(key, null)).Decrypt(password));
     }
     return(defaultValue);
 }
Example #20
0
 private async Task OpenArticle(Article article)
 {
     await browser.OpenAsync(article.Url, new BrowserLaunchOptions
     {
         LaunchMode = preferences.Get(Constants.Preferences.OpenLinksInApp, true) ? BrowserLaunchMode.SystemPreferred : BrowserLaunchMode.External,
         TitleMode  = BrowserTitleMode.Show
     });
 }
Example #21
0
        public SettingsService(IPreferences preferences)
        {
            _preferences = preferences;

            _getDict =
                new Dictionary <Type, Func <string, object, object> >
            {
                { typeof(bool), (key, defaultValue) => _preferences.Get(key, (bool)defaultValue, PreferenceConstants.PreferenceSharedName) },
                { typeof(int), (key, defaultValue) => _preferences.Get(key, (int)defaultValue, PreferenceConstants.PreferenceSharedName) },
                { typeof(double), (key, defaultValue) => _preferences.Get(key, (double)defaultValue, PreferenceConstants.PreferenceSharedName) },
                { typeof(float), (key, defaultValue) => _preferences.Get(key, (float)defaultValue, PreferenceConstants.PreferenceSharedName) },
                { typeof(long), (key, defaultValue) => _preferences.Get(key, (long)defaultValue, PreferenceConstants.PreferenceSharedName) },
                { typeof(string), (key, defaultValue) => _preferences.Get(key, (string)defaultValue, PreferenceConstants.PreferenceSharedName) },
                { typeof(DateTime), (key, defaultValue) => _preferences.Get(key, (DateTime)defaultValue, PreferenceConstants.PreferenceSharedName) },
            };

            _setDict =
                new Dictionary <Type, Action <string, object> >
            {
                { typeof(bool), (key, value) => _preferences.Set(key, (bool)value, PreferenceConstants.PreferenceSharedName) },
                { typeof(int), (key, value) => _preferences.Set(key, (int)value, PreferenceConstants.PreferenceSharedName) },
                { typeof(double), (key, value) => _preferences.Set(key, (double)value, PreferenceConstants.PreferenceSharedName) },
                { typeof(float), (key, value) => _preferences.Set(key, (float)value, PreferenceConstants.PreferenceSharedName) },
                { typeof(long), (key, value) => _preferences.Set(key, (long)value, PreferenceConstants.PreferenceSharedName) },
                { typeof(string), (key, value) => _preferences.Set(key, (string)value, PreferenceConstants.PreferenceSharedName) },
                { typeof(DateTime), (key, value) => _preferences.Set(key, (DateTime)value, PreferenceConstants.PreferenceSharedName) },
            };
        }
Example #22
0
 protected override void OnStart()
 {
     if (preferences.Get(Constants.Preferences.Analytics, true))
     {
         AppCenter.Start($"android={Secrets.AppCenterDroid};"
                         + $"ios={Secrets.AppCenteriOS};",
                         typeof(Analytics), typeof(Crashes));
     }
 }
        public WorkUnitQueryDataContainer(ILogger logger, IPreferences preferences) : base(logger)
        {
            var path = preferences?.Get <string>(Preference.ApplicationDataFolderPath);

            if (!String.IsNullOrEmpty(path))
            {
                FilePath = System.IO.Path.Combine(path, DefaultFileName);
            }
        }
Example #24
0
        public void Calculate()
        {
            Protein value = _proteinService.Get(SelectedProject);

            if (value == null)
            {
                return;
            }

            Protein protein = value.Copy();

            if (PreferredDeadlineChecked)
            {
                protein.PreferredDays = PreferredDeadline;
            }
            if (FinalDeadlineChecked)
            {
                protein.MaximumDays = FinalDeadline;
            }
            if (KFactorChecked)
            {
                protein.KFactor = KFactor;
            }

            TimeSpan frameTime        = TimeSpan.FromMinutes(TpfMinutes).Add(TimeSpan.FromSeconds(TpfSeconds));
            TimeSpan totalTimeByFrame = TimeSpan.FromSeconds(frameTime.TotalSeconds * protein.Frames);
            TimeSpan totalTimeByUser  = totalTimeByFrame;

            if (TotalWuTimeEnabled)
            {
                totalTimeByUser = TimeSpan.FromMinutes(TotalWuTimeMinutes).Add(TimeSpan.FromSeconds(TotalWuTimeSeconds));
                // user time is less than total time by frame, not permitted
                if (totalTimeByUser < totalTimeByFrame)
                {
                    totalTimeByUser = totalTimeByFrame;
                }
            }

            var decimalPlaces            = _preferences.Get <int>(Preference.DecimalPlaces);
            var noBonus                  = protein.GetProteinProduction(frameTime, TimeSpan.Zero);
            var bonusByUserSpecifiedTime = protein.GetProteinProduction(frameTime, totalTimeByUser);
            var bonusByFrameTime         = protein.GetProteinProduction(frameTime, totalTimeByFrame);

            CoreName          = protein.Core;
            SlotType          = ConvertToSlotType.FromCoreName(protein.Core).ToString();
            NumberOfAtoms     = protein.NumberOfAtoms;
            CompletionTime    = Math.Round(TotalWuTimeEnabled ? totalTimeByUser.TotalDays : totalTimeByFrame.TotalDays, decimalPlaces);
            PreferredDeadline = protein.PreferredDays;
            FinalDeadline     = protein.MaximumDays;
            KFactor           = protein.KFactor;
            BonusMultiplier   = Math.Round(TotalWuTimeEnabled ? bonusByUserSpecifiedTime.Multiplier : bonusByFrameTime.Multiplier, decimalPlaces);
            BaseCredit        = noBonus.Credit;
            TotalCredit       = Math.Round(TotalWuTimeEnabled ? bonusByUserSpecifiedTime.Credit : bonusByFrameTime.Credit, decimalPlaces);
            BasePpd           = noBonus.PPD;
            TotalPpd          = Math.Round(TotalWuTimeEnabled ? bonusByUserSpecifiedTime.PPD : bonusByFrameTime.PPD, decimalPlaces);
        }
Example #25
0
 public override void Load()
 {
     IsSecure    = Preferences.Get <bool>(Preference.EmailReportingServerSecure);
     ToAddress   = Preferences.Get <string>(Preference.EmailReportingToAddress);
     FromAddress = Preferences.Get <string>(Preference.EmailReportingFromAddress);
     Server      = Preferences.Get <string>(Preference.EmailReportingServerAddress);
     Port        = Preferences.Get <int>(Preference.EmailReportingServerPort);
     Username    = Preferences.Get <string>(Preference.EmailReportingServerUsername);
     Password    = Preferences.Get <string>(Preference.EmailReportingServerPassword);
     Enabled     = Preferences.Get <bool>(Preference.EmailReportingEnabled);
     //ReportEuePause = Preferences.Get<bool>(Preference.ReportEuePause);
     //ReportHung = Preferences.Get<bool>(Preference.ReportHung);
 }
Example #26
0
        public MainPageViewModel(IDateProvider dateProvider, IPreferences preferences, IExceptionHandlingService service)
        {
            DateProvider               = dateProvider;
            _handlingService           = service;
            _preferences               = preferences;
            GetDataCommand             = new DelegateCommand(async() => await GetData());
            ChangeChartCommand         = new DelegateCommand(async() => await ChangeChart());
            ChangeForecastsTypeCommand = new DelegateCommand(async() => await ChangeForecastsType());
            RefreshDataCommand         = new DelegateCommand(async() => await RefreshData());

            CityName = _preferences.Get("CityName", "");
        }
Example #27
0
        private async Task RefreshOperationExecuted()
        {
            if (IsBusy)
            {
                return;
            }
            LoggingService.Trace("Executing OperationRootTabbedViewModel.RefreshOperationCommand");

            IsBusy = true;
            _userDialogs.ShowLoading();


            var selectedOpId = _preferences.Get(UserSettingsKeys.SelectedOp, string.Empty);

            if (string.IsNullOrWhiteSpace(selectedOpId))
            {
                return;
            }

            var hasUpdated = false;

            try
            {
                var localData = await _operationsDatabase.GetOperationModel(selectedOpId);

                var updatedData = await _wasabeeApiV1Service.Operations_GetOperation(selectedOpId);

                if (localData != null && updatedData != null && !localData.Modified.Equals(updatedData.Modified))
                {
                    await _operationsDatabase.SaveOperationModel(updatedData);

                    hasUpdated = true;
                }
            }
            catch (Exception e)
            {
                LoggingService.Error(e, "Error Executing OperationRootTabbedViewModel.RefreshOperationCommand");
            }
            finally
            {
                IsBusy = false;

                _userDialogs.HideLoading();
                _userDialogs.Toast(hasUpdated ? "Operation data updated" : "You already have latest OP version");

                if (hasUpdated)
                {
                    _messenger.Publish(new MessageFrom <OperationRootTabbedViewModel>(this));
                }

                _messenger.Publish(new RefreshAllAgentsLocationsMessage(this));
            }
        }
Example #28
0
		public void Initialize (IPreferences preferences)
		{
			if (preferences == null)
				throw new ArgumentNullException ("preferences");
			this.preferences = preferences;

			// *************************************
			// AUTHENTICATION to Remember The Milk
			// *************************************
			string authToken = preferences.Get (PreferencesKeys.AuthTokenKey);
			if (authToken != null) {
				Logger.Debug ("Found AuthToken, checking credentials...");
				try {
					Rtm = new RtmNet.Rtm (ApiKey, SharedSecret, authToken);
					rtmAuth = Rtm.AuthCheckToken (authToken);
					Timeline = Rtm.TimelineCreate ();
					Logger.Debug ("RTM Auth Token is valid!");
					Logger.Debug ("Setting configured status to true");
					IsConfigured = true;
				} catch (RtmNet.RtmApiException e) {
					preferences.Set (PreferencesKeys.AuthTokenKey, null);
					preferences.Set (PreferencesKeys.UserIdKey, null);
					preferences.Set (PreferencesKeys.UserNameKey, null);
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Exception authenticating, reverting "
					              + e.Message);
				} catch (RtmNet.ResponseXmlException e) {
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Cannot parse RTM response. " +
						"Maybe the service is down. " + e.Message);
				} catch (RtmNet.RtmWebException e) {
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Not connected to RTM, maybe proxy: #{0}",
					              e.Message);
				} catch (System.Net.WebException e) {
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Problem connecting to internet: #{0}",
					              e.Message);
				}
			}

			if (Rtm == null) {
				Rtm = new RtmNet.Rtm (ApiKey, SharedSecret);
				return;
			}

			FinishInitialization ();
		}
        public override Task Initialize()
        {
            Analytics.TrackEvent(GetType().Name);

            _devModeActivated = _preferences.Get(UserSettingsKeys.DevModeActivated, false);

            Version = _versionTracking.CurrentVersion;

            var analyticsSetting = _preferences.Get(UserSettingsKeys.AnalyticsEnabled, false);

            SetProperty(ref _isAnonymousAnalyticsEnabled, analyticsSetting);

            var showAgentsFromAnyTeamSetting = _preferences.Get(UserSettingsKeys.ShowAgentsFromAnyTeam, false);

            SetProperty(ref _showAgentsFromAnyTeam, showAgentsFromAnyTeamSetting);

            var showDebugToastsSetting = _preferences.Get(UserSettingsKeys.ShowDebugToasts, false);

            SetProperty(ref _showDebugToasts, showDebugToastsSetting);

            return(base.Initialize());
        }
Example #30
0
        public UserStatsDataModel(ISynchronizeInvoke synchronizeInvoke, IPreferences preferences, EocStatsScheduledTask scheduledTask)
        {
            _preferences   = preferences;
            _scheduledTask = scheduledTask;
            _mapper        = new MapperConfiguration(cfg => cfg.AddProfile <UserStatsDataModelProfile>()).CreateMapper();

            _preferences.PreferenceChanged += (s, e) =>
            {
                switch (e.Preference)
                {
                case Preference.EnableUserStats:
                    ControlsVisible = _preferences.Get <bool>(Preference.EnableUserStats);
                    if (ControlsVisible)
                    {
                        RefreshFromData();
                    }
                    break;

                case Preference.EocUserId:
                    Refresh();
                    break;
                }
            };

            _scheduledTask.Changed += (s, e) =>
            {
                switch (e.Action)
                {
                case ScheduledTaskChangedAction.Finished:
                    // scheduled task completes on thread pool, but RefreshFromData will trigger UI control updates
                    // provide the ISynchronizeInvoke instance for posting the updates back to the UI thread
                    RefreshFromData(synchronizeInvoke);
                    break;
                }
            };

            ControlsVisible = _preferences.Get <bool>(Preference.EnableUserStats);
            RefreshFromData();
        }
Example #31
0
        public EocStatsData GetStatsData()
        {
            string eocXmlDataUrl = String.Concat(UserXmlBaseUrl, _preferences.Get <int>(Preference.EocUserId));

            var xmlData = new XmlDocument();

            xmlData.Load(eocXmlDataUrl);
            xmlData.RemoveChild(xmlData.ChildNodes[0]);

            XmlNode eocNode = GetXmlNode(xmlData, "EOC_Folding_Stats");

            return(CreateStatsDataFromXmlNode(eocNode));
        }
        public async Task <bool> TryUpdateSchedule(IFileAccess fileAccess, string defaultDbFilename)
        {
            var result             = false;
            var lastNewsUpdateTime = _preferences.Get("lastScheduleUpdate", DateTime.MinValue);

            if ((DateTime.Now - lastNewsUpdateTime).TotalDays < SCHEDULE_UPDATE_DAYS)
            {
                return(false);
            }
            var filename = await _cloudService.GetLatestScheduleFilename();

            if (_preferences.Get("dbFilename", defaultDbFilename) != filename)
            {
                var path = await _firebaseStorage.DownloadFileToLocalStorage("/" + filename);

                await fileAccess.CopyToLocal(path, filename);

                _preferences.Set("dbFilename", filename);
                result = true;
            }
            _preferences.Set("lastScheduleUpdate", DateTime.Now);
            return(result);
        }
Example #33
0
		public ProxyDockItem (AbstractDockItemProvider provider, IPreferences prefs)
		{
			StripMnemonics = false;
			
			Provider = provider;
			Provider.ItemsChanged += HandleProviderItemsChanged;
			this.prefs = prefs;
			
			if (prefs == null) {
				currentPos = 0;
			} else {
				currentPos = prefs.Get<int> ("CurrentIndex", 0);
				
				if (CurrentPosition >= Provider.Items.Count ()) 
					CurrentPosition = 0;
			}
			
			ItemChanged ();
		}
        public RtmPreferencesWidget(RtmBackend backend, IPreferences preferences)
            : base()
        {
            if (backend == null)
                throw new ArgumentNullException ("backend");
            if (preferences == null)
                throw new ArgumentNullException ("preferences");
            this.backend = backend;
            this.preferences = preferences;

            LoadPreferences ();

            BorderWidth = 0;

            // We're using an event box so we can paint the background white
            EventBox imageEb = new EventBox ();
            imageEb.BorderWidth = 0;
            imageEb.ModifyBg(StateType.Normal, new Gdk.Color(255,255,255));
            imageEb.ModifyBase(StateType.Normal, new Gdk.Color(255,255,255));
            imageEb.Show ();

            VBox mainVBox = new VBox(false, 0);
            mainVBox.BorderWidth = 10;
            mainVBox.Show();
            Add(mainVBox);

            // Add the rtm logo
            image = new Gtk.Image (normalPixbuf);
            image.Show();
            //make the dialog box look pretty without hard coding total size and
            //therefore clipping displays with large fonts.
            Alignment spacer = new Alignment((float)0.5, 0, 0, 0);
            spacer.SetPadding(0, 0, 125, 125);
            spacer.Add(image);
            spacer.Show();
            imageEb.Add (spacer);
            mainVBox.PackStart(imageEb, true, true, 0);

            // Status message label
            statusLabel = new Label();
            statusLabel.Justify = Gtk.Justification.Center;
            statusLabel.Wrap = true;
            statusLabel.LineWrap = true;
            statusLabel.Show();
            statusLabel.UseMarkup = true;
            statusLabel.UseUnderline = false;

            authButton = new LinkButton (
            #if GETTEXT
            Catalog.GetString ("Click Here to Connect"));
            #elif ANDROID

            #endif
            authButton.Clicked += OnAuthButtonClicked;

            if ( isAuthorized ) {
                statusLabel.Text = "\n\n" +
            #if GETTEXT
                    Catalog.GetString ("You are currently connected");
            #elif ANDROID

            #endif
                string userName = preferences.Get (PreferencesKeys.UserNameKey);
                if (userName != null && userName.Trim () != string.Empty)
                    statusLabel.Text = "\n\n" +
            #if GETTEXT
                        Catalog.GetString ("You are currently connected as") +
            #elif ANDROID

            #endif
                        "\n" + userName.Trim();
            } else {
                statusLabel.Text = "\n\n" +
            #if GETTEXT
                    Catalog.GetString ("You are not connected");
            #elif ANDROID

            #endif
                authButton.Show();
            }
            mainVBox.PackStart(statusLabel, false, false, 0);
            mainVBox.PackStart(authButton, false, false, 0);

            Label blankLabel = new Label("\n");
            blankLabel.Show();
            mainVBox.PackStart(blankLabel, false, false, 0);
        }
Example #35
0
		public void Initialize ()
		{
			prefs = DockServices.Preferences.Get<ThemeService> ();
			
			DockTheme = prefs.Get ("Theme", DefaultTheme);
		}