public async Task <bool> CheckAllFiles(string finalLanguage, string originalLanguage) { var pathes = new List <string>(); foreach (string path in Directory.EnumerateFiles(localPath, "*.html", SearchOption.AllDirectories)) { pathes.Add(path); } foreach (string path in pathes) { var words = HtmlParser.GetWordsFromFile(path); var translatedTexts = new List <TranslatedText>(); foreach (string word in words) { var translated = await Translator.Translate(word, finalLanguage, originalLanguage); translatedTexts.Add(translated); } FileEditor.ReplaceTextInFile(path, translatedTexts); } return(true); }
private void OnOpenFile() { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { System.IO.StreamReader openFile = new System.IO.StreamReader(openFileDialog1.FileName); FileEditor newFileEditor = new FileEditor(tabControl, openFileDialog1.FileName, openFileDialog1.SafeFileName, openFile.ReadToEnd()); if (currentFileEditor.IsNew() && (!currentFileEditor.IsDirty())) { int currentTabIndex = tabControl.SelectedIndex; currentFileEditor = newFileEditor; fileEditors[currentTabIndex] = newFileEditor; tabControl.SelectedTab.Text = openFileDialog1.SafeFileName; tabControl.SelectedTab.Controls.Clear(); tabControl.SelectedTab.Controls.Add(currentFileEditor.GetScintilla()); } else { TabPage newTab = new TabPage(openFileDialog1.SafeFileName); tabControl.TabPages.Add(newTab); currentFileEditor = newFileEditor; fileEditors.Add(newFileEditor); newTab.Controls.Add(currentFileEditor.GetScintilla()); tabControl.SelectTab(fileEditors.Count - 1); } openFile.Close(); } }
public static bool GetDataFromFile(out List <string[]> platformInput, out List <string[]> hazardInput, out List <string[]> checkpointInput) { platformInput = new List <string[]>(); hazardInput = new List <string[]>(); checkpointInput = new List <string[]>(); string filePath = FileEditor.GetFile(); if (filePath != null) { StreamReader reader = new StreamReader(filePath); string line = ""; while (!(line = reader.ReadLine()).Contains("|")) { platformInput.Add(line.Split(' ')); } while (!(line = reader.ReadLine()).Contains("|")) { hazardInput.Add(line.Split(' ')); } while ((line = reader.ReadLine()) != null) { checkpointInput.Add(line.Split(' ')); } return(true); } return(false); }
public FileEditor Post(FileEditor file) { UserProfile _user = AuthManager.CurrentUser; if (_user == null) { throw ExceptionResponse.Forbidden(Request, Messages.InvalidCredentials); } try { const string fileName = "Unititled"; return(EditorServices.Create(file?.Name ?? fileName, _user.Id)); } catch (NotFound ex) { throw ExceptionResponse.NotFound(Request, ex.Message); } catch (RequestForbidden ex) { throw ExceptionResponse.Forbidden(Request, ex.Message); } catch (Exception) { throw ExceptionResponse.ServerErrorResponse(Request); } }
private void OnNewWindow() { currentFileEditor = null; fileEditors = new ArrayList(); tabControl = new TabControl(); tabControl.Name = "tabControl"; tabControl.Selected += TabControl_Selected; tabControl.MouseUp += TabControl_MouseUp; menuStrip1.Dock = DockStyle.Top; tabControl.Dock = DockStyle.Fill; splitContainer1.Panel1.Controls.Add(tabControl); splitContainer1.Panel1.Controls.Add(menuStrip1); //Fixed the problem <- Can this line be avoided splitContainer2.Panel1.Controls.Add(tabControl); splitContainer2.Panel1.Controls.Add(menuStrip1); mnu = new ContextMenu(); mnuClose = new MenuItem("Close"); mnuClose.Click += new EventHandler(MnuClose_Click); mnu.MenuItems.AddRange(new MenuItem[] { mnuClose }); uploadButton.Enabled = false; stepButton.Enabled = false; breakPoints = new ArrayList(); if (!File.Exists(lastSessionName)) { OnNewFile(); } else { using (StreamReader reader = new StreamReader(lastSessionName)) { string line; while ((line = reader.ReadLine()) != null) { if (line.Equals("new tab")) { currentFileEditor = new FileEditor(tabControl); fileEditors.Add(currentFileEditor); TabPage newTab = new TabPage(currentFileEditor.ShortName()); tabControl.Controls.Add(newTab); newTab.Controls.Add(currentFileEditor.GetScintilla()); } else { if (File.Exists(line)) { currentFileEditor = new FileEditor(tabControl, line, line.Substring(line.LastIndexOf("\\") + 1), File.ReadAllText(line)); fileEditors.Add(currentFileEditor); TabPage newTab = new TabPage(currentFileEditor.ShortName()); tabControl.Controls.Add(newTab); newTab.Controls.Add(currentFileEditor.GetScintilla()); } } } } } port = 3002; Client client = new Client(address, port, this); }
/// <summary> /// Ассоциация расширений с редактором /// </summary> public static void Register() { Associations = new Dictionary <string, Type>(); ContentForms = new Dictionary <Type, Type>(); Extensions = new Dictionary <string, ExtensionInfo>(); List <FileCreator> creators = new List <FileCreator>(); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in assembly.GetTypes()) { // Поиск редакторов object[] attribs = type.GetCustomAttributes(typeof(FileEditor), false); if (attribs != null && attribs.Length > 0) { FileEditor ce = attribs[0] as FileEditor; // Сохранение формы ContentForms.Add(type, ce.Form); // Привязка к расширениям foreach (string ex in ce.Extensions) { if (!Associations.ContainsKey(ex)) { Associations.Add(ex, type); } } } // Поиск создаваемых файлов if (type.IsSubclassOf(typeof(Editor))) { object obj = Activator.CreateInstance(type); FileCreator[] fc = (FileCreator[])type.GetProperty("CreatingFiles").GetValue(obj, null); if (fc != null && fc.Length > 0) { creators.AddRange(fc); } // Поиск описания расширений ExtensionInfo[] exinf = (ExtensionInfo[])type.GetProperty("FileExtensionsInfo").GetValue(obj, null); if (exinf != null && exinf.Length > 0) { foreach (ExtensionInfo ex in exinf) { string exs = ex.Extension.ToLower(); if (Extensions.ContainsKey(exs)) { Extensions.Add(exs, ex); } } } } } } creators.Sort((x, y) => x.Order.CompareTo(y.Order)); CreatableList = creators.ToArray(); }
async Task <string> ed(string command) { string result = " "; string name = ""; Folder parent = CurrentFolder; if (command.Substring(3) == "") { return("No File Name"); } else { name = command.Substring(3); } // Check the existence of the File bool IsExist = await ICheckFileExist(name, parent.iFolder); if (IsExist) { foreach (File file in parent.Files) { if (file.Name == name) { FileEditor.Text = await IReadFile(file.iFile); CurrentFile = file; break; } } } else { File file = new File() { Name = name, Parent = parent }; file.iFile = await ICreateFile(file, parent.iFolder); parent.Files.Add(file); CurrentFile = file; } FileEditorTitle.Text = "File Name: " + CurrentFile.Name; FileEditorGrid.IsVisible = true; // Editor.Focus() doesn't work due to timing probelm(?), // so maake it into Timer Device.StartTimer(TimeSpan.FromMilliseconds(1), () => { FileEditor.Focus(); return(false); // Timer Cycle is only one time }); return(result); }
public void TestReadFile() { string path = "C:/Users/nicol/Documents/Graduate Classes/SSE 554/testRead.txt"; MathProblemSolver.FileEditor myEditor = new FileEditor(path); List <string> lines = myEditor.readEntireFile(); Assert.AreEqual(lines[0], "This is a test."); }
static void Main(string[] args) { FileEditor.Open(); for (; ;) { SelectAction(); } }
public void FileEditor_Should_CreateElement_When_ResolveEditor() { var source = new object(); var editor = new FileEditor(); var element = editor.CreateElement(source); Assert.IsNotNull(element); }
private void OnNewFile() { currentFileEditor = new FileEditor(tabControl); fileEditors.Add(currentFileEditor); TabPage newTab = new TabPage(currentFileEditor.ShortName()); tabControl.TabPages.Add(newTab); newTab.Controls.Add(currentFileEditor.GetScintilla()); tabControl.SelectTab(fileEditors.Count - 1); }
public void TestWriteLineToFile() { string path = "C:/Users/nicol/Documents/Graduate Classes/SSE 554/test.txt"; FileEditor myEditor = new FileEditor(path); string testSentence = "Test sentence."; myEditor.writeLineToFile(testSentence); List <string> lines = myEditor.readEntireFile(); Assert.AreEqual(lines[lines.Count - 1], "Test sentence."); }
public void SaveToFile() { string output = ConvertTilemap(platformTilemap); output += "|" + Environment.NewLine; output += ConvertTilemap(hazardTilemap); output += "|" + Environment.NewLine; output += ConvertGameObjects(); FileEditor.SaveString(output); }
public void LoadLastFile() { dataLoaded = FileEditor.GetLastData(out platformInput, out hazardInput, out checkpointInput); if (dataLoaded) { ClearMap(); LoadInTiles(platformInput, hazardInput, checkpointInput); Debug.Log("Load Completed"); } }
public void LoadFromFile() // TODO - build out method to get all tiletypes procedurally { dataLoaded = FileEditor.GetDataFromFile(out platformInput, out hazardInput, out checkpointInput); if (dataLoaded) { ClearMap(); LoadInTiles(platformInput, hazardInput, checkpointInput); Debug.Log("Load Completed"); } }
private void CloseTab() { bool success = true; int currentTabIndex = tabControl.SelectedIndex; currentFileEditor = (FileEditor)fileEditors[currentTabIndex]; if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { success = SaveAs(); } else if (result == DialogResult.Cancel) { success = false; } } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Save(currentFileEditor.Path()); } else if (result == DialogResult.Cancel) { success = false; } } } if (success) { if (tabControl.TabCount == 1) { System.Environment.Exit(0); } else { fileEditors.RemoveAt(currentTabIndex); tabControl.SelectedTab.Dispose(); if (currentTabIndex == tabControl.TabCount) { tabControl.SelectTab(currentTabIndex - 1); } else { tabControl.SelectTab(currentTabIndex); } } } }
public void TestWriteMultipleLinesToFile() { string path = "C:/Users/nicol/Documents/Graduate Classes/SSE 554/test.txt"; FileEditor myEditor = new FileEditor(path); List <string> testSentences = new List <string>(); testSentences.Add("Bow ties are cool."); testSentences.Add("Yer a wizard, Harry!"); testSentences.Add("That's no moon..."); testSentences.Add("It is a truth universally acknowledged"); myEditor.writeMultipleLinesToFile(testSentences.ToArray()); List <string> lines = myEditor.readEntireFile(); Assert.AreEqual(lines.[lines.Count - 1], "It is a truth universally acknowledged");
private TabPage CreateNewTabPage(AssemblyFileViewModel viewModel) { var newTab = new TabPage(); newTab.DataBindings.Add(new Binding(nameof(newTab.Text), viewModel, nameof(viewModel.FileName))); var tabContent = new FileEditor(viewModel, m_Preferences) { Dock = DockStyle.Fill }; newTab.Controls.Add(tabContent); AreAnyFilesOpened = (m_EditorVm.AllOpenFiles.Count > 0); return(newTab); }
private void TabControl_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { for (int i = 0; i < tabControl.TabCount; i++) { Rectangle r = tabControl.GetTabRect(i); if (r.Contains(e.Location)) { currentFileEditor = (FileEditor)fileEditors[i]; tabControl.SelectTab(i); mnu.Show(tabControl, e.Location); } } } }
public void FileEditor_Button_Should_OpenFileDialog() { var source = new object(); var editor = new FileEditor(); var element = editor.CreateElement(source); var grid = element as Grid; foreach (var child in grid.Children) { if (child is Button button) { button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button)); } } }
public void TestSomethingWrittenInOutput() { FileEditor editor = new FileEditor("text1.txt", "solution.txt"); editor.presentResults(); FileInfo info = new FileInfo("solution.txt"); long size = info.Length; if (size > 0) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
private bool CloseFile() { int i = 0; while (i < tabControl.TabCount) { currentFileEditor = (FileEditor)fileEditors[i]; tabControl.SelectTab(i); if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save this file?", "Saving new file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (SaveAs() == false) { return(false); } } else if (result == DialogResult.Cancel) { return(false); } } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Save(currentFileEditor.Path()); } else if (result == DialogResult.Cancel) { return(false); } } } i++; } saveSession(); return(true); }
// Pop up the file editor string ed(string command) { string result = " "; string name = ""; if (command.Substring(3) == "") { return("No File Name"); } else { name = command.Substring(3); } // Check the existence of the File bool IsExist = File.Exists(WorkingDir + name); if (IsExist) // Get all text of the file { FileEditor.Text = File.ReadAllText(WorkingDir + name); OriginalFile = FileEditor.Text; } else // If no file, create a new file { //File.Create(name).Close(); File.Create(name); FileEditor.Text = ""; } FileEditorTitle.Text = "File Name: " + name; FileEditorGrid.IsVisible = true; // Make the file editor visible // Editor.Focus() doesn't work due to timing probelm(?), // so maake it into Timer Device.StartTimer(TimeSpan.FromMilliseconds(1), () => { FileEditor.Focus(); return(false); // Timer Cycle is only one time }); return(result); }
private bool CloseFile() { int i = 0; while (i < tabControl.TabCount) { currentFileEditor = (FileEditor)fileEditors[i]; tabControl.SelectTab(i); if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save this file?", "Saving new file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (SaveAs() == false) return false; } else if (result == DialogResult.Cancel) return false; } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) Save(currentFileEditor.Path()); else if (result == DialogResult.Cancel) return false; } } i++; } saveSession (); return true; }
public void SetEditorControl(FileEditor editorControl) { MainContent.Children.Clear(); MainContent.Children.Add(editorControl); }
private void CloseTab() { bool success = true; int currentTabIndex = tabControl.SelectedIndex; currentFileEditor = (FileEditor)fileEditors[currentTabIndex]; if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) success = SaveAs(); else if (result == DialogResult.Cancel) success = false; } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) Save(currentFileEditor.Path()); else if (result == DialogResult.Cancel) success = false; } } if (success) { if (tabControl.TabCount == 1) System.Environment.Exit(0); else { fileEditors.RemoveAt(currentTabIndex); tabControl.SelectedTab.Dispose(); if (currentTabIndex == tabControl.TabCount) { tabControl.SelectTab(currentTabIndex - 1); } else tabControl.SelectTab(currentTabIndex); } } }
private void OnNewFile() { currentFileEditor = new FileEditor (tabControl); fileEditors.Add (currentFileEditor); TabPage newTab = new TabPage (currentFileEditor.ShortName ()); tabControl.TabPages.Add (newTab); newTab.Controls.Add (currentFileEditor.GetScintilla ()); tabControl.SelectTab (fileEditors.Count - 1); }
private void OnNewWindow() { currentFileEditor = null; fileEditors = new ArrayList(); tabControl = new TabControl(); tabControl.Name = "tabControl"; tabControl.Selected += TabControl_Selected; tabControl.MouseUp += TabControl_MouseUp; menuStrip1.Dock = DockStyle.Top; tabControl.Dock = DockStyle.Fill; splitContainer1.Panel1.Controls.Add(tabControl); splitContainer1.Panel1.Controls.Add(menuStrip1); //Fixed the problem <- Can this line be avoided splitContainer2.Panel1.Controls.Add(tabControl); splitContainer2.Panel1.Controls.Add(menuStrip1); mnu = new ContextMenu(); mnuClose = new MenuItem("Close"); mnuClose.Click += new EventHandler(MnuClose_Click); mnu.MenuItems.AddRange(new MenuItem[] { mnuClose }); uploadButton.Enabled = false; stepButton.Enabled = false; breakPoints = new ArrayList(); if (!File.Exists (lastSessionName)) OnNewFile (); else { using (StreamReader reader = new StreamReader (lastSessionName)) { string line; while ((line = reader.ReadLine ()) != null) { if (line.Equals ("new tab")) { currentFileEditor = new FileEditor (tabControl); fileEditors.Add (currentFileEditor); TabPage newTab = new TabPage (currentFileEditor.ShortName ()); tabControl.Controls.Add (newTab); newTab.Controls.Add (currentFileEditor.GetScintilla ()); } else { if (File.Exists (line)) { currentFileEditor = new FileEditor (tabControl, line, line.Substring (line.LastIndexOf ("\\") + 1), File.ReadAllText (line)); fileEditors.Add (currentFileEditor); TabPage newTab = new TabPage (currentFileEditor.ShortName ()); tabControl.Controls.Add (newTab); newTab.Controls.Add (currentFileEditor.GetScintilla ()); } } } } } port = 3002; Client client = new Client(address, port, this); }
private void TabControl_Selected(object sender, TabControlEventArgs e) { currentFileEditor = (FileEditor)fileEditors[tabControl.SelectedIndex]; }
// PUT api/<controller>/5 public void Put(int emailId, [FromBody] FileEditor editor, Permission type) { }
// POST api/<controller> public void Post([FromBody] FileEditor editor, Dictionary <string, Permission> keyValuePairs) { }
public DmiEXSizeChangeUndoItem(FileEditor fileEditor) { _fileEditor = fileEditor; _dmiEx = (DmiEX)fileEditor.DmiEx.Clone(); }
public FileEditorTest(FileEditor fileEditor) { this.fileEditor = fileEditor; }
public OpenEditorFile(string path, FileEditor editor) { FilePath = path; Editor = editor; }