// Update is called once per frame
    void Update()
    {
        int TimesFreeCoins = PreferencesFactory.GetInt(Constants.KeyFreeCoinsCounter, 0);

        if (TimesFreeCoins >= Constants.TimesFreeCoins)
        {
            timeSinceLastCalled += Time.deltaTime;

            if (timeSinceLastCalled > 1f)
            {
                TimeSpan timeSpan = TimeForNextCoins();

                if (timeSpan.TotalSeconds > 0)
                {
                    freeCoinsCounterText.text = string.Format("{0:D2}:{1:D2}:{2:D2}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
                }
                else
                {
                    ResetCounter();
                }

                timeSinceLastCalled = 0f;
            }
        }
    }
Exemplo n.º 2
0
        static MainController()
        {
            StructureMapBootstrapper.Bootstrap();

            if (!(Debugger.IsAttached || Utils.IsRunningAsUWP))
            {
                // Add the event handler for handling UI thread exceptions to the event.
                System.Windows.Forms.Application.ThreadException += ExceptionHandler;

                // Set the unhandled exception mode to force all Windows Forms errors to go through
                // our handler.
                System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            }
            //make sure that a language change takes effect after a restart only
            StartupLanguage = PreferencesFactory.get().getProperty("application.language");
            ProtocolFactory.get().register(new FTPProtocol(), new FTPTLSProtocol(), new SFTPProtocol(), new DAVProtocol(),
                                           new DAVSSLProtocol(), new SwiftProtocol(), new S3Protocol(), new GoogleStorageProtocol(),
                                           new AzureProtocol(), new IRODSProtocol(), new SpectraProtocol(), new B2Protocol(), new DriveProtocol(),
                                           new DropboxProtocol(), new HubicProtocol(), new LocalProtocol(), new OneDriveProtocol(), new SharepointProtocol(), new SharepointSiteProtocol(),
                                           new MantaProtocol(), new SDSProtocol(), new StoregateProtocol(), new BrickProtocol(), new NextcloudProtocol());
            ProtocolFactory.get().loadDefaultProfiles();
        }
Exemplo n.º 3
0
        public static bool ApplicationShouldTerminateAfterDonationPrompt()
        {
            Logger.debug("ApplicationShouldTerminateAfterDonationPrompt");
            License l = LicenseFactory.find();

            if (!l.verify(new DisabledLicenseVerifierCallback()))
            {
                string appVersion  = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                String lastversion = PreferencesFactory.get().getProperty("donate.reminder");
                if (appVersion.Equals(lastversion))
                {
                    // Do not display if same version is installed
                    return(true);
                }

                DateTime nextReminder = new DateTime(PreferencesFactory.get().getLong("donate.reminder.date"));
                // Display prompt every n days
                nextReminder.AddDays(PreferencesFactory.get().getLong("donate.reminder.interval"));
                Logger.debug("Next reminder: " + nextReminder);
                // Display after upgrade
                if (nextReminder.CompareTo(DateTime.Now) == 1)
                {
                    // Do not display if shown in the reminder interval
                    return(true);
                }
                ObjectFactory.GetInstance <IDonationController>().Show();
            }
            return(true);
        }
        // Login Password
        public override void addPassword(Scheme scheme, int port, String hostName, String user, String password)
        {
            Host host = new Host(ProtocolFactory.get().forScheme(scheme), hostName, port);

            host.getCredentials().setUsername(user);
            PreferencesFactory.get().setProperty(new HostUrlProvider().get(host), DataProtector.Encrypt(password));
        }
Exemplo n.º 5
0
    void SaveLog()
    {
        if (stringBuilder.Length == 0)
        {
            return;
        }

        GSRequestData logData = new GSRequestData();

        logData.AddString("key", "InAppPurchase");
        logData.AddString("message", "User purchase in-app");

        GSData _d = new GSData(new Dictionary <string, object>()
        {
            { "purchase", stringBuilder },
        });

        logData.AddObject("data", _d);

        GameSparksManager.Instance.Log(logData);

        string purchaseLog = PreferencesFactory.GetString("PurchaseLog", "");

        purchaseLog = string.Format("{0}\n-----------\n{1}", purchaseLog, stringBuilder);

        PreferencesFactory.SetString("PurchaseLog", purchaseLog);

        stringBuilder.Length = 0;
    }
Exemplo n.º 6
0
 private void Shutdown(bool updating)
 {
     // Clear temporary files
     TemporaryFileServiceFactory.get().shutdown();
     try
     {
         RendezvousFactory.instance().quit();
     }
     catch (SystemException se)
     {
         Logger.warn("No Bonjour support available", se);
     }
     PreferencesFactory.get().setProperty("uses", PreferencesFactory.get().getInteger("uses") + 1);
     try
     {
         PreferencesFactory.get().save();
     }
     catch (UnauthorizedAccessException unauthorizedAccessException)
     {
         Logger.fatal("Could not save preferences", unauthorizedAccessException);
     }
     if (_updater != null && !updating)
     {
         _updater.unregister();
     }
 }
Exemplo n.º 7
0
 public static bool ApplicationShouldTerminate()
 {
     if (null != _instance)
     {
         //Saving state of transfer window
         PreferencesFactory.get().setProperty("queue.window.open.default", _instance.Visible);
         if (TransferCollection.defaultCollection().numberOfRunningTransfers() > 0)
         {
             TaskDialogResult result =
                 _instance.QuestionBox(LocaleFactory.localizedString("Transfer in progress"),
                                       LocaleFactory.localizedString("There are files currently being transferred. Quit anyway?"),
                                       null, String.Format("{0}", LocaleFactory.localizedString("Exit")), true);
             if (result.CommandButtonResult == 0)
             {
                 // Quit
                 for (int i = 0; i < _instance.getRegistry().size(); i++)
                 {
                     ((BackgroundAction)_instance.getRegistry().get(i)).cancel();
                 }
                 return(true);
             }
             // Cancel
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 8
0
    /// <summary>
    /// Called from singletong Awake() - Load saved prize times, or setup new if first run or not saving across restarts
    /// </summary>
    protected override void GameSetup()
    {
        base.GameSetup();

        if (SaveAcrossRestarts && PreferencesFactory.HasKey("FreePrize.NextCountdownStart"))
        {
            NextCountdownStart     = DateTime.Parse(PreferencesFactory.GetString("FreePrize.NextCountdownStart", UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture))); // start countdown immediately if new game
            NextFreePrizeAvailable = DateTime.Parse(PreferencesFactory.GetString("FreePrize.NextPrize", NextFreePrizeAvailable.ToString(CultureInfo.InvariantCulture)));
            SetCurrentPrizeAmount();
        }
        else
        {
            StartNewCountdown();
            SetCurrentPrizeAmount();
        }

        GameManager.SafeAddListener <UserNotificationsChangedMessage>(UserNotificationsChangedHandler);
        GameManager.SafeAddListener <LocalisationChangedMessage>(LocalisationHandler);

        //

#if !UNITY_EDITOR
        CancelLocalNotifications();
        RegisterLocalNotifications();
#endif
    }
Exemplo n.º 9
0
    private void ProcessDailyBonus(bool doublePrize = true)
    {
        _prizeIsProcessed = true;
        int DaysInRow  = PreferencesFactory.GetInt(Constants.KeyFreePrizeTakeDaysInRow, 0);
        int extraCoins = 0;

        if (DaysInRow == 7)                         // reset
        {
            extraCoins = Constants.DialyBonusCoins; // bonus coins at last day

            PreferencesFactory.SetInt(Constants.KeyFreePrizeTakeDaysInRow, 1);
        }

        PreferencesFactory.SetString(Constants.KeyDateLastFreePrizeTake, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture));

        if (PrizeDialogClosedAudioClip != null)
        {
            GameManager.Instance.PlayEffect(PrizeDialogClosedAudioClip);
        }

        if ((prizeIsCoins && this.PrizeItems > 0) || extraCoins > 0)
        {
            // add extra coins to reward coins only of prize is coins
            if (prizeIsCoins)
            {
                extraCoins += this.PrizeItems;
            }

            GameObject       animatedCoins = GameObject.Find("AddCoinsAnimated");
            GameObject       addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent);
            AddCoinsAnimated addCoins      = addCoinsClone.GetComponent <AddCoinsAnimated>();

            addCoins.AnimateCoinsAdding(extraCoins);
        }

        if (prizeIsPoints)
        {
            GameObject animatedPoints = GameObject.Find("AddPointsAnimated");

            GameObject        _clone = Instantiate(animatedPoints, animatedPoints.transform.parent);
            AddPointsAnimated _add   = _clone.GetComponent <AddPointsAnimated>();

            _add.AnimateAdding(this.PrizeItems);

            GameSparksManager.Instance.SendPoints(this.PrizeItems, "FreePrize");
        }

        SetCurrentPrizeAmount();

        // Local notifications
#if !UNITY_EDITOR
        CancelLocalNotifications();
        RegisterLocalNotifications();
#endif

        if (doublePrize)
        {
            ShowDoubleScreen();
        }
    }
Exemplo n.º 10
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 private MainController()
 {
     InitializeAppProperties();
     // Explicitly set SaveMySettingsOnExit to false, preventing UnauthorizedAccessException after Close
     // if no permission for writing to %AppData%
     SaveMySettingsOnExit = false;
     Startup             += ApplicationDidFinishLaunching;
     StartupNextInstance += StartupNextInstanceHandler;
     Shutdown            += delegate
     {
         // Clear temporary files
         TemporaryFileServiceFactory.get().shutdown();
         try
         {
             RendezvousFactory.instance().quit();
         }
         catch (SystemException se)
         {
             Logger.warn("No Bonjour support available", se);
         }
         PreferencesFactory.get().setProperty("uses", PreferencesFactory.get().getInteger("uses") + 1);
         try
         {
             PreferencesFactory.get().save();
         }
         catch (UnauthorizedAccessException unauthorizedAccessException)
         {
             Logger.fatal("Could not save preferences", unauthorizedAccessException);
         }
         if (_updater != null)
         {
             _updater.unregister();
         }
     };
 }
Exemplo n.º 11
0
 public void warn(Protocol protocol, String title, String message, String continueButton, String disconnectButton,
                  String preference)
 {
     AsyncController.AsyncDelegate d = delegate
     {
         _browser.CommandBox(title, title, message, String.Format("{0}|{1}", continueButton, disconnectButton),
                             false, LocaleFactory.localizedString("Don't show again", "Credentials"), TaskDialogIcon.Question,
                             PreferencesFactory.get().getProperty("website.help") + "/" + protocol.getScheme().name(),
                             delegate(int option, Boolean verificationChecked)
         {
             if (verificationChecked)
             {
                 // Never show again.
                 PreferencesFactory.get().setProperty(preference, true);
             }
             switch (option)
             {
             case 1:
                 throw new LoginCanceledException();
             }
         });
     };
     _browser.Invoke(d);
     //Proceed nevertheless.
 }
Exemplo n.º 12
0
 private void InitializeUpdater()
 {
     // register callbacks
     _canShutdownCallback     = CanShutdownCallback;
     _shutdownRequestCallback = ShutdownRequestCallback;
     WinSparklePeriodicUpdateChecker.SetCanShutdownCallback(_canShutdownCallback);
     WinSparklePeriodicUpdateChecker.SetShutdownRequestCallback(_shutdownRequestCallback);
     if (PreferencesFactory.get().getBoolean("update.check"))
     {
         _updater = PeriodicUpdateCheckerFactory.get();
         if (_updater.hasUpdatePrivileges())
         {
             DateTime lastCheck = new DateTime(PreferencesFactory.get().getLong("update.check.last"));
             TimeSpan span      = DateTime.Now.Subtract(lastCheck);
             _updater.register();
             if (span.TotalSeconds >= PreferencesFactory.get().getLong("update.check.interval"))
             {
                 _updater.check(true);
             }
         }
     }
     if (PreferencesFactory.get().getBoolean("profiles.discovery.updater.enable"))
     {
         // Synchronize and register timer
         _profiles.register();
     }
 }
Exemplo n.º 13
0
 public void ReadPasswordFromKeychain()
 {
     if (PreferencesFactory.get().getBoolean("connection.login.keychain"))
     {
         if (string.IsNullOrEmpty(View.Hostname))
         {
             return;
         }
         if (string.IsNullOrEmpty(View.Port))
         {
             return;
         }
         if (string.IsNullOrEmpty(View.Username))
         {
             return;
         }
         Protocol protocol = View.SelectedProtocol;
         string   password = PasswordStoreFactory.get().getPassword(protocol.getScheme(),
                                                                    Integer.parseInt(View.Port), View.Hostname,
                                                                    View.Username);
         if (Utils.IsNotBlank(password))
         {
             View.Password = password;
         }
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Calculates whether we need to run once or have already done so. In derived classes override RunOnce instead.
 /// </summary>
 public override void RunMethod()
 {
     if (PreferencesFactory.CheckAndSetFlag(Key, EnableAfterKey))
     {
         RunOnceMethod();
     }
 }
Exemplo n.º 15
0
        public void warn(Host bookmark, String title, String message, String continueButton, String disconnectButton,
                         String preference)
        {
            AsyncDelegate d = delegate
            {
                _browser.CommandBox(title, title, message, String.Format("{0}|{1}", continueButton, disconnectButton),
                                    false, Utils.IsNotBlank(preference) ? LocaleFactory.localizedString("Don't show again", "Credentials") : null, TaskDialogIcon.Question,
                                    ProviderHelpServiceFactory.get().help(bookmark.getProtocol().getScheme()),
                                    delegate(int option, Boolean verificationChecked)
                {
                    if (verificationChecked)
                    {
                        // Never show again.
                        PreferencesFactory.get().setProperty(preference, true);
                    }
                    switch (option)
                    {
                    case 1:
                        throw new LoginCanceledException();
                    }
                });
            };

            _browser.Invoke(d);
            //Proceed nevertheless.
        }
Exemplo n.º 16
0
        protected override bool isChangedKeyAccepted(string hostname, PublicKey key)
        {
            AsyncController.AsyncDelegate d = delegate
            {
                _parent.CommandBox(
                    String.Format(LocaleFactory.localizedString("Changed fingerprint", "Sftp"), hostname),
                    String.Format(LocaleFactory.localizedString("Changed fingerprint", "Sftp"), hostname),
                    String.Format(
                        LocaleFactory.localizedString("The fingerprint for the {1} key sent by the server is {0}.",
                                                      "Sftp"), new SSHFingerprintGenerator().fingerprint(key), KeyType.fromKey(key).name()),
                    String.Format("{0}|{1}", LocaleFactory.localizedString("Allow"),
                                  LocaleFactory.localizedString("Deny")), false, LocaleFactory.localizedString("Always"),
                    TaskDialogIcon.Warning,
                    PreferencesFactory.get().getProperty("website.help") + "/" + Scheme.sftp.name(),
                    delegate(int option, bool verificationChecked)
                {
                    switch (option)
                    {
                    case 0:
                        allow(hostname, key, verificationChecked);
                        break;

                    case 1:
                        Log.warn("Cannot continue without a valid host key");
                        throw new ConnectionCanceledException();
                    }
                });
            };
            _parent.Invoke(d, true);
            return(true);
        }
Exemplo n.º 17
0
        public object GetBookmarkImage(object host)
        {
            Host h = (Host)host;

            return(IconProvider.GetDisk(h.getProtocol(),
                                        PreferencesFactory.get().getInteger("bookmark.icon.size")));
        }
Exemplo n.º 18
0
    public static bool BonusCoins()
    {
        DateTime dateTime = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyAskFriendsLastDate, UnbiasedTime.Instance.Now().AddDays(-1).ToString(CultureInfo.InvariantCulture)));

        if (dateTime.Date < UnbiasedTime.Instance.Now().Date)
        { // last invite was yesterday, reset all data
            PreferencesFactory.SetString(Constants.KeyAskFriendsLastDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture));
            PreferencesFactory.SetInt(Constants.KeyAskFriendsTotal, 0);

            dateTime = UnbiasedTime.Instance.Now();
        }

        bool addedCoins = false;

        int totalInvites = PreferencesFactory.GetInt(Constants.KeyAskFriendsTotal);

        if (dateTime.Date == UnbiasedTime.Instance.Now().Date&& totalInvites < Constants.AskFriendsPerDay)
        {
            GameObject animatedCoins = GameObject.Find("AddCoinsAnimated");

            GameObject       addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent);
            AddCoinsAnimated addCoins      = addCoinsClone.GetComponent <AddCoinsAnimated>();

            addCoins.AnimateCoinsAdding(Constants.AskFriendsCoins, rect: GameObject.Find("BoardContainer").transform as RectTransform, showAnimation: false);

            addedCoins = true;
        }

        PreferencesFactory.SetInt(Constants.KeyAskFriendsTotal, totalInvites + 1);

        return(addedCoins);
    }
