예제 #1
0
        private void LoadSaveConfiguration()
        {
            Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\OrmGenerator\\";

            if (!Directory.Exists(Path))
            {
                Directory.CreateDirectory(Path);
            }

            Path += Constant.FILE_NAME_SAVE_CONFIGURATION;

            if (!File.Exists(Constant.FILE_NAME_SAVE_CONFIGURATION))
            {
                File.Create(Path);
            }

            Saves = JsonMethod <SaveConfigModel> .ReadAllDataJson(Path);

            if (Saves != null)
            {
                foreach (var item in Saves)
                {
                    ComboBox_Connection_Save.HorizontalContentAlignment = HorizontalAlignment.Left;
                    ComboBox_Connection_Save.Items.Add(item.Name);
                }
            }
            else
            {
                Saves = new List <SaveConfigModel>();
                ComboBox_Connection_Save.HorizontalContentAlignment = HorizontalAlignment.Center;
                ComboBox_Connection_Save.Items.Add(langue.ComboBox_Saves_Empty);
            }
        }
        public TrashDialog(string Path)
        {
            InitializeComponent();

            this.Path = Path;

            foreach (var item in JsonMethod <SaveConfigModel> .ReadAllDataJson(this.Path))
            {
                ComboBox_Configuration_Save.Items.Add(item.Name);
            }
        }
        private void Button_Validate_Click(object sender, RoutedEventArgs e)
        {
            List <SaveConfigModel> saves = JsonMethod <SaveConfigModel> .ReadAllDataJson(Path);

            SaveConfigModel save = saves.Where(x => x.Name == ComboBox_Configuration_Save.SelectedItem.ToString()).FirstOrDefault();

            saves.Remove(save);

            JsonMethod <SaveConfigModel> .WriteDataJson(Path, JsonMethod <SaveConfigModel> .AddData(saves));

            NewSaveConfig = saves;

            this.Close();
        }
예제 #4
0
        private void ComboBox_Connection_Save_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                string saveName = ComboBox_Connection_Save.SelectedItem.ToString();

                if (!string.IsNullOrEmpty(saveName))
                {
                    SaveConfigModel config = JsonMethod <SaveConfigModel> .ReadAllDataJson(Path).Where(x => x.Name == saveName).FirstOrDefault();

                    if (config != null)
                    {
                        TextBox_IP.Text       = config.Address;
                        TextBox_Password.Text = config.Password;
                        TextBox_Username.Text = config.Username;
                        ComboBox_SqlType.Text = config.CurrentConnectorType;
                    }

                    EnableButton();
                }
            }
            catch { }
        }