Eki 12
Digg
Stumbleupon
Technorati
Delicious

Datagridview leri renklendirelim kampanyası

Basit bir uygulama için yaptığım tek amacı Datagridview i biraz renklendirmek olan

ve içinde de birazcık custom column bulunan bir grid kontrolünün hikayesidir bu...

Tek amaç sadece column ve row header lara birazcık görsellik katmak ve birde row header lara satır numaralarını yazdırmaktı

ama masumane isteklerle başlayan kontrol geliştirme hikayesi 30 un üzerinde tema ve 8 tane custom column

(eklenmeyen bir kaç tane daha var . Onları kendime sakladım :D) ile son bulmak üzere terk edildi

(Yoksa şunuda yapıyım şunuda ekliyim diye diye bayağı bir vakit alacaktı ...).

Gelelim görüntülere...

yapılmak istenen sadece buydu...

 Standart grid e eklenen özellikler

30 un üzerinde tema desteği(tema demek yanlış olur sadece arkaplan, column ve row header lara müdahale ediyor.)

ve şimdide custom columnlarımız

ilk column umuz Bar şeklinde grafiksel veriyi göstermek için kullanılıyor. O sütun daki tüm veriler hesaplanarak her bir sütunun yüzde cinsinden değeri belirlenip bar grafik olarak çizdiriliyor..(ColoredDGVBarGraphColumn)

 ikinci sırada ilişkisel verileri göstermek için kullanılabilecek Combobox colum umuz var. Tek yapılması gereken column un FillComboBox() methoduna parametre olarak koleksiyon, dizi veya datatable vermek.(ColoredDGVComboBoxColumn)

 http://muratgenc.info/img/dgv8.pnghttp://muratgenc.info/img/dgv9.png

 üçüncüsü ise tarih alanları için datetimepicker kontrolü(ColoredDGVEditingCalendarColumn)

and number 4. Kullanıcıdan bir dosyanın yolu alınacaksa kullanılabilecek bir kontrol. openfiledialog kontrolü ile dosyanın adı alılnıyor.(ColoredDGVEditingFilePathColumn)

beşinci sırada maskedtextbox column yer almakta. mask tanımı column un MaskA() methoduna string olarak verilmektedir.(ColoredDGVEditingMaskedTextBoxColumn)

belli aralıktaki sayıları girdirtmek için msdn den yürütülen numericupdown column u(ColoredDGVNumericUpDownColumn)

basit bir progressbar column u(ColoredDGVProgressBarColumn)

ve listedeki son kontrol gene bir msdn tabanlı column star rating(ColoredDGVRatingColumn)

bu da kendime ayırdığım bir column :D. sanırım ne olduğu açık

 

indirmek isterseniz buyrunDownload


Not : Kontrolü kullanmak için rar dosyası içinden çıkan dll i toolbox ınıza sürükleyip bırakın. Uygulama .Net 2.0 için geliştirilmiştir.

Feedback için http://muratgenc.info/mail.png adresini kullanabilirsiniz.

Haz 3
Digg
Stumbleupon
Technorati
Delicious

VS2005 Settings

Visual Studio kuşkusuz ki en güçlü IDE lerden biri. Peki herşey mükemmel mi ? . Hiçbirşey olmasa bile syntax renklendirme ve arka plan renginin ciddi olarak rahatsız etmeye başladığını söyleyebilirim. Beyaz arka planda sanki uçsuz bir denizde kaybolmuş gibi odaklanma sorunu yaşadığım bir gerçek. Bunca zamandır neden renk ayarlarıyla oynamadığıma da pek inanamıyorum zaten. Neyse ki geç de olsa iyi oldu.

