Example #1
0
        private void mnuSnippetEdit_Click(object sender, System.EventArgs e)
        {
            if (this.tvSnippets.SelectedNode == null)
            {
                return;
            }

            if (this.tvSnippets.SelectedNode.Tag == null)
            {
                return;
            }

            frmSnippetNew fSnippetNew = new frmSnippetNew((CSnippetter.CodeEntry) this.tvSnippets.SelectedNode.Tag, false, false);

            fSnippetNew.Show();
        }
Example #2
0
        private void mnuSnippetImport_Click(object sender, System.EventArgs e)
        {
            string id = frmMain.ShowPrompt("Import Snippet", "Please enter the ID of the snippet you wish to import.", "Enter snippet ID:");

            if (id == "")
            {
                return;
            }

            // Construct a web server request
            WebClient client = new WebClient();

            // Populate the querystrings
            client.QueryString.Add("op", "fetch");
            client.QueryString.Add("id", id);

            // Execute the request
            string code = System.Text.ASCIIEncoding.ASCII.GetString(client.DownloadData("http://www.torquedev.com/network/snippetter.php"));

            // Check if we're successful
            if (client.ResponseHeaders["X-Snippet-Success"] == null || client.ResponseHeaders["X-Snippet-Success"] == "False")
            {
                MessageBox.Show(this, "Failed to retrieve snippet.  Snippet does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Create the new snippet
            CSnippetter.CodeEntry entry = new TSDev.CSnippetter.CodeEntry();

            // Populate the fields
            entry.CodeCategory = client.ResponseHeaders["X-Snippet-Category"];
            entry.CodeTitle    = client.ResponseHeaders["X-Snippet-Title"];
            entry.CodeDescr    = client.ResponseHeaders["X-Snippet-Description"];
            string keywords = client.ResponseHeaders["X-Snippet-Keywords"];

            // Process keywords
            foreach (string keyword in keywords.Trim().Split(' '))
            {
                entry.CodeKeywords.Add(keyword);
            }

            // Write the codeblock
            entry.CodeContents = code;

            // Update the URL and date
            entry.CodeURL     = "http://www.torquedev.com/network/snippetter.php?op=showcode&id=" + id;
            entry.CodeExpires = DateTime.Now.Ticks + (new TimeSpan(30, 0, 0, 0, 0)).Ticks;

            // Spawn a snippetter edit window to make any changes
            frmSnippetNew fSnippetNew = new frmSnippetNew(entry, true, false);

            fSnippetNew.ShowInTaskbar = false;

            DialogResult result = fSnippetNew.ShowDialog();

            // If they cancelled, then don't add this to the collection
            if (result == DialogResult.Cancel)
            {
                return;
            }

            // Add it to the collection
            frmMain.stc_Snippets.CodeSnippets.Add(entry);

            // Refresh the list
            RefreshTree();
        }
Example #3
0
        private void mnuSnippetAdd_Click(object sender, System.EventArgs e)
        {
            frmSnippetNew fSnippetNew = new frmSnippetNew("");

            fSnippetNew.Show();
        }
Example #4
0
        private void mnuSnippetImport_Click(object sender, System.EventArgs e)
        {
            string id = frmMain.ShowPrompt("Import Snippet", "Please enter the ID of the snippet you wish to import.", "Enter snippet ID:");

            if (id == "")
                return;

            // Construct a web server request
            WebClient client = new WebClient();

            // Populate the querystrings
            client.QueryString.Add("op", "fetch");
            client.QueryString.Add("id", id);

            // Execute the request
            string code = System.Text.ASCIIEncoding.ASCII.GetString(client.DownloadData("http://www.torquedev.com/network/snippetter.php"));

            // Check if we're successful
            if (client.ResponseHeaders["X-Snippet-Success"] == null || client.ResponseHeaders["X-Snippet-Success"] == "False") {
                MessageBox.Show(this, "Failed to retrieve snippet.  Snippet does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Create the new snippet
            CSnippetter.CodeEntry entry = new TSDev.CSnippetter.CodeEntry();

            // Populate the fields
            entry.CodeCategory = client.ResponseHeaders["X-Snippet-Category"];
            entry.CodeTitle = client.ResponseHeaders["X-Snippet-Title"];
            entry.CodeDescr = client.ResponseHeaders["X-Snippet-Description"];
            string keywords = client.ResponseHeaders["X-Snippet-Keywords"];

            // Process keywords
            foreach(string keyword in keywords.Trim().Split(' '))
                entry.CodeKeywords.Add(keyword);

            // Write the codeblock
            entry.CodeContents = code;

            // Update the URL and date
            entry.CodeURL = "http://www.torquedev.com/network/snippetter.php?op=showcode&id=" + id;
            entry.CodeExpires = DateTime.Now.Ticks + (new TimeSpan(30, 0, 0, 0, 0)).Ticks;

            // Spawn a snippetter edit window to make any changes
            frmSnippetNew fSnippetNew = new frmSnippetNew(entry, true, false);
            fSnippetNew.ShowInTaskbar = false;

            DialogResult result = fSnippetNew.ShowDialog();

            // If they cancelled, then don't add this to the collection
            if (result == DialogResult.Cancel)
                return;

            // Add it to the collection
            frmMain.stc_Snippets.CodeSnippets.Add(entry);

            // Refresh the list
            RefreshTree();
        }
Example #5
0
        private void mnuSnippetEdit_Click(object sender, System.EventArgs e)
        {
            if (this.tvSnippets.SelectedNode == null)
                return;

            if (this.tvSnippets.SelectedNode.Tag == null)
                return;

            frmSnippetNew fSnippetNew = new frmSnippetNew((CSnippetter.CodeEntry)this.tvSnippets.SelectedNode.Tag, false, false);
            fSnippetNew.Show();
        }
Example #6
0
 private void mnuSnippetAdd_Click(object sender, System.EventArgs e)
 {
     frmSnippetNew fSnippetNew = new frmSnippetNew("");
     fSnippetNew.Show();
 }
Example #7
0
 private void mnuCt_CreateSnippet_Click(object sender, System.EventArgs e)
 {
     // Create a snippet of code from the current selection
     frmSnippetNew fSnippetNew = new frmSnippetNew(this.txtEditor.SelectedView.SelectedText);
     fSnippetNew.Show();
 }