Пример #1
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     Settings.Default.Save();
     Messages.Add("=== Applying modifications ===");
     status.Save(RunAndLogResult);
     init();
 }
Пример #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //PrivateIsOutBlockedNotif is also valid for public and domain
            status.PublicIsOutBlockedNotif = status.PrivateIsOutBlockedNotif;
            status.DomainIsOutBlockedNotif = status.PrivateIsOutBlockedNotif;
            if (status.PrivateIsOutBlockedNotif == false)
            {
                //if not blocked, allowed must be true
                if (status.PrivateIsOutBlocked == false)
                {
                    status.PrivateIsOutAllowed = true;
                }
                if (status.PublicIsOutBlocked == false)
                {
                    status.PublicIsOutAllowed = true;
                }
                if (status.DomainIsOutBlocked == false)
                {
                    status.DomainIsOutAllowed = true;
                }
            }
            status.Save();

            bool checkResult(Func <bool> boolFunction, string okMsg, string errorMsg)
            {
                try
                {
                    bool success = boolFunction.Invoke();
                    LastMessage = success ? okMsg : errorMsg;
                    LogHelper.Debug($"{boolFunction.Method.Name}: {LastMessage}");
                    return(success);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex.Message, ex);
                    LastMessage = $"{errorMsg}: {ex.Message}";
                    return(false);
                }
            }

            if (!isInstalled)
            {
                if (!InstallHelper.Install(checkResult))
                {
                    return;
                }
            }
            else if (isInstalled)
            {
                if (!InstallHelper.InstallCheck(checkResult))
                {
                    return;
                }
            }

            init();
        }