Click here to Skip to main content
16,011,482 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: request.responseJSON.d - what's ".d"? Pin
Pete O'Hanlon4-Jun-09 1:02
mvePete O'Hanlon4-Jun-09 1:02 
QuestionLogin when user press enter in passwordtextbox Pin
Ravi Mori3-Jun-09 21:10
Ravi Mori3-Jun-09 21:10 
AnswerRe: Login when user press enter in passwordtextbox Pin
Pete O'Hanlon3-Jun-09 22:48
mvePete O'Hanlon3-Jun-09 22:48 
GeneralRe: Login when user press enter in passwordtextbox Pin
Ravi Mori3-Jun-09 23:37
Ravi Mori3-Jun-09 23:37 
GeneralRe: Login when user press enter in passwordtextbox Pin
Pete O'Hanlon3-Jun-09 23:52
mvePete O'Hanlon3-Jun-09 23:52 
QuestionHow can we set Height and width to polygon shape Pin
wpfhelp3-Jun-09 19:17
wpfhelp3-Jun-09 19:17 
AnswerRe: How can we set Height and width to polygon shape Pin
User 2710098-Jun-09 18:29
User 2710098-Jun-09 18:29 
GeneralRe: How can we set Height and width to polygon shape Pin
wpfhelp8-Jun-09 21:28
wpfhelp8-Jun-09 21:28 
Hi Karl,

Thanks for reply

but i have some other problems occur when i place in viewBox or Grid, it is a Vector editing Application that have 2 type selection, first one is Direct Selection that helps for Standard resizing(Height and Width) next is Node selection that helps for Node editing (Drag and change the polygon points using a Adorner Thumb), when i place the polygon in a viewbox i cant do Node Editing, so please check this sample and give a reply

Thanks
Vineeth

<Window x:Class="SampleApplication.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Sample" Height="600" Width="922" WindowState="Maximized" Loaded="Window_Loaded">
    <Grid>
        <Canvas Name="myCanvas" Background="AliceBlue">
            <Polygon Name="polygonFill" Stretch="Fill" Points="177,177 0,177 88.5,0" Fill="Transparent" Stroke="Black" StrokeThickness="2" Canvas.Left="100" Canvas.Top="100" 
                     Height="{Binding ElementName=sliderStretchFill,Path=Value}"
                     />
            <Slider Name="sliderStretchFill" Width="150" Height="22" Canvas.Left="112" Canvas.Top="35" Minimum="10" Maximum="200" Value="100" />
            <Label Canvas.Left="100" Canvas.Top="66" Height="28" Name="lblStretchFill" Width="77">Stretch="Fill"</Label>
            <Label Canvas.Left="175" Canvas.Top="66" >Height=</Label>
            <Label Canvas.Left="215" Canvas.Top="66" Height="28" Name="lblStretchHeight" Width="29" Content="{Binding ElementName=sliderStretchFill,Path=Value}"/>
            <Polygon Name="polygonNone" Stretch="None" Points="177,177 0,177 88.5,0" Fill="Transparent" Stroke="Black" StrokeThickness="2" Canvas.Left="700" Canvas.Top="100" 
                     Height="{Binding ElementName=sliderStretchNone,Path=Value}"
                     />
            <Slider Name="sliderStretchNone" Width="150" Height="22" Canvas.Left="712" Canvas.Top="35" Minimum="10" Maximum="200" Value="100" />
            <Label Canvas.Left="700" Canvas.Top="66" Height="28" Name="lblStretchNone" Width="91">Stretch="None"</Label>
            <Label Canvas.Left="785" Canvas.Top="66" >Height=</Label>
            <Label Canvas.Left="825" Canvas.Top="66" Height="28" Name="lblStretchNoneHeight" Width="29" Content="{Binding ElementName=sliderStretchNone,Path=Value}"/>
        </Canvas>
    </Grid>
</Window>

namespace SampleApplication
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
        Selection selection;
        AdornerLayer adornerLayer;

        void AddAdornerLayerToPolygonFill()
        {
            adornerLayer = AdornerLayer.GetAdornerLayer(polygonFill);
            selection = new Selection(polygonFill);
            adornerLayer.Add(selection);
        }
        void AddAdornerLayerToPolygonNone()
        {
            adornerLayer = AdornerLayer.GetAdornerLayer(polygonNone);
            selection = new Selection(polygonNone);
            adornerLayer.Add(selection);
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            AddAdornerLayerToPolygonFill();
            AddAdornerLayerToPolygonNone();
        }
    }
}






