Tuesday, August 16, 2011

Stack Panel Smooth Flowing with List Box and List Items


<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">

<MediaElement Height="1" Name="mediaElement_A" Width="2" Opacity="1" MediaOpened="mediaElement_A_MediaOpened" Volume="1" />

<Button BorderBrush="#FFEF2B2B" Foreground="Black" Height="113" Name="button5" Width="375" Click="button5_Click_1" DataContext="{Binding}" IsEnabled="True" Opacity="0.65" Content="Slightly Stoopid >>" FontSize="36">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="Black" Foreground="Black" Height="113" Name="button11" Width="375" Click="button11_Click" Opacity="0.75" Content="John Butler Trio >>" FontSize="36">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="#FF3FE520" Foreground="Black" Height="113" Name="button12" Width="375" Click="button12_Click" Opacity="0.75" Content="Grateful Dead >>" FontSize="36">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="#FFF5E410" Foreground="Black" Height="113" Name="button52" Width="375" IsEnabled="True" Click="button52_Click" Opacity="0.65" Content="Umphrey's Mcgee >>" FontSize="32">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="Tomato" Content="Flowmotion >>" Foreground="Brown" Height="113" Name="button13" Width="375" Opacity="0.75" Click="Flow_Click">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="Blue" Content="Matisyahu >>" Foreground="Brown" Height="113" Name="button14" Width="375" Opacity="0.75" Click="Matis_Click">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="Black" Content="Buckethead >>" Foreground="Black" Height="113" Name="button16" Width="375" Opacity="0.75" Click="Bucket_Click" FontSize="32" FontFamily="Verdana" FontWeight="Bold">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<Button BorderBrush="Red" Content="Tea Leaf Green >>" Foreground="Brown" Height="113" Name="button18" Width="375" Opacity="0.65" Click="TLG_Click">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

<ListBoxItem>

<Button Content="Lankerspoon >>" Height="113" Name="button34341" Width="375" Click="Lanker_Click" Foreground="#FF78DC18" BorderBrush="Blue" Opacity="0.85" >

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

ListBoxItem>

<ListBoxItem>

<Button BorderBrush="Black" Content="Jack Johnson >>" Foreground="Red" Height="113" Name="button4" Click ="JJClick" Width="375" Opacity="0.8">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

ListBoxItem>

<ListBoxItem>

<Button BorderBrush="Blue" Content="MOE. >>" Foreground="Chartreuse" Height="113" Name="button2" Width="375" Click="SS_Click" FontSize="28">

<Button.Background>

<ImageBrush ImageSource="/JAMiTechnoPanorama;component/Resources/FMbutton.PNG" />

Button.Background>

Button>

ListBoxItem>

ListBox>

StackPanel>


Monday, August 15, 2011

Global Variables

Problem Scenario:

Need variables that can be global throughout the entire application. A couple examples of this may include knowing if the phone is connected to a network. I also utilize it for timing and scores in games so I can always show the scores and game time.

Step #1:


in app.xaml.cs

after #endregion of phone initialization

place this code:
#region Phone application initialization



#endregion

}

public partial class globalstuff

{

public int myprop1 { get; set; }



public static class GlobalVariables

{

public static int networkgood = 0;

public static string networksolid = "NO";




}

}





}





Step #2:


Now within your pages you create an actual instance that you can utilize throughout your application. Normally on main page I perform the following:



public MainPage()

{

InitializeComponent();



// create an instance of your global stuff



globalstuff myglobalstuff = new globalstuff();



}


Now anywhere in your application you can utilize your global variables, example:


globalstuff.GlobalVariables.networksolid = "YES"; // default


Then to perform checks and perform actions based on the variable:



if (globalstuff.GlobalVariables.networksolid == "NO")

{

textBlock2.Text += "No Network connection!!!";

textBlock3.Text += "No Network connection!!!";

}

else

{

textBlock3.Text = "Good Network Connection";

// textBlock3.Text += NetworkInterface.NetworkInterfaceType.ToString();

}