DHL Fail

Nice Tracking…

VN:F [1.9.15_1155]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.15_1155]
Rating: 0 (from 0 votes)

SourceGrid with Columns Drag and Swap – a grid all C# for .NET 2.0

Last night I discovery SourceGrid is not stopped on .NET 1.1, Davide Icardi version, but it’s maintained by dariusdamalakas (I don’t know if he’s the same guy, I think no), however is a great grid, but there was something missing really important for my project, lucky for me it’s quite simple to do, I need a columns drag and reorder or drag and swap reordering functionality.

First attempt [at the end failed] was to build a Controller for dragging headers, and it was working, but I cannot find a nice way to call column Swap and redraw header under mouse without changing more code that I was think it was a good code.
If I write too much code to do simple task, there’s a voice in me that tell me I’m wrong on what I’ve done.

So, trashed all tests, I prefer to keep original code “as is” and inherit original object:

* override OnMouseDown and save dragged column header
* override OnMouseMove to set destination column header by moving pointer
* override OnMouseUp to set final destination column header
* override OnPaint to redraw destination column header by moving pointer with a nice veil of transparent white

here a snapshot of result:

and here is the code:

using System;
using System.Drawing;

namespace SourceGrid_ColumnDragNSwap
{
    public class SourceGrid_ColumnDragNSwap:SourceGrid.DataGrid
    {
        int draggingColumn = -1;
        int targetColumn = -1;
        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            base.OnMouseDown(e);

            draggingColumn = -1;
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
                if (this.MouseCellPosition.Row == 0) // header
                    draggingColumn = this.MouseCellPosition.Column;
        }

        protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (draggingColumn != -1)
            {
                int newTargetColumn = this.PositionAtPoint(e.Location).Column;
                if (targetColumn != newTargetColumn)
                {
                    targetColumn = newTargetColumn;
                    // Invalidate to redraw all header cells
                    if (targetColumn != -1) this.InvalidateRange(new SourceGrid.Range(0, 0, 0, this.Columns.Count - 1));
                }
            }
        }

        protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (draggingColumn != -1)
            {
                targetColumn = this.PositionAtPoint(e.Location).Column;
                if (targetColumn != -1)
                {
                    //Swap Columns
                    if (targetColumn != draggingColumn) this.Columns.Swap(targetColumn, draggingColumn);
                    targetColumn = -1;
                }
                draggingColumn = -1;
            }
        }

        private Brush whiteVeilBrush = new SolidBrush(Color.FromArgb(150, Color.White));
        private Rectangle cellVeilRectangle = new Rectangle();
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            //Paint over target header cell a white veil
            if (draggingColumn != -1 && targetColumn != -1 && draggingColumn != targetColumn)
            {
                Rectangle currentCellRectangle = this.PositionToRectangle(new SourceGrid.Position(0, targetColumn));
                cellVeilRectangle.X = currentCellRectangle.X;
                cellVeilRectangle.Y = currentCellRectangle.Y;
                cellVeilRectangle.Width = currentCellRectangle.Width - 2;
                cellVeilRectangle.Height = currentCellRectangle.Height - 1;
                e.Graphics.FillRectangle(whiteVeilBrush, cellVeilRectangle);
            }
        }
    }
}

My source with test project is here

This work is based on SourceGrid:
Last source on https://bitbucket.org/dariusdamalakas/sourcegrid
Main site is http://sourcegrid.codeplex.com/

A great thing about SourceGrid, that’s all C# managed code, I want to try to see what happens on Mono…

VN:F [1.9.15_1155]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.15_1155]
Rating: 0 (from 0 votes)

Share HP Deskjet 1280 from Windows XP to Windows 7

Consider this scenario:

* HP Deskjet 1280 on USB on a Windows XP machine
* Windows 7 machine
* We want to share HP Deskjet 1280 and use from Windows 7 machine

the thing seems very simple, but at the end seem really impossible, and finally a compromise that works

so, let go by step, I want to tell you all story:

