コード例 #1
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.IsBusy))
     {
         if (ViewModel.IsBusy)
         {
             ViewModel.SetRefreshImage();
             userPhoto.ImageUrl = string.Empty;
             AnimateImage(userPhoto);
         }
         if (!ViewModel.IsBusy)
         {
             userPhoto.ImageUrl = ViewModel.Profile.ProfilePictureURL;
             userPhoto.ClearAnimation();
         }
     }
     //if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.ItemSelected))
     //{
     //    if (!ViewModel.ItemSelected)
     //    {
     //        adapter.SetUserPhotoUrl();
     //    }
     //}
 }
コード例 #2
0
        private void ResultBtn_Click(object sender, EventArgs e)
        {
            try
            {
                switch ((sender as Button)?.Name)
                {
                case "ResultYes":
                    PropertiesExtension.Set("ShowUpdatePromptOnStart", "Yes");
                    DoUpdate();
                    _mgr.Dispose();
                    UpdateDialog.IsOpen = false;
                    break;

                case "ResultNo":
                    UpdateDialog.IsOpen = false;
                    _mgr.Dispose();
                    break;

                case "ResultDontRemind":
                    PropertiesExtension.Set("ShowUpdatePromptOnStart", "Disabled");
                    Log.Information("Update check on start was disabled by the user.");
                    _mgr.Dispose();
                    UpdateDialog.IsOpen = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unexpected Error");
            }
        }
コード例 #3
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => (ViewModel as BaseChallengesViewModel).Challenge))
     {
         if ((ViewModel as BaseChallengesViewModel).Challenge != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLat != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLong != null && _map != null)
         {
             //ViewModel.RequiredLocation = true;
             GoogleMapHelper.UpdateMapZoom(_map, ViewModel.Challenge.LocationLat.Value, ViewModel.Challenge.LocationLong.Value, ViewModel.Challenge.RadiusMeters);
         }
         //else
         //    ViewModel.RequiredLocation = false;
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonAnimated))
     {
         if (ViewModel.SubmitButtonAnimated)
         {
             AnimateButton(button, Resource.Drawable.ic_loadingIndicator);
         }
         if (!ViewModel.SubmitButtonAnimated)
         {
             button.SetImageResource(Resource.Drawable.challenges_postering_btn);
             button.ClearAnimation();
         }
     }
 }
コード例 #4
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.NeedShowSendMenu))
     {
         if (ViewModel.NeedShowSendMenu)
         {
             inviteService.ShowMenu(imageButton);
             //inviteService.ShareLink("What kind of message?", ViewModel.GetInviteText);
             ViewModel.NeedShowSendMenu = false;
         }
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonAnimated))
     {
         if (ViewModel.SubmitButtonAnimated)
         {
             AnimateButton(imageButton, Resource.Drawable.ic_loadingIndicator);
         }
         if (!ViewModel.SubmitButtonAnimated)
         {
             imageButton.SetImageResource(Resource.Drawable.challenge_invite_btn);
             imageButton.ClearAnimation();
         }
     }
 }
コード例 #5
0
        public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnViewModelChanged(sender, e);
            if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonAnimated))
            {
                if (ViewModel.SubmitButtonAnimated)
                {
                    AnimateButton(button, Resource.Drawable.ic_loadingIndicator);
                }
                if (!ViewModel.SubmitButtonAnimated)
                {
                    button.SetImageResource(Resource.Drawable.challenge_docsubmit_btn);
                    button.ClearAnimation();
                }
            }

            if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.Challenge))
            {
                if (ViewModel.Challenge != null && !string.IsNullOrEmpty(ViewModel.Challenge.Status) && ViewModel.Challenge.Status == ChallengesConstants.ChallengeStatusPending || ViewModel.Challenge.Status == ChallengesConstants.ChallengeStatusComplete)
                {
                    ViewModel.SubmitButtonHidden = true;
                }
                else
                {
                    ViewModel.SubmitButtonHidden = false;
                }
            }
        }
コード例 #6
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => (ViewModel as BaseChallengesViewModel).Challenge))
     {
         if ((ViewModel as BaseChallengesViewModel).Challenge != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLat != null && (ViewModel as BaseChallengesViewModel).Challenge.LocationLong != null && _map != null)
         {
             GoogleMapHelper.UpdateMapZoom(_map, ViewModel.Challenge.LocationLat.Value, ViewModel.Challenge.LocationLong.Value, ViewModel.Challenge.RadiusMeters);
         }
     }
 }
