示例#1
0
        private void SetListResult(string baseName, List <string> choosen)
        {
            ListClassfy list = new ListClassfy(choosen, baseName);

            listResult            = list.Classify();
            listDescriptionResult = FileAdapter.GetDescripionToResult(listResult, baseName);
            string result = listResult + "\n" + listDescriptionResult;

            ListClassfyLabel.Text = result;
        }
示例#2
0
 private void AddDianoseCategory()
 {
     if (!FileAdapter.isEmpty(baseName))
     {
         MessageBox.Show("Diagnoza już istnieje", "Error");
     }
     else
     {
         FileAdapter.AddNewDiagnoseFile(baseName, CategoryTextBox.Text, Description.Text);
     }
 }
示例#3
0
        public Request(string baseName, List <string> choosen)
        {
            InitializeComponent();
            this.indegrades = FileAdapter.GetIngredients("data\\" + baseName + ".boi");
            Header.Content  = indegrades[index][0];
            indegrades[index].RemoveAt(0);
            OptionsComboBox.ItemsSource = indegrades[index];
            Descriptions.Text           = FileAdapter.GetDescripionToCategory(baseName, index);

            isFirst       = false;
            this.choosen  = choosen;
            this.baseName = baseName;
        }
示例#4
0
        public DelRule(string baseName)
        {
            InitializeComponent();
            this.baseName = baseName;
            List <string[]> Rules = FileAdapter.GetAllRuleForDisplay(baseName);

            GoodRules = new List <string>();
            foreach (string[] rule in Rules)
            {
                GoodRules.Add(rule[0] + " = " + rule[1]);
            }
            RuleComboBox.ItemsSource = GoodRules;
        }
示例#5
0
 public AddIngredence(string baseName)
 {
     InitializeComponent();
     this.baseName  = baseName;
     ListOfCategory = FileAdapter.GetAllCategory(baseName);
     try
     {
         ListOfCategory.Add(FileAdapter.GetDiagnoseName(baseName));
     }
     catch
     {
     }
     Category.ItemsSource = ListOfCategory;
 }
示例#6
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            string diagnose = ListOfCategory[ListOfCategory.Count - 1];

            if (Category.Text == diagnose)
            {
                FileAdapter.SaveNewDiagnoseIngredient(baseName, Category.Text, Ingedence.Text, Description.Text);
            }
            else
            {
                FileAdapter.SaveNewIngredient(baseName, Category.Text, Ingedence.Text, Description.Text);
            }

            this.Close();
        }
示例#7
0
        private void AddCategoryButton_Click(object sender, RoutedEventArgs e)
        {
            if (isDecisionClass.IsChecked == true)
            {
                AddDianoseCategory();
            }
            else
            {
                FileAdapter.AddNewCategoryToFile(baseName, CategoryTextBox.Text, Description.Text /*, CopyPhoto(filePath)*/);
                FileAdapter.UpdateRules(baseName, CategoryTextBox.Text);
            }
            BaseEditor baseEditor = new BaseEditor(baseName);

            baseEditor.Show();
            this.Close();
        }
示例#8
0
        private void SetVoteResult(string baseName, List <string> choosen)
        {
            VoteClassfy vote = new VoteClassfy(choosen);

            voteResult = vote.Vote(baseName);
            string result = voteResult;

            try
            {
                voteDescriptionResult = FileAdapter.GetDescripionToResult(result.Split("\n")[1], baseName);
                result += voteDescriptionResult;
            }
            catch { }

            VoteClassfyLabel.Text = result;
        }
示例#9
0
        public AddRule(string baseName, List <string> listOfChoosen)
        {
            InitializeComponent();
            this.baseName      = baseName;
            this.listOfChoosen = listOfChoosen;
            try
            {
                ListOfIngredients = FileAdapter.GetIngredients("data\\" + baseName + ".boi");
                ListOfDiagnose    = FileAdapter.GetIngredients("data\\" + baseName + ".bod");
            }
            catch
            {
                return;
            }

            SetCategoryInWindow();
        }
