Ejemplo n.º 1
0
        public void ShowErrorTest()
        {
            string error = string.Empty;             // TODO: Initialize to an appropriate value

            DockingService.ShowError(error);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
        private void okButton_Click(object sender, EventArgs e)
        {
            var refs = _projectService.FindAllReferences(_extractedMethod);

            foreach (var file in refs)
            {
                string fileName = file.First().File;

                TextEditorControl editor = new WabbitcodeTextEditor();
                editor.LoadFile(fileName);

                foreach (var reference in file)
                {
                    int offset = editor.Document.GetOffsetForLineNumber(reference.Line) + reference.Col;
                    int len    = reference.ReferenceString.Length;
                    editor.Document.Replace(offset, len, nameBox.Text);
                }

                try
                {
                    editor.SaveFile(fileName);
                }
                catch (Exception ex)
                {
                    DockingService.ShowError("Error saving refactor", ex);
                }
            }
        }
Ejemplo n.º 3
0
        protected override void Execute()
        {
            if (_fileNames == null)
            {
                if (!ShowDialog())
                {
                    return;
                }

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

            foreach (var fileName in _fileNames)
            {
                try
                {
                    if (!_fileTypeMethodFactory.OpenRegisteredFile(fileName))
                    {
                        throw new IOException("Opening file failed");
                    }
                }
                catch (IOException ex)
                {
                    DockingService.ShowError("Error opening file", ex);
                }
            }
        }
Ejemplo n.º 4
0
        protected override void Execute()
        {
            FilePath fileName;

            using (OpenFileDialog openFileDialog = new OpenFileDialog
            {
                CheckFileExists = true,
                DefaultExt = "*.wcodeproj",
                Filter = "Project Files (*.wcodeproj)|*.wcodeproj|All Files(*.*)|*.*",
                FilterIndex = 0,
                RestoreDirectory = true,
                Title = "Open Project File",
            })
            {
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                fileName = new FilePath(openFileDialog.FileName);
            }

            try
            {
                if (!_projectService.OpenProject(fileName))
                {
                    _projectService.CreateInternalProject();
                }
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Error opening file.", ex);
            }
        }
Ejemplo n.º 5
0
 protected override void Execute()
 {
     try
     {
         _editor.SaveFile();
     }
     catch (Exception ex)
     {
         DockingService.ShowError("Error saving file.", ex);
     }
 }
Ejemplo n.º 6
0
 private void RestoreWindow()
 {
     try
     {
         WindowState = Settings.Default.WindowState;
         Size        = Settings.Default.WindowSize;
     }
     catch (Exception ex)
     {
         DockingService.ShowError("Error restoring the window size", ex);
     }
 }
Ejemplo n.º 7
0
        internal static void InitFiles()
        {
            try
            {
                if (!File.Exists(SpasmFile))
                {
                    Resources.Resources.GetResource("spasm.exe", SpasmFile);
                }

                if (!File.Exists(WabbitemuFile))
                {
                    Resources.Resources.GetResource("Wabbitemu.exe", WabbitemuFile);
                }
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Unable to initialize files", ex);
            }
        }
Ejemplo n.º 8
0
        internal static void InitDirs()
        {
            if (!Settings.Default.CreateFolders)
            {
                return;
            }

            try
            {
                Directory.CreateDirectory(WabbitcodeFolder);
                Directory.CreateDirectory(TemplatesDir);
                Directory.CreateDirectory(IncludesDir);
                Directory.CreateDirectory(ProjectsDir);
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Unable to create directories", ex);
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
0
        private void LoadStartupProject()
        {
            if (string.IsNullOrEmpty(Settings.Default.StartupProject))
            {
                return;
            }

            try
            {
                bool valid = false;
                if (File.Exists(Settings.Default.StartupProject))
                {
                    valid = _projectService.OpenProject(new FilePath(Settings.Default.StartupProject));
                }
                else
                {
                    Settings.Default.StartupProject = string.Empty;
                    DockingService.ShowError("Error: Project file not found");
                }

                if (_projectService.Project.IsInternal || !valid)
                {
                    _projectService.CreateInternalProject();
                }
            }
            catch (Exception ex)
            {
                _projectService.CreateInternalProject();
                var result = MessageBox.Show(
                    "There was an error loading the startup project, would you like to remove it?\n" + ex,
                    "Error",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    Settings.Default.StartupProject = string.Empty;
                }
            }
        }
Ejemplo n.º 12
0
        private static void Main(string[] args)
        {
            try
            {
                if (Settings.Default.FirstRun)
                {
                    Settings.Default.Upgrade();
                    Settings.Default.FirstRun = false;
                    Settings.Default.Save();
                }
            }
            catch (ConfigurationErrorsException ex)
            {
                DockingService.ShowError("Error upgrading settings", ex);
            }

            Application.EnableVisualStyles();

            DockPanel          panel              = new WabbitcodeDockPanel();
            StatusStrip        statusBar          = new WabbitcodeStatusBar();
            ToolStripContainer toolStripContainer = new WabbitcodeToolStripContainer(statusBar, panel);

            Task.Factory.StartNew(() => InitializeDependencies(panel, statusBar, toolStripContainer), TaskCreationOptions.PreferFairness);
            Task.Factory.StartNew(() =>
            {
                FileLocations.InitDirs();
                FileLocations.InitFiles();
                HighlightingUtils.MakeHighlightingFile();
            });

            Task.Factory.StartNew(() =>
            {
                if (!UpdateService.CheckForUpdate())
                {
                    return;
                }

                var result = MessageBox.Show("New version available. Download now?", "Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.None);
                if (result != DialogResult.Yes)
                {
                    return;
                }

                UpdateService.StartUpdater();
                Application.Exit();
            });

            int     numErrors = 0;
            AppBase appBase   = new AppBase(toolStripContainer);

#if !DEBUG
            try
            {
#endif
            appBase.Run(args);
#if !DEBUG
        }
        catch (Exception ex)
        {
            numErrors++;
            DockingService.ShowError("Unhandled exception occurred. Please report this to the developers", ex);
        }
#endif

            if (numErrors == 0)
            {
                return;
            }

            do
            {
                try
                {
                    appBase.DoEvents();
                }
                catch (Exception ex)
                {
                    numErrors++;
                    DockingService.ShowError("Unhandled exception occurred. Please report this to the developers", ex);
                }
            } while (numErrors < 5);
        }
Ejemplo n.º 13
0
        public static void MakeHighlightingFile()
        {
            string commentsColor = Settings.Default.CommentColor.ToHexString();

            string blockCommentsColor = Settings.Default.BlockCommentColor.ToHexString();
            string stringsColor       = Settings.Default.StringColor.ToHexString();
            string directivesColor    = Settings.Default.DirectiveColor.ToHexString();
            string preProcessorColor  = Settings.Default.PreProcessorColor.ToHexString();
            string opcodesColor       = Settings.Default.OpcodeColor.ToHexString();
            string registersColor     = Settings.Default.RegisterColor.ToHexString();
            string conditionsColor    = Settings.Default.ConditionColor.ToHexString();
            string labelsColor        = Settings.Default.LabelColor.ToHexString();

            if (!Settings.Default.CommentsEnabled)
            {
                commentsColor = "#000000";
            }

            if (!Settings.Default.BlockCommentEnabled)
            {
                blockCommentsColor = "#000000";
            }

            if (!Settings.Default.StringsEnabled)
            {
                stringsColor = "#000000";
            }

            if (!Settings.Default.DirectivesEnabled)
            {
                directivesColor = "#000000";
            }

            if (!Settings.Default.PreProcessorEnabled)
            {
                preProcessorColor = "#000000";
            }

            if (!Settings.Default.OpcodesEnabled)
            {
                opcodesColor = "#000000";
            }

            if (!Settings.Default.RegistersEnabled)
            {
                registersColor = "#000000";
            }

            if (!Settings.Default.ConditionsEnabled)
            {
                conditionsColor = "#000000";
            }

            if (!Settings.Default.LabelsEnabled)
            {
                labelsColor = "#000000";
            }

            try
            {
                XmlWriterSettings writerSettings = new XmlWriterSettings
                {
                    Encoding = Encoding.UTF8
                };

                XmlWriter writer = XmlWriter.Create(FileLocations.DefaultHighlightingFile, writerSettings);
                writer.WriteStartDocument();
                writer.WriteComment("Z80 Asm syntax highlighting file");
                writer.WriteStartElement("SyntaxDefinition");
                writer.WriteAttributeString("name", "Z80 Assembly");
                writer.WriteAttributeString("extensions", String.Join(";", Extensions));
                writer.WriteStartElement("Environment");
                writer.WriteStartElement("Custom");
                writer.WriteAttributeString("name", "TypeReference");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#04ABAB");
                writer.WriteEndElement();

                writer.WriteStartElement("Custom");
                writer.WriteAttributeString("name", "UnknownEntity");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#AB0404");
                writer.WriteEndElement();

                writer.WriteStartElement("Default");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "Black");
                writer.WriteAttributeString("bgcolor", "White");
                writer.WriteEndElement();

                writer.WriteStartElement("Selection");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "White");
                writer.WriteAttributeString("bgcolor", "#316AC5");
                writer.WriteEndElement();

                writer.WriteStartElement("VRuler");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#F1EFE2");
                writer.WriteAttributeString("bgcolor", "White");
                writer.WriteEndElement();

                writer.WriteStartElement("InvalidLines");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "Red");
                writer.WriteEndElement();

                writer.WriteStartElement("CaretMarker");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#FFFFCC");
                writer.WriteEndElement();

                writer.WriteStartElement("LineNumbers");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#ACA899");
                writer.WriteAttributeString("bgcolor", "White");
                writer.WriteEndElement();

                writer.WriteStartElement("FoldLine");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "Gray");
                writer.WriteAttributeString("bgcolor", "Black");
                writer.WriteEndElement();

                writer.WriteStartElement("SelectedFoldLine");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "Black");
                writer.WriteEndElement();

                writer.WriteStartElement("EOLMarkers");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#F1EFE2");
                writer.WriteAttributeString("bgcolor", "White");
                writer.WriteEndElement();

                writer.WriteStartElement("SpaceMarkers");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#F1EFE2");
                writer.WriteAttributeString("bgcolor", "White");
                writer.WriteEndElement();

                writer.WriteStartElement("TabMarkers");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "#F1EFE2");
                writer.WriteAttributeString("bgcolor", "White");
                writer.WriteEndElement();

                writer.WriteStartElement("FirstWord");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", labelsColor);
                writer.WriteEndElement();

                writer.WriteEndElement(); // </environment>

                writer.WriteStartElement("Properties");
                writer.WriteStartElement("Property");
                writer.WriteAttributeString("name", "LineComment");
                writer.WriteAttributeString("value", ";");
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteStartElement("Digits");
                writer.WriteAttributeString("name", "Digits");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("color", "DarkBlue");
                writer.WriteEndElement();

                writer.WriteStartElement("RuleSets");
                writer.WriteStartElement("RuleSet");
                writer.WriteAttributeString("ignorecase", "true");
                writer.WriteAttributeString("escapecharacter", "\\");

                writer.WriteElementString("Delimiters", "&<>~!%^*()-+=|\\/{}[]:;\"' ,	?");

                writer.WriteStartElement("Span");
                writer.WriteAttributeString("name", "DocLineComment");
                writer.WriteAttributeString("rule", "DocCommentSet");
                writer.WriteAttributeString("stopateol", "true");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", commentsColor);
                writer.WriteStartElement("Begin");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "Gray");
                writer.WriteString("///@!/@");
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteStartElement("Span");
                writer.WriteAttributeString("name", "LineComment");
                writer.WriteAttributeString("stopateol", "true");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", commentsColor);
                writer.WriteElementString("Begin", ";");
                writer.WriteEndElement();

                writer.WriteStartElement("Span");
                writer.WriteAttributeString("name", "BlockComment");
                writer.WriteAttributeString("stopateol", "false");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", blockCommentsColor);
                writer.WriteElementString("Begin", "#comment");
                writer.WriteElementString("End", "#endcomment");
                writer.WriteEndElement();

                writer.WriteStartElement("Span");
                writer.WriteAttributeString("name", "String");
                writer.WriteAttributeString("escapecharacter", "\\");
                writer.WriteAttributeString("stopateol", "true");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", stringsColor);
                writer.WriteElementString("Begin", "\"");
                writer.WriteElementString("End", "\"");
                writer.WriteEndElement();

                writer.WriteStartElement("Span");
                writer.WriteAttributeString("name", "Char");
                writer.WriteAttributeString("escapecharacter", "\\");
                writer.WriteAttributeString("stopateol", "true");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", stringsColor);
                writer.WriteElementString("Begin", "'");
                writer.WriteElementString("End", "'");
                writer.WriteEndElement();

                writer.WriteStartElement("MarkPrevious");
                writer.WriteAttributeString("bold", "true");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "MidnightBlue");
                writer.WriteString("(");
                writer.WriteEndElement();

                writer.WriteStartElement("MarkPrevious");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", labelsColor);
                writer.WriteAttributeString("markmarker", "true");
                writer.WriteString(":");
                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "Punctuation");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "Black");

                foreach (string punc in Punctuation)
                {
                    writer.WriteStartElement("Key");
                    writer.WriteAttributeString("word", punc);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement(); // </KeyWords>

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "Registers");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", registersColor);
                foreach (string register in Registers)
                {
                    writer.WriteStartElement("Key");
                    writer.WriteAttributeString("word", register);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "Preprocessor");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", preProcessorColor);
                foreach (string pre in Preprocessor)
                {
                    writer.WriteStartElement("Key");
                    writer.WriteAttributeString("word", pre);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "Directives");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", directivesColor);
                foreach (string directive in Directives)
                {
                    writer.WriteStartElement("Key");
                    writer.WriteAttributeString("word", directive);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "Opcodes");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", opcodesColor);
                foreach (string opcode in Opcodes)
                {
                    writer.WriteStartElement("Key");
                    writer.WriteAttributeString("word", opcode);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "Conditions");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", conditionsColor);
                foreach (string condition in Conditions)
                {
                    writer.WriteStartElement("Key");
                    writer.WriteAttributeString("word", condition);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndElement(); // </ruleset>

                writer.WriteStartElement("RuleSet");
                writer.WriteAttributeString("name", "DocCommentSet");
                writer.WriteAttributeString("ignorecase", "false");
                writer.WriteElementString("Delimiters", "&<>~!@%^*()-+=|\\#/{}[]:;\"' ,	.?");
                writer.WriteStartElement("Span");
                writer.WriteAttributeString("name", "XmlTag");
                writer.WriteAttributeString("stopateol", "true");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "SystemColors.WindowText");
                writer.WriteElementString("Begin", "<");
                writer.WriteElementString("End", ">");
                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "ErrorWords");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "SystemColors.WindowText");
                writer.WriteStartElement("Key");
                writer.WriteAttributeString("word", "TODO");
                writer.WriteEndElement();
                writer.WriteStartElement("Key");
                writer.WriteAttributeString("word", "FIXME");
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteStartElement("KeyWords");
                writer.WriteAttributeString("name", "WarningWords");
                writer.WriteAttributeString("bold", "false");
                writer.WriteAttributeString("italic", "false");
                writer.WriteAttributeString("color", "SystemColors.WindowText");
                writer.WriteStartElement("Key");
                writer.WriteAttributeString("word", "HACK");
                writer.WriteEndElement();
                writer.WriteStartElement("Key");
                writer.WriteAttributeString("word", "UNDONE");
                writer.WriteEndElement();
                writer.WriteEndElement();

                writer.WriteEndElement(); // </RuleSet>
                writer.WriteEndElement(); // </RuleSets>
                writer.WriteEndElement(); // </SyntaxDefinition>
                writer.Flush();
                writer.Close();

                // Create new provider with the temp directory
                FileSyntaxModeProvider provider = new FileSyntaxModeProvider(Path.GetDirectoryName(FileLocations.DefaultHighlightingFile));

                // Attach to the text editor
                HighlightingManager.Manager.AddSyntaxModeFileProvider(provider);
            }
            catch (Exception ex)
            {
                DockingService.ShowError("Error creating highlighting file!", ex);
            }
            // we don't dispose the memory stream here, the HighlightingManager will be responsible

            if (string.IsNullOrEmpty(Settings.Default.ExternalHighlight))
            {
                return;
            }

            FileSyntaxModeProvider fileProvider = new FileSyntaxModeProvider(Path.GetDirectoryName(Settings.Default.ExternalHighlight));

            HighlightingManager.Manager.AddSyntaxModeFileProvider(fileProvider);
        }