locked
WPF Bottle RRS feed

  • Question

  • Hi,

    I want to draw a bottle using wpf(c# code)  can any body help me. i had the dimensions of the bottle

    thanks

    sarath.

    Tuesday, August 31, 2010 4:04 PM

All replies

  • Are you having problems? Here is an intro to drawing in WPF:

    http://msdn.microsoft.com/en-us/library/ms747393.aspx

     

    You could draw your bottle using Expression Design and export it to xaml as well.

    Tuesday, August 31, 2010 4:48 PM
    Moderator
  • can you please provide pseudo code sample application

     

    thanks

     

    Tuesday, August 31, 2010 9:43 PM
  • Could you be more specific?  The pseudo code for drawing a bottle would be something like "draw_bottle()" but I don't think that is what you are really looking for? Are you having trouble with xaml? What do you want the bottle to look like? Etc... please provide a few more details.
    Tuesday, August 31, 2010 9:52 PM
    Moderator
  • Thanks for you reply,

    This is my scenerio

    I had a pack with with bottle slot. first i need to show the slots when user click on the slot i need to show the bottle with the related information.

    i had the bottle and slot dimensions. i completed the first level(i.e) creating the pack slots. now the challenging part is when uer click on the slot i need to draw the bottle wpf(c# code) .

    thanks

    sarath.

    Tuesday, August 31, 2010 9:59 PM
  • Does the bottle already exist as xaml? If it is a usercontrol you can just create an instance of it with new and add it to the current visual scene.

     

    For ex:

    this.LayoutRoot.Children.Add(new MyBottleClass());

     

    Wednesday, September 1, 2010 2:07 PM
    Moderator
  • I am doing the same thing for slots but the hardest part is i need draw bottle dynamically in wpf where the dimensions keep changing  . i need help in drawing the bottle

    Wednesday, September 1, 2010 2:16 PM
  • If it isn't clear yet I don't understand what you are asking.

    Do you need to produce xaml?  Do you already have xaml? Xaml objects can be resized at runtime with rendertransforms.

    If you can ask a concrete question with details we can hopefully help you further.

    Wednesday, September 1, 2010 2:29 PM
    Moderator
  • sorry for that, i need to produce xaml

    Wednesday, September 1, 2010 2:32 PM
  • Here is probably the world's worst xaml bottle:

     

    <Path x:Name="Path" Width="107.667" Stretch="Fill" StrokeThickness="7" StrokeLineJoin="Round" Stroke="Black" Data="F1 M 60.1667,4.16663L 93.5,3.5L 120.833,5.5L 130.167,8.16663L 132.167,17.5L 128.833,17.5L 126.167,26.1666L 130.167,33.5L 134.167,44.1666L 133.5,50.1666L 129.5,56.1666L 129.5,91.5L 133.5,106.833L 137.5,128.167L 150.167,156.167L 159.5,182.833L 168.167,217.5L 170.167,222.833L 166.833,226.167L 170.167,249.5L 173.5,275.5L 174.167,294.833L 172.167,328.833L 174.167,332.167L 173.5,338.167L 166.167,388.833L 160.833,426.833L 160.167,446.167L 160.833,462.833L 165.5,481.5L 169.5,504.167L 170.167,521.5L 169.5,541.5L 160.167,558.833L 144.167,564.833L 123.5,571.5L 98.1667,574.167L 72.8333,573.5L 49.5,568.833L 24.8333,563.5L 22.8333,561.5L 14.1667,552.167L 7.5,540.167L 4.83331,529.5L 5.5,510.167L 6.83331,496.833L 10.8333,480.833L 16.1667,466.167L 16.8333,457.5L 18.8333,447.5L 16.8333,426.833L 14.1667,404.167L 8.83331,374.833L 6.83331,357.5L 3.5,332.167L 5.5,330.833L 6.16669,291.5L 6.83331,272.167L 8.16669,249.5L 13.5,228.167L 10.8333,224.833L 10.8333,221.5L 10.8333,214.833L 16.8333,195.5L 24.8333,174.167L 32.8333,151.5L 38.1667,136.167L 43.5,125.5L 48.8333,108.833L 51.5,88.1666L 51.5,55.5L 46.8333,52.1666L 46.1667,42.8333L 50.1667,34.8333L 52.8333,26.1666L 53.5,17.5L 50.8333,17.5L 51.5,8.83331L 60.1667,4.16663 Z " HorizontalAlignment="Left" Margin="0,0.167,0,129.765" UseLayoutRounding="False"/>
    

    Wednesday, September 1, 2010 3:03 PM
    Moderator
  • Thanks for your fast reply,  Is there any way to upload an image to this forum, to have a feel how the bottle looks like

     

     

    Wednesday, September 1, 2010 7:09 PM
  • Not that I know, but you could just paste that into Blend or VS. I can promise that it won't be what you want. I just don't know what you want/how to help you.
    Wednesday, September 1, 2010 7:16 PM
    Moderator
  • please check the image how bottle looks like

    http://cid-25532420ac958ee7.office.live.com/self.aspx/.Public/Bottle.PNG

    these are the dimensions

    Bottle Height

    Internal Diameter

    External diameter

    bottle thickness

    height of v part

    diameter of v bottom

    Wednesday, September 1, 2010 7:35 PM
  • Hi

    i upload the project and bottle dimension file. just run the application and feed the dimension file(.rpd). application will generate slots when user click on the slot i need to draw the bottle with the given dimensions.

    rpd file linke

    http://cid-25532420ac958ee7.office.live.com/self.aspx/.Public/New.RPD

    application link

    http://cid-25532420ac958ee7.office.live.com/self.aspx/.Public/Reagent%20Pack%20Custom%20Control.zip

    Bottle image link

    http://cid-25532420ac958ee7.office.live.com/self.aspx/.Public/Bottle.PNG

    thanks

    sarath.

    Wednesday, September 1, 2010 7:57 PM
  • How to convert Millimeter to pixel (WPF)

    Friday, September 3, 2010 3:10 PM
  • perhaps that helps you.

    mm = (pixels * 25.4) / dpi


    -- Miseria solo trae miseria --
    Friday, September 3, 2010 3:19 PM
  • can i use same conversion for touchscreen and desktop

    Friday, September 3, 2010 3:25 PM
  • can i use same conversion for touchscreen and desktop


    of course.
    -- Miseria solo trae miseria --
    Friday, September 3, 2010 3:27 PM
  • suppose my path height is 30 mm how can i convert to normal height in wpf
    Friday, September 3, 2010 3:30 PM
  • suppose my path height is 30 mm how can i convert to normal height in wpf


    you also need  dpi (dots per inch) of the picture.


    -- Miseria solo trae miseria --
    Friday, September 3, 2010 3:42 PM
  • dpi is 96 points per inch
    Friday, September 3, 2010 3:44 PM
  • pixels = (mm * dpi) / 254

    (30*96)/254=11,34  mm

     


    -- Miseria solo trae miseria --
    Friday, September 3, 2010 3:48 PM
  • thanks let me implement and see the result, i will get back to u asap
    Friday, September 3, 2010 3:49 PM
  • (45.2*96)/254 = 17.08  but the actual value is 196

    i am getting wrong result, output render is very tiny.

    Friday, September 3, 2010 3:58 PM