internal void AddNewFile(string fileName)
        {
            TreeNodeAdv parent = projViewer.SelectedNode;

            if (parent == null)
            {
                //parent = projViewer.Nodes[0];
            }
            else if (parent.Tag is ProjectFile)
            {
                parent = parent.Parent;
            }

            if (parent == null)
            {
                parent = projViewer.Root.Children.First();
            }

            FilePath file = _projectService.Project.ProjectDirectory.Combine(fileName);

            using (StreamWriter writer = File.CreateText(file))
            {
                writer.Close();
            }

            AddFile(file, (ProjectFolder)parent.Tag);
            AbstractUiAction.RunCommand(new OpenFileAction(file));
        }
示例#2
0
        private void gotoCurrentToolButton_Click(object sender, EventArgs e)
        {
            IWabbitcodeDebugger debugger = _debuggerService.CurrentDebugger;
            DocumentLocation    location = debugger.GetAddressLocation(debugger.CPU.PC);

            AbstractUiAction.RunCommand(new GotoLineAction(location));
        }
示例#3
0
        private void okButton_Click(object sender, EventArgs e)
        {
            string symbolString = inputBox.Text;

            Close();
            AbstractUiAction.RunCommand(new GotoDefinitionAction(new FilePath(string.Empty), symbolString, 0));
        }
        private void OpenNode(TreeNodeAdv dropNode)
        {
            if (dropNode == null || dropNode.Tag is ProjectFolder || !projViewer.SelectedNodes.Contains(dropNode))
            {
                return;
            }

            ProjectFile file = dropNode.Tag as ProjectFile;

            Debug.Assert(file != null, "file != null");

            FilePath filePath = file.FileFullPath;

            if (File.Exists(filePath))
            {
                AbstractUiAction.RunCommand(new OpenFileAction(filePath));
            }
            else
            {
                if (MessageBox.Show("File no longer exists, would you like to remove from project?",
                                    "File Not Found", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                ProjectFolder folder = file.Folder;
                folder.DeleteFile(file);
                _model.OnNodesChanged(folder);
            }
        }
示例#5
0
        private void gotoMenuItem_Click(object sender, EventArgs e)
        {
            int      row  = errorGridView.SelectedRows[0].Index;
            int      line = (int)errorGridView.Rows[row].Cells[4].Value;
            FilePath file = (FilePath)errorGridView.Rows[row].Cells[3].Tag;

            AbstractUiAction.RunCommand(new GotoLineAction(file, line));
        }
示例#6
0
        public IDocument GetOpenDocument(FilePath fileName)
        {
            if (_openDocuments.ContainsKey(fileName))
            {
                return(_openDocuments[fileName]);
            }

            AbstractUiAction.RunCommand(new OpenFileAction(fileName));
            return(_openDocuments[fileName]);
        }
示例#7
0
        private void callStackView_DoubleClick(object sender, EventArgs e)
        {
            if (callStackView.SelectedRows.Count == 0)
            {
                return;
            }

            DocumentLocation location = _callLocations[callStackView.SelectedRows[0].Index];

            AbstractUiAction.RunCommand(new GotoLineAction(location));
        }
        private static void fixCaseContext_Click(object sender, EventArgs e)
        {
            MenuItem item = sender as MenuItem;

            if (item == null)
            {
                return;
            }

            AbstractUiAction.RunCommand(new FixCaseAction(item.Text));
        }
示例#9
0
        private static void HandleArgs(ICollection <string> args)
        {
            if (args.Count == 0)
            {
                return;
            }

            AbstractUiAction.RunCommand(new OpenFileAction(args
                                                           .Where(arg => !string.IsNullOrEmpty(arg))
                                                           .Select(arg => new FilePath(arg))
                                                           .ToArray()));
        }
示例#10
0
        private void gotoSourceMenuItem_Click(object sender, EventArgs e)
        {
            ContextMenu menu = ((MenuItem)sender).GetContextMenu();

            if (menu == null)
            {
                return;
            }
            TextBox          box      = (TextBox)menu.SourceControl;
            ushort           address  = ushort.Parse(box.Text, System.Globalization.NumberStyles.HexNumber);
            DocumentLocation location = _debugger.GetAddressLocation(address);

            AbstractUiAction.RunCommand(new GotoLineAction(location));
        }
示例#11
0
        private void stackView_DoubleClick(object sender, EventArgs e)
        {
            if (stackView.SelectedRows.Count == 0)
            {
                return;
            }

            string stackValue = stackView.SelectedRows[0].Cells[StackDataColIndex].Value.ToString();

            stackValue = stackValue.TrimStart().Substring(0, 4);
            ushort           address  = ushort.Parse(stackValue, NumberStyles.HexNumber);
            DocumentLocation location = _debugger.GetAddressLocation(address);

            AbstractUiAction.RunCommand(new GotoLineAction(location));
        }
示例#12
0
        private void errorGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            int      line = (int)errorGridView.Rows[e.RowIndex].Cells[4].Value;
            FilePath file = (FilePath)errorGridView.Rows[e.RowIndex].Cells[3].Tag;

            if (file != FcreateFile)
            {
                AbstractUiAction.RunCommand(new GotoLineAction(file, line - 1));
            }
        }
示例#13
0
        private void findResultsBox_DoubleClick(object sender, EventArgs e)
        {
            int    line         = findResultsBox.GetLineFromCharIndex(findResultsBox.SelectionStart);
            string lineContents = findResultsBox.Lines[line];
            Match  match        = Regex.Match(lineContents, @"(?<fileName>.+) \((?<lineNum>\d+)\): (?<line>.+)");

            if (!match.Success)
            {
                return;
            }

            FilePath file = new FilePath(match.Groups["fileName"].Value);

            line = Convert.ToInt32(match.Groups["lineNum"].Value);
            AbstractUiAction.RunCommand(new GotoLineAction(file, line - 1));
        }
示例#14
0
        private void fixMenuItem_Click(object sender, EventArgs e)
        {
            int      row   = errorGridView.SelectedRows[0].Index;
            int      line  = (int)errorGridView.Rows[row].Cells[4].Value;
            FilePath file  = (FilePath)errorGridView.Rows[row].Cells[3].Tag;
            string   error = errorGridView.Rows[row].Cells[2].Value.ToString();

            AbstractUiAction.RunCommand(new GotoLineAction(file, line - 1));
            if (!error.Contains("Relative jump"))
            {
                return;
            }

            // TODO: look at
            //_documentService.ActiveDocument.FixError(line, DocumentService.FixableErrorType.RelativeJump);
            errorGridView.Rows.RemoveAt(row);
        }
示例#15
0
        private void CurrentDebugger_DebuggerStep(object sender, DebuggerStepEventArgs e)
        {
            _dockingService.DockPanel.BeginInvoke(() =>
            {
                ITextEditor editor = _dockingService.ActiveDocument as ITextEditor;
                if (editor != null)
                {
                    editor.RemoveDebugHighlight();
                }

                AbstractUiAction.RunCommand(new GotoLineAction(e.Location.FileName, e.Location.LineNumber - 1));

                editor = _dockingService.ActiveDocument as ITextEditor;
                if (editor != null)
                {
                    editor.HighlightDebugLine(e.Location.LineNumber - 1);
                }
            });
        }
示例#16
0
        private IDockContent GetContentFromPersistString(string persistString)
        {
            string[] parsedStrings = persistString.Split(';');
            Type     type          = Type.GetType(parsedStrings[0]);

            if (type == null)
            {
                return(null);
            }

            if (typeof(ToolWindow).IsAssignableFrom(type))
            {
                ToolWindow window = _dockingService.GetDockingWindow(type);
                if (window != null)
                {
                    return(window);
                }
            }

            if (parsedStrings.Length < 2 || !typeof(AbstractFileEditor).IsAssignableFrom(type))
            {
                return(null);
            }

            FilePath fileName = new FilePath(parsedStrings[1]);

            if (!File.Exists(fileName))
            {
                return(null);
            }

            AbstractUiAction.RunCommand(new OpenFileAction(fileName));
            var doc = _dockingService.Documents.OfType <AbstractFileEditor>()
                      .FirstOrDefault(d => fileName == d.FileName);

            if (doc == null)
            {
                return(null);
            }

            doc.PersistStringLoad(parsedStrings);
            return(doc);
        }
示例#17
0
        protected override void SaveFileInner()
        {
            if (string.IsNullOrEmpty(FileName))
            {
                AbstractUiAction.RunCommand(new SaveAsCommand(this));
                return;
            }

            _stackTop = editorBox.Document.UndoStack.UndoItemCount;
            try
            {
                editorBox.SaveFile(FileName);
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Error saving the file", ex);
            }

            editorBox.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(FileName);
        }
示例#18
0
        private void MainFormRedone_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_debuggerService.CurrentDebugger != null)
            {
                AbstractUiAction.RunCommand(new StopDebuggerAction());
            }

            if (!_projectService.Project.IsInternal)
            {
                AbstractUiAction.RunCommand(new CloseProjectAction());
            }

            _pluginService.UnloadPlugins();

            try
            {
                SaveWindow();
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Error saving window location", ex);
            }

            try
            {
                _dockingService.SavePanels();
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Error destroying DockService", ex);
            }

            try
            {
                Settings.Default.Save();
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Error saving configuration file", ex);
            }
        }
