Showing posts with label source code. Show all posts
Showing posts with label source code. Show all posts

10 April 2014

Key Down events in wp7

<TextBox Name="hrTextBox" MaxLength="1" Text="0"  KeyDown="hrTextBox_KeyDown" TextAlignment="Center" InputScope="Number"/>


Add this in your construcor to allow only numbers in text box


            InputScope scope = new InputScope();
            InputScopeName name = new InputScopeName();

            name.NameValue = InputScopeNameValue.Number;
            scope.Names.Add(name);

         

            minTextBox.InputScope = scope;

 private void hrTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.D0:
                case Key.D1:
                case Key.D2:
                case Key.D3:
                case Key.D4:
                case Key.Back:
                case Key.Delete:
                    break;
                default: e.Handled = true;
                    return;
            }
        }


     
        private void minTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (minTextBox.Text != "")
            {
                if (int.Parse(minTextBox.Text) >= 6)
                {
                    switch (e.Key)
                    {
                        case Key.Back:
                        case Key.Delete:
                            break;
                        default: e.Handled = true;
                            return;
                    }
                }
            }

09 April 2014

Play shoutcast stream in Windows phone 7



Here are the steps to play shoutcast stream in wp7.

1) Download the open source project from here
2) extract the file and check the folders in the project
you will find "Bin" and "src" folders. open "src" folder
3) Now you will find following packages:-
Shoutcast.Sample
Shoutcast.Sample.Phone
Shoutcast.Sample.Phone.Background
Shoutcast.Sample.Phone.Background.PlaybackAgent
Silverlight.Media.ShoutCast
4) Add Shoutcast.Sample.Phone.Background.PlaybackAgent, and
Silverlight.Media.ShoutCast in to your project
5) Now go to your main project(UI project) right click on Referencts and select add Reference
6) Select "Solution" in right pannel there you will find projects (Shoutcast.Sample.Phone.Background.Playback
Silverlight.Media.ShoutCast.Phone)
7) Check the box Shoutcast.Sample.Phone.Background.Playback project and click "Ok"
(Note:- if you dont want to play background audio than you can add only Silverlight.Media.ShoutCast.Phone to your project)
8) Now go to Properties folder on top of the References go to WMAppManifest.xml right click on that and open with "xml(Text) editor"(this is for vs 2012)
9) add the following lines below </Capabilities>
    <Tasks>
      <DefaultTask Name="_default" NavigationPage="YourMainPage.xaml" />
      <ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Specifier="AudioPlayerAgent" Name="Shoutcast.Sample.Phone.Background.PlaybackAgent" Source="Shoutcast.Sample.Phone.Background.PlaybackAgent" Type="Shoutcast.Sample.Phone.Background.Playback.AudioPlayer" />
        <BackgroundServiceAgent Specifier="AudioStreamingAgent" Name="Shoutcast.Sample.Phone.Background.StreamAgent" Source="Shoutcast.Sample.Phone.Background.PlaybackAgent" Type="Shoutcast.Sample.Phone.Background.Playback.AudioTrackStreamer" />
      </ExtendedTask>
    </Tasks>
10) now rebuild your entire solution check to see if any errors in your build. if no errors found then your back ground audio should work


-Please comment for any quires. 

14 March 2014

Change Background Image on pressed ListBox

<Grid x:Name="LayoutRoot" Background="Transparent">
        <!--toolkit:TiltEffect.IsTiltEnabled="True"-->
        <ListBox x:Name="Channel_List" SelectionChanged="Listbox1_SelectionChanged" >
         
            <ListBox.ItemTemplate>
                <DataTemplate>
                 
                    <ListBoxItem >
                        <StackPanel Width="490" MouseLeave="StackPanel_MouseLeave"  MouseLeftButtonDown="StackPanel_MouseLeftButtonDown" MouseLeftButtonUp="StackPanel_MouseLeftButtonUp">
                            <StackPanel.Background>
                                <ImageBrush ImageSource="/Assets/Images/channel-bg-unsel.png"/>
                            </StackPanel.Background>
                            <Image Source="{Binding Image}" />
                            <TextBlock Text="{Binding StationName}" FontFamily="Segoe Print" />
                        </StackPanel>
                    </ListBoxItem>
                 
                </DataTemplate>
            </ListBox.ItemTemplate>
         
        </ListBox>

     
     
    </Grid>


/////handle click events in code behind..



private void StackPanel_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var obj = (sender as StackPanel);
            ImageSource img = new BitmapImage(new Uri("/Assets/Images/channel-bg-sel.png", UriKind.Relative));
           ImageBrush ig = new ImageBrush();
           ig.ImageSource = img;
           obj.Background = ig;
            //obj.Background =
        }

        private void StackPanel_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var obj = (sender as StackPanel);
            ImageSource img = new BitmapImage(new Uri("/Assets/Images/channel-bg-unsel.png", UriKind.Relative));
            ImageBrush ig = new ImageBrush();
            ig.ImageSource = img;
            obj.Background = ig;
        }

        private void StackPanel_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            var obj = (sender as StackPanel);
            ImageSource img = new BitmapImage(new Uri("/Assets/Images/channel-bg-unsel.png", UriKind.Relative));
            ImageBrush ig = new ImageBrush();
            ig.ImageSource = img;
            obj.Background = ig;
        }









selectedSelected-background-image

unselectedSelected-background-image

12 March 2014

WP7 Identity of the caller.

unable to determine application identity of the caller. settings class

or


Exception while using IsolatedStorageSettings:
System.IO.IsolatedStorage.IsolatedStorageException: Unable to determine
application Identity of the caller.
 at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedScope
scope,Type appEvidenceType)
 at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedScope
scope,Type applicationEvidenceType)
 at System.Io.IsolatedStorage.IsolatedStorageSettings..ctor(boolean
useSiteSettings)
 at System.IO.IsolatedStorage.IsolatedStorageSettings.get_ApplicationSettings()
 at ManasutoApp.AppSettings..ctor() in


Try this code in your settings class.

if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
                {
                    settings = IsolatedStorageSettings.ApplicationSettings;
                }


"check if the code is running in (visual studio or blend) using DesignerProperties.IsInDesignTool since accessing IsolatedStorageSettings in Visual Studio or Expression Blend is invalid."

I found this from StackOverFlow ..





Specified argument was out of the range of valid values. wp7.

for this you need to lode the settings class in Loded event.
public partial class Page2 : UserControl
public Page2(){
  Loaded += ChannelsPage_Loaded;
         
        }

        void ChannelsPage_Loaded(object sender, RoutedEventArgs e)
        {
            appSettings = new AppSettings();
            this.isolatedSettings(); // here you are calling method that uses isolated class

            var deviceId = DeviceExtendedProperties.GetValue("DeviceUniqueId"); // devide id of your Wp7
            byte[] bID = (byte[])deviceId;
            string deviceID = Convert.ToBase64String(bID);
        }


if possible instantiate "settings" Class as


if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
                {
                    settings = AppSettings();// where you lode entire data from isolated storage
                }

Contact Form

Name

Email *

Message *

Smooth Graphics Java

// Arrange Bricks in Game //java brick breaker game code without flickering // added game levels 1,2,3 in the game //java paddle ball ga...