|
Thing is that it should be a general question. I assumed lots of people had the same issue.
|
|
|
|
|
Hrmf.. Started a new project, uploaded all dependencies again, and now everything is working as it should 
|
|
|
|
|
Can we use this article as Xamarin platform.can u suggest me??
|
|
|
|
|
Ask this question under that article. We have no idea, which article you are talking about.
Secondly, MVC Page list is different than Xamarin platform. Xamarin is for mobile, MVC is for web. Please be more specific while asking.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Here's a pretty basic question:
I have a windows forms application that has a form that uses Form1.ShowDialog(this); to open a child form. The problem is that when an exception occurs in my child form, all i get back in the output window of Visual Studio 2017 is
Exception thrown: 'System.NullReferenceException' in TreeView.exe
I've inserted breakpoints to locate the class that's throwing the exception but I don't have really anything else to go on, other than something is null.
First off, how do I throw the exception in the child form instead of returning to caller?
Maybe there's a better way to debug this?
|
|
|
|
|
Check the stack trace of the exception in the exception helper window.
If that doesn't help, see if there is an inner exception.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks for the reply! I wasn't sure which window was the exception helper, as I (stupidly) have not given exception handling and debugging the priority it deserves. So this helps me better state the problem. The Exception Helper is not showing up inline, next to my code, for exceptions that occur in the child dialog. It's just throwing the exception back to the caller in the parent window. No exception helper window opens and the application continues in the running state.
I checked my settings to make sure that Exception Helper is still enabled in Options > Debugging > General > Use the new Exception Helper.
|
|
|
|
|
I see. Well what you should do is trap the exception with a try/catch block. Then place a breakpoint inside the catch block and examine the exception object. It will include all the information in there. Hope this helps!
try
{
}
catch (Exception e)
{
e.ToString();
}
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
That was my thought as well. I should be able to get the inner exceptions from there.
|
|
|
|
|
Issue Resolved, thanks in part to your suggestion.
Here's how I fixed it.
This is probably overkill, but for my own learning, I created this method to output stacktrace and other exception info to the output window. It did the trick. I can see, just form the exception's StackTrace property:
Now, I'm seeing this in the Output window:
EXCEPTION StackTrace: at TreeView.frmResources.DropTargetListBox_DragDrop(Object sender, DragEventArgs e) in D:\xxx\TreeView\frmResources.cs:line 255
Here's my exception handling method:
private static string ExceptionToString ( Exception exception_object , int errorcount )
{
if ( exception_object == null ) return "";
StringBuilder result = new StringBuilder ( );
result.Append ( "General Exception " + errorcount + ": \n" );
result.Append ( "Message: " + exception_object.Message + "\n" );
result.Append ( "Source: " + exception_object.Source + "\n" );
result.Append ( "HelpLink: " + exception_object.HelpLink + "\n" );
result.Append ( "TargetSite: " + exception_object.TargetSite + "\n" );
if ( exception_object.Data != null )
{
result.Append ( "Exception Data: \n" );
foreach ( DictionaryEntry item in exception_object.Data )
result.AppendFormat ( "{0} : {1}\n" , item.Key , item.Value );
}
if ( exception_object.InnerException != null )
{
result.Append ( "InnerException.Message: " + exception_object.InnerException.Message + "\n" );
result.Append ( "InnerException.Source: " + exception_object.InnerException.Source + "\n" );
result.Append ( "InnerException.HelpLink: " + exception_object.InnerException.HelpLink + "\n" );
result.Append ( "InnerException.TargetSite: " + exception_object.InnerException.TargetSite + "\n" );
if ( exception_object.Data != null )
{
result.Append ( "Exception Data: \n" );
foreach ( DictionaryEntry item in exception_object.Data )
result.AppendFormat ( "{0} : {1}\n" , item.Key , item.Value );
}
}
result.Append ( "\n\n\n EXCEPTION StackTrace: " + exception_object.StackTrace + "\n" );
if ( exception_object.InnerException != null ) result.Append ( "\n\n\n INNER EXCEPTION StackTrace: " + exception_object.InnerException.StackTrace + "\n" );
return result.ToString ( );
}
Here's how I called it:
try
{
}
catch ( Exception ex )
{
ExceptionToString ( ex , "Some text to add to output" );
throw;
}
|
|
|
|
|
var result = from tab in dt.AsEnumerable()
group tab by new
{
ID_Gaminio = tab.Field<int>("Id_gaminio"),
Nr_Pcb = tab.Field<int>("Nr_pcb"),
Pavadinimas_M = tab.Field<string>("Pavadinimas_M"),
Data_surinkimo = tab.Field<datetime>("Data_surinkimo"),
Pavadinimas_gam = tab.Field<string>("Pavadinimas_g")
}
into groupDt
select new
{
ID_Gaminio = groupDt.Key.ID_Gaminio,
Nr_Pcb = groupDt.Key.Nr_Pcb,
Pavadinimas_M = groupDt.Key.Pavadinimas_M,
Data_surinkimo = groupDt.Key.Data_surinkimo,
Pavadinimas_gam = groupDt.Key.Pavadinimas_gam,
Mount_all = new TimeSpan(0, 0, (int)(groupDt.Average(r => r.Field<datetime>("MountCT").TimeOfDay.TotalSeconds))),
Bord_all = groupDt.Count()};
|
|
|
|
|
This is just a code dump.
You need to explain exactly what you mean by "don't add up."
What is the expected result? What is the actual result? Are there errors, and if so, where do they occur?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi
I try to compile this cs app
RegEx Tester - Regular Expression Tester
Pablo Osés, 22 May 2011
I'm converted the original project to one file as shown below
and when I command line compile it I get thes errors:
The name 'HttpUtility' does not exist in the current context
The name 'interaction' does not exist in the current context
Please can someone help me in this.
<pre>
using System;
using System.Text;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Web;
using Microsoft.VisualBasic;
namespace RegExTester
{
public class Program
{
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
}}
namespace RegExTester
{
partial class frmMain
{
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.statusBar = new System.Windows.Forms.StatusBar();
this.statusStatusBarPanel = new System.Windows.Forms.StatusBarPanel();
this.matchesStatusBarPanel = new System.Windows.Forms.StatusBarPanel();
this.executionTimeStatusBarPanel = new System.Windows.Forms.StatusBarPanel();
this.contextStatusBarPanel = new System.Windows.Forms.StatusBarPanel();
this.topAndMiddleSplitContainer = new System.Windows.Forms.SplitContainer();
this.aboutButton = new System.Windows.Forms.Button();
this.regExLibraryButton = new System.Windows.Forms.Button();
this.regExCheatSheetButton = new System.Windows.Forms.Button();
this.replaceModeButton = new System.Windows.Forms.Button();
this.indentedInputButton = new System.Windows.Forms.Button();
this.singleLineButton = new System.Windows.Forms.Button();
this.multiLineButton = new System.Windows.Forms.Button();
this.cultureInvariantButton = new System.Windows.Forms.Button();
this.ignoreCaseButton = new System.Windows.Forms.Button();
this.replaceModeCheckBox = new System.Windows.Forms.CheckBox();
this.indentedInputCheckBox = new System.Windows.Forms.CheckBox();
this.copyButton = new System.Windows.Forms.Button();
this.testButton = new System.Windows.Forms.Button();
this.singleLineCheckBox = new System.Windows.Forms.CheckBox();
this.multiLineCheckBox = new System.Windows.Forms.CheckBox();
this.ignoreCaseCheckBox = new System.Windows.Forms.CheckBox();
this.cultureInvariantCheckBox = new System.Windows.Forms.CheckBox();
this.regExAndRepExSplitContainer = new System.Windows.Forms.SplitContainer();
this.regExLabel = new System.Windows.Forms.Label();
this.regExTextBox = new System.Windows.Forms.TextBox();
this.repExLabel = new System.Windows.Forms.Label();
this.repExTextBox = new System.Windows.Forms.TextBox();
this.middleAndBottomSplitContainer = new System.Windows.Forms.SplitContainer();
this.textAndResultsSplitContainer = new System.Windows.Forms.SplitContainer();
this.textLabel = new System.Windows.Forms.Label();
this.textRichTextBox = new RegExTester.CustomRichTextBox();
this.resultsLabel = new System.Windows.Forms.Label();
this.resultsRichTextBox = new RegExTester.CustomRichTextBox();
this.exportResultsButton = new System.Windows.Forms.Button();
this.resultListView = new System.Windows.Forms.ListView();
this.matchColumnHeader = new System.Windows.Forms.ColumnHeader();
this.positionColumnHeader = new System.Windows.Forms.ColumnHeader();
this.lengthColumnHeader = new System.Windows.Forms.ColumnHeader();
this.resultsListLabel = new System.Windows.Forms.Label();
this.copyButtonContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyGeneric0MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyGeneric1MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyGeneric2MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyGeneric3MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportSaveFileDialog = new System.Windows.Forms.SaveFileDialog();
((System.ComponentModel.ISupportInitialize)(this.statusStatusBarPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.matchesStatusBarPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.executionTimeStatusBarPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.contextStatusBarPanel)).BeginInit();
this.topAndMiddleSplitContainer.Panel1.SuspendLayout();
this.topAndMiddleSplitContainer.Panel2.SuspendLayout();
this.topAndMiddleSplitContainer.SuspendLayout();
this.regExAndRepExSplitContainer.Panel1.SuspendLayout();
this.regExAndRepExSplitContainer.Panel2.SuspendLayout();
this.regExAndRepExSplitContainer.SuspendLayout();
this.middleAndBottomSplitContainer.Panel1.SuspendLayout();
this.middleAndBottomSplitContainer.Panel2.SuspendLayout();
this.middleAndBottomSplitContainer.SuspendLayout();
this.textAndResultsSplitContainer.Panel1.SuspendLayout();
this.textAndResultsSplitContainer.Panel2.SuspendLayout();
this.textAndResultsSplitContainer.SuspendLayout();
this.copyButtonContextMenu.SuspendLayout();
this.SuspendLayout();
this.statusBar.Location = new System.Drawing.Point(0, 435);
this.statusBar.Name = "statusBar";
this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusStatusBarPanel,
this.matchesStatusBarPanel,
this.executionTimeStatusBarPanel,
this.contextStatusBarPanel});
this.statusBar.ShowPanels = true;
this.statusBar.Size = new System.Drawing.Size(592, 22);
this.statusBar.TabIndex = 1;
this.statusBar.Text = "statusBar";
this.statusStatusBarPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusStatusBarPanel.Name = "sbpStatus";
this.statusStatusBarPanel.Text = "Nothing searched yet.";
this.statusStatusBarPanel.Width = 546;
this.matchesStatusBarPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
this.matchesStatusBarPanel.MinWidth = 0;
this.matchesStatusBarPanel.Name = "sbpMatches";
this.matchesStatusBarPanel.Width = 10;
this.executionTimeStatusBarPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
this.executionTimeStatusBarPanel.MinWidth = 0;
this.executionTimeStatusBarPanel.Name = "sbpExecutionTime";
this.executionTimeStatusBarPanel.Width = 10;
this.contextStatusBarPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
this.contextStatusBarPanel.MinWidth = 0;
this.contextStatusBarPanel.Name = "sbpContext";
this.contextStatusBarPanel.Width = 10;
this.topAndMiddleSplitContainer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.topAndMiddleSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.topAndMiddleSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.topAndMiddleSplitContainer.IsSplitterFixed = true;
this.topAndMiddleSplitContainer.Location = new System.Drawing.Point(0, 0);
this.topAndMiddleSplitContainer.Name = "topAndMiddleSplitContainer";
this.topAndMiddleSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.aboutButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.regExLibraryButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.regExCheatSheetButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.replaceModeButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.indentedInputButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.singleLineButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.multiLineButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.cultureInvariantButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.ignoreCaseButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.replaceModeCheckBox);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.indentedInputCheckBox);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.copyButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.testButton);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.singleLineCheckBox);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.multiLineCheckBox);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.ignoreCaseCheckBox);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.cultureInvariantCheckBox);
this.topAndMiddleSplitContainer.Panel1.Controls.Add(this.regExAndRepExSplitContainer);
this.topAndMiddleSplitContainer.Panel1MinSize = 100;
this.topAndMiddleSplitContainer.Panel2.Controls.Add(this.middleAndBottomSplitContainer);
this.topAndMiddleSplitContainer.Size = new System.Drawing.Size(592, 435);
this.topAndMiddleSplitContainer.SplitterDistance = 100;
this.topAndMiddleSplitContainer.TabIndex = 0;
this.aboutButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.aboutButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.aboutButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.aboutButton.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.aboutButton.ForeColor = System.Drawing.Color.Blue;
this.aboutButton.Location = new System.Drawing.Point(438, 1);
this.aboutButton.Name = "aboutButton";
this.aboutButton.Size = new System.Drawing.Size(137, 25);
this.aboutButton.TabIndex = 31;
this.aboutButton.Text = "About This Program";
this.aboutButton.UseVisualStyleBackColor = true;
this.aboutButton.Click += new System.EventHandler(this.aboutButton_Click);
this.regExLibraryButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.regExLibraryButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.regExLibraryButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.regExLibraryButton.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.regExLibraryButton.ForeColor = System.Drawing.Color.Blue;
this.regExLibraryButton.Location = new System.Drawing.Point(328, 1);
this.regExLibraryButton.Name = "regExLibraryButton";
this.regExLibraryButton.Size = new System.Drawing.Size(102, 25);
this.regExLibraryButton.TabIndex = 30;
this.regExLibraryButton.Text = "RegEx Library";
this.regExLibraryButton.UseVisualStyleBackColor = true;
this.regExLibraryButton.Click += new System.EventHandler(this.regExLibraryButton_Click);
this.regExCheatSheetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.regExCheatSheetButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.regExCheatSheetButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.regExCheatSheetButton.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.regExCheatSheetButton.ForeColor = System.Drawing.Color.Blue;
this.regExCheatSheetButton.Location = new System.Drawing.Point(186, 1);
this.regExCheatSheetButton.Name = "regExCheatSheetButton";
this.regExCheatSheetButton.Size = new System.Drawing.Size(127, 25);
this.regExCheatSheetButton.TabIndex = 28;
this.regExCheatSheetButton.Text = "RegEx CheatSheet";
this.regExCheatSheetButton.UseVisualStyleBackColor = true;
this.regExCheatSheetButton.Click += new System.EventHandler(this.regExCheatSheetButton_Click);
this.replaceModeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.replaceModeButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.replaceModeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.replaceModeButton.ForeColor = System.Drawing.Color.Blue;
this.replaceModeButton.Location = new System.Drawing.Point(375, 73);
this.replaceModeButton.Name = "replaceModeButton";
this.replaceModeButton.Size = new System.Drawing.Size(22, 22);
this.replaceModeButton.TabIndex = 24;
this.replaceModeButton.Text = "?";
this.replaceModeButton.UseVisualStyleBackColor = true;
this.replaceModeButton.Click += new System.EventHandler(this.replaceModeButton_Click);
this.indentedInputButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.indentedInputButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.indentedInputButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.indentedInputButton.ForeColor = System.Drawing.Color.Blue;
this.indentedInputButton.Location = new System.Drawing.Point(380, 51);
this.indentedInputButton.Name = "indentedInputButton";
this.indentedInputButton.Size = new System.Drawing.Size(22, 22);
this.indentedInputButton.TabIndex = 23;
this.indentedInputButton.Text = "?";
this.indentedInputButton.UseVisualStyleBackColor = true;
this.indentedInputButton.Click += new System.EventHandler(this.indentedInputButton_Click);
this.singleLineButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.singleLineButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.singleLineButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.singleLineButton.ForeColor = System.Drawing.Color.Blue;
this.singleLineButton.Location = new System.Drawing.Point(243, 73);
this.singleLineButton.Name = "singleLineButton";
this.singleLineButton.Size = new System.Drawing.Size(22, 22);
this.singleLineButton.TabIndex = 22;
this.singleLineButton.Text = "?";
this.singleLineButton.UseVisualStyleBackColor = true;
this.singleLineButton.Click += new System.EventHandler(this.singleLineButton_Click);
this.multiLineButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.multiLineButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.multiLineButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.multiLineButton.ForeColor = System.Drawing.Color.Blue;
this.multiLineButton.Location = new System.Drawing.Point(232, 51);
this.multiLineButton.Name = "multiLineButton";
this.multiLineButton.Size = new System.Drawing.Size(22, 22);
this.multiLineButton.TabIndex = 21;
this.multiLineButton.Text = "?";
this.multiLineButton.UseVisualStyleBackColor = true;
this.multiLineButton.Click += new System.EventHandler(this.multiLineButton_Click);
this.cultureInvariantButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cultureInvariantButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.cultureInvariantButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cultureInvariantButton.ForeColor = System.Drawing.Color.Blue;
this.cultureInvariantButton.Location = new System.Drawing.Point(130, 73);
this.cultureInvariantButton.Name = "cultureInvariantButton";
this.cultureInvariantButton.Size = new System.Drawing.Size(22, 22);
this.cultureInvariantButton.TabIndex = 20;
this.cultureInvariantButton.Text = "?";
this.cultureInvariantButton.UseVisualStyleBackColor = true;
this.cultureInvariantButton.Click += new System.EventHandler(this.cultureInvariantButton_Click);
this.ignoreCaseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ignoreCaseButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.ignoreCaseButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.ignoreCaseButton.ForeColor = System.Drawing.Color.Blue;
this.ignoreCaseButton.Location = new System.Drawing.Point(102, 51);
this.ignoreCaseButton.Name = "ignoreCaseButton";
this.ignoreCaseButton.Size = new System.Drawing.Size(22, 22);
this.ignoreCaseButton.TabIndex = 19;
this.ignoreCaseButton.Text = "?";
this.ignoreCaseButton.UseVisualStyleBackColor = true;
this.ignoreCaseButton.Click += new System.EventHandler(this.ignoreCaseButton_Click);
this.replaceModeCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.replaceModeCheckBox.CausesValidation = false;
this.replaceModeCheckBox.Checked = true;
this.replaceModeCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.replaceModeCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.replaceModeCheckBox.Location = new System.Drawing.Point(275, 73);
this.replaceModeCheckBox.Name = "replaceModeCheckBox";
this.replaceModeCheckBox.Size = new System.Drawing.Size(127, 22);
this.replaceModeCheckBox.TabIndex = 15;
this.replaceModeCheckBox.Text = "Replace mode";
this.replaceModeCheckBox.CheckedChanged += new System.EventHandler(this.replaceModeCheckBox_CheckedChanged);
this.indentedInputCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.indentedInputCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.indentedInputCheckBox.Location = new System.Drawing.Point(275, 51);
this.indentedInputCheckBox.Name = "indentedInputCheckBox";
this.indentedInputCheckBox.Size = new System.Drawing.Size(127, 22);
this.indentedInputCheckBox.TabIndex = 13;
this.indentedInputCheckBox.Text = "Indented Input";
this.indentedInputCheckBox.CheckedChanged += new System.EventHandler(this.indentedInputCheckBox_CheckedChanged);
this.copyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.copyButton.Location = new System.Drawing.Point(405, 56);
this.copyButton.Name = "copyButton";
this.copyButton.Size = new System.Drawing.Size(75, 34);
this.copyButton.TabIndex = 17;
this.copyButton.Text = "Copy";
this.copyButton.UseVisualStyleBackColor = true;
this.copyButton.Click += new System.EventHandler(this.copyButton_Click);
this.testButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.testButton.Location = new System.Drawing.Point(486, 56);
this.testButton.Name = "testButton";
this.testButton.Size = new System.Drawing.Size(92, 34);
this.testButton.TabIndex = 18;
this.testButton.Text = "Test [F5]";
this.testButton.Click += new System.EventHandler(this.testButton_Click);
this.singleLineCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.singleLineCheckBox.Checked = true;
this.singleLineCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.singleLineCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.singleLineCheckBox.Location = new System.Drawing.Point(160, 73);
this.singleLineCheckBox.Name = "singleLineCheckBox";
this.singleLineCheckBox.Size = new System.Drawing.Size(109, 22);
this.singleLineCheckBox.TabIndex = 11;
this.singleLineCheckBox.Text = "Single Line";
this.multiLineCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.multiLineCheckBox.Checked = true;
this.multiLineCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.multiLineCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.multiLineCheckBox.Location = new System.Drawing.Point(160, 51);
this.multiLineCheckBox.Name = "multiLineCheckBox";
this.multiLineCheckBox.Size = new System.Drawing.Size(109, 22);
this.multiLineCheckBox.TabIndex = 9;
this.multiLineCheckBox.Text = "Multi Line";
this.ignoreCaseCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ignoreCaseCheckBox.Checked = true;
this.ignoreCaseCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.ignoreCaseCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.ignoreCaseCheckBox.Location = new System.Drawing.Point(11, 51);
this.ignoreCaseCheckBox.Name = "ignoreCaseCheckBox";
this.ignoreCaseCheckBox.Size = new System.Drawing.Size(142, 22);
this.ignoreCaseCheckBox.TabIndex = 5;
this.ignoreCaseCheckBox.Text = "Ignore Case";
this.cultureInvariantCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cultureInvariantCheckBox.Checked = true;
this.cultureInvariantCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.cultureInvariantCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cultureInvariantCheckBox.Location = new System.Drawing.Point(11, 73);
this.cultureInvariantCheckBox.Name = "cultureInvariantCheckBox";
this.cultureInvariantCheckBox.Size = new System.Drawing.Size(142, 22);
this.cultureInvariantCheckBox.TabIndex = 7;
this.cultureInvariantCheckBox.Text = "Culture Invariant";
this.regExAndRepExSplitContainer.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.regExAndRepExSplitContainer.Location = new System.Drawing.Point(11, 5);
this.regExAndRepExSplitContainer.Name = "regExAndRepExSplitContainer";
this.regExAndRepExSplitContainer.Panel1.Controls.Add(this.regExLabel);
this.regExAndRepExSplitContainer.Panel1.Controls.Add(this.regExTextBox);
this.regExAndRepExSplitContainer.Panel2.Controls.Add(this.repExLabel);
this.regExAndRepExSplitContainer.Panel2.Controls.Add(this.repExTextBox);
this.regExAndRepExSplitContainer.Size = new System.Drawing.Size(567, 42);
this.regExAndRepExSplitContainer.SplitterDistance = 283;
this.regExAndRepExSplitContainer.TabIndex = 4;
this.regExLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.regExLabel.Location = new System.Drawing.Point(0, 3);
this.regExLabel.Name = "regExLabel";
this.regExLabel.Size = new System.Drawing.Size(283, 16);
this.regExLabel.TabIndex = 1;
this.regExLabel.Text = "Regular Expression";
this.regExTextBox.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.regExTextBox.HideSelection = false;
this.regExTextBox.Location = new System.Drawing.Point(0, 21);
this.regExTextBox.Name = "regExTextBox";
this.regExTextBox.Size = new System.Drawing.Size(283, 21);
this.regExTextBox.TabIndex = 0;
this.repExLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.repExLabel.Location = new System.Drawing.Point(0, 3);
this.repExLabel.Name = "repExLabel";
this.repExLabel.Size = new System.Drawing.Size(284, 16);
this.repExLabel.TabIndex = 2;
this.repExLabel.Text = "Replacement Expression";
this.repExTextBox.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.repExTextBox.HideSelection = false;
this.repExTextBox.Location = new System.Drawing.Point(0, 21);
this.repExTextBox.Name = "repExTextBox";
this.repExTextBox.Size = new System.Drawing.Size(280, 21);
this.repExTextBox.TabIndex = 0;
this.middleAndBottomSplitContainer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.middleAndBottomSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.middleAndBottomSplitContainer.Location = new System.Drawing.Point(0, 0);
this.middleAndBottomSplitContainer.Name = "middleAndBottomSplitContainer";
this.middleAndBottomSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.middleAndBottomSplitContainer.Panel1.Controls.Add(this.textAndResultsSplitContainer);
this.middleAndBottomSplitContainer.Panel1MinSize = 61;
this.middleAndBottomSplitContainer.Panel2.Controls.Add(this.exportResultsButton);
this.middleAndBottomSplitContainer.Panel2.Controls.Add(this.resultListView);
this.middleAndBottomSplitContainer.Panel2.Controls.Add(this.resultsListLabel);
this.middleAndBottomSplitContainer.Panel2MinSize = 89;
this.middleAndBottomSplitContainer.Size = new System.Drawing.Size(592, 331);
this.middleAndBottomSplitContainer.SplitterDistance = 191;
this.middleAndBottomSplitContainer.TabIndex = 0;
this.textAndResultsSplitContainer.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.textAndResultsSplitContainer.Location = new System.Drawing.Point(11, 9);
this.textAndResultsSplitContainer.Name = "textAndResultsSplitContainer";
this.textAndResultsSplitContainer.Panel1.Controls.Add(this.textLabel);
this.textAndResultsSplitContainer.Panel1.Controls.Add(this.textRichTextBox);
this.textAndResultsSplitContainer.Panel2.Controls.Add(this.resultsLabel);
this.textAndResultsSplitContainer.Panel2.Controls.Add(this.resultsRichTextBox);
this.textAndResultsSplitContainer.Size = new System.Drawing.Size(567, 166);
this.textAndResultsSplitContainer.SplitterDistance = 283;
this.textAndResultsSplitContainer.TabIndex = 1;
this.textLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textLabel.Location = new System.Drawing.Point(-3, 0);
this.textLabel.Name = "textLabel";
this.textLabel.Size = new System.Drawing.Size(286, 16);
this.textLabel.TabIndex = 1;
this.textLabel.Text = "Test Text";
this.textRichTextBox.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.textRichTextBox.HideSelection = false;
this.textRichTextBox.Location = new System.Drawing.Point(0, 19);
this.textRichTextBox.Name = "textRichTextBox";
this.textRichTextBox.Size = new System.Drawing.Size(283, 147);
this.textRichTextBox.TabIndex = 0;
this.textRichTextBox.Text = "";
this.resultsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.resultsLabel.Location = new System.Drawing.Point(-3, 0);
this.resultsLabel.Name = "resultsLabel";
this.resultsLabel.Size = new System.Drawing.Size(287, 16);
this.resultsLabel.TabIndex = 2;
this.resultsLabel.Text = "Test Results";
this.resultsRichTextBox.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.resultsRichTextBox.HideSelection = false;
this.resultsRichTextBox.Location = new System.Drawing.Point(0, 19);
this.resultsRichTextBox.Name = "resultsRichTextBox";
this.resultsRichTextBox.Size = new System.Drawing.Size(280, 147);
this.resultsRichTextBox.TabIndex = 0;
this.resultsRichTextBox.Text = "";
this.exportResultsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.exportResultsButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.Control;
this.exportResultsButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.exportResultsButton.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.exportResultsButton.ForeColor = System.Drawing.Color.Blue;
this.exportResultsButton.Location = new System.Drawing.Point(473, 1);
this.exportResultsButton.Name = "exportResultsButton";
this.exportResultsButton.Size = new System.Drawing.Size(102, 25);
this.exportResultsButton.TabIndex = 32;
this.exportResultsButton.Text = "Export Results (CSV)";
this.exportResultsButton.UseVisualStyleBackColor = true;
this.exportResultsButton.Click += new System.EventHandler(this.exportResultsButton_Click);
this.resultListView.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.resultListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.matchColumnHeader,
this.positionColumnHeader,
this.lengthColumnHeader});
this.resultListView.FullRowSelect = true;
this.resultListView.GridLines = true;
this.resultListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.resultListView.HideSelection = false;
this.resultListView.Location = new System.Drawing.Point(11, 27);
this.resultListView.MultiSelect = false;
this.resultListView.Name = "resultListView";
this.resultListView.Size = new System.Drawing.Size(567, 91);
this.resultListView.TabIndex = 1;
this.resultListView.UseCompatibleStateImageBehavior = false;
this.resultListView.View = System.Windows.Forms.View.Details;
this.resultListView.SelectedIndexChanged += new System.EventHandler(this.resultListView_SelectedIndexChanged);
this.matchColumnHeader.Text = "Match";
this.matchColumnHeader.Width = 350;
this.positionColumnHeader.Text = "Position";
this.lengthColumnHeader.Text = "Length";
this.resultsListLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.resultsListLabel.Location = new System.Drawing.Point(8, 9);
this.resultsListLabel.Name = "resultsListLabel";
this.resultsListLabel.Size = new System.Drawing.Size(570, 15);
this.resultsListLabel.TabIndex = 0;
this.resultsListLabel.Text = "Test Results";
this.copyButtonContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyGeneric0MenuItem,
this.copyGeneric1MenuItem,
this.copyGeneric2MenuItem,
this.copyGeneric3MenuItem});
this.copyButtonContextMenu.Name = "btnCopyContextMenuStrip";
this.copyButtonContextMenu.Size = new System.Drawing.Size(163, 92);
this.copyGeneric0MenuItem.Image = global::RegExTester.Properties.Resources.CSharpSnippet;
this.copyGeneric0MenuItem.Name = "copyGeneric0MenuItem";
this.copyGeneric0MenuItem.Size = new System.Drawing.Size(162, 22);
this.copyGeneric0MenuItem.Tag = "csharp snippet";
this.copyGeneric0MenuItem.Text = "C# code &snippet";
this.copyGeneric0MenuItem.Click += new System.EventHandler(this.copyGeneric0MenuItem_Click);
this.copyGeneric1MenuItem.Image = global::RegExTester.Properties.Resources.CSharp;
this.copyGeneric1MenuItem.Name = "copyGeneric1MenuItem";
this.copyGeneric1MenuItem.Size = new System.Drawing.Size(162, 22);
this.copyGeneric1MenuItem.Tag = "csharp";
this.copyGeneric1MenuItem.Text = "&C# escaped string";
this.copyGeneric1MenuItem.Click += new System.EventHandler(this.copyGeneric0MenuItem_Click);
this.copyGeneric2MenuItem.Image = global::RegExTester.Properties.Resources.Html;
this.copyGeneric2MenuItem.Name = "copyGeneric2MenuItem";
this.copyGeneric2MenuItem.Size = new System.Drawing.Size(162, 22);
this.copyGeneric2MenuItem.Tag = "html";
this.copyGeneric2MenuItem.Text = "&HTML encoded";
this.copyGeneric2MenuItem.Click += new System.EventHandler(this.copyGeneric0MenuItem_Click);
this.copyGeneric3MenuItem.Image = global::RegExTester.Properties.Resources.Plain;
this.copyGeneric3MenuItem.Name = "copyGeneric3MenuItem";
this.copyGeneric3MenuItem.Size = new System.Drawing.Size(162, 22);
this.copyGeneric3MenuItem.Tag = "plain";
this.copyGeneric3MenuItem.Text = "&Plain text";
this.copyGeneric3MenuItem.Click += new System.EventHandler(this.copyGeneric0MenuItem_Click);
this.exportSaveFileDialog.DefaultExt = "csv";
this.exportSaveFileDialog.Filter = "Comma Separated Values|*.csv|All files|*.*";
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(592, 457);
this.Controls.Add(this.topAndMiddleSplitContainer);
this.Controls.Add(this.statusBar);
this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
this.MinimumSize = new System.Drawing.Size(600, 390);
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "RegEx Tester";
this.Load += new System.EventHandler(this.MainForm_Load);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyUp);
((System.ComponentModel.ISupportInitialize)(this.statusStatusBarPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.matchesStatusBarPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.executionTimeStatusBarPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.contextStatusBarPanel)).EndInit();
this.topAndMiddleSplitContainer.Panel1.ResumeLayout(false);
this.topAndMiddleSplitContainer.Panel2.ResumeLayout(false);
this.topAndMiddleSplitContainer.ResumeLayout(false);
this.regExAndRepExSplitContainer.Panel1.ResumeLayout(false);
this.regExAndRepExSplitContainer.Panel1.PerformLayout();
this.regExAndRepExSplitContainer.Panel2.ResumeLayout(false);
this.regExAndRepExSplitContainer.Panel2.PerformLayout();
this.regExAndRepExSplitContainer.ResumeLayout(false);
this.middleAndBottomSplitContainer.Panel1.ResumeLayout(false);
this.middleAndBottomSplitContainer.Panel2.ResumeLayout(false);
this.middleAndBottomSplitContainer.ResumeLayout(false);
this.textAndResultsSplitContainer.Panel1.ResumeLayout(false);
this.textAndResultsSplitContainer.Panel2.ResumeLayout(false);
this.textAndResultsSplitContainer.ResumeLayout(false);
this.copyButtonContextMenu.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private StatusBar statusBar;
private StatusBarPanel statusStatusBarPanel;
private StatusBarPanel contextStatusBarPanel;
private SplitContainer topAndMiddleSplitContainer;
private SplitContainer middleAndBottomSplitContainer;
private Button copyButton;
private Button testButton;
private CheckBox cultureInvariantCheckBox;
private CheckBox singleLineCheckBox;
private CheckBox multiLineCheckBox;
private CheckBox ignoreCaseCheckBox;
private Label resultsListLabel;
private ListView resultListView;
private ColumnHeader matchColumnHeader;
private ColumnHeader positionColumnHeader;
private ColumnHeader lengthColumnHeader;
private CheckBox indentedInputCheckBox;
private System.ComponentModel.IContainer components;
private ContextMenuStrip copyButtonContextMenu;
private ToolStripMenuItem copyGeneric1MenuItem;
private ToolStripMenuItem copyGeneric2MenuItem;
private ToolStripMenuItem copyGeneric3MenuItem;
private CheckBox replaceModeCheckBox;
private SplitContainer textAndResultsSplitContainer;
private CustomRichTextBox resultsRichTextBox;
private CustomRichTextBox textRichTextBox;
private SplitContainer regExAndRepExSplitContainer;
private TextBox regExTextBox;
private TextBox repExTextBox;
private ToolStripMenuItem copyGeneric0MenuItem;
private Label textLabel;
private Label resultsLabel;
private Label regExLabel;
private Label repExLabel;
private StatusBarPanel matchesStatusBarPanel;
private StatusBarPanel executionTimeStatusBarPanel;
private Button ignoreCaseButton;
private Button cultureInvariantButton;
private Button multiLineButton;
private Button singleLineButton;
private Button replaceModeButton;
private Button indentedInputButton;
private Button aboutButton;
private Button regExLibraryButton;
private Button regExCheatSheetButton;
private SaveFileDialog exportSaveFileDialog;
private Button exportResultsButton;
} }
namespace RegExTester
{
public partial class frmMain : Form
{
private const string STOPPED_MODE_BUTTON_TEXT = "Test [F5]";
private const string RUNNING_MODE_BUTTON_TEXT = "Stop [Esc]";
private Thread worker;
public frmMain()
{
InitializeComponent();
ActiveControl = regExTextBox;
}
private void MainForm_Load(object sender, System.EventArgs e)
{
this.Text += " - v" + Application.ProductVersion.ToString();
contextStatusBarPanel.Text = string.Format("CLR {0}.{1}", Environment.Version.Major, Environment.Version.Minor);
Control.CheckForIllegalCrossThreadCalls = false;
replaceModeCheckBox.Checked = false;
}
private void MainForm_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F5 && testButton.Text == STOPPED_MODE_BUTTON_TEXT && !e.Control && !e.Alt && !e.Shift)
{
StartTest();
}
else if (e.KeyCode == Keys.Escape && testButton.Text == RUNNING_MODE_BUTTON_TEXT && !e.Control && !e.Alt && !e.Shift)
{
AbortTest();
}
}
private void testButton_Click(object sender, System.EventArgs e)
{
if (testButton.Text == STOPPED_MODE_BUTTON_TEXT)
{
StartTest();
}
else if (testButton.Text == RUNNING_MODE_BUTTON_TEXT)
{
AbortTest();
}
}
#region Test/Evaluate Feature implementation
private void StartTest()
{
statusStatusBarPanel.Text = "Creating the Test Thread...";
worker = new Thread(AsyncTest);
worker.IsBackground = true;
worker.Start();
}
private void AbortTest()
{
if (worker.IsAlive)
worker.Abort();
}
private void AsyncTest()
{
int rtbSelectionStart = int.MinValue;
int rtbSelectionLength = int.MinValue;
int matchesFound = 0;
int matchesProcessed = 0;
DateTime startMoment = DateTime.Now;
try
{
statusStatusBarPanel.Text = "Making UI Adjustments...";
testButton.Text = RUNNING_MODE_BUTTON_TEXT;
matchesStatusBarPanel.Text = string.Empty;
executionTimeStatusBarPanel.Text = string.Empty;
statusStatusBarPanel.Text = "Configuring the RegEx engine...";
RegexOptions regexOptions = new RegexOptions();
if (ignoreCaseCheckBox.Checked) regexOptions |= RegexOptions.IgnoreCase;
if (cultureInvariantCheckBox.Checked) regexOptions |= RegexOptions.CultureInvariant;
if (multiLineCheckBox.Checked) regexOptions |= RegexOptions.Multiline;
if (singleLineCheckBox.Checked) regexOptions |= RegexOptions.Singleline;
if (indentedInputCheckBox.Checked) regexOptions |= RegexOptions.IgnorePatternWhitespace;
statusStatusBarPanel.Text = "Creating the RegEx Engine and parsing the RegEx string...";
Regex regex = new Regex(regExTextBox.Text, regexOptions);
statusStatusBarPanel.Text = "Evaluating the RegEx against the Test Text...";
MatchCollection matchCollection = regex.Matches(textRichTextBox.Text);
matchesFound = matchCollection.Count;
if (replaceModeCheckBox.Checked)
{
statusStatusBarPanel.Text = "Evaluating the RegEx Replace against the Test Text...";
resultsRichTextBox.Text = regex.Replace(textRichTextBox.Text, repExTextBox.Text);
}
statusStatusBarPanel.Text = "Preparing the Results grid...";
resultListView.Items.Clear();
for (int i = resultListView.Columns.Count; i > 3; i--)
resultListView.Columns.RemoveAt(i-1);
int[] groupNumbers = regex.GetGroupNumbers();
string[] groupNames = regex.GetGroupNames();
string groupName = null;
foreach (int groupNumber in groupNumbers)
{
if (groupNumber > 0)
{
groupName = "Group " + groupNumber;
if (groupNames[groupNumber] != groupNumber.ToString()) groupName += " (" + groupNames[groupNumber] + ")";
resultListView.Columns.Add(groupName, 100, HorizontalAlignment.Left);
}
}
rtbSelectionStart = textRichTextBox.SelectionStart;
rtbSelectionLength = textRichTextBox.SelectionLength;
textRichTextBox.SuspendLayout();
resultListView.SuspendLayout();
resultListView.BeginUpdate();
textRichTextBox.SelectAll();
textRichTextBox.SelectionColor = Color.Black;
statusStatusBarPanel.Text = "Processing the " + matchesFound + " matchs...";
foreach (Match match in matchCollection)
{
ListViewItem lvi = resultListView.Items.Add(match.ToString());
lvi.SubItems.Add(match.Index.ToString());
lvi.SubItems.Add(match.Length.ToString());
for (int c = 1; c < match.Groups.Count; c++)
{
Group group = match.Groups[c];
if (group.Captures.Count == 1)
lvi.SubItems.Add(group.Value);
else
{
StringBuilder capturedValues = new StringBuilder();
foreach (Capture capture in group.Captures)
{
if (capturedValues.Length > 0)
capturedValues.Append(" ¦ ");
capturedValues.Append(capture.Value);
}
lvi.SubItems.Add(capturedValues.ToString());
}
}
textRichTextBox.Select(match.Index, match.Length);
textRichTextBox.SelectionColor = Color.Red;
matchesProcessed++;
}
statusStatusBarPanel.Text = "Test success.";
}
catch (ThreadAbortException)
{
statusStatusBarPanel.Text = "Test aborted by the user.";
}
catch (Exception e)
{
statusStatusBarPanel.Text = "Test aborted by an error.";
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
testButton.Text = STOPPED_MODE_BUTTON_TEXT;
if (rtbSelectionStart != int.MinValue && rtbSelectionLength != int.MinValue)
textRichTextBox.Select(rtbSelectionStart, rtbSelectionLength);
if (matchesProcessed == matchesFound)
matchesStatusBarPanel.Text = string.Format("{0} match(es).", matchesProcessed);
else
matchesStatusBarPanel.Text = string.Format("{0} match(es) of {1} found.", matchesProcessed, matchesFound);
TimeSpan executionTimeSpan = DateTime.Now.Subtract(startMoment);
if (executionTimeSpan.TotalHours > 1) executionTimeStatusBarPanel.Text = string.Format("{0} hs.", executionTimeSpan.TotalHours.ToString("##.##"));
else if (executionTimeSpan.TotalMinutes > 1) executionTimeStatusBarPanel.Text = string.Format("{0} mins.", executionTimeSpan.TotalMinutes.ToString("##.##"));
else if (executionTimeSpan.TotalSeconds > 1) executionTimeStatusBarPanel.Text = string.Format("{0} s.", executionTimeSpan.TotalSeconds.ToString("##.##"));
else if (executionTimeSpan.TotalMilliseconds > 1) executionTimeStatusBarPanel.Text = string.Format("{0} ms.", executionTimeSpan.TotalMilliseconds.ToString("#"));
resultListView.EndUpdate();
resultListView.ResumeLayout();
textRichTextBox.ResumeLayout();
}
}
private void resultListView_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (resultListView.SelectedItems.Count == 0) return;
textRichTextBox.Select(0, 0);
int position = Convert.ToInt32(resultListView.SelectedItems[0].SubItems[1].Text);
int length = Convert.ToInt32(resultListView.SelectedItems[0].SubItems[2].Text);
textRichTextBox.Select(position, length);
}
#endregion
#region IndentedInput and ReplaceMode UI adjustments
private void indentedInputCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (indentedInputCheckBox.Checked)
{
regExTextBox.Multiline = repExTextBox.Multiline = true;
regExTextBox.AcceptsTab = repExTextBox.AcceptsTab = true;
regExTextBox.ScrollBars = repExTextBox.ScrollBars = ScrollBars.Vertical;
topAndMiddleSplitContainer.IsSplitterFixed = false;
topAndMiddleSplitContainer.SplitterDistance = 160;
}
else
{
regExTextBox.Multiline = repExTextBox.Multiline = false;
regExTextBox.AcceptsTab = repExTextBox.AcceptsTab = false;
regExTextBox.ScrollBars = repExTextBox.ScrollBars = ScrollBars.None;
topAndMiddleSplitContainer.SplitterDistance = 100;
topAndMiddleSplitContainer.IsSplitterFixed = true;
}
}
private void replaceModeCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (replaceModeCheckBox.Checked)
{
regExAndRepExSplitContainer.Panel2Collapsed = false;
textAndResultsSplitContainer.Panel2Collapsed = false;
regExCheatSheetButton.Visible = false;
regExLibraryButton.Visible = false;
aboutButton.Visible = false;
}
else
{
regExAndRepExSplitContainer.Panel2Collapsed = true;
textAndResultsSplitContainer.Panel2Collapsed = true;
regExCheatSheetButton.Visible = true;
regExLibraryButton.Visible = true;
aboutButton.Visible = true;
}
}
#endregion
#region Copy Feature implementation
private void copyButton_Click(object sender, EventArgs e)
{
copyButtonContextMenu.Show(copyButton, new Point(0, copyButton.Height));
}
private void copyGeneric0MenuItem_Click(object sender, EventArgs e)
{
string regex = regExTextBox.Text;
string format = ((ToolStripMenuItem)sender).Tag.ToString();
if (format == "html")
{
regex = HttpUtility.HtmlEncode(regex);
}
else if (format.StartsWith("csharp"))
{
regex = string.Format("@\"{0}\"", regex.Replace("\"", "\"\""));
if (format.EndsWith("snippet"))
{
StringBuilder regexsb = new StringBuilder();
regexsb.Append("Regex regex = new Regex(");
if (indentedInputCheckBox.Checked && regex.Contains("\n"))
{
regexsb.Append("\r\n ");
regexsb.Append(Regex.Replace(regex, @"\r?\n", "$0 ", RegexOptions.Singleline));
}
else
regexsb.Append(regex);
if (ignoreCaseCheckBox.Checked || multiLineCheckBox.Checked || singleLineCheckBox.Checked || cultureInvariantCheckBox.Checked || indentedInputCheckBox.Checked)
{
regexsb.Append(", ");
if (indentedInputCheckBox.Checked && regex.Contains("\n"))
regexsb.Append("\r\n ");
if (ignoreCaseCheckBox.Checked) regexsb.Append("RegexOptions.IgnoreCase | ");
if (cultureInvariantCheckBox.Checked) regexsb.Append("RegexOptions.CultureInvariant | ");
if (multiLineCheckBox.Checked) regexsb.Append("RegexOptions.Multiline | ");
if (singleLineCheckBox.Checked) regexsb.Append("RegexOptions.Singleline | ");
if (indentedInputCheckBox.Checked) regexsb.Append("RegexOptions.IgnorePatternWhitespace | ");
regexsb.Remove(regexsb.Length - 3, 3);
}
regexsb.AppendLine(");");
regexsb.AppendLine("MatchCollection matchCollection = regex.Matches( [Target_string] );");
regexsb.AppendLine("foreach (Match match in matchCollection)");
regexsb.AppendLine("{");
regexsb.AppendLine(" do some work;");
regexsb.AppendLine("}");
regex = regexsb.ToString();
}
}
if (!string.IsNullOrEmpty(regex)) Clipboard.SetText(regex);
}
#endregion
#region Export Feature implementation
private void exportResultsButton_Click(object sender, EventArgs e)
{
if (resultListView.Items.Count < 1)
{
MessageBox.Show("There are no results to export.", "Export failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
statusStatusBarPanel.Text = "Export failed.";
return;
}
if (exportSaveFileDialog.ShowDialog() == DialogResult.OK)
{
StringBuilder sb = new StringBuilder();
bool firstColumn = true;
foreach (ColumnHeader columnHeader in resultListView.Columns)
{
if (!firstColumn)
sb.Append(",");
sb.AppendFormat("\"{0}\"", columnHeader.Text);
firstColumn = false;
}
sb.AppendLine();
foreach (ListViewItem listViewItem in resultListView.Items)
{
firstColumn = true;
foreach (ListViewItem.ListViewSubItem listViewSubItem in listViewItem.SubItems)
{
if (!firstColumn)
sb.Append(",");
sb.AppendFormat("\"{0}\"", listViewSubItem.Text);
firstColumn = false;
}
sb.AppendLine();
}
File.WriteAllText(exportSaveFileDialog.FileName, sb.ToString());
statusStatusBarPanel.Text = "Export saved.";
}
}
#endregion
#region Help links, Web Links and About
private void ignoreCaseButton_Click(object sender, EventArgs e)
{
MessageBox.Show("This option makes the RegEx case-insensitive which means that 'a' and 'A' are treated as the same letter.", "Ignore Case Option", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void cultureInvariantButton_Click(object sender, EventArgs e)
{
MessageBox.Show("If you use the Ignore Case Option you should always keep in mind the Culture Invariant Option because (\"file\" == \"FILE\") is True for many cultures (e.g. en-US) but it's False on some of them (e.g. tr-TR Turkish). Turning On this option is generally safer.", "Culture Invariant Option", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void multiLineButton_Click(object sender, EventArgs e)
{
MessageBox.Show("This option makes ^ and $ match beginning and end of each line insted of the beginning and end of the whole text.", "Treat as Multi Line Option", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void singleLineButton_Click(object sender, EventArgs e)
{
MessageBox.Show("This option makes . match every character including newline.", "Treat as Single Line Option", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void indentedInputButton_Click(object sender, EventArgs e)
{
MessageBox.Show(@"If you activate this option the RegEx will be stripped of \r \n \t \v and spaces before execution. This allows you to write thouse ugly, long and cryptic RegEx in an indented and spaced fashion. The whitespace characters still works inside character classes.", "Indented Input Option", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void replaceModeButton_Click(object sender, EventArgs e)
{
MessageBox.Show(@"You will be able to test a RegEx replacement expression. Remember that $0 represents the match and $N represents the Nth capture group.", "RegEx Replace Option", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void regExLibraryButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("This would open the uri http://regexlib.com/ in your default browser.", "RegEx Library", MessageBoxButtons.OKCancel) == DialogResult.OK)
Process.Start("http://regexlib.com/");
}
private void regExCheatSheetButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("This would open the uri http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ in your default browser.", "RegEx CheatSheet", MessageBoxButtons.OKCancel) == DialogResult.OK)
Process.Start("http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/");
}
private void aboutButton_Click(object sender, EventArgs e)
{
frmAbout af = new frmAbout();
af.ShowDialog();
af.Dispose();
}
#endregion
}}namespace RegExTester
{
partial class CustomRichTextBox
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmiUndo = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiRedo = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.tsmiCut = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiCopy = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiPaste = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiDelete = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.tsmiFind = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiFindNext = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.tsmiSelectAll = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.tsmiWordWrap = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip.SuspendLayout();
this.SuspendLayout();
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmiUndo,
this.tsmiRedo,
this.tsmiSeparator1,
this.tsmiCut,
this.tsmiCopy,
this.tsmiPaste,
this.tsmiDelete,
this.tsmiSeparator2,
this.tsmiFind,
this.tsmiFindNext,
this.tsmiSeparator3,
this.tsmiSelectAll,
this.tsmiSeparator4,
this.tsmiWordWrap});
this.contextMenuStrip.Name = "rtbTextContextMenuStrip";
this.contextMenuStrip.Size = new System.Drawing.Size(138, 248);
this.tsmiUndo.Image = global::RegExTester.Properties.Resources.Undo;
this.tsmiUndo.Name = "tsmiUndo";
this.tsmiUndo.Size = new System.Drawing.Size(137, 22);
this.tsmiUndo.Text = "&Undo";
this.tsmiUndo.Click += new System.EventHandler(this.tsmiUndo_Click);
this.tsmiRedo.Image = global::RegExTester.Properties.Resources.Redo;
this.tsmiRedo.Name = "tsmiRedo";
this.tsmiRedo.Size = new System.Drawing.Size(137, 22);
this.tsmiRedo.Text = "&Redo";
this.tsmiRedo.Click += new System.EventHandler(this.tsmiRedo_Click);
this.tsmiSeparator1.Name = "tsmiSeparator1";
this.tsmiSeparator1.Size = new System.Drawing.Size(134, 6);
this.tsmiCut.Image = global::RegExTester.Properties.Resources.Cut;
this.tsmiCut.Name = "tsmiCut";
this.tsmiCut.Size = new System.Drawing.Size(137, 22);
this.tsmiCut.Text = "Cu&t";
this.tsmiCut.Click += new System.EventHandler(this.tsmiCut_Click);
this.tsmiCopy.Image = global::RegExTester.Properties.Resources.Copy;
this.tsmiCopy.Name = "tsmiCopy";
this.tsmiCopy.Size = new System.Drawing.Size(137, 22);
this.tsmiCopy.Text = "&Copy";
this.tsmiCopy.Click += new System.EventHandler(this.tsmiCopy_Click);
this.tsmiPaste.Image = global::RegExTester.Properties.Resources.Paste;
this.tsmiPaste.Name = "tsmiPaste";
this.tsmiPaste.Size = new System.Drawing.Size(137, 22);
this.tsmiPaste.Text = "&Paste";
this.tsmiPaste.Click += new System.EventHandler(this.tsmiPaste_Click);
this.tsmiDelete.Image = global::RegExTester.Properties.Resources.Delete;
this.tsmiDelete.Name = "tsmiDelete";
this.tsmiDelete.Size = new System.Drawing.Size(137, 22);
this.tsmiDelete.Text = "&Delete";
this.tsmiDelete.Click += new System.EventHandler(this.tsmiDelete_Click);
this.tsmiSeparator2.Name = "tsmiSeparator2";
this.tsmiSeparator2.Size = new System.Drawing.Size(134, 6);
this.tsmiFind.Image = global::RegExTester.Properties.Resources.Find;
this.tsmiFind.Name = "tsmiFind";
this.tsmiFind.Size = new System.Drawing.Size(137, 22);
this.tsmiFind.Text = "&Find...";
this.tsmiFind.Click += new System.EventHandler(this.tsmiFind_Click);
this.tsmiFindNext.Image = global::RegExTester.Properties.Resources.FindNext;
this.tsmiFindNext.Name = "tsmiFindNext";
this.tsmiFindNext.Size = new System.Drawing.Size(137, 22);
this.tsmiFindNext.Text = "Find &Next";
this.tsmiFindNext.Click += new System.EventHandler(this.tsmiFindNext_Click);
this.tsmiSeparator3.Name = "tsmiSeparator3";
this.tsmiSeparator3.Size = new System.Drawing.Size(134, 6);
this.tsmiSelectAll.Image = global::RegExTester.Properties.Resources.Plain;
this.tsmiSelectAll.Name = "tsmiSelectAll";
this.tsmiSelectAll.Size = new System.Drawing.Size(137, 22);
this.tsmiSelectAll.Text = "Select &All";
this.tsmiSelectAll.Click += new System.EventHandler(this.tsmiSelectAll_Click);
this.tsmiSeparator4.Name = "tsmiSeparator4";
this.tsmiSeparator4.Size = new System.Drawing.Size(134, 6);
this.tsmiWordWrap.Checked = true;
this.tsmiWordWrap.CheckOnClick = true;
this.tsmiWordWrap.CheckState = System.Windows.Forms.CheckState.Checked;
this.tsmiWordWrap.Image = global::RegExTester.Properties.Resources.WordWrap;
this.tsmiWordWrap.Name = "tsmiWordWrap";
this.tsmiWordWrap.Size = new System.Drawing.Size(137, 22);
this.tsmiWordWrap.Text = "&WordWrap";
this.tsmiWordWrap.CheckStateChanged += new System.EventHandler(this.tsmiWordWrap_CheckStateChanged);
this.ContextMenuStrip = this.contextMenuStrip;
this.contextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem tsmiUndo;
private System.Windows.Forms.ToolStripMenuItem tsmiRedo;
private System.Windows.Forms.ToolStripSeparator tsmiSeparator1;
private System.Windows.Forms.ToolStripMenuItem tsmiCut;
private System.Windows.Forms.ToolStripMenuItem tsmiCopy;
private System.Windows.Forms.ToolStripMenuItem tsmiPaste;
private System.Windows.Forms.ToolStripMenuItem tsmiDelete;
private System.Windows.Forms.ToolStripSeparator tsmiSeparator2;
private System.Windows.Forms.ToolStripMenuItem tsmiFind;
private System.Windows.Forms.ToolStripMenuItem tsmiFindNext;
private System.Windows.Forms.ToolStripSeparator tsmiSeparator3;
private System.Windows.Forms.ToolStripMenuItem tsmiSelectAll;
private System.Windows.Forms.ToolStripSeparator tsmiSeparator4;
private System.Windows.Forms.ToolStripMenuItem tsmiWordWrap;
}}
namespace RegExTester
{
public partial class CustomRichTextBox : RichTextBox
{
public CustomRichTextBox() : base()
{
InitializeComponent();
}
#region Custom extension of the SuspendLayout feature
[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
private const int WM_SETREDRAW = 11;
public new void SuspendLayout()
{
base.SuspendLayout();
SendMessage(base.Handle, WM_SETREDRAW, false, 0);
}
public new void ResumeLayout()
{
this.ResumeLayout(true);
}
public new void ResumeLayout(bool performLayout)
{
SendMessage(base.Handle, WM_SETREDRAW, true, 0);
base.ResumeLayout(performLayout);
base.Refresh();
}
#endregion
#region ContextMenu feature
private string _lastFindString = "";
private void tsmiUndo_Click(object sender, EventArgs e)
{
base.Undo();
}
private void tsmiRedo_Click(object sender, EventArgs e)
{
base.Redo();
}
private void tsmiCut_Click(object sender, EventArgs e)
{
base.Cut();
}
private void tsmiCopy_Click(object sender, EventArgs e)
{
base.Copy();
}
private void tsmiPaste_Click(object sender, EventArgs e)
{
base.Paste();
}
private void tsmiDelete_Click(object sender, EventArgs e)
{
SendKeys.Send("{DEL}");
}
private void tsmiFind_Click(object sender, EventArgs e)
{
string findString = Interaction.InputBox("Insert text to find...", "Find Function", _lastFindString, -1, -1);
if (string.IsNullOrEmpty(findString)) return;
int position = base.Find(findString, 0, RichTextBoxFinds.None);
if (position == -1)
{
MessageBox.Show("Text not found", "Find Function", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
base.Select(position, findString.Length);
_lastFindString = findString;
}
}
private void tsmiFindNext_Click(object sender, EventArgs e)
{
string findString = _lastFindString;
if (string.IsNullOrEmpty(findString)) return;
int position = base.Find(findString, base.SelectionStart + base.SelectionLength, RichTextBoxFinds.None);
if (position == -1)
{
MessageBox.Show("No more occurrences found", "Find Next Function", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
base.Select(position, findString.Length);
}
}
private void tsmiSelectAll_Click(object sender, EventArgs e)
{
base.SelectAll();
}
private void tsmiWordWrap_CheckStateChanged(object sender, EventArgs e)
{
base.WordWrap = tsmiWordWrap.Checked;
}
#endregion
}}
namespace RegExTester
{
partial class frmAbout
{
private System.ComponentModel.Container components = null;
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAbout));
this.llHomepage1 = new System.Windows.Forms.LinkLabel();
this.label1 = new System.Windows.Forms.Label();
this.titleLabel = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.llProject1 = new System.Windows.Forms.LinkLabel();
this.closeButton = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.llProject2 = new System.Windows.Forms.LinkLabel();
this.llProject3 = new System.Windows.Forms.LinkLabel();
this.llTCPArticle3 = new System.Windows.Forms.LinkLabel();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.llHomepage1.AutoSize = true;
this.llHomepage1.Location = new System.Drawing.Point(367, 155);
this.llHomepage1.Name = "llHomepage1";
this.llHomepage1.Size = new System.Drawing.Size(112, 13);
this.llHomepage1.TabIndex = 5;
this.llHomepage1.TabStop = true;
this.llHomepage1.Text = "Davide Homepage";
this.llHomepage1.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llHomepage1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llHomepage1_LinkClicked);
this.label1.Location = new System.Drawing.Point(13, 81);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(506, 45);
this.label1.TabIndex = 2;
this.label1.Text = resources.GetString("label1.Text");
this.titleLabel.Font = new System.Drawing.Font("Verdana", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.titleLabel.Location = new System.Drawing.Point(11, 9);
this.titleLabel.Name = "titleLabel";
this.titleLabel.Size = new System.Drawing.Size(508, 32);
this.titleLabel.TabIndex = 0;
this.titleLabel.Text = "RegEx Tester";
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 41);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(157, 13);
this.label3.TabIndex = 1;
this.label3.Text = "Regular Expression Tester";
this.label4.Location = new System.Drawing.Point(12, 155);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(247, 20);
this.label4.TabIndex = 3;
this.label4.Text = "Originally written by Davide Mauri (2003)";
this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llProject1.AutoSize = true;
this.llProject1.Location = new System.Drawing.Point(265, 155);
this.llProject1.Name = "llProject1";
this.llProject1.Size = new System.Drawing.Size(96, 13);
this.llProject1.TabIndex = 4;
this.llProject1.TabStop = true;
this.llProject1.Text = "Project Website";
this.llProject1.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llProject1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llProject1_LinkClicked);
this.closeButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.closeButton.Location = new System.Drawing.Point(438, 290);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(75, 23);
this.closeButton.TabIndex = 0;
this.closeButton.Text = "Close";
this.closeButton.Click += new System.EventHandler(this.btnClose_Click);
this.label5.Location = new System.Drawing.Point(12, 178);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(247, 20);
this.label5.TabIndex = 6;
this.label5.Text = "Enhanced by Kurt Griffiths (2006)";
this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.label6.Location = new System.Drawing.Point(12, 201);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(247, 20);
this.label6.TabIndex = 8;
this.label6.Text = "Turbocharged by Pablo Osיs (2009)";
this.label6.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llProject2.AutoSize = true;
this.llProject2.Location = new System.Drawing.Point(265, 178);
this.llProject2.Name = "llProject2";
this.llProject2.Size = new System.Drawing.Size(96, 13);
this.llProject2.TabIndex = 7;
this.llProject2.TabStop = true;
this.llProject2.Text = "Project Website";
this.llProject2.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llProject2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llProject2_LinkClicked);
this.llProject3.AutoSize = true;
this.llProject3.Location = new System.Drawing.Point(265, 201);
this.llProject3.Name = "llProject3";
this.llProject3.Size = new System.Drawing.Size(96, 13);
this.llProject3.TabIndex = 9;
this.llProject3.TabStop = true;
this.llProject3.Text = "Project Website";
this.llProject3.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llProject3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llProject3_LinkClicked);
this.llTCPArticle3.AutoSize = true;
this.llTCPArticle3.Location = new System.Drawing.Point(367, 201);
this.llTCPArticle3.Name = "llTCPArticle3";
this.llTCPArticle3.Size = new System.Drawing.Size(146, 13);
this.llTCPArticle3.TabIndex = 10;
this.llTCPArticle3.TabStop = true;
this.llTCPArticle3.Text = "The Code Project Article";
this.llTCPArticle3.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.llTCPArticle3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llTCPArticle3_LinkClicked);
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(265, 224);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(159, 13);
this.linkLabel1.TabIndex = 12;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "E-mail: opablo@gmail.com";
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
this.label2.Location = new System.Drawing.Point(16, 265);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(497, 20);
this.label2.TabIndex = 13;
this.label2.Text = "Feature contributions: Eric Lebetsamer (2010)";
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(531, 325);
this.Controls.Add(this.label2);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.llTCPArticle3);
this.Controls.Add(this.llProject3);
this.Controls.Add(this.llProject2);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.closeButton);
this.Controls.Add(this.llProject1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.titleLabel);
this.Controls.Add(this.label1);
this.Controls.Add(this.llHomepage1);
this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmAbout";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "About";
this.Load += new System.EventHandler(this.frmAbout_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.LinkLabel llHomepage1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label titleLabel;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.LinkLabel llProject1;
private System.Windows.Forms.Button closeButton;
private Label label5;
private Label label6;
private LinkLabel llProject2;
private LinkLabel llProject3;
private LinkLabel llTCPArticle3;
private LinkLabel linkLabel1;
private Label label2;
}}
namespace RegExTester
{
public partial class frmAbout : Form
{
public frmAbout()
{
InitializeComponent();
}
private void llHomepage1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.davidemauri.it/");
}
private void llProject1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.sourceforge.net/projects/regextest");
}
private void llProject2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.codeproject.com/KB/cs/dotnetregextest.aspx");
}
private void llProject3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/opablo/RegExTester");
}
private void llTCPArticle3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.codeproject.com/KB/string/regextester.aspx");
}
private void btnClose_Click(object sender, System.EventArgs e)
{
Close();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("mailto://opablo@gmail.com");
}
private void frmAbout_Load(object sender, EventArgs e)
{
titleLabel.Text += " - v" + Application.ProductVersion.ToString();
}
}}
namespace RegExTester.Properties {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RegExTester.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Icon App {
get {
object obj = ResourceManager.GetObject("App", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
internal static System.Drawing.Bitmap Copy {
get {
object obj = ResourceManager.GetObject("Copy", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap CSharp {
get {
object obj = ResourceManager.GetObject("CSharp", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap CSharpSnippet {
get {
object obj = ResourceManager.GetObject("CSharpSnippet", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Cut {
get {
object obj = ResourceManager.GetObject("Cut", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Delete {
get {
object obj = ResourceManager.GetObject("Delete", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Find {
get {
object obj = ResourceManager.GetObject("Find", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap FindNext {
get {
object obj = ResourceManager.GetObject("FindNext", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Html {
get {
object obj = ResourceManager.GetObject("Html", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Paste {
get {
object obj = ResourceManager.GetObject("Paste", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Plain {
get {
object obj = ResourceManager.GetObject("Plain", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Redo {
get {
object obj = ResourceManager.GetObject("Redo", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Undo {
get {
object obj = ResourceManager.GetObject("Undo", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap WordWrap {
get {
object obj = ResourceManager.GetObject("WordWrap", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
|
|
|
|
|
You need to edit your question and remove all the code that is not relevant to your question, and indicate exactly where the error occurs.
|
|
|
|
|
|
I answered a question here: Convert text to unicode[^]
Now once again I read a lot of articles this weekend and the question comes up: Did I really answered correctly?
Is the statement "c# strings are Unicode strings" correct?
Should it not better be only "c# strings represents text as a sequence of UTF-16 code units"?
Thank you in advance.
[Edit]
In this context I'm asking me also if e.g. "ä" saved to mssql one time composed ('ä') and one time decomposed ('a' '¨') will be treated as equal... this I Need to test...
modified 16-Dec-17 12:05pm.
|
|
|
|
|
Yeah, Unicode defines characters (code points) but not strings or streams of them.
On the other hand, my pedanticism doesn't extend to saying that there is no such thing as "Unicode strings" -- it seems a reasonable shorthand for "text as a sequence of UTF-16 code units".
|
|
|
|
|
|
PIEBALDconsult wrote: my pedanticism
On the other other hand, my pedantry does extend to saying there's no such word as "pedanticism".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You must not be a true pedanticist.
|
|
|
|
|
Hi,
I am creating an Asp.Net MVC5 application where I have two areas called Teacher and Parent. I want to display a Child's home page based on the area, that is, both the teacher and parent have their own page layout. I can pull the child data using json. How can display it as a partial view in both parent and teacher home page?
Thanks
|
|
|
|
|
sunsher wrote: I am creating an Asp.Net MVC5 application Then you should post your question in the ASP.NET forum: ASP.NET Discussion Boards[^].
|
|
|
|
|
This is a spin-off from the thread Efficiently sort the following? - Algorithms Discussion Boards , but specifically is about converting .NET 4.5 LINQ code into .NET 2.0 code using LinqBridge. The following code is using .NET 4.5 and works fine in Visual Studio 2013:
public struct Record
{
public string column1 { get; set; }
public string column2 { get; set; }
public string column3 { get; set; }
}
public Form1()
{
InitializeComponent();
Record[] UnsortedRecords =
{
new Record { column1 = "City", column2 = "Florida", column3 = "Miami"},
new Record { column1 = "Animal", column2 = "Land", column3 = "Dog"},
new Record { column1 = "Animal", column2 = "Land", column3 = "Rabbit"},
new Record { column1 = "Food", column2 = "Dessert", column3 = "Chocolate Mousse"},
new Record { column1 = "Food", column2 = "Dinner", column3 = "Hamburger"},
new Record { column1 = "Animal", column2 = "Water", column3 = "Fish"},
new Record { column1 = "Animal", column2 = "Land", column3 = "Cat"},
new Record { column1 = "Food", column2 = "Dessert", column3 = "Cake"},
new Record { column1 = "Animal", column2 = "Air", column3 = "Bird"},
new Record { column1 = "Food", column2 = "Dessert", column3 = "Ice Cream"},
new Record { column1 = "Food", column2 = "Dinner", column3 = "Steak"},
new Record { column1 = "Animal", column2 = "Water", column3 = "Sea Lion"},
new Record { column1 = "City", column2 = "Texas", column3 = "Austin"},
new Record { column1 = "Food", column2 = "Breakfast", column3 = "Cereal"},
new Record { column1 = "Food", column2 = "Breakfast", column3 = "Pancakes"},
new Record { column1 = "City", column2 = "Florida", column3 = "Tampa"},
new Record { column1 = "Animal" , column2 = "Air", column3 = "Fly"},
new Record { column1 = "City", column2 = "California", column3 = "San Francisco"},
new Record { column1 = "Food", column2 = "Breakfast", column3 = "Bacon and Eggs"},
new Record { column1 = "City", column2 = "Texas", column3 = "Dallas"},
new Record { column1 = "City", column2 = "Texas", column3 = "Houston"},
new Record { column1 = "City", column2 = "California", column3 = "Los Angeles"},
new Record { column1 = "Animal", column2 = "Water", column3 = "Dolphin"},
new Record { column1 = "Animal", column2 = "Air", column3 = "Bee"},
new Record { column1 = "City", column2 = "Florida", column3 = "Orlando"},
new Record { column1 = "City", column2 = "California", column3 = "San Diego"},
new Record { column1 = "Food", column2 = "Dinner", column3 = "Lasagna" },
};
/* Sorted:
"City" "Florida" "Miami"
"City" "Florida" "Tampa"
"City" "Florida" "Orlando"
"City" "Texas" "Austin"
"City" "Texas" "Dallas"
"City" "Texas" "Houston"
"City" "California" "San Francisco"
"City" "California" "Los Angeles"
"City" "California" "San Diego"
"Animal" "Land" "Dog"
"Animal" "Land" "Rabbit"
"Animal" "Land" "Cat"
"Animal" "Water" "Fish"
"Animal" "Water" "Sea Lion"
"Animal" "Water" "Dolphin"
"Animal" "Air" "Bird"
"Animal" "Air" "Fly"
"Animal" "Air" "Bee"
"Food" "Dessert" "Chocolate Mousse"
"Food" "Dessert" "Cake"
"Food" "Dessert" "Ice Cream"
"Food" "Dinner" "Hamburger"
"Food" "Dinner" "Steak"
"Food" "Dinner" "Lasagna"
"Food" "Breakfast" "Cereal"
"Food" "Breakfast" "Bacon and Eggs"
"Food" "Breakfast" "Pancakes"
*/
IEnumerable<Record> SortedRecords = SortRecords(UnsortedRecords);
}
public static IEnumerable<Record> SortRecords(IEnumerable<Record> source)
{
return source
.GroupBy(r => r.column1, (key, items) => items
.GroupBy(r => r.column2)
.SelectMany(g => g)
)
.SelectMany(g => g);
}
The code above works great, but I need to run it in Visual Studio 2005, that is .NET 2.0. I have downloaded LinqBridge.dll ( LinqBridge ) and added a reference to it and I have tried the following, but I get build errors:
public class Record
{
public string column1;
public string column2;
public string column3;
public Record(string column1, string column2, string column3)
{
this.column1 = column1;
this.column2 = column2;
this.column3 = column3;
}
}
public Form1()
{
InitializeComponent();
System.Collections.ArrayList UnsortedRecords = new System.Collections.ArrayList();
UnsortedRecords.Add(new Record("City", "Florida", "Miami"));
UnsortedRecords.Add(new Record("Animal", "Land", "Dog"));
UnsortedRecords.Add(new Record("Animal", "Land", "Rabbit"));
UnsortedRecords.Add(new Record("Food", "Dessert", "Chocolate Mousse"));
UnsortedRecords.Add(new Record("Food", "Dinner", "Hamburger"));
UnsortedRecords.Add(new Record("Animal", "Water", "Fish"));
UnsortedRecords.Add(new Record("Animal", "Land", "Cat"));
UnsortedRecords.Add(new Record("Food", "Dessert", "Cake"));
UnsortedRecords.Add(new Record("Animal", "Air", "Bird"));
UnsortedRecords.Add(new Record("Food", "Dessert", "Ice Cream"));
UnsortedRecords.Add(new Record("Food", "Dinner", "Steak"));
UnsortedRecords.Add(new Record("Animal", "Water", "Sea Lion"));
UnsortedRecords.Add(new Record("City", "Texas", "Austin"));
UnsortedRecords.Add(new Record("Food", "Breakfast", "Cereal"));
UnsortedRecords.Add(new Record("Food", "Breakfast", "Pancakes"));
UnsortedRecords.Add(new Record("City", "Florida", "Tampa"));
UnsortedRecords.Add(new Record("Animal" , "Air", "Fly"));
UnsortedRecords.Add(new Record("City", "California", "San Francisco"));
UnsortedRecords.Add(new Record("Food", "Breakfast", "Bacon and Eggs"));
UnsortedRecords.Add(new Record("City", "Texas", "Dallas"));
UnsortedRecords.Add(new Record("City", "Texas", "Houston"));
UnsortedRecords.Add(new Record("City", "California", "Los Angeles"));
UnsortedRecords.Add(new Record("Animal", "Water", "Dolphin"));
UnsortedRecords.Add(new Record("Animal", "Air", "Bee"));
UnsortedRecords.Add(new Record("City", "Florida", "Orlando"));
UnsortedRecords.Add(new Record("City", "California", "San Diego"));
UnsortedRecords.Add(new Record("Food", "Dinner", "Lasagna" ));
/* Sorted:
"City" "Florida" "Miami"
"City" "Florida" "Tampa"
"City" "Florida" "Orlando"
"City" "Texas" "Austin"
"City" "Texas" "Dallas"
"City" "Texas" "Houston"
"City" "California" "San Francisco"
"City" "California" "Los Angeles"
"City" "California" "San Diego"
"Animal" "Land" "Dog"
"Animal" "Land" "Rabbit"
"Animal" "Land" "Cat"
"Animal" "Water" "Fish"
"Animal" "Water" "Sea Lion"
"Animal" "Water" "Dolphin"
"Animal" "Air" "Bird"
"Animal" "Air" "Fly"
"Animal" "Air" "Bee"
"Food" "Dessert" "Chocolate Mousse"
"Food" "Dessert" "Cake"
"Food" "Dessert" "Ice Cream"
"Food" "Dinner" "Hamburger"
"Food" "Dinner" "Steak"
"Food" "Dinner" "Lasagna"
"Food" "Breakfast" "Cereal"
"Food" "Breakfast" "Bacon and Eggs"
"Food" "Breakfast" "Pancakes"
*/
System.Collections.ArrayList SortedRecords = SortRecords(UnsortedRecords);
}
// You can either replace the ArrayList with a List<T>[^], or use the Cast[^] or OfType[^]
// methods to convert it to an IEnumerable<T>.
public static IEnumerable<Record> SortRecords(IEnumerable<Record> source)
{
IEnumerable<IEnumerable<Record>> groupT = System.Linq.Enumerable.GroupBy<Record, string, IEnumerable<Record>>(source,
delegate(Record r) { return r.column1; },
delegate(string key, IEnumerable<Record> items)
{
IEnumerable<IGrouping<string, Record>> groupH = System.Linq.Enumerable.GroupBy<Record, string>(items, delegate(Record r) { return r.column2; });
return System.Linq.Enumerable.SelectMany<IEnumerable<Record>, Record>(groupH, delegate(IEnumerable<Record> g) { return g; });
});
return System.Linq.Enumerable.SelectMany<IEnumerable<Record>, Record>(groupT, delegate(IEnumerable<Record> g) { return g; });
}
Can someone please help me get this work?
|
|
|
|
|
The obvious error is that you're trying to pass the non-generic ArrayList class to a parameter which expects the generic IEnumerable<T> interface, and trying to assign an IEnumerable<T> to an ArrayList .
ArrayList doesn't implement IEnumerable<T> , because it pre-dates generics. Change the variables:
List<Record> UnsortedRecords = new List<Record>();
UnsortedRecords.Add(...);
...
IEnumerable<Record> SortedRecords = SortRecords(UnsortedRecords);
With that change in place, your code should work. If you're still getting compiler errors, then post them here.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
 I have re-arranged the code a little to make it easier to spot the compile errors:
30
31 List<Record> UnsortedRecords = new List<Record>();
32 UnsortedRecords.Add(new Record("City", "Florida", "Miami"));
33 // The rest of the adds are removed in order to compact the code
34
35 List<Record> SortedRecords = SortRecords(UnsortedRecords);
36 }
37
38 // You can either replace the ArrayList with a List<T>[^], or use the Cast[^] or OfType[^]
39 // methods to convert it to an IEnumerable<T>.
40 public static IEnumerable<Record> SortRecords(IEnumerable<Record> source)
41 {
42 IEnumerable<IEnumerable<Record>> groupT = System.Linq.Enumerable.GroupBy<Record, string, IEnumerable<Record>>
43 (source,
44 delegate(Record r) { return r.column1; },
45 delegate(
46 string key, IEnumerable<Record> items)
47 {
48 IEnumerable<System.Linq.IGrouping<string, Record>> groupH = System.Linq.Enumerable.GroupBy<Record, string>(items, delegate(Record r) { return r.column2; });
49 return System.Linq.Enumerable.SelectMany<IEnumerable<Record>,
50 Record>(groupH,
51 delegate(IEnumerable<Record> g) {
52 return g; });
53 });
54
55 return System.Linq.Enumerable.SelectMany<IEnumerable<Record>, Record>(groupT, delegate(IEnumerable<Record> g) { return g; });
56 }
57 }
58 }
I get the following 5 compile errors:
Line 35: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<sort.form1.record>' to 'System.Collections.Generic.List<sort.form1.record>'. An explicit conversion exists (are you missing a cast?)
Line 43: The best overloaded method match for 'System.Linq.Enumerable.GroupBy<sort.form1.record,string,system.collections.generic.ienumerable<sort.form1.record>>(System.Collections.Generic.IEnumerable<sort.form1.record>, System.Func<sort.form1.record,string>, System.Func<sort.form1.record,system.collections.generic.ienumerable<sort.form1.record>>)' has some invalid arguments
Line 45: Argument '3': cannot convert from 'anonymous method' to 'System.Func<sort.form1.record,system.collections.generic.ienumerable<sort.form1.record>>'
Line 50: The best overloaded method match for 'System.Linq.Enumerable.SelectMany<system.collections.generic.ienumerable<sort.form1.record>,Sort.Form1.Record>(System.Collections.Generic.IEnumerable<system.collections.generic.ienumerable<sort.form1.record>>, System.Func<system.collections.generic.ienumerable<sort.form1.record>,System.Collections.Generic.IEnumerable<sort.form1.record>>)' has some invalid arguments
Line 50: Argument '1': cannot convert from 'System.Collections.Generic.IEnumerable<system.linq.igrouping<string,sort.form1.record>>' to 'System.Collections.Generic.IEnumerable<system.collections.generic.ienumerable<sort.form1.record>>'
|
|
|
|
|