zoukankan      html  css  js  c++  java
  • uwp 基础知识

    (TitleId,DiaplayName,args,LogoUri,size);
    
                Obj.VisualElements.ShowNameOnSquare150x150Logo = true;
                
    
                if (await Obj.RequestCreateAsync())
                {
                    await new MessageDialog("OK").ShowAsync();
                }
                
            }
      
    
    
    
    
    复制代码

    删除,修改磁贴

    复制代码
     private async void Button_Click_1(object sender, RoutedEventArgs e)
            {
                //磁贴的唯一标识
                string TitleId = "My_Title";
                var Title = new SecondaryTile(TitleId);
    
                Title.VisualElements.ShowNameOnSquare150x150Logo = false;
                await Title.RequestDeleteAsync();
    
            }
    复制代码

     

    磁贴通知


    复制代码
                var toast = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
    
                var textNodes = toast.GetElementsByTagName("text");
    
                textNodes[0].InnerText = "呵呵呵";
                textNodes[1].InnerText = "你是猴子请来的救兵吗?";
                textNodes[2].InnerText = "呵呵呵";
    
                var Message = new TileNotification(toast);
                TileUpdateManager.CreateTileUpdaterForSecondaryTile("My_Title").Update(Message);
      
    复制代码

    HttpClient


                string url = "http://www.baidu.com";
                HttpClient client = new HttpClient();
                string responce = await client.GetStringAsync(url);

     Weather天气实战


    利用GPS获取手机坐标(经纬度)

                var geo = new Geolocator();
                var P = await geo.GetGeopositionAsync();
                var Po = P.Coordinate.Point.Position;

    百度地图API获取位置信息

    复制代码
                string AppId = "XTTNdkZYIFCIqKVW1vfYUID3eWOgizwC";
    string Type = "json"; string Url = "http://api.map.baidu.com/geocoder/v2/?ak=" + AppId + "&location=" + Po.Latitude + "," + Po.Longitude + "&output=" + Type + ""; HttpClient client = new HttpClient(); var json = await client.GetStringAsync(Url); JsonObject jsonRes = JsonObject.Parse(json); var City = jsonRes.GetNamedObject("result").GetNamedObject("addressComponent").GetNamedString("city");
    复制代码

    百度天气接口 获取天气信息

                string WeaApi = "http://api.map.baidu.com/telematics/v3/weather?location=" + City + "&output=json&ak=" + AppId;
    
                var WeatherJson = await client.GetStringAsync(WeaApi);
                Info i= JsonConvert.DeserializeObject<Info>(WeatherJson);
                this.DataContext = i;

    天气信息 Info Class

    复制代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Weather
    {
      public  class Info
        {
            public int error { get; set; }
            public string status { get; set; }
            public string date { get; set; }
            public List<result> results { get; set; }
    
         
        }
    
        public class result
        {
            public string currentCity { get; set; }
            public string pm25 { get; set; }
    
            public IList<indexitem> index { get; set; }
            public IList<weather_data_item> weather_data { get; set; }
        }
    
        public struct weather_data_item
        {
            public string date { get; set; }
            public string dayPictureUrl { get; set; }
            public string nightPictureUrl { get; set; }
            public string weather { get; set; }
            public string wind { get; set; }
            public string temperature { get; set; }
          
    
    
        }
    
        public struct indexitem
        {
    
            public string title { get; set; }
            public string zs { get; set; }
            public string tipt { get; set; }
            public string des { get; set; }
        }
    }
    复制代码

    前台Xmal代码绑定

    复制代码
    <Page
        x:Class="Weather.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:Weather"    
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        <Grid>
            <Grid.Background>
                <ImageBrush ImageSource="ms-appx:///Assets/zhuo.jpeg"/>
            </Grid.Background>
            <ProgressRing x:Name="gif"></ProgressRing>
            <Hub  Header="Weather">
                <HubSection>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding results[0].currentCity}" FontSize="60"></TextBlock>
                            <TextBlock Text="{Binding results[0].pm25}" FontSize="30"></TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </HubSection>
                <HubSection>
                    <DataTemplate>
                        <ListView ItemsSource="{Binding results[0].weather_data}">
                            <ListView.ItemTemplate>
                                <DataTemplate>
    
                                    <Border Width="360" BorderThickness="2" BorderBrush="Green">
                                        <StackPanel>
                                            <TextBlock Text="{Binding date}" FontSize="25"></TextBlock>
                                            <TextBlock Text="{Binding weather}" FontSize="30"></TextBlock>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="{Binding dayPictureUrl}" Stretch="Uniform" Width="60" Height="60"></Image>
                                            </StackPanel>
                                            <TextBlock Text="{Binding wind}" FontSize="25"></TextBlock>
                                            <TextBlock Text="{Binding temperature}" FontSize="30"></TextBlock>
    
                                        </StackPanel>
                                    </Border>
    
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </DataTemplate>
                </HubSection>
                <HubSection>
                    <DataTemplate>
                        <ListView ItemsSource="{Binding results[0].index}">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <Border>
                                        <StackPanel>
                                            <TextBlock Text="{Binding tipt}" FontSize="25" Foreground="#FF2996AE"></TextBlock>
                                            <TextBlock Text="{Binding zs}" FontSize="30" Foreground="Green"></TextBlock>
                                            <TextBlock Text="{Binding des}" FontSize="20" TextWrapping="Wrap"></TextBlock>
                                        </StackPanel>
                                    </Border>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </DataTemplate>
                </HubSection>
            </Hub>
        </Grid>
    </Page>
    复制代码

    天气数据加载时用ProgressRing控制

    复制代码
     <ProgressRing x:Name="Pro"></ProgressRing>
    
    加载前
    
    Pro.IsActive=True;
    
    加载完毕
    
    Pro.IsActive=false;
    复制代码

    数据绑定 


    复制代码
     public  class User
        {
            public string Name { get; set; }
            public string Phone { get; set; }
            public string Address { get; set; }
        }
    
    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                // TODO: 准备此处显示的页面。
    
                // TODO: 如果您的应用程序包含多个页面,请确保
                // 通过注册以下事件来处理硬件“后退”按钮:
                // Windows.Phone.UI.Input.HardwareButtons.BackPressed 事件。
                // 如果使用由某些模板提供的 NavigationHelper,
                // 则系统会为您处理该事件。
    
                User U = new User();
                U.Name = "张三";
                U.Phone = "1888";
                U.Address = "东北";
                this.DataContext = U;
            }
    复制代码
           <TextBox Text="{Binding }"></TextBox>
            <TextBox Text="{Binding Name}"></TextBox>
            <TextBox Text="{Binding Address}"></TextBox>

    UWP汉堡包菜单 


    复制代码
    Xaml: 
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <AppBarButton Click="Button_Click" Height="50" Width="50"> <SymbolIcon Symbol="Bold" HorizontalAlignment="Left" VerticalAlignment="Top"/> </AppBarButton> <SplitView x:Name="mySplit" DisplayMode="CompactOverlay" CompactPaneLength="0" OpenPaneLength="200" IsPaneOpen="False" > <SplitView.Pane> <StackPanel Background="Pink"> <AppBarButton Click="Button_Click" Height="50" Width="50"> <SymbolIcon Symbol="Bold" HorizontalAlignment="Left" VerticalAlignment="Top"/> </AppBarButton> <TextBlock FontSize="20">第一项</TextBlock> <TextBlock FontSize="20">第二项</TextBlock> <TextBlock FontSize="20">第一项</TextBlock> <TextBlock FontSize="20">第二项</TextBlock> <TextBlock FontSize="20">第一项</TextBlock> <TextBlock FontSize="20">第二项</TextBlock> </StackPanel> </SplitView.Pane> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="100">Spring</TextBlock> </SplitView> </Grid>



    CS:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
      mySplit.IsPaneOpen = !mySplit.IsPaneOpen;
    }

    
    
  • 相关阅读:
    前段性能----详细渲染过程
    前段性能----repaint和reflow
    前段性能----缓存机制
    前段性能----带宽与延迟
    前端性能----从输入URL开始到返回数据的中间经历过程
    前端性能----TCP协议
    前端性能----CDN
    前端性能优化-学习链接,待持续更新
    前端性能----图像优化(图片)
    前端性能----静态资源,资源压缩
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14244790.html
Copyright © 2011-2022 走看看