The Complete Source Code for a Notepad C# Application

Notepad Clone in C# .NET

I use notepad all the time, sometimes I just wanted to add one little feature, but it’s not extendable so I can’t. If I could just get my hands on the source code and if that source code was in C# I’d be set. So I decided to write a clone so I can do just that, and share it so that others could as well.

I attempted to make an exact clone and I think I did pretty good with three exceptions. One I decided I wanted a different icon so I can tell it apart from the actual notepad. Two, the real notepad has header and footer information as part of the page setup. I didn’t know how to do that since the page setup dialog is a system dialog. And three I didn’t try to duplicate the windows notepad help file.

As you can see from the screenshot it includes the following features:

  • File
    • New
    • Open
    • Save
    • Save As
    • Page Setup
    • Header & Footer (you can use variables to include filename, date, and other information)
    • Print
    • Exit
  • Edit
    • – Undo
    • – Cut
    • – Copy
    • – Paste
    • – Delete
    • – Find
      • Find next
      • Direction up/down
      • Match case
    • – Find Next
    • – Replace
      • Find next
      • Replace
      • Replace all
      • Match case
    •  Go To (a specific line number)
    •  Select All
    •  Time/Date (inserts the date and time e.g 9:18 PM 2/11/2014)
    • insert (e.g 9:18 PM 2/11/2014)
  • Format
    • Word Wrap
    • Font
  • View
    • Status bar (displays the line number and column number)
  • Help
    • View Help (you will have to provide your own documentation)
    • About Notepad Clone

Download Notepad Clone .NET Binary (exe)

You can get the source code at GitHub:

https://github.com/luisperezphd/NotepadClone

If you would like to be notified of future posts subscribe to my mailing list using the widget on the bottom.

Knockout JS 1.3 Performance in Chrome

UDPATE – This blog post refers to a performance issue in Knockout 1.3, the issue has since been resolved in Knockout 2.0

First I want to say I love knockout.js not just for it’s data binding but it’s combination of data binding with inline templates.

I ran into a problem today though I was using Knockout.js beta 1.3 and  the performance for 100+ object list was going really slow. But only on Chrome, it turned out to be a chrome issue (I’m using Chrome 16.0.912.63 m). The finally narrowed down the issue to be the performance of the innerText property specifically when you get the property.

To fix the issue I replaced Knockout’s built in text binding with my own and used jQuery’s text() function to set the innerText/textContent property. Here is the code for that binding (by the way it’s awesome that Knockout lets you replace their bindings).

ko.bindingHandlers['text'] = {
 'update': function (element, valueAccessor) {
  var value = ko.utils.unwrapObservable(valueAccessor());
  if ((value === null) || (value === undefined)) value = "";
  //typeof element.innerText == "string" ? element.innerText = value : element.textContent = value;
  $(element).text(value);
 }
};

Just wanted to add a quick note on what Knockout.js is and does:

I find inline templates much easier to follow and understand, because it keeps the HTML in tact it makes it very easy to work with the HTML given to you by a designer, since you practically don’t have to alter at all you can even leave in sample data.

You can also use other constructs like observables to automagically update your html as you change your objects. For example if you add more people to your model it’s automatically reflected on the screen. Also if you changed the name of the one of the people.