private void MainForm_Load(object sender, EventArgs e) { var menuItems = new List<ToolStripMenuItem>(); var processors = new CstGenerator[] { CstGenerators.JavaUsingAntlr3, CstGenerators.CSharpUsingAntlr3, CstGenerators.JavaScriptUsingAntlr3, CstGenerators.Python2, CstGenerators.PhpUsingAntlr3, CstGenerators.LuaUsingAntlr3, }; foreach (var processor in processors) { var menuItem = menuItemLanguage.DropDownItems.Add(processor.LanguageNameWithVersion) as ToolStripMenuItem; menuItems.Add(menuItem); var processorForClosure = processor; menuItem.Click += (o, args) => { _activeProcessor = processorForClosure; foreach (var item in menuItems) { item.Checked = false; } menuItem.Checked = true; Code = ""; _activeFile = null; lvModifiableFile.Items.Clear(); lvFreezedFile.Items.Clear(); lvModifiableRule.Items.Clear(); lvFreezedRule.Items.Clear(); lvWillBeMarkedElements.Items.Clear(); lvMarkedElements.Items.Clear(); }; // Set default processor if (processor is JavaCstGeneratorUsingAntlr3) { menuItem.PerformClick(); } } InitializeModeMenu(); }
private void ChangeActiveFile(CodeFile activeFile) { _activeFile = activeFile; Code = _activeFile.Code; RedrawActiveFile(); var rule = InferRule(); var range2Elements = rule.ExtractRange2Elements(_activeFile.Ast); DrawMarkers(range2Elements, 2); ListElements(range2Elements, lvWillBeMarkedElements); btnApply.Enabled = CanApplyThis(range2Elements); azuki.ContextMenuStrip = _activeFile.ReadOnly ? null : contextMenuStrip; }
public FileListViewItem(CodeFile file) : base(file.Info.Name, file.Info.FullName) { File = file; }
private void azuki_DragDrop(object sender, DragEventArgs e) { var paths = (string[])e.Data.GetData(DataFormats.FileDrop, false); var count = lvModifiableFile.Items.Count; var filePaths = paths.SelectMany( path => Directory.Exists(path) ? Directory.EnumerateFiles( path, "*", SearchOption.AllDirectories) .Where( filePath => _activeProcessor.SupportedExtensions .Contains( Path.GetExtension( filePath))) : Enumerable.Repeat(path, 1)); foreach (var filePath in filePaths) { var file = new FileInfo(filePath); var codeFile = new CodeFile(_activeProcessor, file); var item = new FileListViewItem(codeFile); lvModifiableFile.Items.Add(item); } lvModifiableFile.Items[count].Selected = true; }