示例#10
0
        public string Vote(string baseName)
        {
            List <List <string> > ind      = FileAdapter.GetIngredients("data\\" + baseName + ".bod");
            List <string>         diagnose = ind[0];

            int[] score = new int[diagnose.Count - 1];

            int           goodRule    = 0;
            List <string> ListOfRules = FileAdapter.GetAllNotEditedRule(baseName);

            foreach (string rule in ListOfRules)
            {
                if (CheckRule(rule))
                {
                    goodRule++;
                    string res = GetRuleResult(rule);
                    try
                    {
                        score[diagnose.IndexOf(res)]++;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
            }
            string message = "Błąd klasyfikacji";

            if (goodRule == 0)
            {
                message = "nie znana reguła odpowiadająca podanym przesłankom";
            }
            else
            {
                message = "Największą ilość głosów otrzymały diagnozy:\n";
                string[] maxVoted = GetMaxVotedItems(score, diagnose);
                foreach (string item in maxVoted)
                {
                    message += item + '\n';
                }
            }
            return(message);
        }
示例#11
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            string hashPassword = FileAdapter.ComputeSha256Hash(PasswordBox.Password);
            Admin  newAdmin     = new Admin(LoginTextBox.Text, hashPassword, BaseNameTextBox.Text, PasswordHintTextBox.Text, BaseDescriptionTextBox.Text);

            if (!File.Exists("data\\" + newAdmin.baseName + ".bok"))
            {
                bool isUniqLogin = true;
                foreach (Admin adm in admins)
                {
                    if (adm.name == newAdmin.name)
                    {
                        MessageBox.Show("Taki login jest już zajęty");
                        isUniqLogin = false;
                        break;
                    }
                }
                if (isUniqLogin && PassCheck())
                {
                    admins.Add(newAdmin);
                    List <string> ListOfAdminsString = new List <string>();
                    foreach (Admin admin in admins)
                    {
                        ListOfAdminsString.Add(admin.ToCodedString());
                    }
                    File.WriteAllLines("data\\admin.ame", ListOfAdminsString);
                    CreateFiles(newAdmin);
                    BaseEditor baseEditor = new BaseEditor(newAdmin.baseName);
                    baseEditor.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Hasła nie są poprawne");
                }
            }
            else
            {
                MessageBox.Show("Baza już istnieje!");
            }
        }
示例#12
0
        private void DelBase_Click(object sender, RoutedEventArgs e)
        {
            string message = "Czy napewno chcesz usunąć całą baze? \n operacja jest nie odwracalna, wszystkie pliki zostaną usunięte a konto administratora zniknie";

            if (MessageBox.Show(message, "Usuwanie", MessageBoxButton.YesNo, MessageBoxImage.Stop, MessageBoxResult.No) == MessageBoxResult.Yes)
            {
                if (MessageBox.Show("Ale na pewno?", "Usuwanie", MessageBoxButton.YesNo, MessageBoxImage.Stop, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    if (FileAdapter.DeletingBase(baseName))
                    {
                        MessageBox.Show("Udało się", "Usunięto", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Something went not yes", "Usunięto", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    new MainWindow().Show();
                    this.Close();
                }
            }
        }
示例#13
0
        private void DeleteRule()
        {
            string choosenRule = RuleComboBox.Text;

            if (choosenRule == "")
            {
                return;
            }
            if (MessageBox.Show("Czy napewno chcesz usunąć tą regułę ?? \n" + RuleComboBox.Text, "Usuwanie", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None) == MessageBoxResult.Yes)
            {
                int index = IndexOfRule(choosenRule);
                if (index != -1)
                {
                    FileAdapter.DeletingRule(baseName, index);
                }
                else
                {
                    MessageBox.Show("Błąd usuwania", "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
                }
            }
        }
示例#14
0
        private void GetHintButton_Click(object sender, RoutedEventArgs e)
        {
            List <Admin> admins         = FileAdapter.GetAllAdmins();
            string       loginStr       = login.Text;
            bool         isLoginCorrect = false;
            string       hint           = "";

            foreach (Admin admin in admins)
            {
                if (admin.name == loginStr)
                {
                    isLoginCorrect = true;
                    hint           = admin.hint;
                    MessageBox.Show("Podpowiedź brzmi: " + hint, "Podpowiedź", MessageBoxButton.OK, MessageBoxImage.Information);
                    break;
                }
            }
            if (!isLoginCorrect)
            {
                MessageBox.Show("Zły login", "Błąd Loginu", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#15
0
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            if (OptionsComboBox.Text == "" && isFirst)
            {
                MessageBox.Show("Nie wybrałeś bazy");
                return;
            }

            if (isFirst)
            {
                new Request(OptionsComboBox.Text, new List <string>()).Show();
                this.Close();
            }
            else
            {
                choosen.Add(OptionsComboBox.Text);
                this.Visibility = Visibility.Hidden;
                index++;
                try
                {
                    Header.Content = indegrades[index][0];
                    indegrades[index].RemoveAt(0);
                    OptionsComboBox.ItemsSource   = indegrades[index];
                    OptionsComboBox.SelectedIndex = indegrades.Count - 1;
                    Descriptions.Text             = FileAdapter.GetDescripionToCategory(baseName, index);
                }
                catch { }
                this.Visibility = Visibility.Visible;
                ////
                if (index == indegrades.Count)
                {
                    this.Hide();
                    new Sumup(baseName, choosen).Show();
                    this.Close();
                }
            }
        }
示例#16
0
 public RegisterScreen()
 {
     InitializeComponent();
     this.admins = FileAdapter.GetAllAdmins();
 }