Exemplo n.º 19
0
        public AboutBox()
        {
            InitializeComponent();

            Text = String.Format("About {0}", AssemblyTitle);
            logoPictureBox.Image  = ApplicationIcon();
            labelProductName.Text = AssemblyProduct;
            labelVersion.Text     = String.Format("Version {0} ({1})",
                                                  PreferencesFactory.get().getProperty("application.version"),
                                                  PreferencesFactory.get().getProperty("application.revision"));
            labelCopyright.Text = Copyright();

            Font bigBoldFont = new Font(Font.FontFamily, Font.Size + 4, FontStyle.Bold);

            labelProductName.Font = bigBoldFont;

            labelRegistered.Text = RegisteredText();

            creditsRichTextBox.Rtf = Credits();
            creditsRichTextBox.SelectAll();
            creditsRichTextBox.SelectionFont = new Font(Font.FontFamily, 9);
            creditsRichTextBox.DeselectAll();
            creditsRichTextBox.LinkClicked += (sender, e) => BrowserLauncherFactory.get().open(e.LinkText);

            ackButton.Click +=
                delegate { ApplicationLauncherFactory.get().open(LocalFactory.get("Acknowledgments.rtf")); };
            PeriodicUpdateChecker updater = PeriodicUpdateCheckerFactory.get();

            updateButton.Enabled = updater.hasUpdatePrivileges();
            updateButton.Click  += delegate { updater.check(false); };
        }
    public void SyncProgress()
    {
        if (!IsUserLoggedIn())
        {
            return;
        }

        DateTime now = UnbiasedTime.Instance.Now();

        // when implement void SaveState(), add it here to save state before sync
        CustomFreePrizeManager.Instance.SaveState();
        LevelController.Instance.SaveState();

        PreferencesFactory.SetString("LastProgressSyncDate", now.ToString(CultureInfo.InvariantCulture), false);
        PreferencesFactory.Save();

        string json = JSONPrefs.String();

        GSRequestData parsedJson = new GSRequestData(json);

        new LogEventRequest()
        .SetEventKey("PlayerProgress")
        .SetEventAttribute("data", parsedJson)
        .Send(((response) => {
            if (!response.HasErrors)
            {
                PlayerPrefs.SetString("LastProgressSyncDate", now.ToString(CultureInfo.InvariantCulture));
                PlayerPrefs.Save();
            }
        }));
    }
