与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器
原文:与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器
作者:webabcd
介绍
与众不同 windows phone 7.5 (sdk 7.1) 之设备
- 位置服务(GPS 定位)
- FM 收音机
- 麦克风
- 震动器
示例
1、演示如何使用位置服务(GPS 定位)
GpsDemo.xaml
- <phone:PhoneApplicationPage
- x:Class="Demo.Device.GpsDemo"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Portrait" Orientation="Portrait"
- mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <StackPanel Orientation="Vertical">
- <!--跳转到隐私声明页(如果使用了 GPS 则必须要有“隐私声明”,否则不会通过微软的审核)-->
- <HyperlinkButton Content="隐私声明" NavigateUri="/Device/PrivacyPolicy.xaml" FontSize="{StaticResource PhoneFontSizeNormal}" Margin="10,6" HorizontalAlignment="Left" />
- <TextBlock Name="lblStatus" />
- <Button Name="btnLow" Content="低精度定位" Click="btnLow_Click" />
- <Button Name="btnHigh" Content="高精度定位" Click="btnHigh_Click" />
- <Button Name="btnClose" Content="关闭定位" Click="btnClose_Click" />
- <TextBlock Name="lblMsg" />
- </StackPanel>
- </Grid>
- </phone:PhoneApplicationPage>
GpsDemo.xaml.cs
- /*
- * 演示如何使用位置服务(GPS 定位)
- *
- * GeoCoordinateWatcher - 用于提供地理位置数据
- * Start() - 启动位置服务
- * TryStart(bool suppressPermissionPrompt, TimeSpan timeout) - 尝试启动位置服务,返回值为位置服务是否启动成功
- * suppressPermissionPrompt - 是否禁用权限提示对话框。true为禁用,false为启用
- * timeout - 启动位置服务的超时时间
- * Stop() - 停止位置服务
- *
- * DesiredAccuracy - 指定提供位置服务的精度级别(System.Device.Location.GeoPositionAccuracy 枚举)
- * Default - 低精度定位
- * High - 高精度定位
- * Permission - 位置提供程序的权限,只读(System.Device.Location.GeoPositionPermission 枚举)
- * Unknown - 权限未知
- * Granted - 授予定位权限
- * Denied - 拒绝定位权限
- * Status - 位置服务的状态(System.Device.Location.GeoPositionStatus 枚举)
- * Ready - 已经准备好相关数据
- * Initializing - 位置提供程序初始化中
- * NoData - 无有效数据
- * Disabled - 位置服务不可用
- * Position - 定位的位置数据,只读(Position.Location 是一个 System.Device.Location.GeoCoordinate 类型的对象)
- * MovementThreshold - 自上次触发 PositionChanged 事件后,位置移动了此属性指定的距离后再次触发 PositionChanged 事件(单位:米)
- * 此属性默认值为 0,即位置的任何改变都会触发 PositionChanged 事件
- *
- * PositionChanged - 经纬度数据发生改变时所触发的事件(系统会根据 MovementThreshold 属性的值来决定何时触发 PositionChanged 事件,当位置服务被打开后第一次得到位置数据时也会触发此事件)
- * StatusChanged - 位置服务的状态发生改变时所触发的事件
- *
- *
- *
- * GeoCoordinate - 地理坐标
- * Altitude - 海拔高度(单位:米)
- * VerticalAccuracy - 海拔高度的精度(单位:米)
- * Longitude - 经度
- * Latitude - 纬度
- * IsUnknown - 是否无经纬度数据。true代表无数据,false代表有数据
- * HorizontalAccuracy - 经纬度的精度(单位:米)
- * Course - 行进方向(单位:度,正北为 0 度)
- * Speed - 行进速度(单位:米/秒)
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using System.Device.Location;
- using System.Threading;
- namespace Demo.Device
- {
- public partial class GpsDemo : PhoneApplicationPage
- {
- private GeoCoordinateWatcher _watcher;
- public GpsDemo()
- {
- InitializeComponent();
- _watcher = new GeoCoordinateWatcher();
- }
- private void btnLow_Click(object sender, RoutedEventArgs e)
- {
- // 开启低精度位置服务
- StartLocationService(GeoPositionAccuracy.Default);
- }
- private void btnHigh_Click(object sender, RoutedEventArgs e)
- {
- // 开启高精度位置服务
- StartLocationService(GeoPositionAccuracy.High);
- }
- private void btnClose_Click(object sender, RoutedEventArgs e)
- {
- StopLocationService();
- }
- private void StartLocationService(GeoPositionAccuracy accuracy)
- {
- _watcher = new GeoCoordinateWatcher(accuracy);
- // 位置每移动 20 米触发一次 PositionChanged 事件
- _watcher.MovementThreshold = ;
- _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(_watcher_StatusChanged);
- _watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(_watcher_PositionChanged);
- lblStatus.Text = "GPS 服务启动中...";
- new Thread((x) =>
- {
- // 启动 GPS 服务,会阻塞 UI 线程,所以要在后台线程处理
- if (!_watcher.TryStart(true, TimeSpan.FromSeconds()))
- {
- Dispatcher.BeginInvoke(delegate
- {
- lblStatus.Text = "GPS 服务无法启动";
- });
- }
- }).Start();
- }
- private void StopLocationService()
- {
- if (_watcher != null)
- _watcher.Stop();
- lblStatus.Text = "GPS 服务已关闭";
- }
- void _watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
- {
- // 在 UI 上显示经纬度信息
- Dispatcher.BeginInvoke(delegate
- {
- lblMsg.Text = "经度: " + e.Position.Location.Longitude.ToString("0.000");
- lblMsg.Text += Environment.NewLine;
- lblMsg.Text += "纬度: " + e.Position.Location.Latitude.ToString("0.000");
- });
- }
- void _watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
- {
- // 在 UI 上显示 GPS 服务状态
- Dispatcher.BeginInvoke(delegate
- {
- switch (e.Status)
- {
- case GeoPositionStatus.Disabled:
- if (_watcher.Permission == GeoPositionPermission.Denied)
- lblStatus.Text = "GPS 服务拒绝访问";
- else
- lblStatus.Text = "GPS 服务不可用";
- break;
- case GeoPositionStatus.Initializing:
- lblStatus.Text = "GPS 服务初始化";
- break;
- case GeoPositionStatus.NoData:
- lblStatus.Text = "GPS 无有效数据";
- break;
- case GeoPositionStatus.Ready:
- lblStatus.Text = "GPS 接收数据中";
- break;
- }
- });
- }
- }
- }
2、演示如何使用 FM 收音机
FMRadioDemo.xaml
- <phone:PhoneApplicationPage
- x:Class="Demo.Device.FMRadioDemo"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Portrait" Orientation="Portrait"
- mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <StackPanel Orientation="Vertical">
- <TextBlock Name="lblStatus" />
- <Button Name="btnStart" Content="打开收音机" Click="btnStart_Click" />
- <Button Name="btnClose" Content="关闭收音机" Click="btnClose_Click" />
- <TextBlock Name="lblMsg" />
- </StackPanel>
- </Grid>
- </phone:PhoneApplicationPage>
FMRadioDemo.xaml.cs
- /*
- * 演示如何使用 FM 收音机
- *
- * FMRadio - 用于操作 FM 收音机的类
- * Instance - 返回 FMRadio 实例
- * CurrentRegion - 收音机的区域信息(Microsoft.Devices.Radio.RadioRegion 枚举)
- * UnitedStates - 美国
- * Japan - 日本
- * Europe - 其他地区
- * Frequency - 指定 FM 调频的频率
- * PowerMode - 打开或关闭收音机(Microsoft.Devices.Radio.RadioPowerMode 枚举)
- * On - 打开收音机
- * Off - 关闭收音机
- * SignalStrength - 当前频率的信号强度(RSSI - Received Signal Strength Indication)
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Devices.Radio;
- using System.Windows.Threading;
- using System.Threading;
- namespace Demo.Device
- {
- public partial class FMRadioDemo : PhoneApplicationPage
- {
- private FMRadio _radio;
- private DispatcherTimer _timer;
- public FMRadioDemo()
- {
- InitializeComponent();
- // 实例化 FMRadio,收听 90.5 频率
- _radio = FMRadio.Instance;
- _radio.CurrentRegion = RadioRegion.Europe;
- _radio.Frequency = 90.5;
- _timer = new DispatcherTimer();
- _timer.Interval = TimeSpan.FromMilliseconds();
- _timer.Tick += new EventHandler(_timer_Tick);
- _timer.Start();
- if (_radio.PowerMode == RadioPowerMode.On)
- lblStatus.Text = "收音机已打开";
- else
- lblStatus.Text = "收音机已关闭";
- }
- void _timer_Tick(object sender, EventArgs e)
- {
- // 实时显示当前频率及信号强度
- lblMsg.Text = "调频:" + _radio.Frequency;
- lblMsg.Text += Environment.NewLine;
- lblMsg.Text += "RSSI:" + _radio.SignalStrength.ToString("0.00");
- }
- // 打开收音机
- private void btnStart_Click(object sender, RoutedEventArgs e)
- {
- lblStatus.Text = "收音机打开中。。。";
- // 首次启动收音机可能需要多达 3 秒的时间,以后再启动收音机则会在 100 毫秒以内,所以建议在后台线程打开收音机
- new Thread((x) =>
- {
- _radio.PowerMode = RadioPowerMode.On;
- Dispatcher.BeginInvoke(delegate
- {
- lblStatus.Text = "收音机已打开";
- });
- }).Start();
- }
- // 关闭收音机
- private void btnClose_Click(object sender, RoutedEventArgs e)
- {
- _radio.PowerMode = RadioPowerMode.Off;
- lblStatus.Text = "收音机已关闭";
- }
- }
- }
3、演示如何使用麦克风
MicrophoneDemo.xaml
- <phone:PhoneApplicationPage
- x:Class="Demo.Device.MicrophoneDemo"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Portrait" Orientation="Portrait"
- mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <StackPanel Orientation="Vertical">
- <TextBlock Name="lblMsg" />
- <Button Name="btnRecord" Content="录音" Click="btnRecord_Click" />
- <Button Name="btnPlay" Content="播放" Click="btnPlay_Click" />
- <Button Name="btnStop" Content="停止" Click="btnStop_Click" />
- </StackPanel>
- </Grid>
- </phone:PhoneApplicationPage>
MicrophoneDemo.xaml.cs
- /*
- * 演示如何使用麦克风进行录音
- *
- * Microphone - 用于捕获麦克风音频的类
- * Default - 返回默认的 Microphone 实例
- * All - 返回设备的全部 Microphone 实例集合
- * SampleRate - 获取音频的采样率
- * State - Microphone 的状态(Microsoft.Xna.Framework.Audio.MicrophoneState 枚举)
- * Started - 正在捕获音频
- * Stopped - 已经停止工作
- * BufferDuration - 麦克风捕获音频时的缓冲时长
- *
- * BufferReady - 当麦克风捕获的音频时长达到 BufferDuration 设置的值后所触发的事件
- *
- * GetData(byte[] buffer) - 将麦克风最近捕获到的音频数据写入到指定的缓冲区
- * GetSampleSizeInBytes(TimeSpan duration) - 麦克风捕获音频,根据音频时长返回音频字节数
- * GetSampleDuration(int sizeInBytes) - 麦克风捕获音频,根据音频字节数返回音频时长
- * Start() - 开始捕获
- * Stop() - 停止捕获
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Xna.Framework.Audio;
- using System.IO;
- using System.Threading;
- using Microsoft.Xna.Framework;
- namespace Demo.Device
- {
- public partial class MicrophoneDemo : PhoneApplicationPage
- {
- // silverlight 和 xna 混合编程时,所需要用到的计时器
- private GameTimer _timer;
- private Microphone _microphone = Microphone.Default;
- private SoundEffectInstance _soundInstance; // 用于播放音频数据
- private byte[] _buffer; // 每一片录音数据的缓冲区
- private MemoryStream _stream = new MemoryStream(); // 整个录音数据的内存流
- public MicrophoneDemo()
- {
- InitializeComponent();
- _timer = new GameTimer();
- // 指定计时器每 1/30 秒执行一次,即帧率为 30 fps
- _timer.UpdateInterval = TimeSpan.FromTicks();
- // 每次帧更新时所触发的事件
- _timer.FrameAction += FrameworkDispatcherFrameAction;
- _timer.Start();
- _microphone.BufferReady += new EventHandler<EventArgs>(_microphone_BufferReady);
- }
- private void FrameworkDispatcherFrameAction(object sender, EventArgs e)
- {
- // 当使用 silverlight 和 xna 混合编程时,每次帧更新时都需要调用 FrameworkDispatcher.Update()
- FrameworkDispatcher.Update();
- }
- void _microphone_BufferReady(object sender, EventArgs e)
- {
- // 当录音的缓冲被填满后,将数据写入缓冲区
- _microphone.GetData(_buffer);
- // 将缓冲区中的数据写入内存流
- _stream.Write(_buffer, , _buffer.Length);
- }
- private void btnRecord_Click(object sender, RoutedEventArgs e)
- {
- if (lblMsg.Text != "录音中")
- {
- // 设置录音的缓冲时长为 0.5 秒
- _microphone.BufferDuration = TimeSpan.FromMilliseconds();
- // 设置录音用的缓冲区的大小
- _buffer = new byte[_microphone.GetSampleSizeInBytes(_microphone.BufferDuration)];
- // 初始化内存流
- _stream.SetLength();
- _microphone.Start();
- lblMsg.Text = "录音中";
- }
- }
- private void btnPlay_Click(object sender, RoutedEventArgs e)
- {
- if (_stream.Length > )
- {
- // 播放录音
- Thread soundThread = new Thread(new ThreadStart(playSound));
- soundThread.Start();
- lblMsg.Text = "播放录音";
- }
- }
- private void btnStop_Click(object sender, RoutedEventArgs e)
- {
- if (_microphone.State == MicrophoneState.Started)
- {
- // 停止录音
- _microphone.Stop();
- lblMsg.Text = "停止录音";
- }
- else if (_soundInstance.State == SoundState.Playing)
- {
- // 停止播放录音
- _soundInstance.Stop();
- lblMsg.Text = "停止播放录音";
- }
- }
- private void playSound()
- {
- // 播放内存流中的音频
- SoundEffect sound = new SoundEffect(_stream.ToArray(), _microphone.SampleRate, AudioChannels.Mono);
- _soundInstance = sound.CreateInstance();
- _soundInstance.Play();
- }
- }
- }
4、演示如何使用震动器
VibrationDemo.xaml
- <phone:PhoneApplicationPage
- x:Class="Demo.Device.VibrationDemo"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Portrait" Orientation="Portrait"
- mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <StackPanel Orientation="Vertical">
- <Button Name="btnStart" Content="开始震动" Click="btnStart_Click" />
- <Button Name="btnStop" Content="停止震动" Click="btnStop_Click" />
- </StackPanel>
- </Grid>
- </phone:PhoneApplicationPage>
VibrationDemo.xaml.cs
- /*
- * 演示如何使用震动器
- *
- * VibrateController - 用于控制震动器
- * Default - 获取 VibrateController 实例
- * Start(TimeSpan duration) - 指定震动时长,并使设备震动。有效时长在 0 - 5 秒之间,否则会抛出异常
- * Stop() - 停止设备的震动
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Devices;
- namespace Demo.Device
- {
- public partial class VibrationDemo : PhoneApplicationPage
- {
- public VibrationDemo()
- {
- InitializeComponent();
- }
- private void btnStart_Click(object sender, RoutedEventArgs e)
- {
- // 震动 5 秒
- VibrateController.Default.Start(TimeSpan.FromMilliseconds( * ));
- }
- private void btnStop_Click(object sender, RoutedEventArgs e)
- {
- // 停止震动
- VibrateController.Default.Stop();
- }
- }
- }
OK
[源码下载]
与众不同 windows phone (20) - Device(设备)之位置服务(GPS 定位), FM 收音机, 麦克风, 震动器的更多相关文章
- 与众不同 windows phone (18) - Device(设备)之加速度传感器, 数字罗盘传感器
原文:与众不同 windows phone (18) - Device(设备)之加速度传感器, 数字罗盘传感器 [索引页][源码下载] 与众不同 windows phone (18) - Device ...
- 与众不同 windows phone (21) - Device(设备)之摄像头(拍摄照片, 录制视频)
原文:与众不同 windows phone (21) - Device(设备)之摄像头(拍摄照片, 录制视频) [索引页][源码下载] 与众不同 windows phone (21) - Device ...
- 与众不同 windows phone (19) - Device(设备)之陀螺仪传感器, Motion API
原文:与众不同 windows phone (19) - Device(设备)之陀螺仪传感器, Motion API [索引页][源码下载] 与众不同 windows phone (19) - Dev ...
- 与众不同 windows phone (23) - Device(设备)之硬件状态, 系统状态, 网络状态
原文:与众不同 windows phone (23) - Device(设备)之硬件状态, 系统状态, 网络状态 [索引页][源码下载] 与众不同 windows phone (23) - Devic ...
- 与众不同 windows phone (22) - Device(设备)之摄像头(硬件快门, 自动对焦, 实时修改捕获视频)
原文:与众不同 windows phone (22) - Device(设备)之摄像头(硬件快门, 自动对焦, 实时修改捕获视频) [索引页][源码下载] 与众不同 windows phone (22 ...
- 与众不同 windows phone (2) - Control(控件)
原文:与众不同 windows phone (2) - Control(控件) [索引页][源码下载] 与众不同 windows phone (2) - Control(控件) 作者:webabcd介 ...
- 与众不同 windows phone (44) - 8.0 位置和地图
[源码下载] 与众不同 windows phone (44) - 8.0 位置和地图 作者:webabcd 介绍与众不同 windows phone 8.0 之 位置和地图 位置(GPS) - Loc ...
- 与众不同 windows phone (35) - 8.0 新的启动器: ShareMediaTask, SaveAppointmentTask, MapsTask, MapsDirectionsTask, MapDownloaderTask
[源码下载] 与众不同 windows phone (35) - 8.0 新的启动器: ShareMediaTask, SaveAppointmentTask, MapsTask, MapsDirec ...
- 与众不同 windows phone (13) - Background Task(后台任务)之后台文件传输(上传和下载)
原文:与众不同 windows phone (13) - Background Task(后台任务)之后台文件传输(上传和下载) [索引页][源码下载] 与众不同 windows phone (13) ...
随机推荐
- 我的Python成长之路---第一天---Python基础(作业2:三级菜单)---2015年12月26日(雾霾)
作业二:三级菜单 三级菜单 可一次进入各个子菜单 思路: 这个题看似不难,难点在于三层循环的嵌套,我的思路就是通过flag的真假来控制每一层的循环的,简单来说就是就是通过给每一层循环一个单独的布尔变量 ...
- 在不同编译环境中如何使用sleep()函数
今天在学习有关时间函数时,想让程序暂时挂起,一段时间后在继续执行! 用到了系统函数sleep(): 在vc下sleep函数是以毫秒为单位,如果想让其停留3秒,需要这样做 sleep(3*1000); ...
- poj 3258 River Hopscotch 【二分】
题目真是不好读,大意例如以下(知道题意就非常好解了) 大致题意: 一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L. 河中有n块石头,每块石头到S都有唯一的距 ...
- 使用ItextSharp产PDF完整操作
原文 使用ItextSharp产PDF完整操作 记得上回有写到用C#操作Excel(.net 4.0) 很多朋友说推荐用NPOI,的确,用微软自带的操作execl会有很大的问题.客户的主机不愿意安装e ...
- linux下抓取网页快照
1.下载 https://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltoimage-0.11.0_rc1-static-i38 ...
- perl 为什么要用引用来做对象呢?
perl 为什么要用引用来做对象呢? 因为一个重要的原因是 my 引用 脱离作用域,外部仍旧生效
- CodeForces 462B Appleman and Card Game(贪心)
题目链接:http://codeforces.com/problemset/problem/462/B Appleman has n cards. Each card has an uppercase ...
- 开源JDBC工具类DbUtils
本篇将会详细地介绍Apache公司的JDBC帮助工具类DbUtils以及如何使用.在上一篇中我们已经通过将以前对dao层使用JDBC操作数据库的冗余代码进行了简易封装形成自己的简单工具类JdbcUti ...
- 使用gradle打包jar包
近期用android studio来做android开发的IDE,它是使用gradle来构建的,于是開始学习gradle. 如今有一个项目,里面有一个android-library的模块.我想在做re ...
- 解决android应用程序适用新老android系统版本方法
老的android系统不能运行高版本系统的新方法,为了解决这个问题: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ...