How to write an extension for graphic screens for codedui - coded-ui-tests

I want to use codedui for winform application where some windows has graphic but I can not reach beyond graphic page by default. Codede ui recognize Control type as Client for the graphic windows.
So I want to write an extension for it , below pages describes an extension, it implements a class that derives from Control.ControlAccessibleObject, and override the AccessibilityObject property to return an object of your class. I want to ask what should I do next ? Has someone experience on this before ?
https://learn.microsoft.com/en-us/visualstudio/test/enable-coded-ui-testing-of-your-controls?view=vs-2017
public partial class ChartControl : UserControl
{
// Overridden to return the custom AccessibleObject for the control.
protected override AccessibleObject CreateAccessibilityInstance()
{
return new ChartControlAccessibleObject(this);
}
// Inner class ChartControlAccessibleObject represents accessible information
// associated with the ChartControl and is used when recording tests.
public class ChartControlAccessibleObject : ControlAccessibleObject
{
ChartControl myControl;
public ChartControlAccessibleObject(ChartControl ctrl)
: base(ctrl)
{
myControl = ctrl;
}
}
}

Related

UNITY: Is it possible to access the GameObject that a PropertyAttribute is attached to?

For example if I create a PropertyAttribute;
ExampleAttribute : PropertyAttribute { etc...
and a respective PropertyDrawer
[CustomPropertyDrawer (typeof(ExampleAttribute))]
public class ExampleDrawer : PropertyDrawer
Is it possible to talk to the Monobehaviour script that has invoked the [Example] attribute?
When Unity calls your property drawer's OnGUI, it'll pass a SerializedProperty. The property's serializedObject is the SerializedObject that owns it.
You didn't specify what you wanted to do with that object, but now you have a reference to it:
public void OnGUI(Rect rect, SerializedProperty property, GUIContent label) {
//do other GUI stuff
Debug.Log("I belong to " + property.serializedObject.targetObject, this);
}

running a T4 on adding a class

Using t4, I want when the developer adds a class which ends to Report keyword (e.g. CompanyReport), put some code in that class.
Imagine I create a class named CompanyReport, I want the class to be like :
public class CompanyReport : IReportItem
{
private Company _company;
public CompanyReport(Company company)
{
_company = company;
}
public ReportBookmark BookMark
{
get { return ReportBookmark.Company; }
}
public void Report(ISetBookmark wordReport)
{
}
}
Maybe you should consider using a customized ItemTemplate for Visual Studio or just a snippet. Both are quite easy to build and redistribute. I'am also not sure if it is possible to invoke some T4-Template on creating (and really ONLY on creating) a class.

Create SharePoint (2010) ToolPart usable for more than one WebPart

I am using the basic instructions (here) for creating a property driven by a custom ToolPart.
All is good, except for the part where, in order to access the webpart property within the ApplyChanges method I must cast the "this.ParentToolPane.SelectedWebPart" back to a concrete "SimpleWebPart" class.
public override void ApplyChanges()
{
SimpleWebPart wp1 = (SimpleWebPart)this.ParentToolPane.SelectedWebPart;
// Send the custom text to the Web Part.
wp1.Text = Page.Request.Form[inputname];
}
Doing this means that I must pair each toolpart with a specific webpart. Is there a better way?
I cannot create an interface as there is no way of specifying a property in one.
I ineptly tried an passing an event/eventhandler during toolpart creation, but that did not update the webpart property when called.
I could create a base class for all the webparts that have a public "Text" property, but that is fugly.
I could also get desperate and crack open the this.ParentToolPane.SelectedWebPart reference with Reflection and call any properties named "Text" that way.
Either way, I am staring down the barrel of a fair bit of faffing around only to find out each option is a dead end.
Has anyone done this and can recommend the correct method for creating a reusable toolpart?
I have used an interface instead of a specific instance of a webpart.
private class IMyProperty
{
void SetMyProperty(string value);
}
public override void ApplyChanges()
{
IMyProperty wp1 = (IMyProperty)this.ParentToolPane.SelectedWebPart;
// Send the custom text to the Web Part.
wp1.SetMyProperty(Page.Request.Form[inputname]);
}
But this does not give a compile time warning that the toolpart requires the parent webpart to implement the IMyProperty interface.
The simple solution to that is to add a property of the IMyProperty interface in the toolpart constructor and call this reference instead of the this.ParentToolPane.SelectedWebPart property.
public ToolPart1(IContentUrl webPart)
{
// Set default properties
this.Init += new EventHandler(ToolPart1_Init);
parentWebPart = webPart;
}
public override void ApplyChanges()
{
// Send the custom text to the Web Part.
parentWebPart.SetMyProperty(Page.Request.Form[inputname]);
}
public override ToolPart[] GetToolParts()
{
// This is the custom ToolPart.
toolparts[2] = new ToolPart1(this);
return toolparts;
}
This works fine, but I cannot get over the feeling that there is something nasty in the underlying SharePoint code that may trip me up later.

Need help with UITabBarController and orientation

I have an app (written using MonoTouch and currently working) that I want to add landscape orientation to. I am using a UITabBarController.
I don't see how to create a controller that will allow me to override the "ShouldAutorotate..." method. Can anybody point me to an example using a UITabBarController in MonoTouch?
TweetStation contains a sample precisely for this setup, and propagates the rotation down all of the nested view controllers.
Are you subclassing UITabBarController?
You are probably non subclassing and just adding a vanilla controller in Interface Builder. You have to subclass to override that property.
First make a new class like this:
//Test this, it's off the top of my head
[Register("YourTabController")]
public class YourTabController : UITabBarController
{
public YourTabController (IntPtr handle) : base (handle) { }
[Export("initWithCoder:")]
public YourTabController (NSCoder coder) : base (coder) { }
//Override should rotate
public bool ShouldAutoRotateToInterfaceOrientation(UIInterfaceOrientation o)
{ return true; }
}
Then, if you already have a UITabBarController in IB, there is a 'Class' property that you set to the name of your new class.

Compact Framework 3.5 Update Usercontrol With Main Form Variable Data

This seems like it should be simple, however, I cannot find an example through searching...
How do I update a label on a usercontrol using variables from its parent form?
I am building a compact framework 3.5 application.
Thanks for any and all assistance!!!
You can create a public property on the user control, and you update your label from there, for example:
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public string LabelText
{
get
{
return label1.Text;
}
set
{
label1.Text = value;
}
}
}
You can also return the label itself, although some people may say that would break encapsulation on your design.

Resources