locked
Coded UI support for Drawing Context. RRS feed

  • Question

  • Hi Experts,

    I was trying to give accessibility support a ellipse drawn by drawing context. Am not be able to get that ellipse by the cross hair. 

    <Window x:Class="WpfDrawingContextSample.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:y="clr-namespace:WpfDrawingContextSample"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <y:CustomCanvas x:Name="canvas1" Width="50" Height="30" />
        </Grid>
    </Window>
    public class CustomCanvas : Canvas
        {
            private int count;
            private VisualCollection visuals;
    
            public CustomCanvas()
            {
                visuals = new VisualCollection(this);
                this.Loaded += CustomCanvas_Loaded;
            }
    
            void CustomCanvas_Loaded(object sender, RoutedEventArgs e)
            {
                this.Draw();
            }
    
            protected override Int32 VisualChildrenCount
            {
                get { return visuals.Count; }
            }
    
            protected override Visual GetVisualChild(Int32 index)
            {
                if (index < 0 || index > visuals.Count)
                {
                    throw new ArgumentOutOfRangeException("index");
                }
    
                return visuals[index];
            }
    
            private void Draw()
            {
                count++;
                System.Diagnostics.Debug.WriteLine(count);
                SolidColorBrush fore = Brushes.Red;
                SolidColorBrush back = Brushes.Green;
                DrawingVisual visual = new DrawingVisual();
                using (DrawingContext dc = visual.RenderOpen())
                {
                    double x = (this.Width);
                    double y = this.Height;
                    double height = this.Height;
                    double width = (this.Width);
                    dc.DrawEllipse(back, new Pen(fore, 2), new Point(x, y), width, height);
                }
                this.visuals.Add(visual);
            }
    
            protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
            {
                return new CustomAutomationPeer(this);
            }
        }

    How to get fetch the ellipse??

    sankar

    Monday, July 2, 2012 7:18 AM

Answers

All replies

  • Hi sankar,

    Thank you for posting in the MSDN forum.

    I was trying to give accessibility support a ellipse drawn by drawing context.

    Would you mind letting us know more information about this issue? Which app are you testing? Can you share us a screen shot about the app UI? What result do you want to get?

    We need to make sure that the coded UI test support it, see “Supported Configurations and Platforms for Coded UI Tests and Action Recordings”.

    If you record a coded UI test, run it, do you get any error message?

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, July 4, 2012 4:51 AM
    Moderator
  • Hi Jack,

    Thanks for the reply.

    This is my test app screen shot.. i want to give the accessibility support for this ellipse alone and also want to show some custom properties of this.

    How do i achieve the above?

    Thanks,


    sankar

    Wednesday, July 4, 2012 5:07 AM
  • Hi sankar,

    Glad to receive you reply.

    So it is a WPF app, I try to repro this issue, I get the same issue, I couldn’t add Assertions for this control. One idea is that you could add a specialized class that is used to access those properties so that the generated code is simplified. See “Enable Coded UI Testing of Your Custom Controls”. Hope it could help.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, July 5, 2012 4:41 AM
    Moderator
  • Hi Jack,

    I have already undergone this link and its for Win forms, my app is WPF. Please let me know a solution for WPF.

    Thanks 


    sankar


    • Edited by sankarann Tuesday, July 10, 2012 5:42 PM
    Tuesday, July 10, 2012 5:40 PM
  • Hi sankar,

    Sorry for my reply no help.

    I try to repro this issue, as you said that it still doesn’t work, I’m afraid that the coded UI test couldn't add Assertions for this control in default version.

    To help you resolve this issue, if possible, you could submit this feature request: http://visualstudio.uservoice.com/forums/121579-visual-studio. The Visual Studio product team is listening to user voice there. You can send your idea there and people can vote. If you submit this suggestion, I hope you could post that link here, I will vote it. Thanks for your understanding.

    Sincerely,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us


    Wednesday, July 11, 2012 7:19 AM
    Moderator