Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public SledBreakpointConditionForm()
        {
            InitializeComponent();

            // Add items to combo box
            m_cmbEnvironment.Items.Add(new ComboBoxItem("Global", false));
            m_cmbEnvironment.Items.Add(new ComboBoxItem("Environment", true));
            m_cmbEnvironment.SelectedIndex = 0;

            // Create SyntaxEditorControl
            m_txtCondition = TextEditorFactory.CreateSyntaxHighlightingEditor();

            // These values were what the previous TextBox used
            m_txtCondition.Control.Location = new System.Drawing.Point(12, 35);
            m_txtCondition.Control.Size     = new System.Drawing.Size(383, 20);
            m_txtCondition.Control.TabIndex = 2;
            m_txtCondition.Control.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

            // Set some special stuff to make it single line
            m_txtCondition.Multiline = false;
            m_txtCondition.LineNumberMarginVisible = false;
            m_txtCondition.IndicatorMarginVisible  = false;

            Controls.Add(m_txtCondition.Control);

            m_txtCondition.Control.Focus();
        }
Exemple #2
0
        /// <summary>
        /// Constructor</summary>
        /// <param name="uri">URI of document</param>
        public CodeDocument(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            m_uri = uri;

            string filePath = uri.LocalPath;
            string fileName = Path.GetFileName(filePath);

            m_type = GetDocumentType(fileName);

            m_editor = TextEditorFactory.CreateSyntaxHighlightingEditor();

            Languages lang = GetDocumentLanguage(fileName);

            m_editor.SetLanguage(lang);
            Control ctrl = (Control)m_editor;

            ctrl.Tag = this;

            m_editor.EditorTextChanged += editor_EditorTextChanged;

            m_controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center);
            // tell ControlHostService this control should be considered a document in the menu,
            // and using the full path of the document for menu text to avoid adding a number in the end
            // in control header,  which is not desirable for documents that have the same name
            // but located at different directories.
            m_controlInfo.IsDocument = true;
        }
Exemple #3
0
        /// <summary>
        /// Go to a specific variable instance in a file
        /// </summary>
        /// <param name="var">variable to go to</param>
        public void GotoVariable(ISledVarBaseType var)
        {
            if (var == null)
            {
                return;
            }

            if (var.Locations.Count <= 0)
            {
                return;
            }

            if (var.Locations.Count == 1)
            {
                // Go to this specific one
                GotoLineWord(
                    var.Locations[0].File,
                    var.Name,
                    var.Locations[0].Line,
                    var.Locations[0].Occurence,
                    false);
            }
            else
            {
                var dictLocations =
                    new Dictionary <string, List <SledVarLocationType> >(StringComparer.CurrentCultureIgnoreCase);

                // Go through all locations grouping by file
                foreach (var loc in var.Locations)
                {
                    List <SledVarLocationType> lstLocs;
                    if (dictLocations.TryGetValue(loc.File, out lstLocs))
                    {
                        // Add to existing key
                        lstLocs.Add(loc);
                    }
                    else
                    {
                        // Create new key/value pair
                        lstLocs =
                            new List <SledVarLocationType> {
                            loc
                        };

                        dictLocations.Add(loc.File, lstLocs);
                    }
                }

                if (dictLocations.Count <= 0)
                {
                    return;
                }

                // Create variable goto form
                var form = new SledVarGotoForm();

                // Create one syntax editor for all the iterations
                using (var sec = TextEditorFactory.CreateSyntaxHighlightingEditor())
                {
                    // Go through each file pulling out locations
                    foreach (var kv in dictLocations)
                    {
                        StreamReader reader = null;

                        try
                        {
                            // Open the file
                            reader = new StreamReader(kv.Key, true);
                            if (reader != StreamReader.Null)
                            {
                                // Read entire file contents into SyntaxEditor
                                sec.Text = reader.ReadToEnd();

                                // Go through populating form
                                foreach (var loc in kv.Value)
                                {
                                    try
                                    {
                                        // Add location to the form
                                        form.AddLocation(loc, sec.GetLineText(loc.Line).Trim());
                                    }
                                    catch (Exception ex2)
                                    {
                                        SledOutDevice.OutLine(
                                            SledMessageType.Info,
                                            SledUtil.TransSub(Localization.SledGotoVariableError1, loc.Line, kv.Key, ex2.Message));
                                    }
                                }
                            }
                        }
                        catch (Exception ex1)
                        {
                            SledOutDevice.OutLine(
                                SledMessageType.Info,
                                SledUtil.TransSub(Localization.SledGotoVariableError2, kv.Key, ex1.Message));
                        }
                        finally
                        {
                            // Close up reader if everything went well
                            if ((reader != null) && (reader != StreamReader.Null))
                            {
                                reader.Close();
                                reader.Dispose();
                            }
                        }
                    }
                }

                if (form.ShowDialog(m_mainForm) == DialogResult.OK)
                {
                    // Go to this one
                    GotoLineWord(
                        form.SelectedLocation.File,
                        var.Name,
                        form.SelectedLocation.Line,
                        form.SelectedLocation.Occurence,
                        false);
                }

                form.Dispose();
            }
        }
Exemple #4
0
        private SledDocument(Uri uri, ISledDocumentClient client, bool bHidden)
        {
            m_uri        = uri;
            m_type       = client == null ? "SledDocument" : client.Info.FileType;
            m_bHiddenDoc = bHidden;

            var filePath = uri.LocalPath;
            var fileName = Path.GetFileName(filePath);
            var ext      = Path.GetExtension(filePath);

            // Set up language plugin (if any)
            LanguagePlugin = null;
            if (!m_bHiddenDoc)
            {
                if (s_languagePluginService.Get != null)
                {
                    LanguagePlugin = s_languagePluginService.Get.GetPluginForExtension(ext);
                }
            }

            // Create new syntax editor
            m_editor              = TextEditorFactory.CreateSyntaxHighlightingEditor();
            m_editor.Control.Tag  = this;
            m_editor.Control.Name = fileName;

            // Grab reference to image
            if (s_imgLock == null)
            {
                s_imgLock = GetLockImage();
            }

            // Check if readonly
            if (!m_bHiddenDoc)
            {
                m_bReadOnly = IsReadOnly;

                // Create hosting control
                m_control =
                    new SledDocumentControl(m_editor, this, client == null ? null : client.EmbeddedTypes)
                {
                    Name = fileName,
                    Tag  = this
                };
            }

            // Create control info
            m_controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center, !m_bReadOnly ? null : s_imgLock);
            if (!m_bHiddenDoc)
            {
                m_controlInfo.IsDocument = true;
            }

            // Using a custom context menu, so disable the default
            m_editor.DefaultContextMenuEnabled = false;
            m_editor.EditorTextChanged        += EditorEditorTextChanged;
            m_editor.KeyPress               += EditorKeyPress;
            m_editor.ShowContextMenu        += EditorShowContextMenu;
            m_editor.MouseHoveringOverToken += EditorMouseHoveringOverToken;

            if (client == null)
            {
                return;
            }

            // Set syntax highlighting for document
            SledDocumentSyntaxHighlighter.FeedHighlighterToSyntaxEditor(client.SyntaxHighlighter, m_editor);
        }