İlk olarak arka plan rengini seçmeliydim. Şu aralar çok moda olan siyah arka plan mı http://weblogs.asp.net/infinitiesloop/archive/2006/08/06/Join-the-Dark-Side-of-Visual-Studio.aspx yoksa ne siyah ne de ne beyaz griye daha yakın bir arka plan mı? Siyah da odaklanma sorunu gerçekten ortadan kalkıyor ama gözlerim fazla dayanamıyor :D. Bu durumda gri tonları iyi bir seçim oluyor. Diğer renkleri de buna uyumlu olarak (bir kaç örnek den de esinlenmeler olmuyor değil : D ) hallettik mi işte sonuç...


Eğer hoşunuza gitti ise buyrun Download

Font olarak Consolas kullanılmıştır. İndirmek için consolas font pack for vs 2005

May 15
Digg
Stumbleupon
Technorati
Delicious

3 Adımda Drag Drop İşlemi

Temel olrak Drag&Drop işlemini basit bir örnek(form üzerindeki bir resmi belirlediğimiz panele sürükleyip bırakmak) üzerinden 3 adımda nasıl projelerimize adapte edebiliriz;

Adım 1:

PictureBox nesnesi bizim kaynağımız, Panel nesnesi ise hedefimiz.

Adım 2:

İlk önce PictureBox nesnemizi sürükleme(Drag) işlemine hazırlamalıyız. Bunun için;

  • PictureBox nesnesinin Mouse Down ve Mouse Move olaylarını eklemeliyiz.
  • Mouse Down olayında nesneye tıklandığı anki pozisyonunu saklamalıyız.
  • Mouse Move olayında ise nesnenin tıklandığını(Mouse Down olayı) ve sürükleme işlemi için belirlenen aralık dahilinde işlemin gerçekleştirilip gerçekleştirilmediğini kontrol etmeliyiz.
  • Eğer 3. adımda istediklerimiz gerçekleşmiş ise nesnenin DoDragDrop methodunu ClipBoard a kopyalanacak nesneyi ve efekt tipini belirterek çağırırız.

private Point mouseDownLocation = Point.Empty;

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)

{

mouseDownLocation = new Point(e.X,e.Y);

}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

Size dragBoxSize = SystemInformation.DragSize;

if ((dragBoxSize.Width > Math.Abs(mouseDownLocation.X - e.X)) || (dragBoxSize.Height > mouseDownLocation.Y - e.Y))

{

pictureBox1.DoDragDrop(pictureBox1, DragDropEffects.Copy);

}

}

}

Adım 3:

Sıra sürükleme işleminin gerçekleşeceği Panel kontrolu için gerekli işlemlerin gerçekleştirilmesine geldi.

  • İlk olarak nesnenin sürüklenen nesneleri kabul etmesi için AllowDrop özelliğini aktif hale getirmeliyiz.
  • Sürüklenecek olan (örnekte PictureBox) nesnenin DoDragDrop methoduna parametre olarak verilen efektin Panel kontrolünün Drag Enter ve Drag Over olaylarında geçerli olduğunu belirtmeliyiz.
  • ve artık nesnemizi sürükledikten sonra ClipBoard dan onu çağırıp Panel kontrolüne eklemeliyiz. Tabiki bu işlemi DragDrop olayı içinde gerçekleştireceğiz. Önemli bir nokta olarak, Panel kontrolüne sürükleyerek eklediğimiz PictureBox nesnesinin Location(pozisyonunu) belirtmez isek otomatik olarak Panel kontrolünün 0,0 noktasına yerleşecektir. Bunu engellemek içinde gene DragDrop olayı içinde sürükleme işleminin bittiği noktanın koordinatlarını tutmamız grekir ve tabiki bu noktayıda Panel in koordinat sistemine uyarlamalıyız.

private void panel1_DragEnter(object sender, DragEventArgs e)

{

e.Effect = DragDropEffects.Copy;

}

private void panel1_DragOver(object sender, DragEventArgs e)

{

e.Effect = DragDropEffects.Copy;

}

private void panel1_DragDrop(object sender, DragEventArgs e)

{

Int32 dropX = e.X;

Int32 dropY = e.Y;

Point dropLocation = new Point(dropX,dropY);

dropLocation = panel1.PointToClient(dropLocation);

PictureBox pb = e.Data.GetData(typeof(PictureBox)) as PictureBox;

panel1.Controls.Add(pb);

pb.Location=dropLocation;

}