namespace SampleApplication
{
    class Selection : Adorner
    {
        VisualCollection visualChildren;
        Polygon polygon;
        Point point;
        ArrayList thumbArrray = new ArrayList();
        Thumb thumb;

        public Selection(UIElement adornedElement)
            : base(adornedElement)
        {
            visualChildren = new VisualCollection(this);

            polygon = (Polygon)adornedElement;
            for (int i = 0; i < polygon.Points.Count; i++)
            {
                point = polygon.Points[i];
                thumb = new Thumb();
                BuildCorner(ref thumb, Cursors.SizeNESW);
                thumb.Tag = i;
                thumb.DragDelta += new DragDeltaEventHandler(thumb_DragDelta);
                thumbArrray.Add(thumb);
            }
        }

        void thumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
            polygon = (Polygon)adornedElement;

            thumb = (Thumb)sender;
            point = polygon.Points[(int)thumb.Tag];

            point.X += e.HorizontalChange;
            point.Y += e.VerticalChange;

            polygon.Points[(int)thumb.Tag] = point;

            adornedElement = polygon;
            InvalidateArrange();
        }
        void BuildCorner(ref Thumb cornerThumb, Cursor customizedCursor)
        {
            cornerThumb = new Thumb();
            cornerThumb.Height = cornerThumb.Width = 10;
            cornerThumb.Background = Brushes.Black;
            cornerThumb.Cursor = customizedCursor;
            cornerThumb.Opacity = 0.80;
            visualChildren.Add(cornerThumb);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
            polygon = (Polygon)adornedElement;

            for (int i = 0; i < polygon.Points.Count; i++)
            {
                point = polygon.Points[i];
                thumb = (Thumb)thumbArrray[i];
                thumb.Arrange(new Rect(point.X - 5, point.Y - 5, 10, 10));
            }
            return finalSize;
        }

        protected override Visual GetVisualChild(int index) { return visualChildren[index]; }

        protected override int VisualChildrenCount { get { return visualChildren.Count; } }
    }
}

GeneralRe: How can we set Height and width to polygon shape Pin
User 27100918-Jun-09 18:59
User 27100918-Jun-09 18:59 
GeneralRe: How can we set Height and width to polygon shape Pin
wpfhelp28-Jun-09 22:37
wpfhelp28-Jun-09 22:37 
QuestionDatagrid in WPF Pin
Nekkantidivya3-Jun-09 18:26
Nekkantidivya3-Jun-09 18:26 
AnswerRe: Datagrid in WPF Pin
RugbyLeague4-Jun-09 4:48
RugbyLeague4-Jun-09 4:48 
AnswerRe: Datagrid in WPF Pin
Niladri_Biswas6-Jun-09 4:14
Niladri_Biswas6-Jun-09 4:14 
QuestionMoving an Image Element [modified] Pin
Tee1233-Jun-09 5:19
Tee1233-Jun-09 5:19 
AnswerRe: Moving an Image Element Pin
User 2710099-Jun-09 1:51
User 2710099-Jun-09 1:51 
GeneralRe: Moving an Image Element Pin
Tee1239-Jun-09 2:07
Tee1239-Jun-09 2:07 
Question32bit Compiled WPF App - 64bit WOW Mode Pin
Jammer3-Jun-09 5:02
Jammer3-Jun-09 5:02 
QuestionStyling ScrollBar of WPF datagrid Pin
vsaratkar2-Jun-09 5:25
vsaratkar2-Jun-09 5:25 
AnswerRe: Styling ScrollBar of WPF datagrid Pin
#realJSOP2-Jun-09 6:04
professional#realJSOP2-Jun-09 6:04 
GeneralRe: Styling ScrollBar of WPF datagrid Pin
vsaratkar2-Jun-09 7:03
vsaratkar2-Jun-09 7:03 
AnswerRe: Styling ScrollBar of WPF datagrid Pin
Mark Salsbery2-Jun-09 7:16
Mark Salsbery2-Jun-09 7:16 
AnswerRe: Styling ScrollBar of WPF datagrid Pin
Mark Salsbery2-Jun-09 7:27
Mark Salsbery2-Jun-09 7:27 
GeneralRe: Styling ScrollBar of WPF datagrid Pin
Jammer2-Jun-09 8:11
Jammer2-Jun-09 8:11 
GeneralRe: Styling ScrollBar of WPF datagrid Pin
vsaratkar2-Jun-09 9:00
vsaratkar2-Jun-09 9:00 
QuestionBinding Commands to Events? Pin
Steve The Plant2-Jun-09 3:29
Steve The Plant2-Jun-09 3:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.