Esempio n. 1
0
        private void ResetModels()
        {
            settings = SettingsMethods.ReadConfig();

            RolePositionPair = settings.RolePositionsDictionary;
            for (int i = 0; i < blockACheckedListBox.Items.Count; i++)
            {
                blockACheckedListBox.SetItemChecked(i, false);
            }

            RolePermissionPair   = new Dictionary <Guid, List <Guid> >();
            dbRolePermissionPair = new Dictionary <Guid, List <Guid> >();
            using (PermissionData data = new PermissionData(settings.ConnectionString))
            {
                foreach (RoleModel role in Roles)
                {
                    List <PermissionModel> rolePermissionRetrieved = data.GetPermissionListByRoleGuid(role.ID);
                    foreach (PermissionModel perm in rolePermissionRetrieved)
                    {
                        dbRolePermissionPair.AddWithKey(role.ID, perm.ID);
                    }
                }
            }

            foreach (KeyValuePair <Guid, List <Guid> > item in dbRolePermissionPair)
            {
                foreach (Guid value in item.Value)
                {
                    RolePermissionPair.AddWithKey(item.Key, value);
                }
            }

            blockAListBox.SelectedIndex        = -1;
            blockACheckedListBox.SelectedIndex = -1;
        }
Esempio n. 2
0
        private void SaveANDexitButtonClick(object sender, EventArgs e)
        {
            SettingsModel newSettings = (SettingsModel)settings.Clone();

            newSettings.HideBorderMenu      = ConvertStringVariantsToBoolean(showBorderMenu.SelectedItem.ToString(), Yes, No);
            newSettings.ShowAdditionalInfo  = ConvertStringVariantsToBoolean(showAdditionalInfo.SelectedItem.ToString(), Yes, No);
            newSettings.ShowOnlyOwnRequests = ConvertStringVariantsToBoolean(showOnlyOwnRequests.SelectedItem.ToString(), Yes, No);
            newSettings.RestoreBorderMenu   = ConvertStringVariantsToBoolean(restoreBorderMenu.SelectedItem.ToString(), Yes, No);

            newSettings.CloseViewButtonPosition = ConvertStringToIntEnum(
                closeViewButtonPosition.SelectedItem.ToString(),
                (int)DockStyle.Left,
                (int)DockStyle.Right,
                typeof(DockStyle));

            newSettings.FullScreenAtStart = ConvertStringToIntEnum(
                fullScreenAtStart.SelectedItem.ToString(),
                (int)FormWindowState.Normal,
                (int)FormWindowState.Maximized,
                typeof(FormWindowState));

            newSettings.FileFolderPath = fileFolderPath.Text;

            SettingsMethods.SetConfig(newSettings);
            parentForm.UpdateSettings();
            closeView.PerformClick();
        }
        /// <summary>
        /// Gets a list with the index of PI in segment
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private List <int> GetPersonalData(string text)
        {
            var personalDataIndex = new List <int>();

            foreach (var rule in SettingsMethods.GetRules())
            {
                var regex   = new Regex(rule.Name, RegexOptions.IgnoreCase);
                var matches = regex.Matches(text);

                foreach (System.Text.RegularExpressions.Match match in matches)
                {
                    if (match.Index.Equals(0))
                    {
                        personalDataIndex.Add(match.Length);
                    }
                    else
                    {
                        //check if there is any text after PI
                        var remainingText = text.Substring(match.Index + match.Length);
                        if (!string.IsNullOrEmpty(remainingText))
                        {
                            //get the position where PI starts to split before
                            personalDataIndex.Add(match.Index);
                            //split after PI
                            personalDataIndex.Add(match.Index + match.Length);
                        }
                        else
                        {
                            personalDataIndex.Add(match.Index);
                        }
                    }
                }
            }
            return(personalDataIndex);
        }
 private void AcceptWindow_Closing(object sender, CancelEventArgs e)
 {
     if (SettingsMethods.UserAgreed())
     {
         LoadTmView();
     }
 }