示例#19
0
        private void outputWindowBox_DoubleClick(object sender, EventArgs e)
        {
            // file:line:error code:description
            // SPASM uses the format %s:%d: %s %s%03X: %s currently
            int errorLineOffset =
                outputWindowBox.ActiveTextAreaControl.SelectionManager.SelectionCollection.First().Offset;
            int    errorLine    = outputWindowBox.Document.GetLineNumberForOffset(errorLineOffset);
            var    segment      = outputWindowBox.Document.GetLineSegment(errorLine);
            string lineContents = outputWindowBox.Document.GetText(segment);
            Match  match        = Regex.Match(lineContents, @"(?<fileName>.+):(?<lineNum>\d+): (?<errorCode>.+): (?<description>.+)");

            if (!match.Success)
            {
                return;
            }

            FilePath file       = new FilePath(match.Groups["fileName"].Value);
            int      lineNumber = Convert.ToInt32(match.Groups["lineNum"].Value);

            AbstractUiAction.RunCommand(new GotoLineAction(file, lineNumber - 1));
        }
示例#20
0
        private void editorBox_MouseClick(object sender, MouseEventArgs e)
        {
            if ((Control.ModifierKeys & Keys.Control) == 0)
            {
                return;
            }

            var location = GetWordUnderCursor(e.Location);
            var textWord = GetTextWordAtLocation(location);

            if (textWord == null)
            {
                return;
            }

            string   text     = textWord.Word;
            FilePath filePath = new FilePath(_editor.FileName);

            AbstractUiAction.RunCommand(new GotoDefinitionAction(filePath, text, location.Line));
            RemoveCurrentMarker();
        }
