09/12/11

Load a WPF BitmapImage from a System.Drawing.Bitmap

 // imgLogo is WPF image so need to bind it from Bitmap or Image.
 // following code.. to bind image. try this it will work in WPF or Silverlight application
System.Drawing.Bitmap dImg = new System.Drawing.Bitmap(ApplicationVariables.TenantImage);
            MemoryStream ms = new MemoryStream();
            dImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

            BitmapImage bImg = new BitmapImage();
            bImg.BeginInit();
            bImg.StreamSource = new MemoryStream(ms.ToArray());
            bImg.EndInit();
            this.imgLogo.Source = bImg;

12/06/11

FontFactory having problem with intialize the font

Hi,

see when you going to using font factory class while converting simple HTML page to PDF file at that time you will face some kind of problem like font that we are going to used which in not reflect in our page.

like suppose we are using Arial Narrow font but it wouldn't reflect in your page or it is only taking Arial as font. for this problem the see best solution in step wise

1. see the given font available in font factory class. by using it's fontfactory..IsRegistered(font name) method. if it's giving false result then the given font is not available in font factory class.

2. registered those font whoever is not available in the font class i.e.
fontfactory.Registered("path of the font","alies name")

fontfactory.Registered("C:\\WINDOWS\\Fonts\\ARIALN.TTF","ArialNarrow")
finally this font available to use now. i.e fontfactory.Getfont("ArialNarrow").

05/04/11

Multiple user control inside the single .xaml page (Silverlight)

Hi,

i have two user controls name as ucProject, ucProjectActivity respectively inside my single .xaml page

i need to do simple operation like, once ucProject submit their value into to the database after this operation it would get the ID of newly inserted record of project and pass this newly inserted project id to the ucProjectActivity user control for their submission.

so it's kind of two operation

1) ucProject submission ------> after submission it would pass Id of newly inserted record of project id to ucProjectActivity user control.

2) get the project id from first user control name as UcProject and next operation will be ucProjectActivity submission.

my code;

private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
ucProject.Submitprojectdetails();
ucProjectActivity.SubmitProjectActivity(ucProject.ProjectId);
}

inside the ucproject

public void Submitprojectdetails()
{
oProjectDetail.BintModifiedBy = app.CurrentUser.BintUserID;
oProjectDetail.DtModifiedDate = DateTime.Now;
oProjectDetailContext.InsertUpdateTblProject(oProjectDetail, InsertUpdateTblProject_Complete, null);
}


public void InsertUpdateTblProject_Complete(InvokeOperation operation)
{
ProjectId = operation.Value;
}

but after complete Submitprojectdetails() operation it directly go to ucProjectActivity.SubmitProjectActivity() rather than complete operation.

so i am getting ucProject.ProjectId = 0 value always actually it's wrong.


So look for the solution,
i have projectprofile.xaml page inside this there is two user control ucproject and ucProjectActivity
at first in .xaml page when we click on submit button,

private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
/*use entitly class of project details of UcProject usercontrol for submission rathar than submitting inside code behind of ucProject user control.see the code;*/
ProjectDetail oProjectDetail = UcProject.oProjectDetail;
oProjectDetailContext.InsertUpdateTblProject(oProjectDetail, InsertUpdateTblProject_Complete, null);
}

public void InsertUpdateTblProject_Complete(InvokeOperation operation)
{
ucProjectActivity.SubmitProjectActivity(operation.Value);
}

now it's work.