Ejemplo n.º 1
0
        /// <summary>
        /// Read The settings file and set the path for config files
        /// Read the category file and set the combobox = every category
        /// </summary>
        private void readSettingsAndCategoryFiles()
        {
            //Settings File
            if (!Directory.Exists(workDirectoryAppData))
            {
                Directory.CreateDirectory(workDirectoryAppData);
            }
            try
            {
                string[] strSettings = File.ReadAllLines(string.Format(workDirectoryAppData + "\\settings.txt"), Encoding.GetEncoding(1252));
                Console.Write(strSettings[0]);
                txtConfigFilesPath.Text = strSettings[0];
                unitAndCategoryHandler  = new UnitAndCategoryHandler(strSettings[0]);

                //Category file
                if (!File.Exists(strSettings[0] + "\\Category.txt"))
                {
                    return;
                }
                else
                {
                    cbCategory.Items.Clear();
                    strCategorys = File.ReadAllLines(string.Format(strSettings[0] + "\\Category.txt"), Encoding.GetEncoding(1252));
                    for (int i = 0; i < strCategorys.Length; i++)
                    {
                        cbCategory.Items.Add(strCategorys[i]);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Det ser ud som om at der ikke valgt nogen mappe til config filerne\nVælg den venligst nu");

                //Show settings menu
                MainMenu.Opacity        = 0;
                MainMenu.Visibility     = Visibility.Hidden;
                SettingsMenu.Opacity    = 1;
                SettingsMenu.Visibility = Visibility.Visible;
                btnMainMenu.IsEnabled   = false;
            }
        }
 internal void WinEditCategorys(UnitAndCategoryHandler unitAndCategoryHandlerFromBase)
 {
     unitAndCategoryHandler = unitAndCategoryHandlerFromBase;
     ReadCategorysToList();
 }