tüm işlem bu. Eğer buraya kadar bir sorununuz yoksa çok daha gelişmiş işlemler için önünüzde bir engelde yoktur. Sadece siz ve hayal gücünüz :D

 

Nis 28
Digg
Stumbleupon
Technorati
Delicious

is ve as operatörleri ile tip dönüşümü

is operatörü bir nesnenin verilen tipte olup olmadığını kontrol eder. İşlem sonucunda da Boolean bir değer döndürür. Hiçbir zaman bir exception fırlatmaz. Basit olarak;

Object o=new Object();

Boolean deger1=(o is Object); // işlem sonucu deger1 true değerini alacaktır.

Boolean deger2=(o is Car); //İşlem sonucu deger2 false değerini alacaktır.

is operatörü ile yapılan kontrollerde eğer verilen nesnenin referansı null ise herzaman false değeri geri dönecektir çünkü tipinin kontrol edileceği geçerli bir nesne yoktur. Genel olarak is operatörünü şu haliyle kullanabiliriz;

if (o is Car)

{

  Car c = (Car) o;

} 

Kodu birde CLR in gözü ile incelersek; burda nesnenin tip kontrolü iki kez yapılmaktadır. İlk önce is operatörü ile eğer işlem sonucu true ise bu seferde cast işleminde kontrol yapılmaktadır. CLR ın tip kontrolü güvenlik için önemli bir nokta fakat bu artı beraberinde performans kaybını da getirmektedir. Şöyle açıklayabiliriz;CLR ilk olarak o nesnesi tarafından referans alınan nesnenin gerçek tipini saptamalıdır ve bu işlemden sonrada nesnenin(Car) miras alma hiyerarşisinde her bir tipi Car nesnesinin tipine göre kontrol etmelidir.

is operatörünün bu performans problemine nazaran C# bize performans kaybını azaltmak için as operatörünü önermektedir.

Car c = o as Car;

if (c != null)

{

   //işlem

}

Bu örnekte ise CLR o nesnesinin Car tipi ile uyumluluğunu kontrol etmekte, eğer uygunluk varsa geriye aynı nesnenin null olmayan bir referansını geriye döndürür. Uyumlu olmadığı durumda ise geriye null döndürür. Burada ilk örneğe göre(is operatörüne göre) dikkat edilmesi nokta CLR nesnenin tipini sadece bir kez kontrol etmektedir ki buda is operatörüne göre daha hızlı bir tip dönüşüm işlemi gerçekleştirmemizi sağlar.

Mar 18
Digg
Stumbleupon
Technorati
Delicious

Top 10 Must Have Features in O/R Mapping Tools

Iqbal Khan from Alachisoft wrote an excellent article on Top 10 Must Have Features in O/R Mapping Tools - Here's an excerpt of an article.
 
Feature #1: Flexible object mapping - Everything in O/R mapping starts with mapping our objects to our relational tables.
 
Feature #2: Use your existing domain objects - the O/R mapping tool should let us use our existing domain objects and map and generate only the factory objects. It should use .NET Reflection to read our domain object definition and after we have done the mapping, it should generate the factory objects in such a way that these factory objects use our domain objects to hold all the data.
 
Feature #3: Transactional operations (CRUD) - A database transaction allows us to group multiple operations as one atomic operation so either all operations succeed or none of them succeed. Transactional operations include create, read, update, and delete (also called insert, update, load, and delete). Each transaction operation is performed only on one row of data in a table.
 
Feature #4: Relationships and life cycle management - when we map objects to these tables, our objects also need to establish the same relationships with other mapped objects. Therefore, our O/R mapping tool must support this very important feature by letting us determine which relationships we want to keep in our objects.
 
Feature #5: Object inheritance - Relational databases do not automatically provide inheritance in the relational model. But, there are a number of patterns on how to map object inheritance to a relational database. And, a good O/R mapping tool must provide this capability.
 
