示例#1
0
    public MainForm()
    {
        InitializeComponent();
        dataContext                         = new DBClassesDataContext();
        languageService                     = new LanguageService(dataContext);
        wordService                         = new WordService(dataContext);
        translationDBservice                = new TranslationDBService(dataContext);
        applicationSettingsService          = new ApplicationSettingsService(dataContext);
        titleToShortTitleMap                = new Dictionary <String, String>();
        selectLanguageComboBox.SelectedItem = "All";    //default
        insertLanguageComboBox.SelectedItem = "Polish"; //default

        isInternetAccess = checkInternetConnection();
        if (isInternetAccess)
        {
            System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\\Programming\\IPNew\\IPV\\IP\\Inzenyria_programowania-ce5078cd8d32.json");
            client          = Google.Cloud.Translation.V2.TranslationClient.Create();
            googleTranslate = new TranslationAPIService(client);
            foreach (Google.Cloud.Translation.V2.Language language in client.ListLanguages("en"))
            {
                if (languageService.checkIfLanguageExistsInDB(language.Name))
                {
                    insertLanguageComboBox.Items.Add(language.Name);
                    titleToShortTitleMap.Add(language.Name, language.Code);
                }
            }
        }
        else
        {
            MessageBox.Show("Looks like you don't have internet connection, you can't add words, you can only exercise them.");
        }
    }
示例#2
0
        public ApplicationSettingListModel(SDSComContext _db, IMemoryCache _cache)
        {
            db    = _db;
            cache = _cache;

            asService = new ApplicationSettingsService(db, cache);
        }
示例#3
0
        public async Task Scrobble()
        {
            InProgress = true;

            var appsettings = new ApplicationSettingsService();

            var apikey    = appsettings.Get <string>("apikey");
            var apisecret = appsettings.Get <string>("apisecret");
            var username  = appsettings.Get <string>("username");
            var pass      = appsettings.Get <string>("pass");

            var auth = new LastAuth(apikey, apisecret);
            await auth.GetSessionTokenAsync(username, pass);

            var trackApi = new Core.Api.TrackApi(auth);

            var scrobble = new Scrobble(Artist, Album, Track, DateTime.UtcNow)
            {
                AlbumArtist = AlbumArtist
            };

            var response = await trackApi.ScrobbleAsync(scrobble);

            Successful = response.Success;

            InProgress = false;
        }
示例#4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MainForm" /> class.
 /// </summary>
 /// <param name="applicationSettingsService">The application settings service.</param>
 /// <param name="userConfigService">The user configuration service.</param>
 /// <param name="converterService"></param>
 public MainForm(ApplicationSettingsService applicationSettingsService, UserConfigService userConfigService, ImageConverterService converterService)
 {
     _applicationSettingsService = applicationSettingsService;
     _userConfigService          = userConfigService;
     _converterService           = converterService;
     InitializeComponent();
 }
示例#5
0
 public FormWindows(ApplicationSettingsService applicationSettingsService)
 {
     _applicationSettingsService = applicationSettingsService;
     InitializeComponent();
     _formDisposables      = new List <IDisposable>();
     _imageWindowListItems = new Dictionary <Form, ImageWindowListItem>();
 }
示例#6
0
        static void Main(string[] args)
        {
            //initialize services
            IJsonSerializationService <ApplicationSettings> jsonSerializationService = new JsonSerializationService <ApplicationSettings>(); //serialization service
            IAudioService audioService = new AudioService();                                                                                 //audio service
            IApplicationSettingsService applicationSettingsService = new ApplicationSettingsService(jsonSerializationService, audioService); //application service

            //get current application settings
            ApplicationSettings applicationSettings = applicationSettingsService.GetApplicationSettings();

            //add
            applicationSettings.Settings.Add(new Setting()
            {
                Name = "eac3to", Value = @"c:\exe\eac3to.exe"
            });
            //save to disc
            applicationSettingsService.Save(applicationSettings);

            var errors = applicationSettingsService.Errors;

            //get settings
            applicationSettings = applicationSettingsService.GetApplicationSettings();

            errors = applicationSettingsService.Errors;

            System.Console.ReadLine();
        }
