/// <summary>
        /// Click Events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DLLEditorButtonClickEvents(object sender, RoutedEventArgs e)
        {
            Button clickButton = sender as Button;

            try
            {
                switch (clickButton.Name)
                {
                case "BtnSetDLLWorkingSpace":
                    new SubWindows.Global_ListSeleteWithEditWindow(null, null, null, null,
                                                                   SubWindows.Global_ListSeleteWithEditWindow_PRESET.DLL_WORKING_SPACE).ShowDialog();
                    if (!string.IsNullOrEmpty(targetSourceFilePath))
                    {
                        this.Title = $"DLL Editor Window - {targetSourceFilePath.Split('\\').Last().Split('.')[0]}.dll";
                    }
                    InitCreatedSourceCodeTextBox();
                    InitDLLStacks();
                    UpdateCompileButton();
                    break;

                case "BtnCompileDLL":
                    if (string.IsNullOrEmpty(targetSourceFilePath))
                    {
                        DLLEditorButtonClickEvents(BtnSetDLLWorkingSpace, null);
                        return;
                    }
                    TbxLogging.Text = CompileDLL.CompileGivenCodeToDLL(TbxTextEditor.Text, targetSourceFilePath.Split('\\').Last().Split('.')[0]);
                    TbxLogging.ScrollToEnd();
                    UpdateCompileButton();
                    break;

                case "BtnAddCodeBase":
                    if (string.IsNullOrEmpty(targetSourceFilePath))
                    {
                        DLLEditorButtonClickEvents(BtnSetDLLWorkingSpace, null);
                        return;
                    }

                    new DLLEditorGlobalSearchWindow((CodeBlock selectedCodeBlock) =>
                    {
                        rootCodeBlocks.Add(selectedCodeBlock);
                        InitCreatedSourceCodeTextBox();
                        InitDLLStacks();
                    }, null).ShowDialog();
                    break;

                case "BtnAddCodeBlockPreset":
                    if (string.IsNullOrEmpty(targetSourceFilePath))
                    {
                        DLLEditorButtonClickEvents(BtnSetDLLWorkingSpace, null);
                        return;
                    }
                    new DLLEditorCodeBlockPresetWindow((CodeBlockPresets presetData) =>
                    {
                        List <CodeBlock> copiedCodeBlocks = new List <CodeBlock>();
                        presetData.rootCodeBlocks.ForEach((CodeBlock codeBlockToUse) =>
                        {
                            copiedCodeBlocks.Add(codeBlockToUse.Copy());
                        });
                        rootCodeBlocks.AddRange(copiedCodeBlocks);

                        InitCreatedSourceCodeTextBox();
                        InitDLLStacks();
                    }).ShowDialog();
                    break;

                case "BtnClose":
                    this.Close();
                    break;
                }
            }
            catch (Exception ex)
            {
                Tools.MessageBoxTools.ShowErrorMessageBox(ex,
                                                          DM.LocalizeCore.GetLanguageData(DM.LANGUAGE_FILE_NAME.DLL_EDITOR_INFO, $"DLLEditorMainWindow_Error_1"));
            }
        }
Пример #2
0
        private void BtnMakeDLLAuto_Click(object sender, RoutedEventArgs e)
        {
            for (int paraIndex = 0; paraIndex < selectedAutoGenerateCodeBlock.parameterNameList.Count; paraIndex++)
            {
                #region Data empty check
                TextBox tbxToCheck = null;
                Label   lblToShow  = LblData_0;
                switch (paraIndex)
                {
                case 0:
                    tbxToCheck = TbxData_0;
                    lblToShow  = LblData_0;
                    break;

                case 1:
                    tbxToCheck = TbxData_1;
                    lblToShow  = LblData_1;
                    break;

                case 2:
                    tbxToCheck = TbxData_2;
                    lblToShow  = LblData_2;
                    break;

                case 3:
                    tbxToCheck = TbxData_3;
                    lblToShow  = LblData_3;
                    break;

                case 4:
                    tbxToCheck = TbxData_4;
                    lblToShow  = LblData_4;
                    break;

                case 5:
                    tbxToCheck = TbxData_5;
                    lblToShow  = LblData_5;
                    break;

                case 6:
                    tbxToCheck = TbxData_6;
                    lblToShow  = LblData_6;
                    break;

                case 7:
                    tbxToCheck = TbxData_7;
                    lblToShow  = LblData_7;
                    break;

                case 8:
                    tbxToCheck = TbxData_8;
                    lblToShow  = LblData_8;
                    break;

                case 9:
                    tbxToCheck = TbxData_9;
                    lblToShow  = LblData_9;
                    break;
                }

                if (tbxToCheck != null && string.IsNullOrEmpty(tbxToCheck.Text))
                {
                    Tools.MessageBoxTools.ShowErrorMessageBox(String.Format(DM.LocalizeCore.GetLanguageData(DM.LANGUAGE_FILE_NAME.GLOBAL_WINDOW, $"AUTO_CREATE_DLL_ERROR_1"), lblToShow.Content));
                    return;
                }
                #endregion
            }

            if (string.IsNullOrEmpty(TbxDLLName.Text))
            {
                Tools.MessageBoxTools.ShowErrorMessageBox(DM.LocalizeCore.GetLanguageData(DM.LANGUAGE_FILE_NAME.GLOBAL_WINDOW, $"AUTO_CREATE_DLL_ERROR_2"));
                return;
            }
            string OUTPUT_DLL_PATH = $"{DM.Config.CurrentWorkingDirectory}\\{TbxDLLName.Text}.dll";
            if (File.Exists(OUTPUT_DLL_PATH))
            {
                if (MessageBox.Show(DM.LocalizeCore.GetLanguageData(DM.LANGUAGE_FILE_NAME.GLOBAL_WINDOW, $"AUTO_CREATE_DLL_ERROR_3"),
                                    DM.LocalizeCore.GetLanguageData(DM.LANGUAGE_FILE_NAME.GLOBAL_WINDOW, $"AUTO_CREATE_DLL_ERROR_4"), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }
            }

            string GENERATED_CODE = selectedAutoGenerateCodeBlock.codes;
            for (int paraIndex = 0; paraIndex < selectedAutoGenerateCodeBlock.parameterNameList.Count; paraIndex++)
            {
                #region Replace code
                switch (paraIndex)
                {
                case 0:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{0}}", TbxData_0.Text);
                    break;

                case 1:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{1}}", TbxData_1.Text);
                    break;

                case 2:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{2}}", TbxData_2.Text);
                    break;

                case 3:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{3}}", TbxData_3.Text);
                    break;

                case 4:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{4}}", TbxData_4.Text);
                    break;

                case 5:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{5}}", TbxData_5.Text);
                    break;

                case 6:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{6}}", TbxData_6.Text);
                    break;

                case 7:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{7}}", TbxData_7.Text);
                    break;

                case 8:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{8}}", TbxData_8.Text);
                    break;

                case 9:
                    GENERATED_CODE = GENERATED_CODE.Replace("{{9}}", TbxData_9.Text);
                    break;
                }
                #endregion
            }

            TbxCompileResult.Text = CompileDLL.CompileGivenCodeToDLL(GENERATED_CODE, TbxDLLName.Text);
            TbxCompileResult.ScrollToEnd();
        }