zoukankan      html  css  js  c++  java
  • 关于Windows phone的一些语句

    1.把String类型的转换成Int类型的 
    把STRING aa 转换成  int n

    int n= Convert.ToInt16(aa.ToString());

    2.填充颜色
    rectangle.Fill=new SolidColorBrush(Clolrs.Green);

    3.关于图片填充的属性Stresh
    None  图片直接加载 不进行拉伸,如果IMAGE的控件大小为
    100x100,而图片为1000X1000则只显示顶部100X100
    Fill 图片会拉伸或者缩小 以适应充满Image控件,长宽比可能改变
    Uniform 图片会拉伸到最佳 的大小 不一定充满整个Image控件,但是保持
    长宽比不变
    UniformToFill 图片会在不改变长宽比的前提下拉伸,它会充满整个Image控件,
    但是可能被裁剪

    4.判断独立存储里面是否存在文件夹用(DirectoryExists),文件用(FileExists)

     IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();

             if (!file.DirectoryExists("zhibin"))
                {
                    file.CreateDirectory("zhibin");

                }

    5.判断是否有网络链接
      public static bool networkIsAvailable;
     
    networkIsAvailable = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
    networkIsAvailable 是一个布尔型 再根据返回的值去进行判断;

    6.弹出式通知
    首先要去添加Coding4Fun.Phone.Controls.dll 这个DLL
    然后 直接添加写代码 添加USING语句
                    ToastPrompt toast = new ToastPrompt();
                    toast.FontSize = 21;
                    toast.TextWrapping = TextWrapping.Wrap;
                    toast.Margin = new Thickness(0, -32, 0, 0); 
                    toast.Message = message.ToString();
                    toast.Show();


    7  给IMAGE赋地址  两种
     img_Background2.Source = new BitmapImage(new Uri("zhibin.jpg", UriKind.Relative));

       Uri uri = new Uri("zhibin.jpg", UriKind.Relative);
                            BitmapImage pic = new BitmapImage(uri);
                            image.Source = pic;

    8、 WEB请求
                //Webclient请求数据

    uri="http://www.cnblogs.com/zhibin";
                WebClient zhibin_request = new WebClient();
                Focibin_request.DownloadStringCompleted += new DownloadStringCompletedEventHandler(ibin_request_DownloadStringCompleted);
                ibin_request.DownloadStringAsync(new Uri(url));

          void ibin_request_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
            {

    e.result就是 请求返回的数据
    }

    9、字符串替换
           zhibin= zhibin.Replace("1", "2");

    10、 后台代码新建控件


            StackPanel stackpanel = new StackPanel();
            stackpanel.Width = 410;
           stackpanel.Orientation = System.Windows.Controls.Orientation.Horizontal;

    11、给画布添加背景

      Canvas canvas = new Canvas();
                        ImageBrush imagebrush = new ImageBrush();
                        imagebrush.ImageSource= new BitmapImage(new Uri("zhibin.jpg", UriKind.Relative));
                        canvas.Background = imagebrush;
                        canvas.Width = 153;
                        canvas.Height = 113;
                        canvas.Margin = new Thickness(0, 10, 0, 10);
                        canvas.VerticalAlignment = VerticalAlignment.Center;

                        zhibin.TextWrapping = TextWrapping.Wrap;

                        zhibin.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(stackpanel_Tap);

    12桌面Tile背面

                 ShellTile defaultTile = ShellTile.ActiveTiles.First();

                StandardTileData tileData = new StandardTileData()
                {
                    Title = "zhibin",
                    Count = 0,
                    BackgroundImage = new Uri("Background.png", UriKind.Relative),
                    BackTitle = "zhibin",
                    BackBackgroundImage = new Uri("zhibin.jpg", UriKind.Relative),
                    BackContent = "hello",
                };
              
                defaultTile.Update(tileData);

    13控件隐藏


                this.text.Visibility = Visibility.Collapsed;

        void stackpanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
            {

                StackPanel stackpanel = sender as StackPanel;

           }

    14、判断当前在全景视图的第几个页面

           private void panorama1_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                if (panorama1.SelectedIndex == 0) { pageNum.Text = "0"; }
                else if (panorama1.SelectedIndex == 1) { pageNum.Text = "1"; }
                else if (panorama1.SelectedIndex == 2) { pageNum.Text = "2"; }
                else if (panorama1.SelectedIndex == 3) { pageNum.Text = "3"; }
            }

    15、操作数据库完成要提交  注意捕获异常

               try
                            {
                                zhibin.SubmitChanges();
                            }
                            catch (Exception error)
                            {
                                 Console.WriteLine(error);

                            }

    16 关于application bar的操作

     appBarPlay = this.ApplicationBar.Buttons[1] as ApplicationBarIconButton;

    17、全景视图跳转

    panoramaControl.DefaultItem = panoramaControl.Items[indexToSet];

    19、获取当前语言

    string str = System.Globalization.CultureInfo.CurrentCulture.Name;
    if (str == "zh-CN")
    {
    //中文
    }

  • 相关阅读:
    svn提交代码出错
    正则表达式小试
    基于AT91RM9200的ARM Linux的移植方法
    Byte、bit、bps、位、字、字节/包 ,报文,帧
    时间片调度在单片机中的运用
    单片机计数器T0作定时技术(记时器设计)
    fastboot 烧写内核
    菜鸟吧网站
    理解单片机中的计数器和定时器
    svn命令总结(原创)
  • 原文地址:https://www.cnblogs.com/zhibin/p/2506419.html
Copyright © 2011-2022 走看看