Ejemplo n.º 1
0
        private void ShowNotes(NodeBase node)
        {
            var flyout = new Flyout {
                FlyoutPresenterStyle = NotesFlyoutStyle, Placement = FlyoutPlacementMode.Full
            };

            var editor = new NotesEditor(flyout, node);

            flyout.Content = editor;
            flyout.ShowAt(this);
        }
Ejemplo n.º 2
0
        private void NotesEditor_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                // Ctrl+Click Go to notes
                var position = NotesEditor.GetPositionFromPoint(e.GetPosition(NotesEditor.TextArea.TextView));
                if (position != null)
                {
                    // Get the line clicked.
                    var clicked_line_no = position.Value.Line;
                    var line_offset     = NotesEditor.Document.GetLineByNumber(clicked_line_no);
                    var line            = NotesEditor.Document.GetText(line_offset.Offset, line_offset.Length);

                    // Check if there is a link in the line: check with regex
                    if (Regex.IsMatch(line, notes_link_regex))
                    {
                        // Check if click is within link (if there is one).
                        // Parse link and move to vertex.
                        var match_object = Regex.Match(line, notes_link_regex);
                        var vert_id      = int.Parse(match_object.Groups["vertex_id"].Value);
                        var file_name    = match_object.Groups["file_name"].Value;
                        var line_no      = int.Parse(match_object.Groups["line_no"].Value);
                        var no_lines     = int.Parse(match_object.Groups["no_lines"].Value);

                        var           vertex = graph_provider.GetVertexById(vert_id);
                        VertexControl vc     = graph_area.GetAllVertexControls().Where(x => x.Vertex == vertex).FirstOrDefault();

                        TextEditor te = TreeHelpers.FindVisualChild <TextEditor>((DependencyObject)vc);
                        te.TextArea.TextView.BackgroundRenderers.Add(new HighlightNotesSnippetBackgroundRenderer(te, line_no, no_lines));

                        te.ScrollToLine(line_no);

                        Expander ex = TreeHelpers.FindVisualParent <Expander>(te);
                        if (!ex.IsExpanded)
                        {
                            ex.IsExpanded = true;
                        }

                        CenterOnVertex(vc);
                    }
                }
                e.Handled = true;
            }
        }
Ejemplo n.º 3
0
        async private void TestEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.S && !((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) // Not doing ctrl-s to save
            {
                string        selected_text = "";
                TextArea      textarea      = e.OriginalSource as TextArea;
                VertexControl sv            = TreeHelpers.FindVisualParent <VertexControl>(textarea);
                PocVertex     source_vertex = (PocVertex)sv.Vertex;
                selected_text = textarea.Selection.GetText();
                await SearchForString(selected_text, sv);
            }
            else if (e.Key == System.Windows.Input.Key.N && !((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) // Not doing ctrl-n for new project
            {
                string        selected_text = "";
                string        link_text     = "";
                TextArea      textarea      = e.OriginalSource as TextArea;
                var           texteditor    = Utils.TreeHelpers.FindVisualParent <TextEditor>(textarea);
                VertexControl sv            = TreeHelpers.FindVisualParent <VertexControl>(textarea);
                FileVertex    source_vertex = (FileVertex)sv.Vertex;
                selected_text = textarea.Selection.GetText();
                var no_lines   = 0;
                var start_line = "";
                if (textarea.Selection.EndPosition.Line < textarea.Selection.StartPosition.Line)
                {
                    no_lines   = textarea.Selection.StartPosition.Line - textarea.Selection.EndPosition.Line + 1;
                    start_line = textarea.Selection.EndPosition.Location.ToString();
                }
                else
                {
                    no_lines   = textarea.Selection.EndPosition.Line - textarea.Selection.StartPosition.Line + 1;
                    start_line = textarea.Selection.StartPosition.Location.ToString();
                }

                link_text = source_vertex.ID.ToString() + ":" + source_vertex.FileName + ":" + start_line + ":" + no_lines.ToString();
                NotesEditor.TextArea.Document.Text += "\n\n";
                NotesEditor.TextArea.Document.Text += link_text + "\n";
                NotesEditor.TextArea.Document.Text += selected_text;
                NotesEditor.TextArea.Document.Text += "\n\n";

                NotesEditor.ScrollToEnd();

                graph_provider.SaveNotes();
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotesEditorForm));
     this.btnOK = new System.Windows.Forms.Button();
     this.btnCancel = new System.Windows.Forms.Button();
     this.ne = new Nanook.TheGhost.NotesEditor();
     this.SuspendLayout();
     //
     // btnOK
     //
     this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnOK.Location = new System.Drawing.Point(622, 280);
     this.btnOK.Name = "btnOK";
     this.btnOK.Size = new System.Drawing.Size(75, 23);
     this.btnOK.TabIndex = 1;
     this.btnOK.Text = "OK";
     this.btnOK.UseVisualStyleBackColor = true;
     this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
     //
     // btnCancel
     //
     this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.Location = new System.Drawing.Point(703, 280);
     this.btnCancel.Name = "btnCancel";
     this.btnCancel.Size = new System.Drawing.Size(75, 23);
     this.btnCancel.TabIndex = 2;
     this.btnCancel.Text = "Cancel";
     this.btnCancel.UseVisualStyleBackColor = true;
     this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
     //
     // ne
     //
     this.ne.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                 | System.Windows.Forms.AnchorStyles.Left)
                 | System.Windows.Forms.AnchorStyles.Right)));
     this.ne.Location = new System.Drawing.Point(3, 0);
     this.ne.MinimumSize = new System.Drawing.Size(400, 235);
     this.ne.Name = "ne";
     this.ne.Size = new System.Drawing.Size(789, 274);
     this.ne.TabIndex = 0;
     //
     // NotesEditorForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize = new System.Drawing.Size(793, 307);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.btnOK);
     this.Controls.Add(this.ne);
     this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MinimumSize = new System.Drawing.Size(634, 334);
     this.Name = "NotesEditorForm";
     this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
     this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
     this.Text = "Notes Viewer";
     this.Load += new System.EventHandler(this.NotesEditorForm_Load);
     this.SizeChanged += new System.EventHandler(this.NotesEditorForm_Resize_Move);
     this.Move += new System.EventHandler(this.NotesEditorForm_Resize_Move);
     this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NotesEditorForm_FormClosing);
     this.ResizeEnd += new System.EventHandler(this.NotesEditorForm_Resize_Move);
     this.ResumeLayout(false);
 }