Ejemplo n.º 1
0
        private void RemoveButton_Click(object sender, RoutedEventArgs e)
        {
            if (_removeUser == null)
            {
                return;
            }

            string objects = string.Empty;

            foreach (StackPanel stack in RemoveRulesDP.Children.OfType <StackPanel>())
            {
                CheckBox check = stack.Children.OfType <CheckBox>().FirstOrDefault();

                Label label = stack.Children.OfType <Label>().FirstOrDefault();

                if (check.IsChecked ?? false)
                {
                    objects += label.Content;
                }
            }

            UsersWorker.RemoveRules(_removeUser, objects);

            Close();
        }
Ejemplo n.º 2
0
        private void InputTB_TextChanged(object sender, TextChangedEventArgs e)
        {
            _currentAccessUser = null;

            foreach (var panel in _panels)
            {
                if (_radios.FirstOrDefault(item => (string)item.Content == panel.Key).IsChecked ?? false)
                {
                    UsersWorker.SetupUser(panel.Value, out _currentAccessUser);
                }
            }

            if (_currentAccessUser == null)
            {
                return;
            }

            OutputTB.Text = string.Empty;

            foreach (var ch in InputTB.Text)
            {
                if (_currentAccessUser.AccessDictionary.ContainsKey(ch) && _currentAccessUser.AccessDictionary[ch] == 1)
                {
                    OutputTB.Text += ch;
                }
            }
        }
Ejemplo n.º 3
0
        private void SetupMainStack()
        {
            MainStack.Children.Clear();
            _radios.Clear();
            _panels.Clear();

            Dictionary <string, MyUser> users = UsersWorker.AccessUsers;

            foreach (var item in users)
            {
                UsersWorker.SetupDock(item.Value, "test", out DockPanel dockPanel, out RadioButton radio);

                if (_panels.ContainsKey(item.Key))
                {
                    _panels[item.Key] = dockPanel;
                }
                else
                {
                    _panels.Add(item.Key, dockPanel);
                }

                _radios.Add(radio);

                MainStack.Children.Add(dockPanel);
            }

            SetupEvents();
        }
Ejemplo n.º 4
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            string objects = string.Empty;

            foreach (StackPanel stack in CreateRulesDP.Children.OfType <StackPanel>())
            {
                CheckBox check = stack.Children.OfType <CheckBox>().FirstOrDefault();

                Label label = stack.Children.OfType <Label>().FirstOrDefault();

                if (check?.IsChecked ?? false)
                {
                    objects += label.Content;
                }
            }

            UsersWorker.CreateSubject(NameTB.Text, objects);

            Close();
        }
Ejemplo n.º 5
0
        private void Check_Checked(object sender, RoutedEventArgs e)
        {
            _currentAccessUser = null;

            Dictionary <string, MyUser> users = new Dictionary <string, MyUser>();

            foreach (var item in MainStack.Children)
            {
                if (item is DockPanel dock)
                {
                    UsersWorker.SetupUser(dock, out MyUser myUser);
                    users.Add(myUser.Name, myUser);
                }
            }

            UsersWorker.AccessUsers = users;

            foreach (var panel in _panels)
            {
                if (_radios.FirstOrDefault(item => (string)item.Content == panel.Key).IsChecked ?? false)
                {
                    UsersWorker.SetupUser(panel.Value, out _currentAccessUser);
                }
            }

            if (_currentAccessUser == null)
            {
                return;
            }

            OutputTB.Text = string.Empty;

            foreach (var ch in InputTB.Text)
            {
                if (_currentAccessUser.AccessDictionary.ContainsKey(ch) && _currentAccessUser.AccessDictionary[ch] == 1)
                {
                    OutputTB.Text += ch;
                }
            }
        }