示例#7
0
 public FileBrowser(ApplicationSettingsService applicationSettingsService, ImageLoaderService imageLoaderService, Autofac.ILifetimeScope scope)
 {
     _applicationSettingsService = applicationSettingsService;
     _applicationSettingsService.LoadSettings();
     _imageLoaderService = imageLoaderService;
     _scope = scope;
     InitializeComponent();
 }
示例#8
0
 public FormBookmarks(BookmarkService bookmarkService, BookmarkManager bookmarkManager, ApplicationSettingsService applicationSettingsService)
 {
     _bookmarkService            = bookmarkService;
     _bookmarkManager            = bookmarkManager;
     _applicationSettingsService = applicationSettingsService;
     _overlayFormManager         = new OverlayFormManager();
     InitializeComponent();
 }
        public FormAddBookmark(BookmarkManager bookmarkManager, BookmarkService bookmarkService, ApplicationSettingsService applicationSettingsService)
        {
            InitializeComponent();

            _bookmarkManager            = bookmarkManager;
            _bookmarkService            = bookmarkService;
            _applicationSettingsService = applicationSettingsService;
        }
示例#10
0
 public void Init(ApplicationSettingsService settingsService)
 {
     _settingsService = settingsService;
     _settingsService.LoadSettings();
     model      = settingsService.Settings;
     _validator = ApplicationSettingsService.CreateModelValidator(model);
     BindControlValues();
 }
示例#11
0
        public void Save_InvalidatesCache()
        {
            var cache          = new Mock <ICache>();
            var classUnderTest = new ApplicationSettingsService(cache.Object);

            classUnderTest.SaveCredentials("url42", "teamId42", "username42", MattermostVersion.ApiVersionOne);

            cache.Verify(c => c.Invalidate());
        }
        public TrialHelper()
        {
            _settings = new ApplicationSettingsService();
#if TRIAL
            IsTrial = true;
#else
            IsTrial = new LicenseInformation().IsTrial();
#endif
        }
示例#13
0
        public TrialHelper()
        {
            _settings = new ApplicationSettingsService();
#if TRIAL
            IsTrial = true;
#else
            IsTrial = new LicenseInformation().IsTrial();
#endif
        }
示例#14
0
 public FormSettings(BookmarkService bookmarkService, ApplicationSettingsService applicationSettingsService, ImageCacheService imageCacheService)
 {
     applicationSettingsService.LoadSettings();
     _originalSettings           = applicationSettingsService.Settings;
     _bookmarkService            = bookmarkService;
     _applicationSettingsService = applicationSettingsService;
     _imageCacheService          = imageCacheService;
     _selectedCacheSize          = _imageCacheService.CacheSize;
     InitializeComponent();
 }
        private void Deliver(SendGridMessage message)
        {
            IApplicationSettingsService applicationSettings = new ApplicationSettingsService(_userName);
            var username     = applicationSettings.GetEmailServiceUsername();
            var password     = applicationSettings.GetEmailServiceKeyCode();
            var credentials  = new NetworkCredential(username, password);
            var transportWeb = new Web(credentials);

            transportWeb.DeliverAsync(message);
        }
示例#16
0
        public void Load_ReturnsSavedSettings()
        {
            var classUnderTest = new ApplicationSettingsService(Mock.Of <ICache>());
            var settings       = new AddInSettings("url42", "teamId42", "username42", "channelMap", MattermostVersion.ApiVersionOne);

            classUnderTest.SaveCredentials("url42", "teamId42", "username42", MattermostVersion.ApiVersionOne);
            classUnderTest.SaveChannels("channelMap");

            var loaded = classUnderTest.Load();

            loaded.Should().Be(settings);
        }
