/// <summary>
        /// Load code block dictionary data
        /// </summary>
        public static void LoadData()
        {
            loadedAutoGenCodeBlocks.Clear();
            if (!Directory.Exists(DS.PROGRAM_PATHS.AUTO_GENERATE_CODE_BLOCK))
            {
                Directory.CreateDirectory(DS.PROGRAM_PATHS.AUTO_GENERATE_CODE_BLOCK);
            }

            Directory.GetFiles(DS.PROGRAM_PATHS.AUTO_GENERATE_CODE_BLOCK).ToList().ForEach((string codeBlockFile) =>
            {
                if (codeBlockFile.Split('.').Last() == "json")
                {
                    Dictionary <string, List <string> > loadedCodeBlockDes = Tools.JsonFile.LoadJsonFile <Dictionary <string, List <string> > >(codeBlockFile);
                    if (loadedCodeBlockDes.ContainsKey(DM.Config.config.localizeOption))
                    {
                        List <string> localizedCodeBlockDes             = loadedCodeBlockDes[DM.Config.config.localizeOption];
                        AutoGenerateCodeBlock newAutoGeneratedCodeBlock = new AutoGenerateCodeBlock();
                        newAutoGeneratedCodeBlock.title             = localizedCodeBlockDes[0];
                        newAutoGeneratedCodeBlock.description       = localizedCodeBlockDes[1];
                        newAutoGeneratedCodeBlock.parameterNameList = localizedCodeBlockDes[2].Split(',').ToList();

                        string SOURCE_DATA = codeBlockFile.Replace(".json", ".txt");
                        if (File.Exists(SOURCE_DATA))
                        {
                            newAutoGeneratedCodeBlock.codes = File.ReadAllText(SOURCE_DATA);
                        }
                        loadedAutoGenCodeBlocks.Add(newAutoGeneratedCodeBlock);
                    }
                }
            });
        }
Beispiel #2
0
 private void LbxSourceCodeBlocks_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (LbxSourceCodeBlocks.SelectedIndex != -1)
     {
         selectedAutoGenerateCodeBlock = autoGenCodeBlockSearchResults[LbxSourceCodeBlocks.SelectedIndex];
         ReflectDataInputUIs();
     }
 }
Beispiel #3
0
 private void InitSearchItems()
 {
     HideAllDataGrids();
     selectedAutoGenerateCodeBlock = null;
     if (LbxSearchType.SelectedItem != null)
     {
         LbxSourceCodeBlocks.Items.Clear();
         autoGenCodeBlockSearchResults.Clear();
         foreach (AutoGenerateCodeBlock codeBlock in AutoGenerateCodeBlockDataManagement.loadedAutoGenCodeBlocks)
         {
             string SEARCH_STR = $"{codeBlock.title.ToLower()}{codeBlock.description.ToLower()}";
             if (!string.IsNullOrEmpty(TbxSearch.Text) && !SEARCH_STR.Replace(" ", "").Contains(TbxSearch.Text.ToLower().Replace(" ", "")))
             {
                 continue;
             }
             if (LbxSearchType.SelectedIndex == 0)
             {
                 LbxSourceCodeBlocks.Items.Add($"{codeBlock.title} - {codeBlock.description}");
                 autoGenCodeBlockSearchResults.Add(codeBlock);
             }
             else
             {
                 switch (LbxSearchType.SelectedItem.ToString())
                 {
                 default:
                     if (SEARCH_STR.Contains(LbxSearchType.SelectedItem.ToString().ToLower()))
                     {
                         LbxSourceCodeBlocks.Items.Add($"{codeBlock.title} - {codeBlock.description}");
                         autoGenCodeBlockSearchResults.Add(codeBlock);
                     }
                     break;
                 }
             }
         }
         if (LbxSourceCodeBlocks.Items.Count > 0)
         {
             LbxSourceCodeBlocks.SelectedIndex = 0;
         }
     }
 }