コード例 #7
0
        private async void DoUpdate()
        {
            try
            {
                PropertiesExtension.Set("ShowUpdatePromptOnStart", "");

                Log.Information("Update accepted by the user.");

                try
                {
                    Log.Information("Downloading updates.");
                    await _mgr.DownloadReleases(_updates.ReleasesToApply);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Error downloading the release");
                    // Notify user of the error
                }

                try
                {
                    Log.Information("Applying updates.");
                    await _mgr.ApplyReleases(_updates);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Error while applying updates");
                    // Notify user of the error
                }

                try
                {
                    await _mgr.CreateUninstallerRegistryEntry();
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Error while trying to create uninstaller registry entry");
                    // Notify user of the error
                }


                var latestExe = Path.Combine(_mgr.RootAppDirectory, string.Concat("app-", _latestVersion.Version.Version.Major, ".", _latestVersion.Version.Version.Minor, ".", _latestVersion.Version.Version.Build), "GiroZilla.exe");
                Log.Information("Updates applied successfully.");

                Log.Information($"New exe path: {latestExe}");

                UpdateManager.RestartApp(latestExe);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unexpected Error");
            }
        }
コード例 #8
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.FBLoaderImage))
     {
         if (ViewModel.IsBusy)
         {
             AnimateImage(twitterNetworkLoader);
             var auth          = new FacebookAuthenticator(Configuration.FbClientId, Configuration.Scope, ViewModel);
             var authenticator = auth.GetAuthenticator();
             var intent        = authenticator.GetUI(this.Activity);
             this.StartActivity(intent);
             AnimateImage(fbNetworkLoader);
         }
         if (!ViewModel.IsBusy)
         {
             fbNetworkLoader.ClearAnimation();
         }
         ChangeSocialNetworkTextColor();
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.TwitterLoaderImage))
     {
         if (ViewModel.IsBusy)
         {
             var auth          = new TwitterAuthentificator(Configuration.ConsumerKeyTwitter, Configuration.ConsumerSecretTwitter, Configuration.Scope, ViewModel);
             var authenticator = auth.GetAuthenticator();
             var intent        = authenticator.GetUI(this.Activity);
             this.StartActivity(intent);
             AnimateImage(twitterNetworkLoader);
         }
         if (!ViewModel.IsBusy)
         {
             twitterNetworkLoader.ClearAnimation();
         }
         ChangeSocialNetworkTextColor();
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.InstaLoaderImage))
     {
         if (ViewModel.IsBusy)
         {
             var auth          = new InstagramAuthenticator(Configuration.ConsumerKeyInsta, string.Empty, Configuration.InstaScope, ViewModel);
             var authenticator = auth.GetAuthenticator();
             var intent        = authenticator.GetUI(this.Activity);
             this.StartActivity(intent);
             AnimateImage(instaNetworkLoader);
         }
         if (!ViewModel.IsBusy)
         {
             instaNetworkLoader.ClearAnimation();
         }
         ChangeSocialNetworkTextColor();
     }
 }
コード例 #9
0
        private string CompanyName()
        {
            var address = PropertiesExtension.Get <string>("AddressLine");

            var temp = address.Split('+')[0];

            if (string.IsNullOrWhiteSpace(temp))
            {
                temp = "No Company";
            }

            return(temp);
        }
コード例 #10
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonImage))
     {
         if (ViewModel.GetSubmitButtonImageNormalName() != ViewModel.SubmitButtonImage)
         {
             AnimateImage(submitButton);
         }
         if (ViewModel.GetSubmitButtonImageNormalName() == ViewModel.SubmitButtonImage)
         {
             submitButton.ClearAnimation();
         }
     }
 }
コード例 #11
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.PlaceholderHidden))
     {
         if (ViewModel.PlaceholderHidden)
         {
             gifImageView.StartAnimation();
         }
         if (!ViewModel.PlaceholderHidden)
         {
             gifImageView.StopAnimation();
         }
     }
 }
コード例 #12
0
        public async override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnViewModelChanged(sender, e);
            if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.NeedGetContacts))
            {
                if (ViewModel.NeedGetContacts)
                {
                    var contacts = await inviteService.GetContacts();

                    ViewModel.SetContactsCollectionFromPlatform(contacts);
                    //contactsAdapter.ItemsSource = ViewModel.Contacts;
                    ViewModel.NeedGetContacts = false;
                }
            }
        }
コード例 #13
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonAnimated))
     {
         if (ViewModel.SubmitButtonAnimated)
         {
             AnimateButton(submitButton, Resource.Drawable.ic_loadingIndicator);
         }
         if (!ViewModel.SubmitButtonAnimated)
         {
             submitButton.SetImageResource(Resource.Drawable.challenges_fb_btn);
             submitButton.ClearAnimation();
         }
     }
 }
コード例 #14
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.IsBusy))
     {
         if (ViewModel.IsBusy)
         {
             ViewModel.SetRefreshImage();
             AnimateImage(scoreImage);
         }
         if (!ViewModel.IsBusy)
         {
             scoreImage.ClearAnimation();
         }
     }
 }
