Windows Phone 程序的基本概念和架构

namespace 培训第三章程序和基本结构和架构
{
    public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            //Loaded += MainPage_Loaded;

            getDeviceStatus();
        }

        /*private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            pageHeight.Text = this.ActualHeight.ToString();
        }

        private void MainPage_OrientationChanged_1(object sender, OrientationChangedEventArgs e)
        {
            if ((e.Orientation & PageOrientation.Portrait) == PageOrientation.Portrait)
            {
                //坚屏处理
                MessageBox.Show("坚屏处理");
            }
            else
            {
                //横屏处理
                MessageBox.Show("横屏处理");
            }
        }*/


        // 为 ViewModel 项加载数据隐藏
        /*protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            MessageBox.Show("程序启动或激活OnNavigatedTo");
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            MessageBox.Show("程序退出或隐藏到后台OnNavigatedFrom");
        }*/



        /*private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar) Resources["appbar1"];
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            ApplicationBar = (Microsoft.Phone.Shell.ApplicationBar) Resources["appbar2"];
        }*/

        /*protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //base.OnNavigatedTo(e);
            App app = Application.Current as App;
            post.Text = app.Post;
            //app.Post = post.Text;
            base.OnNavigatedTo(e);
        }


        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Uri url = new Uri(String.Format("/Page1.xaml?name={0}",name.Text),UriKind.Relative);
            NavigationService.Navigate(url);
        }*/



        /*private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            PhoneApplicationService.Current.State["name"] = name.Text;
            NavigationService.Navigate(new Uri("/DetailPage.xaml", UriKind.Relative));
        }*/



        /*private void button_Click(object sender, RoutedEventArgs e)
        {
            IsolatedStorageFile fileStoreage = IsolatedStorageFile.GetUserStoreForApplication();
            if (!fileStoreage.FileExists("log.txt"))
            {
                fileStoreage.CreateFile("log.txt");
            }
            NavigationService.Navigate(new Uri("/hello.xaml", UriKind.Relative));
        }*/


        private void getDeviceStatus()
        {
            this._CurrentMomoryUsage.Text =(DeviceStatus.ApplicationCurrentMemoryUsage / 1024 / 1024).ToString();

            this._MemoryUsageLimit.Text = (DeviceStatus.ApplicationMemoryUsageLimit/1024/1024).ToString();
            this._PeakMemoryUsage.Text = (DeviceStatus.ApplicationPeakMemoryUsage/1024/1024).ToString();
            this._eFirmwareVersion.Text = (DeviceStatus.DeviceFirmwareVersion);
            this._HardwareVersion.Text = (DeviceStatus.DeviceFirmwareVersion);
            this._DeviceManufacturer.Text = (DeviceStatus.DeviceManufacturer);
            this._DeviceName.Text = (DeviceStatus.DeviceName);
            this._DeviceTotalMemory.Text = (DeviceStatus.DeviceTotalMemory / 1024 / 1024).ToString();
        }
    }

  

    <!--  LayoutRoot 是包含所有页面内容的根网格  -->
    <Grid x:Name="LayoutRoot" Background="Transparent">


        <!--
            <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <StackPanel x:Name="TitlePanel"
            Grid.Row="0"
            Margin="12,17,0,28" />
            
            <Grid x:Name="ContentPanel"
            Grid.Row="1"
            Margin="12,0,12,0" />
        -->


        <!--
            <StackPanel x:Name="ContentPanel" Margin="12,0,12,0">
            <Button Height="100"
            Click="Button_Click_1"
            Content="change appbar to 1" />
            <Button Height="100"
            Click="Button_Click_2"
            Content="change appbar to 2" />
            </StackPanel>
        -->



        <!--
            <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            
            <StackPanel x:Name="TitlePanel"
            Grid.Row="0"
            Margin="12,17,0,28" />
            
            <Grid x:Name="ContentPanel"
            Grid.Row="1"
            Margin="12,0,12,0">
            <TextBlock Width="159"
            Height="65"
            Margin="10,202,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            FontSize="30"
            Text="Page高度:"
            TextWrapping="Wrap" />
            <TextBlock Name="pageHeight"
            Width="164"
            Height="64"
            Margin="174,202,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            FontSize="30"
            TextWrapping="Wrap" />
            </Grid>
        -->



        <!--
            <Button Width="273"
            Height="133"
            Margin="72,110,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Click="Button_Click_1"
            Content="编辑小刘的信息" />
            
            <TextBlock Width="96"
            Height="42"
            Margin="47,296,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            TextWrapping="Wrap">
            <Run Text="姓" />
            <Run Text="   " />
            <Run Text="名" />
            <Run Text=": " />
            </TextBlock>
            
            <TextBox Name="name"
            Width="197"
            Height="67"
            Margin="148,276,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Text="小刘"
            TextWrapping="Wrap" />
            
            <TextBlock Width="101"
            Height="49"
            Margin="47,365,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Text="职  位:"
            TextWrapping="Wrap" />
            
            <TextBox Name="post"
            Width="205"
            Height="67"
            Margin="140,358,0,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Text="工程师"
            TextWrapping="Wrap" />
        -->



        <!--
            <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBox Name="name" />
            <Button Click="Button_Click_1" Content="提交" />
            </StackPanel>
        -->



        <!--
            <Button Width="300"
            Height="100"
            Click="button_Click"
            Content="GO To Hello Page" />
        -->


        <!--  设备信息  -->
        <TextBlock Name="_CurrentMomoryUsage"
                   Width="137"
                   Height="47"
                   Margin="248,18,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="当前使用内存"
                   TextWrapping="Wrap" />

        <TextBlock Name="_MemoryUsageLimit"
                   Width="137"
                   Height="47"
                   Margin="248,100,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="内存使用上限"
                   TextWrapping="Wrap" />

        <TextBlock Name="_eFirmwareVersion"
                   Width="137"
                   Height="47"
                   Margin="248,175,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="访火墙版本"
                   TextWrapping="Wrap" />

        <TextBlock Name="_HardwareVersion"
                   Width="137"
                   Height="47"
                   Margin="248,219,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="硬件版本信息"
                   TextWrapping="Wrap" />


        <TextBlock Name="_DeviceManufacturer"
                   Width="137"
                   Height="47"
                   Margin="248,271,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="设备制造商"
                   TextWrapping="Wrap" />


        <TextBlock Name="_DeviceName"
                   Width="137"
                   Height="47"
                   Margin="248,323,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="设备名称"
                   TextWrapping="Wrap" />

        <TextBlock Name="_DeviceTotalMemory"
                   Width="114"
                   Height="47"
                   Margin="251,134,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="设备总内存"
                   TextWrapping="Wrap" />


        <TextBlock Name="_PeakMemoryUsage"
                   Width="137"
                   Height="47"
                   Margin="248,63,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="内存使用峰值"
                   TextWrapping="Wrap" />

        <TextBlock Width="149"
                   Height="47"
                   Margin="94,18,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   TextWrapping="Wrap">
            <Run Text="当前使用内存" />
            <Run Text="M" />
        </TextBlock>
        <TextBlock Width="147"
                   Height="47"
                   Margin="94,100,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   TextWrapping="Wrap">
            <Run Text="内存使用上限" />
            <Run Text="M" />
        </TextBlock>
        <TextBlock Width="114"
                   Height="47"
                   Margin="94,175,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="防火墙版本"
                   TextWrapping="Wrap" />
        <TextBlock Width="132"
                   Height="47"
                   Margin="94,219,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="硬件版本信息"
                   TextWrapping="Wrap" />
        <TextBlock Width="114"
                   Height="47"
                   Margin="94,271,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="设备制造商"
                   TextWrapping="Wrap" />
        <TextBlock Width="114"
                   Height="47"
                   Margin="94,323,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="设备名称"
                   TextWrapping="Wrap" />
        <TextBlock Width="144"
                   Height="47"
                   Margin="97,134,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   TextWrapping="Wrap">
            <Run Text="设备总内存" />
            <Run Text="M" />
        </TextBlock>
        <TextBlock Width="147"
                   Height="47"
                   Margin="94,63,0,0"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   TextWrapping="Wrap">
            <Run Text="内存使用峰值" />
            <Run Text="M" />
        </TextBlock>





    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True">
            <shell:ApplicationBarIconButton IconUri="images/1.png" Text="Button2_1" />
            <shell:ApplicationBarIconButton IconUri="images/4.png" Text="Button2_2" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

  

你可能感兴趣的:(windows phone)