示例#21
0
        private void okButton_Click(object sender, EventArgs e)
        {
            int lineNum;

            if (!int.TryParse(lineBox.Text, out lineNum))
            {
                return;
            }

            lineNum--;
            FilePath fileName = new FilePath(fileBox.Text);

            if (File.Exists(fileName))
            {
                AbstractUiAction.RunCommand(new GotoFileAction(fileName));
            }
            else
            {
                DockingService.ShowError("File doesn't exist!");
                return;
            }

            WabbitcodeBreakpointManager.AddBreakpoint(fileName, lineNum);
        }
        private void gotoButton_Click(object sender, EventArgs e)
        {
            int    lineNum   = _editor.ActiveTextAreaControl.Caret.Line;
            string line      = _editor.GetLineText(lineNum);
            Match  match     = IncludeRegex.Match(line);
            bool   isInclude = match.Success;

            bool     shouldEnableButton;
            var      gotoLabel = GetParsedLabelFromLine(isInclude, match, line, out shouldEnableButton);
            FilePath text      = new FilePath(gotoLabel);

            if (isInclude)
            {
                FilePath fileFullPath = Path.IsPathRooted(text) ? text :
                                        _projectService.Project.GetFilePathFromRelativePath(text).NormalizePath();
                AbstractUiAction.RunCommand(new GotoFileAction(fileFullPath));
            }
            else
            {
                FilePath filePath   = new FilePath(_editor.FileName);
                int      lineNumber = _editor.ActiveTextAreaControl.Caret.Line;
                AbstractUiAction.RunCommand(new GotoDefinitionAction(filePath, text, lineNumber));
            }
        }
        private void okTemplate_Click(object sender, EventArgs e)
        {
            FilePath projectDir  = new FilePath(locTextBox.Text.Trim());
            string   projectName = nameTextBox.Text.Trim();
            var      listBox     = (ListBox)tabControl.SelectedTab.Controls["templatesBox"];

            if (listBox.SelectedItem == null)
            {
                DockingService.ShowError("You must select an output type for this project");
                _cancelQuit = true;
                return;
            }

            var    item      = (ProjectItemModel)listBox.SelectedItem;
            string outputExt = item.Ext;

            if (string.IsNullOrEmpty(projectDir))
            {
                DockingService.ShowError("Project directory cannot be empty. Please specify a path for your project");
                _cancelQuit = true;
                return;
            }

            if (string.IsNullOrEmpty(projectName))
            {
                DockingService.ShowError("Project name cannot be empty. Please enter a name for your project");
                _cancelQuit = true;
                return;
            }

            _cancelQuit = false;
            if (!projFromDirBox.Checked)
            {
                projectDir = projectDir.Combine(projectName);
            }

            string projectFile = Path.Combine(projectDir, projectName) + ".wcodeproj";

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

            _projectService.CreateNewProject(new FilePath(projectFile), projectName);

            var folder = _projectService.Project.MainFolder;

            if (projFromDirBox.Checked)
            {
                GetFiles(projectDir, fileTypesBox.Text, ref folder);
            }
            else
            {
                FilePath mainFile = new FilePath(Path.Combine(projectDir, projectName + ".asm"));
                FilePath iconFile = new FilePath(Path.Combine(projectDir, "icon.bmp"));
                try
                {
                    File.Copy(item.File, mainFile);
                }
                catch (IOException ex)
                {
                    if (ex.Message.Contains("exists"))
                    {
                        if (MessageBox.Show("'" + projectName + ".asm'  already exists. Overwrite?", "Error", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.None) == DialogResult.Yes)
                        {
                            File.Copy(item.File, mainFile, true);
                        }
                    }
                }

                try
                {
                    if (item.UsesIcon)
                    {
                        File.Copy(Path.Combine(FileLocations.TemplatesDir, "Icon.bmp"), iconFile);
                        _projectService.AddFile(folder, iconFile);
                    }
                }
                catch (IOException ex)
                {
                    Logger.Log("Icon already exists", ex);
                }

                _projectService.AddFile(folder, mainFile);
                AbstractUiAction.RunCommand(new OpenFileAction(mainFile));
            }

            _projectService.Project.IncludeDirs.Add(FileLocations.IncludesDir);
            var debugConfig   = _projectService.Project.BuildSystem.BuildConfigs.Single(c => c.Name == "Debug");
            var releaseConfig = _projectService.Project.BuildSystem.BuildConfigs.Single(c => c.Name == "Release");

            debugConfig.AddStep(new InternalBuildStep(0,
                                                      BuildStepType.All,
                                                      projectDir.Combine(projectName + ".asm"),
                                                      projectDir.Combine(projectName + outputExt)));
            releaseConfig.AddStep(new InternalBuildStep(0,
                                                        BuildStepType.Assemble,
                                                        projectDir.Combine(projectName + ".asm"),
                                                        projectDir.Combine(projectName + outputExt)));
            _projectService.SaveProject();
            Close();
        }
示例#24
0
 private static void restartToolStripButton_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new RestartDebuggerAction());
 }
示例#25
0
 private static void pauseToolButton_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new PauseDebuggerAction());
 }
示例#26
0
 private static void prefsMenuItem_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new EditPreferencesAction());
 }
示例#27
0
 private static void gLineMenuItem_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new GotoLineAction());
 }
示例#28
0
 private void toggleBookmarkMenuItem_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new ToggleBookmark());
 }
示例#29
0
 private static void nextBookmarkMenuItem_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new GotoNextBookmark());
 }
示例#30
0
 private static void stepOutToolButton_Click(object sender, EventArgs e)
 {
     AbstractUiAction.RunCommand(new StepOutDebuggerAction());
 }