示例#17
0
        private static void Main()
        {
            InitializeAutofac();

            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);
            bool debugMode = ApplicationBuildConfig.DebugMode;

            GlobalSettings.Initialize(Assembly.GetExecutingAssembly().GetName().Name, !debugMode);

            Log.Verbose("Application started");

            using (var scope = Container.BeginLifetimeScope())
            {
                // Begin startup async jobs
                ApplicationSettingsService settingsService = scope.Resolve <ApplicationSettingsService>();
                var startupService = scope.Resolve <StartupService>();

                bool readSuccessful = settingsService.LoadSettings();

                if (!readSuccessful)
                {
                    string userDataPath = GlobalSettings.GetUserDataDirectoryPath();
                    Log.Error("Failed to load application settings on program load. User data path {userDataPath}", userDataPath);
                }


                startupService.ScheduleAndRunStartupJobs();
                Task.Delay(1000);
                try
                {
                    FormMain frmMain = scope.Resolve <FormMain>();
                    Application.Run(frmMain);
                }
                catch (Exception ex)
                {
                    Log.Fatal(ex, "Main program failureException: {Message}", ex.Message);
                }



                //settingsService.SaveSettings();
            }

            //Application.Run(new FormMain());
            Log.Information("Application ended");
        }
示例#18
0
 public FormThumbnailView(FormAddBookmark formAddBookmark, ApplicationSettingsService applicationSettingsService, ImageCacheService imageCacheService, ThumbnailService thumbnailService, ImageLoaderService imageLoaderService)
 {
     _formAddBookmark            = formAddBookmark;
     _applicationSettingsService = applicationSettingsService;
     _imageCacheService          = imageCacheService;
     _thumbnailService           = thumbnailService;
     _imageLoaderService         = imageLoaderService;
     _thumbnailSize = ValidateThumbnailSize(_applicationSettingsService.Settings.ThumbnailSize);
     _maxThumbnails = _applicationSettingsService.Settings.MaxThumbnails;
     _applicationSettingsService.OnSettingsSaved += _applicationSettingsService_OnSettingsSaved;
     _thumbnailService.LoadThumbnailDatabase();
     InitializeComponent();
 }
示例#19
0
        private void OnDoneClick(object sender, EventArgs e)
        {
            var service = new ApplicationSettingsService();

            service.Set("apikey", ApiKey.Text);
            service.Set("apisecret", ApiSecret.Text);
            service.Set("username", Username.Text);
            service.Set("pass", Password.Text);

            service.Save();

            NavigationService.Navigate(new Uri("/Pages/ApiTest.xaml", UriKind.Relative));
        }
示例#20
0
        public NameValueCollection DisplayPanels(string userId)
        {
            ApplicationSettingsService settings = new ApplicationSettingsService(userId);
            var dashboardSettingsForUser        = settings.GetDashboardSettingsForUser();

            NameValueCollection collection = new NameValueCollection();

            foreach (var item in dashboardSettingsForUser)
            {
                collection.Add(item.AppSetting.Key, item.Value);
            }
            return(collection);
        }
示例#21
0
        public async Task GetInfo()
        {
            InProgress = true;

            var appsettings = new ApplicationSettingsService();
            var apikey      = appsettings.Get <string>("apikey");
            var apisecret   = appsettings.Get <string>("apisecret");
            var username    = appsettings.Get <string>("username");
            var pass        = appsettings.Get <string>("pass");

            var auth = new LastAuth(apikey, apisecret);

            var response = await auth.GetSessionTokenAsync(username, pass);

            if (response.Success && auth.Authenticated)
            {
                ClearLists();

                var artistApi = new Core.Api.ArtistApi(auth);

                var topTracks = await artistApi.GetTopTracksForArtistAsync(ArtistName);

                if (topTracks.Success)
                {
                    TopTracks = topTracks;
                }

                var topAlbums = await artistApi.GetTopAlbumsForArtistAsync(ArtistName);

                if (topAlbums.Success)
                {
                    TopAlbums = topAlbums;
                }

                var similarArtists = await artistApi.GetSimilarArtistsAsync(ArtistName, false, 20);

                if (similarArtists.Success)
                {
                    SimilarArtists = similarArtists;
                }

                var artist = await artistApi.GetArtistInfoAsync(ArtistName);

                if (artist.Success)
                {
                    LastArtist = artist.Content;
                }
            }

            InProgress = false;
        }
