Wiring up the Search Charm in Universal WinRT apps - search

I haven't seen any examples of how to use the Search Charm in a Universal App.
Usually you wire up the Search Charm using:
SearchPane.GetForCurrentView().QuerySubmitted += new TypedEventHandler<SearchPane, SearchPaneQuerySubmittedEventArgs>(OnQuerySubmitted);
However that doesn't exist in the Shared App.xaml nor does the Windows.ApplicationModel.Search namespace.
Anyone seen how to accomplish this?

I think you just need to override the OnSearchActivated method in App.xaml.cs:
protected override async void OnSearchActivated(SearchActivatedEventArgs args)
{
await LoadApplicationAsync(args.PreviousExecutionState);
// TODO: Handle search query in args
}
LoadApplicationAsync contains the logic which can usually be found in the OnLaunched method.
See my sample project:
https://xp-dev.com/svn/mytoolkit/-%20Samples/SampleWindowsStoreApp/App.xaml.cs
https://xp-dev.com/svn/mytoolkit/-%20Samples/SampleWindowsStoreApp/Views/SearchSamplePage.xaml.cs

Related

jupiter zerocode ParallelLoadExtension choose methods order

Is it possible to use some kind of #Before annotation ?
I want to 'pre-load' datas (POST) before to launch my tests (GET).
But I only want parallel executions on the GET.
I was thinking to define a method with #LoadWith("preload_generation.properties") with :
number.of.threads=1
ramp.up.period.in.seconds=1
loop.count=1
Just to be sure that we execute it only once.
But it looks like I cannot choose the order of execution, and I need this POST method to be the first one executed.
I also tried to put a TestMappings with my 'loading method' at the top of the class.
But it doesn't work neither.
I am not aware of any way that ZeroCode would be able to do this as it is specific to only re-leveraging tests already written in JUnit. My suggestion would be to follow a bit more traditional approach and use standard JUnit setup methods
#BeforeClass
public static void setupClass() {
// setup before the entire class
}
#Before
public void setup() {
// setup before each individual test
}
rather than attempting to use a tool outside of its intended purposes.
As per your described scenario above that you want to ensure data is loaded before your tests are executed, especially in the case of being run under load by ZeroCode it is suggested that you determine how to create your data using the
#BeforeClass
public static void setupClass() {
// setup before the entire class
}
While this may take a bit more thought into how you create your data by creating it before all the tests it will ensure that your load test is excluding data setup time.

How to access Revit Application out of an Execute method in Revit API?