Feature #6: Static and dynamic queries A database application does is to retrieve rows of data from one or more tables. The application does this done by using SQL queries (SELECT statements). However, an object-oriented application wants to fetch a collection of objects and not rows. So, the O/R mapping tool must provide a way for us to create queries that return collections of objects.
 
Feature #7: Stored procedure calls - Our SQL does not have to be compiled at runtime because that is a very expensive process. There are numerous situations that an O/R mapping tool must support when it comes to stored procedures
 
Feature #8: Object caching - Whichever caching product we use, we’ll have to make sure that our persistence objects are making caching calls from appropriate locations. And, our O/R mapping tool should provide the ability to generate code that makes caching calls to one or more leading products.
 
Feature #9: Customization of generated code - To prevent our code from being overwritten, the O/R mapping tool must allow us to mark our code as “Safe Code” which then does not get overwritten in future code regenerations.
 
Feature #10: Template customization -  Good O/R mapping tool is very likely using code templates to determine how to generate the code. The O/R mapping tool combines the templates it has with a combination of our object mapping input and the database schema information to determine exactly how to generate the code.
Mar 17
Digg
Stumbleupon
Technorati
Delicious

TDO - Typed Data Object

Every time we have to develop a n-tiers application, that works on a database, we need to write source code to use these data.  In an object oriented environment, the source code has to be modeled in classes and encapsulated in a Data layer and then used in a Business layer.
During the development process of an application we can say that: 
- The code for the Business layer always comes from the Customer demand (Business Requirements), and such requirements are different every time. 
- The code of the Data layer always comes from the operations made on data, and such functions are always the same (Select, Insert, Update, SPs, ….).

The structure of the Database is created properly to support indirectly, the Customer demand, and directly, the requirements of the application that can change. If we get our attention on Data layer, we can see that all the source code, needed to access those data (Data Object), will not be bind directly to the Customer demand, but it will be bind to the Database structure. This means that every time we have to re-write the Data Object for the specifically database.

Solution: 
Andrea Ferendeles  has developed TDO - Typed Data Object is a .NET source code generator (C#/VB) for data layers based on Microsoft SQL Server 2000/MSDE/2005/Express. Which allows .NET Framework 2.0 developers, to have the source code automatically generated for MS SQL Server databases. It is made up of a NET assembly (Tdo.dll) and a source code generator (TdoCodeGenerator.exe). The source code generator produces a collection of derived classes (VB.NET/C#.NET) that extends the base classes within the Tdo.dll assembly, all under the Object Oriented model.
 
Every generated class has the scope "to represent" an object of your SQL database, where object are Tables, Views, Stored Procedures, Functions. According to this model, every table or view, etc..., is considered as an object itself that shows its attributes and operations (that are properties and methods).
 
That means that the single cell of a table or the single parameter of a stored procedure will be seen as object itself. All these classes are enclosed in a hierarchically macro-object as a representation of the entire database - the TdoHelper class.
More ahead we'll see all the possible operations that we can execute on our database (select, insert, update, delete, stored procedure, etc...) that will be called from the present methods within the TdoHelper class objects.
 
Download:- 
 
To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/tdo-users
or, via email, send a message with subject or body 'help' to tdo-users-request@lists.sourceforge.net

You can reach the person managing the list at
tdo-users-admin@users.sourceforge.net
Mar 17
Digg
Stumbleupon
Technorati
Delicious

C# 2005 Keyboard Shortcut Reference

If you folks looking out Visual C# 2005 Keyboard Shortcut Reference, then Microsoft has been provided wonderful Poster for Keyboard Shortcut Reference. This can help increase productivity when performing certain tasks within the Visual Studio 2005 IDE (Integrated Development Environment). This wall poster provides the shortcut and associated description for the default key bindings setup in the Visual C# 2005 profile. The poster is provided here in both color and grayscale for you to print locally as a PDF file. Download it for your reference