Exemplo n.º 21
0
    public void ChangeUser(string userName)
    {
        if (string.IsNullOrEmpty(userName))
        {
            DialogManager.Instance.ShowError(LocaliseText.Get("Account.UsernameEmptyError"));
            return;
        }

        if (!IsUsernameValid(userName))
        {
            DialogManager.Instance.ShowError(LocaliseText.Get("Account.UsernameNotValid"));
            return;
        }

        new ChangeUserDetailsRequest()
        .SetDisplayName(userName)
        .Send((response) => {
            if (response.HasErrors)
            {
                ParseServerResponse(response.Errors);
                return;
            }

            PreferencesFactory.SetString(Constants.ProfileUsername, userName);
        });
    }
Exemplo n.º 22
0
        public void Show()
        {
            int uses = PreferencesFactory.get().getInteger("uses");

            var notify = (ToolstripNotificationService)NotificationServiceFactory.get();

            var result = TaskDialog.Show(
                owner: IntPtr.Zero,
                allowDialogCancellation: true,
                title: Localize("Please Donate") + " (" + uses + ")",
                verificationText: Localize("Don't show again for this version"),
                mainInstruction: Localize("Thank you for using Cyberduck!"),
                content: $@"{Localize("This is free software, but it still costs money to write, support, and distribute it. If you enjoy using it, please consider a donation to the authors of this software. It will help to make Cyberduck even better!")} {Localize("As a contributor to Cyberduck, you receive a registration key that disables this prompt.")}",
                commandLinks: new[] { Localize("Donate"), Localize("Later"), Localize("Buy in Windows Store") },
                verificationByDefault: Assembly.GetExecutingAssembly().GetName().Version.ToString().Equals(PreferencesFactory.get().getProperty("donate.reminder")));

            if (result.VerificationChecked == true)
            {
                PreferencesFactory.get().setProperty("donate.reminder", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            }

            if (result.CommandButtonResult == 0)
            {
                BrowserLauncherFactory.get().open(PreferencesFactory.get().getProperty("website.donate"));
            }
            if (result.CommandButtonResult == 2)
            {
                BrowserLauncherFactory.get().open(PreferencesFactory.get().getProperty("website.store"));
            }

            PreferencesFactory.get().setProperty("donate.reminder.date", DateTime.Now.Ticks);
        }
Exemplo n.º 23
0
        static void SetLanguageToDefault(bool keepIfAlreadySet = false)
        {
            if (keepIfAlreadySet && !string.IsNullOrEmpty(Language))
            {
                return;
            }

            // 1. try and set from prefs
            var prefsLanguage = PreferencesFactory.GetString("Language", useSecurePrefs: false);

            if (TrySetAllowedLanguage(prefsLanguage))
            {
                return;
            }

            //// 2. if not then try and set system Language.
            if (TrySetAllowedLanguage(Application.systemLanguage.ToString()))
            {
                return;
            }

            // 3. use the first language from any user localisation file
            //Language = _defaultUserLanguage;
            if (SupportedLanguages.Length > 0 && TrySetAllowedLanguage(SupportedLanguages[0]))
            {
                return;
            }

            //// 2. if not set then fall back to first Language from first (default) file
            if (LocalisationData != null && LocalisationData.Languages.Count > 0 && TrySetAllowedLanguage(LocalisationData.Languages[0].Name))
            {
                return;
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Set the saved properties to perferences within the context of the specified GameItem.
        /// </summary>
        /// Save / SaveBest mode of 'Always' will cause XxAmount(Best) be copied to the corresponding saved
        /// variables before saving to prefs, other modes of updating the should be triggered coopied.
        public void UpdatePlayerPrefs()
        {
            if (Configuration.CounterType == CounterConfiguration.CounterTypeEnum.Int)
            {
                if (Configuration.Save != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetInt(_prefsKey, IntAmountSaved);       // CI = CounterInt)
                }
                if (Configuration.SaveBest != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetInt(_prefsKeyBest, IntAmountBestSaved);  // CIH = CounterIntHighest)
                }
            }
            else
            {
                if (Configuration.Save != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetFloat(_prefsKey, FloatAmountSaved);
                }

                if (Configuration.SaveBest != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetFloat(_prefsKeyBest, FloatAmountBestSaved);
                }
            }
        }
Exemplo n.º 25
0
        private void View_ChangedAnonymousCheckboxEvent()
        {
            if (View.AnonymousChecked)
            {
                View.UsernameEnabled = false;
                View.Username        = PreferencesFactory.get().getProperty("connection.login.anon.name");
            }
            else
            {
                View.UsernameEnabled = true;
                if (
                    PreferencesFactory.get()
                    .getProperty("connection.login.name")
                    .Equals(PreferencesFactory.get().getProperty("connection.login.anon.name")))
                {
                    View.Username = String.Empty;
                }
                else
                {
                    View.Username = PreferencesFactory.get().getProperty("connection.login.name");
                }
            }

            ItemChanged();
            Update();
        }
    public static void RewardRate()
    {
        DateTime dateTime = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyRateRewardLastDate, UnbiasedTime.Instance.Now().AddDays(-1).ToString(CultureInfo.InvariantCulture)));

        if (dateTime.Date < UnbiasedTime.Instance.Now().Date)
        { // last rate was yesterday, reset all data
            PreferencesFactory.SetString(Constants.KeyRateRewardLastDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture));
            PreferencesFactory.SetInt(Constants.KeyRateRewardTotal, 0);

            dateTime = UnbiasedTime.Instance.Now();
        }

        int totalRates = PreferencesFactory.GetInt(Constants.KeyRateRewardTotal);

        if (dateTime.Date == UnbiasedTime.Instance.Now().Date&& totalRates < 1)
        {
            GameObject animatedCoins = GameObject.Find("AddCoinsAnimated");

            GameObject       addCoinsClone = Instantiate(animatedCoins, animatedCoins.transform.parent);
            AddCoinsAnimated addCoins      = addCoinsClone.GetComponent <AddCoinsAnimated>();

            RectTransform tr = null;
            GameObject    _c = GameObject.Find("BoardContainer");

            if (_c != null)
            {
                tr = _c.transform as RectTransform;
            }

            addCoins.AnimateCoinsAdding(Constants.RateRewardCoins, rect: tr, showAnimation: false);
        }

        PreferencesFactory.SetInt(Constants.KeyRateRewardTotal, totalRates + 1);
        PreferencesFactory.SetInt(Constants.KeyRateMaxRewardsTime, PreferencesFactory.GetInt(Constants.KeyRateMaxRewardsTime, 0) + 1);
    }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>Return true to allow the application to terminate</returns>
        public static bool ApplicationShouldTerminate()
        {
            Logger.debug("ApplicationShouldTerminate");

            // Determine if there are any running transfers
            bool terminate = TransferController.ApplicationShouldTerminate();

            if (!terminate)
            {
                return(false);
            }

            // Determine if there are any open connections
            foreach (BrowserController controller in new List <BrowserController>(Browsers))
            {
                if (PreferencesFactory.get().getBoolean("browser.serialize"))
                {
                    if (controller.IsMounted())
                    {
                        // The workspace should be saved. Serialize all open browser sessions
                        Host serialized =
                            new HostDictionary().deserialize(
                                controller.Session.getHost().serialize(SerializerFactory.get()));
                        serialized.setWorkdir(controller.Workdir);
                        Application._sessions.add(serialized);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 28
0
        void ICyberduck.RegisterRegistration(string registrationPath)
        {
            Local   f       = LocalFactory.get(registrationPath);
            License license = LicenseFactory.get(f);

            if (license.verify(new DisabledLicenseVerifierCallback()))
            {
                f.copy(LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                        f.getName()));
                _bc.InfoBox(license.ToString(),
                            LocaleFactory.localizedString(
                                "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                "License"),
                            LocaleFactory.localizedString(
                                "Your registration key has been copied to the Application Support folder.",
                                "License"),
                            String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), null, false);
                foreach (BrowserController controller in new List <BrowserController>(Browsers))
                {
                    controller.RemoveDonateButton();
                }
            }
            else
            {
                _bc.WarningBox(LocaleFactory.localizedString("Not a valid registration key", "License"),
                               LocaleFactory.localizedString("Not a valid registration key", "License"),
                               LocaleFactory.localizedString("This registration key does not appear to be valid.",
                                                             "License"), null,
                               String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), false,
                               ProviderHelpServiceFactory.get().help(), delegate { });
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Mounts the default bookmark if any
        /// </summary>
        /// <param name="controller"></param>
        public static void OpenDefaultBookmark(BrowserController controller)
        {
            String defaultBookmark = PreferencesFactory.get().getProperty("browser.open.bookmark.default");

            if (null == defaultBookmark)
            {
                return; //No default bookmark given
            }
            Host bookmark = BookmarkCollection.defaultCollection().lookup(defaultBookmark);

            if (null == bookmark)
            {
                Logger.info("Default bookmark no more available");
                return;
            }
            foreach (BrowserController browser in Browsers)
            {
                if (browser.IsMounted())
                {
                    if (bookmark.equals(browser.Session.getHost()))
                    {
                        Logger.debug("Default bookmark already mounted");
                        return;
                    }
                }
            }
            Logger.debug("Mounting default bookmark " + bookmark);
            controller.Mount(bookmark);
        }
    void ResetCounter()
    {
        PreferencesFactory.SetInt(Constants.KeyFreeCoinsCounter, 0);

        GameObjectHelper.SafeSetActive(FreeCoinsObject, true);
        GameObjectHelper.SafeSetActive(FreeCoinsCounterObject, false);
    }