01 September 2010

Tip #1 MVVM Delegate Command with an ObservableCollection

First of all I get the DelegateCommand from the .toolbox courses (I encourage you to download them and find it).

Using this DelegateCommand wich we bind to a button Command for instance (I always add CommandParameter in xaml too, (in order to work fine).

Now my layoutroot datacontext viewmodel has the following property:

private ObservableCollection _sales;
public ObservableCollection Sales
{
  get { return _sales; }
  set
      {
         _sales= value;
         NotifyPropertyChanged("Sales");
         }
        }


And now (in this case is a WPF application, in case you use SL I recommend you to use PagedViewCollection), I instance the command in the constructor:


PaidCommand = new DelegateCommand()
{
 ExecuteCommand = () =>
   {
      bw = new BackgroundWorker();
      bw.RunWorkerCompleted += (s, e) =>
        {
          NotifyPropertyChanged("Sales"); //#1
        };
      bw.DoWork += (s1, e1) =>
        {
           _sales= DM.GetSales(_date1, _date2); //#2
        };
      bw.RunWorkerAsync();
    }

};

 In #2 we process every lines of code we want filling our private fields and when it's finished we publish
simply Notifying them #1 (In my case I have a datagrid with ItemsSource = {Binding Sales})

I hope it helps you (I like this way to do).


And now just a question if any one knows , for other classes I would like to define. Let's suppose a not MVVM environment

Button1.OnClick += (s,e) =>
{
 ...
};

Do you know a way to remove inside the ... the previous delegates like the old way:


Button1.OnClick -= OnButton1Clicked;

26 May 2010

Open asp.net crystal report from Silverlight 4 - Report with List T and List S subreport


1.- The sources: (To do not have CR errors)

Let's suppose (I like when it works) create a Crystal Report with a Subreport and the source are two List and List.

How can I set the sources.
A.- Create a new report in the project.
B.- Set the following as sources (Both the main and the child one):




 C.- Now you add the subreport to the main report:

D.-And add only the child class.
E.- Now in the main Report from database expert remove the child class because we needed it only to be able to add the child report.



In this moment we have defined the design of the report. Now by code we will fill it in the aspx:
 
E.- We add the viewer and a source

F.- In the .cs we add the following: (Create the templates, depending on the version you will need it)



#region Create XML Templates
XEvento xe = new XEvento();
xe.Cliente = "";
xe.Comercial = "";
xe.Fecha = new DateTime(2010, 10, 10);
xe.SerializeObj(XEvento.ItemsFile);

XHistorico xh = new XHistorico();
xh.Nombre = "Prueba";
xh.Fecha = new DateTime(2010, 10, 10);
xh.Detalle = "Esto es otra prueba";
xh.SerializeObj(XHistorico.ItemsFile);
#endregion

G.- Fill the two lists with your data.
H.- On Page_Load:
this.CrystalReportSource1.ReportDocument.Subreports[0].SetDataSource(xhs);
            this.CrystalReportSource1.ReportDocument.SetDataSource(xes);


And that's all the first part in the asp.net


2.- In a method in the silverlight:


private void BPrint_Click(object sender, RoutedEventArgs e)
        {
            HtmlPopupWindowOptions options = new HtmlPopupWindowOptions()
            {
                Directories = false,
                Location = false,
                Menubar = false,
                Status = false,
                Toolbar = false,
            };

            HtmlPage.PopupWindow(new Uri("http://localhost:51694/Reporting.aspx?Fecha=" + DP.SelectedDate.Value.Date.ToShortDateString().Replace('/','.') ), "_blank", options);
        }


3.- In the Page_Load in the asp.net capture the parameter:


this.TextBox1.Text = HttpContext.Current.Request.Params["Fecha"];

Now you have to set it as a parameter of the crystal report and that's all.

15 March 2010

Tip: Gimp remove red lines

If you have scracths, dust or anything that makes your pictures with lines or bands, apply the filter disparasite, check adaptative, uncheck recursive, radius =1,black level = -1, white level = 256
And that's all

09 March 2010

Tip for WPF Mess Resizing

When you begin to add containers and controls inside a WPF and you resize the form, you realize that the mess that happens, what you should do to keep the form is change the main grid container to a canvas, and you will have the control again.

31 January 2010

Context Menu - Send to... Boss

Suppose you have to send many times to your account or to your boss attachments from your computer. Well, if you have MS Outlook 2007 there's a way adding in two big steps, creating a new form in Outlook and the second creating a shortcut in the sendto folder, so let's go

A.- Creating the new form (template) from a standard message form:

1.- Have installed Outlook 2007
2.- Open it.
3.- Tools -> Forms -> Design Form
4.- Choose Message from the List
5.- Click on the To Text Box
6.- Click on the Properties icon
7.- Choose the 'Value'
8.- Set Initial value checked
9.- Set a value between ""
10.- Check automatic... to check it works
11.- Publish -> Publish Form As
12.- In Look In: Choose "Personal Forms Library"
13.- Display Name "Boss"
14.- Now Click Publish
15.- Close and save the changes

B.- Creating a new shortcut:
1.- Run: "shell:sendto"
2.- Copy the shortcut of Outlook to send to
3.- Right click - properties
4.- in Start in, after the last " add :  /c IPM.note.Boss /a "%1"  where Boss is the name of the form
5.- Click ok and rename the shortcut to  Boss and that's done.

I will add some screenshots to have a better idea.

23 October 2008

8,16,32 GB Flash drives review

Due to I have bought some multimedia devices (1080i mkv usb player) and the files from my hard disk takes a lot of time copying and reading in usual flash drives. The HD files with huge Mbps from my Canon HV20 are actual problems I try to avoid. I have made a chart from multiples sources, reviews and prices because I have not found any benchmark of this kind. I have not included Buffalo neither Transcend due to I have not found any decent review or benchmark. Might be Buffalo has a chance, who knows. Well, take a look:



Take care that I have done from Internet sources, I am not responsible of the data showed before, It's only sharing information. Those are my conclusions:

16GB:After analyzing the scores (Read1+Read2+Write1+Write2)/Price, we take care that a 16 GB is the best one (Patriot 8GB can be the first one), and as you see it has a really interesting price. As you see the OCZ Rally2 16GB has the half speed on writing so there is no doubt.

32GB:About 32GB now OCZ wins, I am not sure why the writing speed vs the 16GB is so huge. Of course I haven't the flash drives to test them, but the technology could have changed. In case of doubt, followint this is Patriot again.

08GB:In the 8GB flash drives, I am sure that Patriot wins, then Corsair Survivor GT (may be the Voyager GT too), and after the Sandisk, which is not typical in this kind of charts. Well, I hope the analysis helps you because now I know that I have to buy the Patriot 16GB, because 8GB could be little today.

17 October 2008

Preparing a new article

After so much time, I have a new idea for an article that is not only visually great, it has extreme functionality. The idea is a new fresh styles and UI for making forums, because the typical style of the forums when they grow is unhandle, so my new article will be a silverlight developed forum in a new mind style.
I hope have time enough to give it form and publish it before the end of the year, I am not to telling you more details to do not have copiers. But be sure a great article is coming.

If you have not seen my articles, take a look here. Have a nice weekend