private void LbxItems_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (LbxSourceCodeBlocks.SelectedIndex != -1)
     {
         CodeBlock SELECTED_CODE_BLOCK = CodeBlockDataManagement.GetBaseBlockFromTargetPathOrTitle(LbxSourceCodeBlocks.SelectedItem.ToString());
         afterSelectCodeBlock(SELECTED_CODE_BLOCK.Copy());
         this.Close();
     }
 }
 private void LbxSourceCodeBlocks_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (LbxSourceCodeBlocks.SelectedIndex != -1)
     {
         CodeBlock SELECTED_CODE_BLOCK = CodeBlockDataManagement.GetBaseBlockFromTargetPathOrTitle(LbxSourceCodeBlocks.SelectedItem.ToString());
         TbxSourceCodeDes.Text    = SELECTED_CODE_BLOCK.description;
         TbxSourceCodeDetail.Text = SELECTED_CODE_BLOCK.codes;
     }
 }
        /// <summary>
        /// Load code block dictionary data
        /// </summary>
        public static void LoadData()
        {
            loadedCodeBlockPresets.Clear();
            if (!Directory.Exists(DS.PROGRAM_PATHS.CODE_BLOCK_PRESET))
            {
                Directory.CreateDirectory(DS.PROGRAM_PATHS.CODE_BLOCK_PRESET);
            }

            Directory.GetFiles(DS.PROGRAM_PATHS.CODE_BLOCK_PRESET).ToList().ForEach((string codeBlockPresetFile) =>
            {
                if (codeBlockPresetFile.Contains("DESCRIPTION_"))
                {
                    Dictionary <string, List <string> > loadedCodeBlockDes = Tools.JsonFile.LoadJsonFile <Dictionary <string, List <string> > >(codeBlockPresetFile);
                    if (loadedCodeBlockDes.ContainsKey(DM.Config.config.localizeOption))
                    {
                        List <string> localizedCodeBlockDes = loadedCodeBlockDes[DM.Config.config.localizeOption];
                        CodeBlockPresets newCodeBlockPreset = new CodeBlockPresets();
                        newCodeBlockPreset.title            = localizedCodeBlockDes[0];
                        newCodeBlockPreset.description      = localizedCodeBlockDes[1];

                        string CODE_BLCOKS_FILE_NAME = codeBlockPresetFile.Replace("DESCRIPTION_", "CODE_BLOCKS_");
                        if (File.Exists(CODE_BLCOKS_FILE_NAME))
                        {
                            List <List <string> > loadedCodeBlockPresetSyntaxStrLists = Tools.JsonFile.LoadJsonFile <List <List <string> > >(CODE_BLCOKS_FILE_NAME);
                            List <CodeBlock> newCodeBlockLists = new List <CodeBlock>();

                            Dictionary <string, CodeBlock> codeBlockDics = new Dictionary <string, CodeBlock>();
                            foreach (List <string> loadedCodeBlockPresetSyntaxStrList in loadedCodeBlockPresetSyntaxStrLists)
                            {
                                string CODE_BLOCK_PATH_TO_USE = loadedCodeBlockPresetSyntaxStrList[0];
                                string CODE_BLOCK_UNIQUE_NAME = loadedCodeBlockPresetSyntaxStrList[1];
                                string CODE_BLOCK_PERENT_NAME = loadedCodeBlockPresetSyntaxStrList[2];

                                CodeBlock newCodeBlock = CodeBlockDataManagement.GetBaseBlockFromTargetPathOrTitle(CODE_BLOCK_PATH_TO_USE).Copy();
                                codeBlockDics[CODE_BLOCK_UNIQUE_NAME] = newCodeBlock;
                                if (string.IsNullOrEmpty(CODE_BLOCK_PERENT_NAME))
                                {
                                    newCodeBlockLists.Add(newCodeBlock);
                                }
                                else if (codeBlockDics.ContainsKey(CODE_BLOCK_PERENT_NAME))
                                {
                                    codeBlockDics[CODE_BLOCK_PERENT_NAME].subCodeBlocks.Add(newCodeBlock);
                                }
                            }

                            newCodeBlockPreset.rootCodeBlocks = newCodeBlockLists;
                            loadedCodeBlockPresets.Add(newCodeBlockPreset);
                        }
                    }
                }
            });
        }
        public DLLEditorMainWindow(string fileName, List <string> autoParaPaths = null, List <CodeBlock> rootCodeBlocksToUse = null)
        {
            InitializeComponent();
            TbxNameSpace.Text = DM.Config.config.nameSpaceToUse;
            Tools.WindowControls.LocalizeWindowControls(this, DM.LANGUAGE_FILE_NAME.DLL_EDITOR_INFO);

            string DLL_DIR_SEARCH_PATH = $"{DM.Config.CurrentWorkingDirectory}\\{DLLEditor.GlobalDatas.DLL_SOURCE_FILE_DIR_NAME}";

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

            string JSON_FILE_PATH = $"{DLL_DIR_SEARCH_PATH}\\{fileName}.json";

            if (!File.Exists(JSON_FILE_PATH))
            {
                File.Create(JSON_FILE_PATH);
                if (rootCodeBlocks != null)
                {
                    rootCodeBlocks = rootCodeBlocksToUse;
                }
                if (autoParaPaths != null)
                {
                    rootCodeBlocks = CodeBlockDataManagement.MakeCodeBlockListWithParameters(autoParaPaths);
                }
            }
            else
            {
                rootCodeBlocks = Tools.JsonFile.LoadJsonFile <List <DLLEditor.CodeBlock> >(JSON_FILE_PATH);
                if (rootCodeBlocks == null)
                {
                    rootCodeBlocks = new List <DLLEditor.CodeBlock>();
                }
            }
            targetSourceFilePath = JSON_FILE_PATH;

            InitCreatedSourceCodeTextBox();
            InitDLLStacks();
            UpdateCompileButton();
        }
        public DLLEditorGlobalSearchWindow(Action <CodeBlock> afterSelectCodeBlock, List <string> subNodesToShow)
        {
            InitializeComponent();
            Tools.WindowControls.LocalizeWindowControls(this, DM.LANGUAGE_FILE_NAME.GLOBAL_WINDOW);
            this.afterSelectCodeBlock = afterSelectCodeBlock;
            List <string> searchTypes = new List <string>();

            codeBlockList.Clear();
            if (subNodesToShow == null)
            {
                List <string> RootCodeBlockList = Tools.JsonFile.LoadJsonFile <List <string> >(DS.PROGRAM_RESOURCE_PATHS.RESOURCE_ROOT_CODE_BLOCK_LIST);
                codeBlockList = CodeBlockDataManagement.GetMultipleBaseBlockFromTargetPathListOrTitle(RootCodeBlockList);
            }
            else
            {
                codeBlockList = CodeBlockDataManagement.GetMultipleBaseBlockFromTargetPathListOrTitle(subNodesToShow);
            }

            searchTypes.AddRange(CodeBlockDataManagement.GetALLLocalizedBlockType());
            searchTypes.AddRange(CodeBlockDataManagement.GetALLCodeBlockKeys());
            InitLbxSearchType(searchTypes);
        }