示例#22
0
    public ExerciseForm(WordService wordService, DBClassesDataContext dataContext, TranslationDBService translationDBService, ApplicationSettingsService applicationSettingsService)
    {
        InitializeComponent();

        this.applicationSettingsService = applicationSettingsService;
        this.dataContext          = dataContext;
        this.wordService          = wordService;
        this.translationDBservice = translationDBService;
        timer          = new Timer();
        timer.Interval = 3000;
        timer.Tick    += new EventHandler(setClickeable);

        generateWords();
    }
示例#23
0
        public void Initialize()
        {
            _windowService              = A.Fake <IWindowService>();
            _dataTransferService        = A.Fake <IDataTransferService>();
            _clipboardService           = A.Fake <IClipboardService>();
            _httpService                = A.Fake <IHttpService>();
            _schedulerProvider          = A.Fake <ISchedulerProvider>();
            _textToSpeechService        = A.Fake <ITextToSpeechService>();
            _applicationSettingsService = new ApplicationSettingsService(new MockApplicationDataContainer());
            _uiSettingsService          = A.Fake <ISettingsService>();
            _shareDataRepository        = A.Fake <IShareDataRepository>();
            _navigationService          = A.Fake <INavigationService>();

            A.CallTo(() => _schedulerProvider.Default).Returns(_testScheduler);
        }
示例#24
0
        public static SendEmailTemplate GetSendEmailType(IRepository <Email> emailRepository, string userName)
        {
            IApplicationSettingsService applicationSettings = new ApplicationSettingsService(userName);

            switch (applicationSettings.GetEmailServiceOnlineType())
            {
            case EnumHelper.EmailServiceTypes.Offline:
                return(new SendEmailOffline(emailRepository));

            case EnumHelper.EmailServiceTypes.OnlineSendGrid:
                return(new SendEmailSendGrid(emailRepository, userName));

            default:
                return(new SendEmailOffline(emailRepository));
            }
        }
示例#25
0
        public FormImageView(int id, FormAddBookmark formAddBookmark, BookmarkManager bookmarkManager, ApplicationSettingsService applicationSettingsService, ImageCacheService imageCache, ImageLoaderService imageLoaderService)
        {
            InitializeComponent();
            _imageViewFormInfo          = new ImageViewFormImageInfo(this, null, 0);
            _observers                  = new List <IObserver <ImageViewFormInfoBase> >();
            pictureBox.Paint           += pictureBox_Paint;
            FormId                      = id;
            _formAddBookmark            = formAddBookmark;
            _bookmarkManager            = bookmarkManager;
            _applicationSettingsService = applicationSettingsService;
            _imageCache                 = imageCache;
            _imageLoaderService         = imageLoaderService;
            _lastFormState              = WindowState;

            ReloadSettings();
        }
示例#26
0
        private async Task Authenticate()
        {
            var appsettings = new ApplicationSettingsService();

            var apikey    = appsettings.Get <string>("apikey");
            var apisecret = appsettings.Get <string>("apisecret");
            var username  = appsettings.Get <string>("username");
            var pass      = appsettings.Get <string>("pass");

            var auth = new LastAuth(apikey, apisecret);

            InProgress = true;
            await auth.GetSessionTokenAsync(username, pass);

            InProgress = false;

            Auth = auth;
        }