Esempio n. 5
0
        //todo:доработать сохранение настроек
        private void SaveANDexitButtonClick(object sender, EventArgs e)
        {
            CompareRolePermissionsAndUpdateDatabase(dbRolePermissionPair, RolePermissionPair);
            SettingsModel model = (SettingsModel)settings.Clone();

            model.RolePositionsDictionary = RolePositionPair;
            SettingsMethods.SetConfig(model);
            closeView.PerformClick();
        }
        private void Ok(object window)
        {
            var settings = SettingsMethods.GetSettings();

            settings.Accepted = Accepted;
            File.WriteAllText(Constants.SettingsFilePath, JsonConvert.SerializeObject(settings));
            var accept = (AcceptWindow)window;

            accept.Close();
        }
        private void InitializeWpfApplicationSettings()
        {
            if (System.Windows.Application.Current == null)
            {
                new System.Windows.Application();
            }
            if (System.Windows.Application.Current != null)
            {
                System.Windows.Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                var controlsResources = new ResourceDictionary
                {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml", UriKind.Absolute)
                };
                var colorsResources = new ResourceDictionary
                {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml", UriKind.Absolute)
                };
                var fontsResources = new ResourceDictionary
                {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml", UriKind.Absolute)
                };
                var greenResources = new ResourceDictionary
                {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Green.xaml", UriKind.Absolute)
                };
                var baseLightResources = new ResourceDictionary
                {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml", UriKind.Absolute)
                };
                var flatButtonsResources = new ResourceDictionary
                {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml", UriKind.Absolute)
                };

                //System.Windows.Application.Current.Resources.MergedDictionaries.Add(fontsResources);
                System.Windows.Application.Current.Resources.MergedDictionaries.Add(colorsResources);
                System.Windows.Application.Current.Resources.MergedDictionaries.Add(greenResources);
                System.Windows.Application.Current.Resources.MergedDictionaries.Add(baseLightResources);
                System.Windows.Application.Current.Resources.MergedDictionaries.Add(flatButtonsResources);
                System.Windows.Application.Current.Resources.MergedDictionaries.Add(controlsResources);
            }

            //create settings folder
            if (!Directory.Exists(Constants.SettingsFolderPath))
            {
                Directory.CreateDirectory(Constants.SettingsFolderPath);
            }

            var settings = SettingsMethods.GetSettings();

            if (!settings.AlreadyAddedDefaultRules)
            {
                AddDefaultRules(settings);
            }
        }
 private bool ContainsPi(string text)
 {
     foreach (var rule in SettingsMethods.GetRules())
     {
         var regex = new Regex(rule.Name, RegexOptions.IgnoreCase);
         var match = regex.Match(text);
         if (match.Success)
         {
             return(true);
         }
     }
     return(false);
 }
        public TmAnonymizerUserControl()
        {
            InitializeComponent();
            InitializeWpfApplicationSettings();

            if (!SettingsMethods.UserAgreed())
            {
                var acceptWindow = new AcceptWindow();
                acceptWindow.InitializeComponent();
                acceptWindow.Show();
                acceptWindow.Closing += AcceptWindow_Closing;
            }
            else
            {
                LoadTmView();
            }
        }
 public TranslationViewModel(TranslationMemoryViewModel translationMemoryViewModel)
 {
     _selectedItems = new List <Rule>();
     _translationMemoryViewModel   = translationMemoryViewModel;
     _anonymizeTranslationMemories = new ObservableCollection <AnonymizeTranslationMemory>();
     _rules = SettingsMethods.GetRules();
     foreach (var rule in _rules)
     {
         rule.PropertyChanged += Rule_PropertyChanged;
     }
     _sourceSearchResults                  = new ObservableCollection <SourceSearchResult>();
     _backgroundWorker                     = new BackgroundWorker();
     _backgroundWorker.DoWork             += _backgroundWorker_DoWork;
     _backgroundWorker.RunWorkerCompleted += _backgroundWorker_RunWorkerCompleted;
     _tmsCollection = _translationMemoryViewModel.TmsCollection;
     _tmsCollection.CollectionChanged            += _tmsCollection_CollectionChanged;
     _translationMemoryViewModel.PropertyChanged += _translationMemoryViewModel_PropertyChanged;
     RulesCollection.CollectionChanged           += RulesCollection_CollectionChanged;
 }
        private bool ShouldAnonymize(string currentText, string prevText)
        {
            foreach (var rule in SettingsMethods.GetRules())
            {
                var regex   = new Regex(rule.Name, RegexOptions.IgnoreCase);
                var matches = regex.Matches(currentText);
                foreach (System.Text.RegularExpressions.Match match in matches)
                {
                    var matchesDeselected = _deSelectedWordsDetails.Where(n => n.Text.Equals(match.Value.TrimEnd())).ToList();
                    if (matchesDeselected.Any())
                    {
                        //check the previous word to see if is the same word which user deselected

                        if (!string.IsNullOrEmpty(prevText))
                        {
                            var combinedText = prevText + currentText;

                            var firstPartOfString = combinedText.Substring(0, combinedText.IndexOf(match.Value, StringComparison.Ordinal))
                                                    .TrimEnd();
                            var prevWord = firstPartOfString.Substring(firstPartOfString.LastIndexOf(" ", StringComparison.Ordinal));

                            var matchToBeDeselected = matchesDeselected.FirstOrDefault(w => w.PreviousWord.Equals(prevWord));
                            if (matchToBeDeselected != null)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            //this means the unselected text is checked second time we need to skip it because we already created a text element
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 12
0
        public AuthForm()
        {
            InitializeComponent();
            Icon     = Resources.system;
            settings = SettingsMethods.ReadConfig();

            LoginBox.TextChanged    += TextBoxesValueChanged;
            PasswordBox.TextChanged += TextBoxesValueChanged;

            SettingsMethods.CheckDatabaseExist(settings);

#if DEBUG
            LoginBox.TextChanged    -= TextBoxesValueChanged;
            PasswordBox.TextChanged -= TextBoxesValueChanged;
            LoginBox.TextChanged    += (s, e) => PasswordBox.Text = LoginBox.Text;
            PasswordBox.TextChanged += (s, e) => PasswordBox.Text = LoginBox.Text;
            LoginBox.Text            = "admin";
            AuthorizeButton.Enabled  = true;
            ActiveControl            = AuthorizeButton;
#endif
        }
Esempio n. 13
0
        private void ResetModel()
        {
            settings = SettingsMethods.ReadConfig();
            showBorderMenu.SelectedItem      = ConvertBooleanToStringVariants(settings.HideBorderMenu, Yes, No);
            showAdditionalInfo.SelectedItem  = ConvertBooleanToStringVariants(settings.ShowAdditionalInfo, Yes, No);
            showOnlyOwnRequests.SelectedItem = ConvertBooleanToStringVariants(settings.ShowOnlyOwnRequests, Yes, No);
            restoreBorderMenu.SelectedItem   = ConvertBooleanToStringVariants(settings.RestoreBorderMenu, Yes, No);

            closeViewButtonPosition.SelectedItem = ConvertIntEnumToString(
                settings.CloseViewButtonPosition,
                (int)DockStyle.Left,
                (int)DockStyle.Right,
                typeof(DockStyle));

            fullScreenAtStart.SelectedItem = ConvertIntEnumToString(
                settings.FullScreenAtStart,
                (int)FormWindowState.Normal,
                (int)FormWindowState.Maximized,
                typeof(FormWindowState));

            fileFolderPath.Text = settings.FileFolderPath;
        }
Esempio n. 14
0
        private void InitializeWpfApplicationSettings()
        {
            if (System.Windows.Application.Current == null)
            {
                new System.Windows.Application();
            }
            if (System.Windows.Application.Current != null)
            {
                System.Windows.Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            }

            //create settings folder
            if (!Directory.Exists(Constants.SettingsFolderPath))
            {
                Directory.CreateDirectory(Constants.SettingsFolderPath);
            }

            var settings = SettingsMethods.GetSettings();

            if (!settings.AlreadyAddedDefaultRules)
            {
                AddDefaultRules(settings);
            }
        }
Esempio n. 15
0
 public AdminApi( string server ) {
     _server = server;
     Process = new AdminProcessMethods(this);
     Settings = new SettingsMethods(this);
     Log = new LogMethods(this);
 }