//Paste to from the Clipboard private void Button_PasteFromClipboard(object sender, RoutedEventArgs e) { //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //Get Item from the ComboBox string MyEncoding = ReturnEncoding(); if (MyEncoding != null) { Encoding encoding = Encoding.Default; //Get Encoding encoding = DesignUtils.GetEncodingIDText(MyIDText); //Paste Argument from the Clipboard string OutputText = DesignUtils.PasteArgumentFromClipboard(); //Update Control UpdateControl(MyArgument.Replace(" ", ""), OutputText); //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, OutputText, encoding); } }
//Button Open Preview private void Button_OpenPreview(object sender, RoutedEventArgs e) { Encoding encoding = Encoding.Default; //Return IDText Parent string MyIDTextParent = DesignUtils.ReturnCurrentFileIDText(); //Get Encoding encoding = DesignUtils.GetEncodingIDText(MyIDTextParent); //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //Occurence Position MyArgument = "Occurence Position"; string OccurencePosition = ReturnOccurrenceNumber(); if (OccurencePosition != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, OccurencePosition, encoding); } else { //Delete Argument in case it is null DesignUtils.DeleteTextFileRowArgument(FilePath, MyArgument, encoding); } #region Open Preview Extraction //Read Text File string Source = System.IO.File.ReadAllText(FilePath, encoding); //Check if all Parameters are in the File string[] searchWords = { "Words" + Utils.DefaultSeparator(), "Occurence Parameter" + Utils.DefaultSeparator() }; double PercResults = Utils.FindWordsInString(Source, searchWords, false); //Case all Parameters are found if (PercResults == 1) { //Open Form Preview Extraction DesignUtils.CallformPreviewExtraction(MyIDText, "Remove Words", MyIDTextParent, encoding); } else { //Error Message MessageBox.Show("Please fill in all arguments", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error); } #endregion }
//Auto Fill Controls public void AutoFillControls() { //Check if File Exists, if not create it //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //If false create it if (File.Exists(FilePath) == false) { //Create File System.IO.File.WriteAllText(FilePath, ""); } #region Encoding string MyArgument = "Encoding"; //Get Item from the ComboBox string MyEncoding = ReturnEncoding(); if (MyEncoding != null) { Encoding encoding = Utils.ConvertStringToEncoding(MyEncoding); //Log ComboBox DesignUtils.CallLogComboBox(MyIDText, MyArgument, MyEncoding, encoding); #region File Name //Copy the Arguments, in case there is string FilePathPreview = ReturnCurrentFile(); if (FilePathPreview != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, "FileName", FilePathPreview, encoding); } #endregion } #endregion }
//Paste to from the Clipboard private void Button_PasteFromClipboard(object sender, RoutedEventArgs e) { Encoding encoding = Encoding.Default; //Return IDText Parent string MyIDTextParent = DesignUtils.ReturnCurrentFileIDText(); //Get Encoding encoding = DesignUtils.GetEncodingIDText(MyIDTextParent); //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //Paste Argument from the Clipboard string OutputText = DesignUtils.PasteArgumentFromClipboard(); //Update Control UpdateControl("SearchWord", OutputText); //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, OutputText, encoding); }
//Create New TextID private void CreateNewIDText(object sender, RoutedEventArgs e) { Encoding encoding = Encoding.Default; //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //Get Encoding encoding = DesignUtils.GetEncodingIDText(MyIDText); //Clear the Current IDText ModelProperty property = this.ModelItem.Properties["IDText"]; property.SetValue(null); //Update IDText UpdateIDText(); //Copy the Arguments, in case there is string FilePathPreview = ReturnCurrentFile(); //File Name if (FilePath != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, "FileName", FilePathPreview, encoding); } //Encoding string MyEncoding = ReturnEncoding(); if (MyEncoding != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, "Encoding", MyEncoding, encoding); } }
public void Button_RefreshCurrentFile() { //Get Data from Control //string CurrentExcelFilePath = this.FilePath.Expression.ToString(); string CurrentTextFilePath = ReturnCurrentFile(); //Case it is a Variable if (CurrentTextFilePath == "1.5: VisualBasicValue<String>") { MessageBox.Show("File Path as Variable" + Environment.NewLine + "Please select Text file to use functionality ", "Select Text File", MessageBoxButton.OK, MessageBoxImage.Warning); //Exit the Procedure return; } //If Current File is not found, exit the procedure if (File.Exists(CurrentTextFilePath) == false) { //Error Message MessageBox.Show("The Preview file cannt be found:" + Environment.NewLine + CurrentTextFilePath, "Validation Error", MessageBoxButton.OK, MessageBoxImage.Warning); //Exit the Procedure return; } //In case file is found if (CurrentTextFilePath != null) { #region Update Text Files //Get the full file path string filePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/FileNames/" + Path.GetFileNameWithoutExtension(CurrentTextFilePath) + ".txt"; //Check if file exists bool bExists = File.Exists(filePath); //Case File Exists switch (bExists) { //File Exists case true: //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //Get Current File string CurrentFile = System.IO.File.ReadAllText(Directory.GetCurrentDirectory() + "/StorageTextToolbox/FileNames/" + Path.GetFileNameWithoutExtension(CurrentTextFilePath) + ".txt"); //Get Item from the ComboBox string MyEncoding = ReturnEncoding(); if (MyEncoding != null) { Encoding encoding = Utils.ConvertStringToEncoding(MyEncoding); //Update Text File Row Argument MyArgument = "FileName"; DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, CurrentFile, encoding); } break; //Case File does not exists case false: //Warning Message MessageBox.Show("This funcionality is not available", "File does not exists", MessageBoxButton.OK, MessageBoxImage.Warning); break; } } #endregion else { //Error Message MessageBox.Show("Please select template file", "Select Text File", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void Button_RefreshCurrentFile() { //Get Data from Control string CurrentTextFilePath = ReturnCurrentFile(); //Case it is a Variable if (CurrentTextFilePath == "1.5: VisualBasicValue<String>") { //Error Message MessageBox.Show("File Path as Variable" + Environment.NewLine + "Please select Text file to use functionality ", "Select Text File", MessageBoxButton.OK, MessageBoxImage.Warning); //Exit the Procedure return; } //If Current File is not found, exit the procedure if (File.Exists(CurrentTextFilePath) == false) { //Error Message MessageBox.Show("The Preview file cannt be found:" + Environment.NewLine + CurrentTextFilePath, "Validation Error", MessageBoxButton.OK, MessageBoxImage.Warning); //Exit the Procedure return; } //In case file is found if (CurrentTextFilePath != null) { #region Update Text Files //Get the full file path string filePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/FileNames/" + Path.GetFileNameWithoutExtension(CurrentTextFilePath) + ".txt"; //Check if file exists bool bExists = File.Exists(filePath); //Case file does not exists, create it! if (bExists == false) { System.IO.File.WriteAllText(filePath, CurrentTextFilePath); } ////Case File Exists //switch (bExists) //{ // //File Exists // case true: #region Update CurrentFile.txt //Open File string CurrentFile = System.IO.File.ReadAllText(Directory.GetCurrentDirectory() + "/StorageTextToolbox/FileNames/" + Path.GetFileNameWithoutExtension(CurrentTextFilePath) + ".txt"); //Write Text File: Current File System.IO.File.WriteAllText(Directory.GetCurrentDirectory() + "/StorageTextToolbox/CurrentFile.txt", CurrentFile); //Write Text File: IDText System.IO.File.WriteAllText(Directory.GetCurrentDirectory() + "/StorageTextToolbox/CurrentFileIDText.txt", MyIDText); #endregion //Get Current Text File CurrentFile = System.IO.File.ReadAllText(Directory.GetCurrentDirectory() + "/StorageTextToolbox/CurrentFile.txt"); //if (CurrentTextFilePath == DesignUtils.TrimFilePath(CurrentFile, Directory.GetCurrentDirectory())) //{ //this.btn.Background = new SolidColorBrush(Colors.DarkGreen); //Write to Text File: Updated done! System.IO.File.WriteAllText(Directory.GetCurrentDirectory() + "/StorageTextToolbox/CurrentFileUpdated.txt", "-1"); //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //If false create it if (File.Exists(FilePath) == false) { //Create File System.IO.File.WriteAllText(FilePath, ""); } //Update Text File Row Argument //Get Item from the ComboBox string MyEncoding = ReturnEncoding(); if (MyEncoding != null) { Encoding encoding = Utils.ConvertStringToEncoding(MyEncoding); MyArgument = "FileName"; DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, CurrentFile, encoding); } //Hide the Button btnWarning.Visibility = Visibility.Hidden; //} //else //{ // //this.btn.Background = new SolidColorBrush(Colors.IndianRed); //} //break; // //Case File does not exists // case false: // //Warning Message // MessageBox.Show("This funcionality is not available", "File does not exists", MessageBoxButton.OK, MessageBoxImage.Warning); // break; //} } #endregion else { //Error Message MessageBox.Show("Please select template file", "Select Text File", MessageBoxButton.OK, MessageBoxImage.Warning); } }
//Button Open Preview private void Button_OpenPreview(object sender, RoutedEventArgs e) { Encoding encoding = Encoding.Default; //Return IDText Parent string MyIDTextParent = DesignUtils.ReturnCurrentFileIDText(); //Get Encoding encoding = DesignUtils.GetEncodingIDText(MyIDTextParent); //Get the File Path string FilePath = Directory.GetCurrentDirectory() + "/StorageTextToolbox/Infos/" + MyIDText + ".txt"; //Lines Below MyArgument = "Lines Below"; string LinesAbove = ReturnLinesBelow(); if (LinesAbove != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, LinesAbove, encoding); } else { //Delete Argument in case it is null DesignUtils.DeleteTextFileRowArgument(FilePath, MyArgument, encoding); } //Number of Lines MyArgument = "Number of Lines"; string NumberofLines = ReturnNumberofLines(); if (NumberofLines != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, NumberofLines, encoding); } else { //Delete Argument in case it is null DesignUtils.DeleteTextFileRowArgument(FilePath, MyArgument, encoding); } //Anchor Words Parameter MyArgument = "Anchor Words Parameter"; string MyAnchorWordsParameter = ReturnAnchorTextParam(); if (MyAnchorWordsParameter != null) { //Update Text File Row Argument DesignUtils.CallUpdateTextFileRowArgument(FilePath, MyArgument, MyAnchorWordsParameter, encoding); } else { //Delete Argument in case it is null DesignUtils.DeleteTextFileRowArgument(FilePath, MyArgument, encoding); } #region Open Preview Extraction //Read Text File string Source = System.IO.File.ReadAllText(FilePath, encoding); //Check if all Parameters are in the File string[] searchWords = { "Anchor Words" + Utils.DefaultSeparator(), "Lines Below" + Utils.DefaultSeparator(), "Number of Lines" + Utils.DefaultSeparator(), "Anchor Words Parameter" + Utils.DefaultSeparator() }; double PercResults = Utils.FindWordsInString(Source, searchWords, false); //Case all Parameters are found if (PercResults == 1) { //Open Form Preview Extraction DesignUtils.CallformPreviewExtraction(MyIDText, "Extract Text Below Anchor Words", MyIDTextParent, encoding); } else { //Error Message MessageBox.Show("Please fill in all arguments", "Validation Error", MessageBoxButton.OK, MessageBoxImage.Error); } #endregion }