PrintDialog dlg = new PrintDialog();
GeneralTransform transformToRoot = this.TransformToAncestor(win_root);
Rect rect = new Rect(transformToRoot.Transform(new Point(0, 0)), transformToRoot.Transform(new Point(this.ActualWidth, this.ActualHeight)));
double scale = 300 / 96;
RenderTargetBitmap bitmap = new RenderTargetBitmap((int)(scale * (rect.Width + 1)), (int)(scale * (rect.Height + 1)), scale * 96, scale * 96, PixelFormats.Default);
bitmap.Render(g); // g=grid
Image img = new Image();
img.Source = bitmap;
img.Stretch = Stretch.None;
img.Measure(new Size(dlg.PrintableAreaWidth,
dlg.PrintableAreaHeight));
Size sizeImage = img.DesiredSize;
img.Arrange(new Rect(new Point(0, 0), sizeImage));
dlg.PrintVisual(img, "Test300DPI");
For 3D:
Rect = Viewport3DVisual.ViewPort and it comes from visual brush:
<Border>
<Border.Background>
<VisualBrush Stretch="None">
<VisualBrush.Visual>
<Viewport3DVisual x:Name="visual3d" Viewport="0 0 384 384">
Friday, February 25, 2011
WPF 300DPI High Resoluation Printing
Saturday, February 19, 2011
Create OData Producer
(1) Create a Web App and add .mdf file to App Data Folder
(2) Add EF edmx and drag drop the .mdf's table (SQL Express)
(3) Add new item Web ->WCF Data Service (Will generate Atom Data Feed Service)
(4)
public class WcfDataService1 : DataService<AdventureWorks_DataEntities>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("Products", EntitySetRights.AllRead);
config.SetEntitySetPageSize("Products", 2);
.. }
[QueryInterceptor("Products")]
public Expression<Func<Product,bool>> OnQueryCustomer()
{
return p => p.Name.Contains("Adjustable");
}
(5) Test in browser http://localhost/WcfDataService1/Products?$select=Name
...?$top=5
Feed Reader can be turned off Tool->Internet option->content->..
(6) Also test using Silverlight Client
...
AdventureWorks_DataEntities _svs;
DataServiceCollection<Product> _products;
public MainPage()
{
InitializeComponent();
_products.LoadCompleted += new EventHandler(_products_LoadCompleted);
Tuesday, February 15, 2011
WCF NamedPipeBinding in AppFabric
(1) Create anApp under default site running ASP.Net 4.0 AppPool
( net.pipe cannot have port number)
(2) Setting Binding for defulat site and App Advanced Setting to Enable net.pipe protocol
(3)Create a WCP Lib project by VS.net 2010 and publish into the App
(if svc file are missing, manually add one. It should be there if protocol include wsHttp*)
(4) VS.net 2001 ->Tool->WCF Config editor to edit App Web Config and add net.pipe endpoint and mexnetpipe endpoint. Note that Address for net.pipe can be empty but must set up mex for net.pipe.
(5) IIS Manager -> Manage WCF -> Config --> auto-start enabled
(6) svcutil net.pipe://localhost/TestNP/WcfServiceLibrary6.Service1.svc
(7) Client Code:
Service1Client c = new Service1Client("NetNamedPipeBinding_IService1");
c.Open();
string s= c.GetData(123));
c.Close();
<endpoint binding="netNamedPipeBinding" contract="WcfServiceLibrary6.IService1" />
<endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration="" contract="IMetadataExchange" />
Note: binding config is optional
<bindings>
<netNamedPipeBinding>
<binding name="binding1">
<security mode="None" />
</binding>
</netNamedPipeBinding>
</bindings>
Thursday, February 3, 2011
Screen Shot into Clipboard
Bitmap ScreenShot;
int w = (int)aGrid.ActualWidth;
int h = (int)aGrid.ActualHeight;
int x = (int)aGrid.PointToScreen(new System.Windows.Point(0, 0)).X;
int y = (int)aGrid.PointToScreen(new System.Windows.Point(0, 0)).Y;
ScreenShot = new Bitmap(w, h);
Graphics g = Graphics.FromImage(ScreenShot);
g.CopyFromScreen(x, y, 0, 0, new System.Drawing.Size(w, h));
g.Dispose();
System.Windows.Forms.Clipboard.SetImage(ScreenShot);
Subscribe to:
Posts (Atom)