コード例 #15
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SelectedArea))
     {
         if (ViewModel.SelectedArea != null && !string.IsNullOrEmpty(ViewModel.SelectedArea.areaPrimaryColor))
         {
             //areasDetailsIndicatorImage.SetColorFilter(Android.Graphics.Color.ParseColor(ViewModel.SelectedArea.areaPrimaryColor));
             if (!ViewModel.SelectedArea.IsSuggestedArea)
             {
                 areasDetailsIndicatorImage.SetColorFilter(Android.Graphics.Color.ParseColor("#22F3D1"));
             }
             if (ViewModel.SelectedArea.IsSuggestedArea)
             {
                 areasDetailsIndicatorImage.SetColorFilter(Android.Graphics.Color.ParseColor("#F2FA98"));
             }
         }
     }
 }
コード例 #16
0
        private async void CheckForUpdates(bool manualUpdate = false)
        {
            try
            {
                var result = PropertiesExtension.Get <string>("ShowUpdatePromptOnStart");

                switch (result)
                {
                case "Yes":
                {
                    DoCheck(manualUpdate);
                    break;
                }

                case "Disabled":
                {
                    switch (manualUpdate)
                    {
                    case true:
                    {
                        DoCheck(manualUpdate);
                        break;
                    }

                    default:
                    {
                        Log.Information("Update check is disabled.");
                        UpdateDialog.IsOpen = false;
                        break;
                    }
                    }
                    break;
                }
                }
                await Task.FromResult(true);
            }
            catch (Exception ex)
            {
                Log.Warning(ex, "Something went wrong while checking for updates");
                UpdateDialog.IsOpen = false;
            }
        }
コード例 #17
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.IsBusy))
     {
         if (ViewModel.IsBusy)
         {
             ViewModel.SetRefreshImage();
             AnimateImage(scoreImage);
         }
         if (!ViewModel.IsBusy)
         {
             scoreImage.ClearAnimation();
         }
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.DetailsViewHidden))
     {
         (Activity as MainActivity).ChangeShieldViewsVisibility(ViewModel.DetailsViewHidden);
     }
 }
コード例 #18
0
        private void OnApplicationStartup(object sender, StartupEventArgs e)
        {
            switch (string.IsNullOrWhiteSpace(PropertiesExtension.Get <string>("LogsPath")))
            {
            case true:
            {
                PropertiesExtension.Set("LogsPath", $@"{DefaultDirectories.AppData}\GiroZilla\Logs");
                break;
            }
            }

            //Log formats
            const string outputTemplate = "{Timestamp:HH:mm:ss zzz}{NewLine}{Level} | Thread: {ThreadId} | Source: {SourceContext} | Message: {Message}{NewLine}{Exception}{NewLine}";

            //const string summaryFormat = "{Timestamp:dd/MM/yyyy} [{Level}] {Message}";
            //const string descriptionFormat = "{Timestamp:HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";

            //var file = File.CreateText($@"{DefaultDirectories.CurrentUserDesktop}\Serilog.log");                                  // Create a new file for SeriLoggers 'SelfLog'
            //Serilog.Debugging.SelfLog.Enable(TextWriter.Synchronized(file));                                                      // Debug serilog and create a new log file for information.

            Log.Logger = new LoggerConfiguration()                                                                                  // Logging configuration for serilog.
                         .MinimumLevel.Debug()                                                                                      // Serilog implements the common concept of a 'minimum level' for log event processing.
                         .Enrich.WithThreadId()                                                                                     // Adds a ThreadID to the log events
                         .Enrich.FromLogContext()                                                                                   // Adds properties from "LogContext" to the event log.
                         .Enrich.WithProperty("Customer", CompanyName())

                         //.WriteTo.Console(                                                                                                 // Sink configured to the console.
                                                                                                         //   LogEventLevel.Information,                                                                                     // The minimum level for events passed through the sink.
                                                                                                         //   outputTemplate)                                                                                                // A message template describing the format used to write to the sink.

                         .WriteTo.File($@"{PropertiesExtension.Get<string>("LogsPath")}\GiroZilla_.log", // Sink configured for physical files.
                                       LogEventLevel.Information,                                        // The minimum level for events passed through the sink.
                                       outputTemplate,                                                   // A message template describing the format used to write to the sink.
                                       rollingInterval: RollingInterval.Day)                             // The interval which logging will roll over to a new file.

                         .WriteTo.MySQL(PropertiesExtension.Get <string>("LicenseConnString"),           // Sink configured for database entries.
                                        restrictedToMinimumLevel: LogEventLevel.Warning)                 // The minimum level for events passed through the sink.


                         .CreateLogger();                                                                                           // Create the logger using the configured minimum level, enrichers & sinks.
        }
