Tuesday, December 27, 2011
Calling a web Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Linq.Expressions;
namespace PhoneApp1
{
public partial class MainPage : PhoneApplicationPage
{
ListBox mylistbox;
public MainPage()
{
InitializeComponent();
SupportedOrientations = SupportedPageOrientation.Portrait SupportedPageOrientation.Landscape;
//http://ws.cdyne.com/WeatherWS/Weather.asmx?WSDL
//Uri url = new Uri("http://api.bart.gov/api/stn.aspx?cmd=stns&key=MW9S-E7SL-26DU-VV8V", UriKind.Absolute);
Uri url = new Uri("http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=85020", UriKind.Absolute);
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(url);
mylistbox = new ListBox();
}
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
ListBoxItem areaItem = null;
StringReader stream = new StringReader(e.Result);
XmlReader reader = XmlReader.Create(stream);
string imageName = String.Empty;
string areaName = String.Empty;
string fileName = String.Empty;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "Temperature")
{
//if (true == reader.MoveToFirstAttribute())
//{
//reader.MoveToContent();
areaName = reader.ReadElementContentAsString();
//areaName = reader.Value.ToString();
areaItem = new ListBoxItem();
areaItem.Content = areaName;
//listBox
listBox1.Items.Add(areaItem);
//}
}
}
}
}
}
}
}
Wednesday, November 2, 2011
Tuesday, September 27, 2011
Silverlight timing, performing something at intervals
// Nigel notes, added an Event Handler so I can perform activities during certain time intervals, running
// anywhere from 10MS to 10 minutes and anywhere in between, including utilizing random to perform
// random items. In this case i WANT volume to fade out over a 20 minute time period
DispatcherTimer XnaDispatchTimer = new DispatcherTimer();
XnaDispatchTimer.Interval = TimeSpan.FromMilliseconds(10);
// Call FrameworkDispatcher.Update to update the XNA Framework internals.
XnaDispatchTimer.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };
XnaDispatchTimer.Tick += new EventHandler(frameworkDispatcherTimer_Tick);
// Start the DispatchTimer running.
XnaDispatchTimer.Start();
// in code do this
// make a method:
public void frameworkDispatcherTimer_Tick(object sender, EventArgs e)
{
textBlock1.Text = "i RAN" + nigelcounter;
nigelcounter += 1;
//Console.WriteLine( nigelcounter);
}
Wednesday, September 21, 2011
Stack Panel List Box for Jeff I.
<controls:PanoramaItem>
<Grid VerticalAlignment="Top">
<StackPanel Margin="1,165,10,10" Width="400" Orientation="Vertical" Background="Transparent">
<ListBox Name="ld" Width="400" Height="400" SelectionChanged="ListBox_SelectionChanged_1" SelectionMode="Single" Background="Transparent" FontFamily="Segoe WP Black" FontSize="36">
<MediaElement Height="1" Name="mediaElement_A" Width="2" Opacity="1" MediaOpened="mediaElement_A_MediaOpened" Volume="1" />
<Button BorderBrush="#FF3FE520" Content="Jack Johnson " Foreground="#FF145B94" Height="113" Name="button4" Click ="JJClick" Width="375" FontSize="36" FontFamily="Segoe WP Black" Opacity="0.8" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="Matisyahu " Foreground="#FF145B94" Height="113" Name="button14" Width="375" Opacity="0.85" Click="Matis_Click" FontFamily="Segoe WP Black" FontSize="40" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="Slightly Stoopid " Foreground="#FF145B94" Height="113" Name="button2" Width="375" Click="SS_Click" FontFamily="Segoe WP Black" FontSize="32" Opacity="0.75" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="Dispatch " Foreground="#FF145B94" Height="113" Name="button19" Width="375" Click="DISPATCH_Click" FontFamily="Segoe WP Black" FontSize="40" Opacity="0.75" HorizontalAlignment="Left" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button Content="Lankerspoon " BorderBrush="#FF3FE520" Height="113" Name="button34341" Width="375" Click="Lanker_Click" Foreground="#FF145B94" Opacity="0.85" FontSize="40" HorizontalContentAlignment="Left" FontFamily="Segoe WP Black">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="Flowmotion " Foreground="#FF145B94" Height="113" Name="button13" Width="375" Opacity="0.75" Click="Flow_Click" FontFamily="Segoe WP Black" FontSize="40" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="Buckethead " Foreground="#FF145B94" Height="113" Name="button16" Width="375" Opacity="0.75" Click="Bucket_Click" FontSize="36" FontFamily="Segoe WP Black" FontWeight="Bold" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="Tea Leaf Green " Foreground="#FF145B94" Height="113" Name="button18" Width="375" Opacity="0.75" Click="TLG_Click" FontSize="36" HorizontalContentAlignment="Left" FontFamily="Segoe WP Black">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Content="STS9 " Foreground="#FF145B94" Height="113" Name="button20" Click ="STS9Click" Width="375" FontSize="36" FontFamily="Segoe WP Black" Opacity="0.8" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Foreground="#FF145B94" Height="113" Name="button5" Width="375" Click="button5_Click_1" DataContext="{Binding}" IsEnabled="True" Opacity="0.75" Content="MOE. " FontSize="40" FontFamily="Segoe WP Black" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Foreground="#FF145B94" Height="113" Name="button11" Width="375" Click="button11_Click" Opacity="0.75" Content="John Butler Trio " FontSize="32" FontFamily="Segoe WP Black" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Foreground="#FF145B94" Height="113" Name="button12" Width="375" Click="button12_Click" Opacity="0.75" Content="Grateful Dead " FontSize="36" FontFamily="Segoe WP Black" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
<Button BorderBrush="#FF3FE520" Foreground="#FF145B94" Height="113" Name="button52" Width="375" IsEnabled="True" Click="button52_Click" Opacity="0.75" Content="Umphrey's Mcgee " FontSize="28" FontFamily="Segoe WP Black" HorizontalContentAlignment="Left">
<Button.Background>
<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton2.PNG" />
Button.Background>
Button>
ListBox>
StackPanel>
<Image Height="177" Name="Matis1" Stretch="FILL" Width="431" Source="/JAMiTechnoPanorama;component/Resources/SS4.png" Opacity="1" Margin="-12,17,1,0" VerticalAlignment="Top" />
<TextBlock Height="72" HorizontalAlignment="Left" Margin="89,17,0,0" Name="textBlock3" Text="TextBlock" VerticalAlignment="Top" Width="293" Foreground="Black" FontFamily="Segoe WP Black" FontSize="26" />
Grid>
controls:PanoramaItem>
<controls:PanoramaItem>