示例#27
0
        public FormMain(FormAddBookmark formAddBookmark, BookmarkService bookmarkService, FormSettings formSettings, ApplicationSettingsService applicationSettingsService, ImageCacheService imageCacheService, ImageLoaderService imageLoaderService,
                        ILifetimeScope scope, UserInteractionService interactionService)
        {
            _formAddBookmark            = formAddBookmark;
            _bookmarkService            = bookmarkService;
            _formSettings               = formSettings;
            _applicationSettingsService = applicationSettingsService;
            _applicationSettingsService.LoadSettings();

            _imageCacheService  = imageCacheService;
            _imageLoaderService = imageLoaderService;
            _scope = scope;
            _interactionService = interactionService;

            InitializeComponent();
            _imageViewFormList = new List <FormImageView>();
            _windowTitle       = "Image Viewer - " + Application.ProductVersion;
        }
        public LoginPageViewModel(SteamClientService steamClientService,
                                  ApplicationSettingsService applicationSettingsService)
        {
            _steamClientService         = steamClientService;
            _applicationSettingsService = applicationSettingsService;

            _shouldRememberAccount = _applicationSettingsService.Settings.ShouldRememberAccount;
            if (_shouldRememberAccount)
            {
                _username = _applicationSettingsService.Settings.LastUsername;
                _password = _applicationSettingsService.Settings.LastPassword;
            }

            MessengerInstance.Register <ClearPageHistoryOnNextTryLoginMessage>(this,
                                                                               msg => { _clearPageHistoryOnNextTryLogin = true; });

            MessengerInstance.Register <LogoutOnNextTryLoginMessage>(this, msg => { _logoutOnNextTryLogin = true; });
        }
        public MainPageViewModel(IWindowService windowService,
                                 IDataTransferService dataTransferService,
                                 IClipboardService clipboardService,
                                 IHttpService httpService,
                                 ISchedulerProvider schedulerProvider,
                                 ITextToSpeechService textToSpeechService,
                                 ApplicationSettingsService settingsService,
                                 ISettingsService settingsUiService,
                                 INavigationService navigationService)
        {
            Text = DefineClipboardObservable(windowService.IsVisibleObservable, clipboardService).ToReactiveProperty();

            SelectAllTextTrigger = DefineSelectAllTextTriggerObservable(windowService.IsVisibleObservable, schedulerProvider.Default)
                                   .ToReadonlyReactiveProperty(mode: ReactivePropertyMode.None);

            var formattedStringObservable = DefineFormattedStringObservable(Text);

            var validLinkObservable = DefineValidUriObservable(formattedStringObservable);

            ShareCommand      = validLinkObservable.ToReactiveCommand();
            KeyPressedCommand = validLinkObservable.ToReactiveCommand <object>();

            var enterPressedObservable = DefineEnterPressedObservable(KeyPressedCommand);

            var shareTrigger = DefineShareTrigger(formattedStringObservable, ShareCommand, enterPressedObservable);

            var urlTitleResolveObservable = DefineUrlTitleResolveObservable(shareTrigger, httpService);

            IsInProgress = DefineInProgressObservable(shareTrigger, urlTitleResolveObservable)
                           .ToReadonlyReactiveProperty();

            ErrorMessage = DefineErrorMessageObservable(shareTrigger, urlTitleResolveObservable)
                           .ToReadonlyReactiveProperty();

            _textToSpeechSubscription = DefineTextToSpeachObservable(urlTitleResolveObservable, settingsService, textToSpeechService)
                                        .Subscribe();

            _shareLinkSubscription = urlTitleResolveObservable.ObserveOnUI()
                                     .Subscribe(shareData => ShareLink(dataTransferService, shareData.Title, shareData.Uri));

            SettingsCommand = new DelegateCommand(settingsUiService.ShowSettings);
            HistoryCommand  = new DelegateCommand(() => navigationService.Navigate("History", null));
        }
示例#30
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            MultiApplicationBar.SelectedIndex = 0;

            var service = new ApplicationSettingsService();

            if (string.IsNullOrEmpty(service.Get <string>("apikey")))
            {
                ApiKey.Text    = "a6ab4b9376e54cdb06912bfbd9c1f288";
                ApiSecret.Text = "3aa7202fd1bc6d5a7ac733246cbccc4b";
            }
            else
            {
                ApiKey.Text    = service.Get <string>("apikey");
                ApiSecret.Text = service.Get <string>("apisecret");
                Username.Text  = service.Get <string>("username");
                Password.Text  = service.Get <string>("pass");
            }
        }
示例#31
0
 public FormImageSizeModes(ApplicationSettingsService applicationSettingsService)
 {
     _applicationSettingsService = applicationSettingsService;
     InitializeComponent();
 }