コード例 #19
0
        /// <summary>Verifies if the logs folder exists.</summary>
        private static void VerifyLogsFolder()
        {
            try
            {
                var folderPath = PropertiesExtension.Get <string>("LogsPath");

                switch (Directory.Exists(folderPath))
                {
                case true:
                    return;

                case false:
                    Directory.CreateDirectory(folderPath);
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Warning(ex, "The path could not be made or found");
            }
        }
コード例 #20
0
 public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnViewModelChanged(sender, e);
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.IsBusy))
     {
         if (ViewModel.Challenge.IsFixedContent && !ViewModel.IsBusy)
         {
             photoGalleryService.UserImageWasAdded = true;
         }
     }
     if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.SubmitButtonAnimated))
     {
         if (ViewModel.SubmitButtonAnimated)
         {
             AnimateButton(button, Resource.Drawable.ic_loadingIndicator);
         }
         if (!ViewModel.SubmitButtonAnimated)
         {
             button.SetImageResource(Resource.Drawable.challenges_photo_btn);
             button.ClearAnimation();
         }
     }
 }
コード例 #21
0
        /// <summary>  Verifies the license to check if the license has expired or don't exist.</summary>
        private void CheckLicense()
        {
            try
            {
                Log.Information("Checking License");

                const string getList  = "SELECT * FROM licenses";
                var          licenses = AsyncMySqlHelper.ReturnStringList(getList, "LicenseConnString").Result.ToList();

#if DEBUG
                var localLicense = PropertiesExtension.Get <string>("License");
#else
                var localLicense = RegHelper.Readvalue(@"Software\", "GiroZilla", "License");
#endif

                switch (!string.IsNullOrWhiteSpace(localLicense))
                {
                case true:
                {
                    Log.Information("Local license found");

                    var count = 1;

                    foreach (var s in licenses)
                    {
                        switch (!IsLicenseVerified)
                        {
                        case true:
                        {
                            _isCorrect = Hashing.Confirm(s, localLicense);

                            switch (_isCorrect)
                            {
                            case true:
                            {
                                var searchLicenseId = $"SELECT `License_VALUE` FROM `licenses` WHERE `License_ID`='{count}'";

                                var license    = AsyncMySqlHelper.GetString(searchLicenseId, "LicenseConnString").Result;
                                var query      = $"SELECT * FROM `licenses` WHERE `License_VALUE`='{license}' AND `License_USED` > 0";
                                var canConnect = AsyncMySqlHelper.CheckDataFromDatabase(query, "LicenseConnString").Result;

                                switch (canConnect)
                                {
                                case true:
                                {
                                    _connectionStatus = 1;
                                    break;
                                }

                                case false:
                                {
                                    _connectionStatus = 0;
                                    break;
                                }
                                }

                                switch (_connectionStatus)
                                {
                                case 1:
                                {
                                    LicenseDialog.IsOpen = false;
                                    IsLicenseVerified    = true;
                                    Log.Information(@"GiroZilla v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion + " loaded");
                                    break;
                                }

                                case 0:
                                {
                                    LicenseDialog.IsOpen = true;
                                    IsLicenseVerified    = false;

                                    switch (!string.IsNullOrWhiteSpace(localLicense))
                                    {
                                    case true:
                                    {
                                        Log.Warning("This license is invalid and wil be reset");

                                        ErrorText.Text = "Din nuværende licens er ugyldig & vil blive nulstillet";

#if DEBUG
                                        PropertiesExtension.Set("License", "");
#else
                                        RegHelper.SetRegValue(@"Software\GiroZilla", "License", "", RegistryValueKind.String);
#endif
                                        break;
                                    }
                                    }

                                    break;
                                }

                                default:
                                {
                                    LicenseDialog.IsOpen = true;
                                    IsLicenseVerified    = false;

                                    switch (!string.IsNullOrWhiteSpace(localLicense))
                                    {
                                    case true:
                                    {
                                        Log.Warning("Something went wrong validating this license");

                                        ErrorText.Text = "Kunne ikke validere din licens prøv igen senere";
                                        break;
                                    }

                                    default:
                                    {
                                        Log.Warning("Something went wrong validating this license (String empty or null)");

                                        ErrorText.Text = "Kunne ikke validere din licens";
                                        break;
                                    }
                                    }
                                    break;
                                }
                                }
                                break;
                            }

                            case false:
                            {
                                count++;
                                break;
                            }
                            }
                            break;
                        }
                        }
                    }
                    break;
                }

                default:
                {
                    LicenseDialog.IsOpen = true;
                    IsLicenseVerified    = false;

                    Log.Warning("The license was not found");

                    ErrorText.Text = "Licensen blev ikke fundet";
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                _connectionStatus = 2;

                Log.Error(ex, "Unexpected Error");
            }
        }