I have a number of PubCenter ads on each Windows Phone Page. By default they are all disabled.
I use a Random Generator and a switch to select one to turn on. This works fine with AdDuplex, but when I use Pubcenter I only get an empty space where the ad should be. Does anyone know what I have to do to get these ads to start working?
Various reasons may cause the PubCenter control to be hidden.
The simplest thing you can do to determine why is to subscribe to the AdControlError event in the code-behind of the page, like this:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
myAdControl.AdControlError += AdControlError;
}
private void AdControlError(object sender, ErrorEventArgs e)
{
string error = e.ErrorDescription;
MessageBox.Show(error);
}
I assume you have register with pubcenter, and are setting the AdControl.ApplicationId and AdControl.AdUnitId properties? if you have done that then it should all be good to go.
And these are the settings while you are designing/developing the app:
adControl1.ApplicationId = "test_client";
adControl1.AdUnitId = "Image480_80";
Related
So I'm dabbling in C# properly for the first time trying to make a WPF based desktop application.
So far it's mostly going well, however as part of the project I am trying to take input from the user in one window (essentially where they define a project and the settings they want) and save them for later user in the project and have it act accordingly based on their input.
I've figured out the saving of this data for text inputs etc, however I'm having issues replicating this for check boxes.
I've defined the setting in the settings page as a bool defaulting to false, with the intent to be if the user ticks the checkbox then set the setting to true for later use.
When I'm trying to use .Checked against my checkbox class name it says it must appear on the left hand side of of += or -=, I've looked online for clarification and most similar code & relevant tutorials define it the way I have without issue.
Here's a snippet of the code:
public void CXML_GetSettings()
{
CXML_NewProject_Inc_SubModule_XML.Checked = Properties.Settings.Default.CXML_Project_Inc_SubModule;
}
Tried various ways of changing it but just can't get .Checked to work anywhere.
The Checked is an event for CheckBox, if you want to use it for your CheckBox, you can use it like below:
public MainWindow()
{
InitializeComponent();
MyCheckBox.Checked += MyCheckBox_Checked;
}
private void MyCheckBox_Checked(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
}
Or
<CheckBox IsChecked="False" Name="MyCheckBox" Checked="MyCheckBox_Checked"/>
private void MyCheckBox_Checked(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
}
Here is my xaml code:
<MediaElement x:Name="beepSound" Source="/Sounds/beep.mp3" AutoPlay="False" Visibility="Collapsed"/>
C# code:
private void ButtonClick(object sender, RoutedEventArgs e)
{
if (beepSound.CurrentState == System.Windows.Media.MediaElementState.Playing)
beepSound.Pause();
else
beepSound.Play();
}
This code works perfectly. But after I resume the app (by pressing start button and then back again into the app) the sound doesn't play. What causes this behavior? Is there anything wrong with my code?
There is nothing wrong in your code
Its just that, Media Element stops working in the background. CurrentState of the media elements gives a "Closed" when we get back to the app after pressing the start button.
You need to use a player that plays the sound even when the app goes in the background(start key press/lock key press). And BackgroundAudioPlayer follows over your requirement.
I am not very much aware with how it works but I can suggest you with some links at this point of time.
Please have a look at the BackgroundAudiolayer
and also its namespace.
And a Sample
Enjoy!
After a bit of research I found out that, after the app resumes it loses its source information. So you have to set the source again. Here is how I did it.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
beepSound.Source = new Uri("/Sounds/beep.mp3", UriKind.Relative);
}
I'm working on a little automation project at the min and have hit a brick wall. Firstly i'd like to state the only reason i'm using webbrowser for this component of the project is the site being scraped has obfuscated code and requires a java enabled browser to display the code, i've got another app using webclient which works fine for other test sites but unfortunately can't be used on this target
My problem arises when trying to programatically configure the webbrowser control
First problem i've discovered is if i manually set the url in the controls properties it loads page 1 up and the scraper works for that page. However, I proceeded to clear the url in the properties and set it manually in the Form1_Load method but it returns about:blank as the url despite the fact i've verified the automated parameter being pulled in is fine and should be getting set without issue
Here's what i'm using:
Note:
collection refers to an XML serialized array of definitions
definition refers to the active definition for this target,the idea being to configure this for multiple targets
private void Form1_Load(object sender, EventArgs e)
{
PopulateScraperCollection();
webBrowser1.Url = new Uri(collection.ElementAt(b).AccessUrl);
NavigateToUrl(collection.ElementAt(b).AccessUrl);
}
public void PopulateScraperCollection()
{
string[] xmlFiles = Directory.GetFiles(#"E:\DealerConfigs\");
foreach (string xmlFile in xmlFiles)
{
collection.Add(ScraperDefinition.Deserialize(xmlFile));
}
}
public void NavigateToUrl(string url)
{
Console.WriteLine(collection.ElementAt(b).AccessUrl);
webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
webBrowser1.Navigate(webBrowser1.Url);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser wb = sender as WebBrowser;
Process(collection.ElementAt(b), 0);
b++;
}
Consequently this causes another issue in using DocumentCompleted to navigate to the paginated results. On the first page load i use a DocumentCompleted event to trigger the link extraction. When I attempt to set the url for the the next page,which is being picked out fine using xpath and again verified, using F10 to step over in debug indicates it hasnt been changed and the DocumentCompleted event isn't being triggered
My code to change the url etc. is:
string nextPageUrl = string.Format(definition.NextPageUrlFormat, WebUtility.HtmlDecode(relativeUrl));
webBrowser1.Url = new Uri(nextPageUrl);
webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
webBrowser1.Navigate(webBrowser1.Url);
Any help as always is greatly appreciated, this is proving to be a nightmare to automate, not only because WebBrowser is so much slower than WebClient, but its proving a pain to alter on the fly
Regards
Barry
You should never really set webBrowser1.Url, You should just be using the Navigate void, so
private void Form1_Load(object sender, EventArgs e)
{
PopulateScraperCollection();
NavigateToUrl(collection.ElementAt(b).AccessUrl);
}
My guess would be why it isnt navigating, is that the collection.ElementAt(b).AccessUrl is null or about:blank
Im not really sure how to answer your question, but the Navigate void should change it
NB: WebBrowser control is proper crap, you could try another WebBrowser control like Awesomium or GeckoFX
I want to implement a silverlight based component for Co-Browsing.
Can you please help me get started?
Thanks
Okay, first things first. I'm going to assume that you already figured out how to get commands from the "admin" to the "client". If this is not true, just let me know.
Second: this is an outrageously difficult thing to build
Third: here's a start ;-)
To use the default SL4 webbrowser component, you need to run your application out-of-browser with elevated trust. So you should set that up first.
In my test app, I added a webbrowser component and subscribed to the LoadCompleted event.
In your eventhandler you can use something like:
void webBrowser1_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
//Pseudo code event to update clients
OnAdminNavigated(e.Uri);
}
Clientside you would use something like:
void adminNavigated(MyCustomNavigationEventArgs e)
{
clientBrowser.Navigate(e.Uri);
}
Hope this helps.
Do any have any experience how this cold be done, if you look at the image im looking for a solution to programacly change the Name field to somehing else stored inn a variable from a other textbox.
i was thinking of using something like
private void button1_Click(object sender, EventArgs e)
{
var xBox = textbox1.value;
webBrowser1.Document.All.GetElementsByName("Name")[0].SetAttribute("Value", xBox);
}
but i dont know the name of the Textbox, and Sieble seems to be a java thing? so i cant see the source behind it? does anyone know how to solve this issue. im making a automate app to help at work for handeling over 100 cases a day. Instead of typing the names, im looking for a solution to populate by the click of a button.
I cant handel this by the sieble API because we dont have contorle of the Siebel develompent, and wold take years to get the Sieble department to implement somthing like this in to the GUI. so im making a desktop app that can handel the issue.
Sounds like you need to just search through the html (manually) until you find the names/ids of the fields you need to set.
Also, if the site supports Firefox, try using Firebug. In Firebug's inspect mode you can mouse over a text field and get the id of it.
My solution to this was using cordinates, and simulate keys klicks, im using Global Mouse and Keyboard Library for this, found at this location http://www.codeproject.com/KB/system/globalmousekeyboardlib.aspx
private void button1_Click(object sender, EventArgs e)
{
this.Location = new Point(0, 0);
inputBlocker();
xX = int.Parse(this.Location.X.ToString());
yY = int.Parse(this.Location.Y.ToString());
defaultMousePos();
//Thread.Sleep(600);
Cursor.Position = new Point(Cursor.Position.X + 1185, Cursor.Position.Y + 254);
//Thread.Sleep(600);
MouseSimulator.DoubleClick(MouseButton.Left);
KeyboardSimulator.KeyPress(Keys.T);
KeyboardSimulator.KeyPress(Keys.E);
KeyboardSimulator.KeyPress(Keys.S);
KeyboardSimulator.KeyPress(Keys.T);
KeyboardSimulator.KeyPress(Keys.O);
KeyboardSimulator.KeyPress(Keys.K);
KeyboardSimulator.KeyPress(Keys.Enter);
needUnblock = true;
inputBlocker();
}
#Darkmage - Is this a winforms application ?.If so did you not have any issues with loading the siebel activeX controls in the .NET webroswer control?