I have been playing with Revit API through pyRevit for quite a while (so, using Python) and I now also need to use C# for some parts of my code.
I am trying to access the VersionNumber property, provided by the Application class. Doing that using pyRevit was quite straightforward, as all I did was
app = __revit__.Application
That's it. I can do it anywhere, it works fine.
Now, I look at C# examples illustrating this (I'm a total C# beginner, by the way), and all examples seem to indicate the same way of proceeding:
UIApplication uiApp = commandData.Application;
Application app = uiApp.Application;
with commandData being an ExternalCommandData object passed as an argument in the Execute method of the class.
My question is: how can I access commandData if I'm not in the Execute method? i.e. if commandData isn't passed as an argument. Can I just instantiate an Application object, just as I did with Python? How?
Thanks a lot,
Arnaud.
Whether you are in a context of Revit's ExternalCommand or not you need access to the UIApplication. You are correct that ExternalCommand provides it via commandData. You can also obtain it from an idling event like so:
private static void OnIdling(object sender, IdlingEventArgs e)
{
var app = (UIApplication)sender;
}
It is also accessible from an ExternalEventHandler `Execute method like so:
public void Execute(UIApplication app)
{
}

Get cellular carrier's name from windows phone 10

I am currently developing UWP application that I need to get the celullar carrier's name. I saw posts about it for windows phone 8 and 8.1. They use:
DeviceNetworkInformation.CellularMobileOperator;
But it is depricated now.
Here is what I want for better clarification:
Does anyone knows how to make it work for windows phone 10?
All the help would be greatly appreciated. Thanks in advance.
We can use PhoneLine.NetworkName to get the name of the current network that is being used by the phone line.
To use the Windows.ApplicationModel.Calls namespace, we need add the reference like the following image:
The telephony options and information classes use the CallsPhoneContract. In order to use these classes, you will need to declare the phoneCall capability in your manifest like the following image.
For example:
private async void Button_Click(object sender, RoutedEventArgs e)
{
PhoneCallStore phoneCallStore = await PhoneCallManager.RequestStoreAsync();
Guid lineId = await phoneCallStore.GetDefaultLineAsync();
PhoneLine line = await PhoneLine.FromIdAsync(lineId);
var currentOperatorName = line.NetworkName;
}
An example that demonstrates how to use much of the functionality of the Windows.ApplicationModel.Calls API can be found here.
The UWP does not provide built-in api's for things like Mobile Network and Carrier related information, so MNC, MCC, carrier name etc are not possible to get afaik.
From the documentation thing might help you. I'm not sure, but it stands to reason that some of that information might be hidden there.
Microsoft documentation
Javascript:
var networkInformation = Windows.Networking.Connectivity.NetworkInformation;
C#
public static class NetworkInformation
C++
public ref class NetworkInformation abstract sealed
And you might need to go into one of the submethods provided by this class. Maybe getConnectionProfiles will do what you want

Monotouch PerformSelector on specific thread with multiple arguments and callbacks

I've been having some issues with threading in monotouch. My app makes use of an external library which I've linked with and it works fine. Because of the nature of the app and the library I have to make all the calls to it on a single separate thread.These calls will generally be :
Random non deterministic caused by user
Every t miliseconds(around 20ms). Like an update function
After reading for a bit I decided to try out NSThread. I've managed to call the Update function by attaching an NSTimer to the thread's RunLoop and it's all working fine. The problem that I'm having now is calling other methods on the same thread. I read somewhere that using PerformSelector on the RunLoop adds the selector invocation to the RunLoop's queue and invokes it when available, which is basically exactly what I need. However the methods that I need to call :
Can have multiple paramteres
Have callbacks, which I need to invoke on the main thread, again with multiple parameters
For the multiple parameters problem I saw that NSInvocation can be a solution, but the life of me I can't figure out how to do it with monotouch and haven't found any relevant examples.
For the actuals calls that I need to make to the library, I tried doing a generic way in which I can call any function I choose via delegates on a particular thread, which sort of works until I'm hit with the multiple parameters and/or callbacks to the main thread again with multiple parameters. Should I maybe just register separate selectors for each (wrapped)function that I need to call from the library?
I'm not hellbent on using this approach, if there is a better way I'm open to it, it's just that after searching for other options I saw that they don't fit my case:
GCD(not even sure I have it in monotouch) spawns threads on it's own whenever necessary. I need a single specific thread to schedule my work on
NSInvocationQueue(which uses GCD internally from what I read) does the same thing.
pThreads, seem overkill and managing them will be a pain(not even sure I can use them in monotouch)
I'm not an iOS developer, the app works fine with monodroid where I had Runnables and Handlers which make life easier :) . Maybe I'm not looking at this the right way and there is a simple solution to this. Any input would be appreciated.
Thanks
UPDATE
I was thinking of doing something along these lines :
Have a simple wrapper :
class SelectorHandler : NSObject
{
public static Selector Selector = new Selector("apply");
private Action execute;
public SelectorHandler(Action ex)
{
this.execute = ex;
}
[Register("apply")]
private void Execute()
{
execute();
}
}
Extend NSThread
public class Daemon : NSThread
{
public void Schedule(Action action)
{
SelectorHandler handler = new SelectorHandler(action);
handler.PerformSelector(SelectorHandler.Selector, this, null, true);
}
}
Then, when I want to call something I can do it like this :
private Daemon daemon;
public void Call_Library_With_Callback(float param, Action<int> callback)
{
daemon.Schedule(() =>
{
int callbackResult = 0;
//Native library calls
//{
// Assign callback result
//}
daemon.InvokeOnMainThread(() =>
{
callback(callbackResult);
});
});
}

How do I keep the browser open after a coded ui test finishes?

I'm using Visual Studio 2012 Coded UI tests for a web application. I have a test for logging into the app which starts the browser, locates the login dialogue, enters credentials, and then clicks ok. I have an assertion which checks for the correct url after the login. This test appears to function correctly. My problem is that it closes the browser after the test runs. I need to keep the browser open, so I can run the next test in my sequence. How do I do this?
At the moment, I don't have anything in my [TestCleanup()] section. I'm assuming that what I'm looking for goes here, but so far I haven't had a lot of luck figuring out what that is supposed to be.
I don't have the original source where I found this solution :(
You can have a method like the one showed below. This method needs to be called in TestSetup. Also declare a class level variable _browserWindow of the tyep BrowserWindow
private void SetBrowser()
{
if(_browserWindow == null)
{
BrowserWindow.CurrentBrowser = "ie";
_browserWindow = BrowserWindow.Launch("http://www.google.com");
_browserWindow.CloseOnPlaybackCleanup = false;
_browserWindow.Maximized = !_browserWindow.Maximized;
}
else
{
BrowserWindow.CurrentBrowser = "ie";
_browserWindow = BrowserWindow.Locate("Google");
_browserWindow.Maximized = !_browserWindow.Maximized;
}
}
Ok, so what I needed to have happen was the launch and login before each test. I thought what I wanted was to run the browser and login test first, and then each additional test. After reading more, I've decided what I actually wanted was to run this logic as initialization code for each test. I've done that by adding this code to the default [TestInitialize()] generated when I started the coded ui project in Visual Studio 2012.
I have found the following method to work for my data driven coded UI test in Visual Studio 2015.
You will want to use [ClassInitialize] and get your browser open and direct it according to where your [TestMethod] begins.
Use [ClassCleanup] to release the resources after all the methods in the test class have been executed.
You can redirect test methods different after the class has been initialized by using the [TestInitialize] and clean-up test using the [TestCleanup]. Be careful with those though because they will occur for each test method and if it closes your browser instance your following test will fail.
private static BrowserWindow browserWindow = null;
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
Playback.Initialize();
browserWindow = BrowserWindow.Launch(new Uri("http://198.238.204.79/"));
}
[ClassCleanup]
public static void TestCleanup()
{
browserWindow.Close();
Playback.Cleanup();
}

Resources