First “What The Hell” Path and Fail
* activate printer share in Windows XP
* browse network from Windows 7
* find our shared printer
* double click to install
* Windows 7 says it has no driver
* uhm
* Yeah, it’s simple, let’s click Windows Update to check new driver availability … hours of waiting
* No driver again
* uhm
* Well, let’s go to HP web site, navigate to HP support web site and download manually drivers for HP Deskjet 1280
* web site says that the driver is included in Windows 7, no manual download available
* and now?

Second “What The Hell” Path and Fail
* Create a fake printer in Windows XP for a ipotetic HP LaserJet 4 (Windows 7 has drivers for this)
* Share calling it “HPFake”
* From Windows 7 install “HPFake” share on Windows XP
* On Windows XP rename printer shares, “HPReal” to “HPFake” and “HPFake” to “HPReal”
* You are mine Winzoz!
* Go to Windows 7 and test printer
* But, what? Windows 7 switch automagically share to “HPReal”
* Damn! No way.. I need a new idea… and to buy a new printer?… uhmm

Third “What The Hell” Path and Final Solution
* A thing you have to know is that HP DeskJet 1280 has a compatible driver… and the driver is… HP DeskJet 1220C
* And Windows 7 has this driver
* So in Windows XP add another printer temporally on LPT1 with HP DeskJet 1220C driver
* Modify port on printer and choose USB port used by original installed printer, in order to share USB port with two printers
* Activate sharing
* Go to Windows 7 and install printer
* Do a test print, OK
* … Microsoft + HP = …

See you on next post

VN:F [1.9.15_1155]
Rating: 8.6/10 (5 votes cast)
VN:F [1.9.15_1155]
Rating: +4 (from 6 votes)

NullFileNET – NullFile in .NET way or zeroing disk for Windows in VirtualBox

Updated version 0.2
Exception catched on file object disposing.
———————

I have some VMs with VirtualBox, I use to run nullfile-1.02.exe by Matthias Jordan in order to clear unused sectors with a VBoxManage compact.

It’s a good tool, but I want to know more infos, first of all, when app thinks to finish to wipe?
I remember to see nullfile sources in pascal, great language, I want to thanks Matthias Jordan because he shares it.

I need a faster application to do this work…
… Think .NET …
So I decide to write a very similar command line app, with some new statistical features:

Download NullFileNET source and binary (.exe), and here only binary (.exe).

I can resume code lines that do the work in:

string filename = "appleapplebananacoffee";
byte[] bArray = new byte[1024];
FileStream zeroingFile = File.Create(filename, 1024, FileOptions.DeleteOnClose);
while (true)
   zeroingFile.Write(bArray, 0, 1024);

Have a good 2011!!!

P.S.: There is a thing I’ve not understand, when process finish, it seems to throw an ex on a lower level than main call, but I think it’s because of low disk space; when I have another slice of time I’ll try to solve this.

VN:F [1.9.15_1155]
Rating: 10.0/10 (3 votes cast)
VN:F [1.9.15_1155]
Rating: 0 (from 0 votes)

Ubuntu 10.10 – Kernel panic – not syncing: VFS: Unable to mount root fs on unkown block

Booting Ubuntu 10.10 from my laptop Dell XPS I run into a kernel panic:

Kernel panic - not syncing: VFS: Unable to mount root fs on unkown block
Pid 1 com: swapper not tainted 2.6.35-24 generic
(or something similar, I’ve wrote down by hand)

…Mind panic…

I lost 2 hours, and then find a really simple solution:

* Boot with older kernel (I’ve also 2.6.35-22)
* Reintall linux-image-2.6.35-24-generic (Linux kernel image for version 2.6.35 on x86/x86_64) from Synaptic
* I’ve done also a sudo update-grub to update grub menu

sudo reboot!

Good Luck

VN:F [1.9.15_1155]
Rating: 7.9/10 (8 votes cast)
VN:F [1.9.15_1155]
Rating: +2 (from 2 votes)