- 博客(38)
- 收藏
- 关注
转载 C#int类型 转Byte[]
方法1:使用左移和右移int转化为byte[]: public byte[] intToBytes(int value) { byte[] src = new byte[4]; src[3] = (byte)((value >> 24) & 0xFF); src[2] = (byte)...
2019-09-19 10:03:00
951
转载 C#Socket发16进制以及进制转换
stringinput="HelloWorld!";char[]values=input.ToCharArray();foreach(charletterinvalues){//Gettheintegralvalueofthecharacter.intvalue=Convert.ToInt32(letter);//Con...
2019-09-17 18:54:00
1495
转载 WPF跨线程操作UI界面控件
在WPF应用中,如果遇到多线程的需求时,如果引用WPF控件时会引发异常,异常内容:调用线程无法访问此对象,因为另一个线程拥有该对象。具体如下: 调用代码: ThreadcountThread= new Thread( new ThreadStart(Count)); countThread.Start(); 在调用的Count方法引发如下 在WPF应用中,如果遇到多线程的需求时,...
2019-09-17 09:36:00
2120
转载 DispatcherTimer和Timer的区别
两者区别是 Timer在非UI线程跑的,DispatcherTimer是在UI线程跑的,DispatcherTimer 可以直接更新UITimer必须使用this.Dispatcher.BeginInvoke去更新UI private void DisPatcherTimerMethod() { DispatcherT...
2019-09-11 09:43:00
820
转载 C#等比列放大缩小图片
public Bitmap ChangeImgSize(Image bit, double Multiple) { Bitmap newBitmap = new Bitmap(Convert.ToInt32(bit.Width * Multiple), Convert.ToInt32(bit.Height * Multiple)); ...
2019-08-20 16:40:00
769
转载 C#实现鼠标滚筒缩放界面的效果
elementCanvas继承UserControl声明属性: #region 缩放属性添加 float ratio = 1.0f; public float Ratio { set { ratio = value; Width =...
2019-08-16 11:42:00
441
转载 QT 安卓 悬浮窗权限动态申请
一:申请方式:String ACTION_MANAGE_OVERLAY_PERMISSION = "android.settings.action.MANAGE_OVERLAY_PERMISSION";Intent intent = new Intent(ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPac...
2019-08-15 15:12:00
604
转载 Qt 中使用Java代码获取安卓设备的MAC地址(安卓9.0)
public String GetDeviceMAC() { String strMacAddr = null; try { // 获得IpD地址 InetAddress ip = getLocalInetAddress(); byte[] b = NetworkInterface.g...
2019-08-14 16:07:00
475
转载 WPF 键盘事件
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.KeyStates==Keyboard.GetKeyStates(Key.Escape)) { this.Close(); } }...
2019-08-13 14:30:00
519
转载 C#选择文件保存路劲
private void button8_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; if (dial...
2019-08-12 13:57:00
267
转载 C#颜色对话框(WPF可用)
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog(); //允许使用该对话框的自定义颜色 colorDialog.AllowFullOpen = true; colorDialog.FullOpen = ...
2019-08-09 11:31:00
584
转载 C# WPF 数据绑定
后台通知: public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { ...
2019-08-07 18:14:00
437
转载 QT 安卓 调用java类
用以下方式即可调用java类中的方法 QAndroidJniObject activity = QtAndroid::androidActivity(); QAndroidJniObject DeviceSN=activity.callObjectMethod<jstring>("getDeviceSN"); QAndroidJniObject De...
2019-08-01 16:38:00
878
转载 QT 安卓动态获取权限
一:在AndroidManifest.xml文件中赋予相关权限二:package ckdz.Appproject;import android.Manifest;import android.app.Activity;import android.content.Context;import android.content.pm.PackageManager;...
2019-08-01 16:36:00
1004
转载 C# WPF集中引用图片等资源的路劲方式
第一内部资源:pack://application:,,,/images/my.jpg第二 外部程序资源:pack://SiteOfOrigin:,,,/images/my.jpg需要将资源放于运行目录转载于:https://www.cnblogs.com/LCLBook/p/11271082.html...
2019-07-30 16:46:00
460
转载 WPF 遍历资源字典中的控件
object obItem=this.FindResource("canvasdt"); if (obItem is System.Windows.DataTemplate) { System.Windows.DataTemplate getDtemplate = obItem as System.Windows...
2019-07-30 15:30:00
319
转载 C#绘图、画笔相关
dg.SmoothingMode = SmoothingMode.HighSpeed; //高质量 dg.PixelOffsetMode = PixelOffsetMode.HighSpeed; //高像素偏移质量 dg.CompositingQuality = CompositingQuality.HighSpeed;设置为高速度,这样...
2019-07-30 11:08:00
240
转载 C#键盘事件
一:protected override void OnKeyDown(KeyEventArgs e) { if (e.Key==Key.Enter) { sendAppToServer(); } base.OnKeyDown(e); }...
2019-07-29 17:13:00
815
转载 C#Linq之求和,平均值,最大值,最小值
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Wolfy.LinqAggregation{ class Program { static void Main(str...
2019-07-29 10:32:00
2414
转载 QT获取屏幕分表率(PC、安卓)
QRect screenRect = QGuiApplication::primaryScreen()->geometry();double devicePixelRatio = QGuiApplication::primaryScreen()->devicePixelRatio();int screenW = screenRect.width();int scr...
2019-07-26 15:50:00
405
转载 QT 获取字体大小
QFont font(androidFont);QFontInfo fInfo(font);qDebug()<<"FFFFFFFFFFFFFFFFFFFFFFFPPPSIZE::"<<fInfo.pixelSize();转载于:https://www.cnblogs.com/LCLBook/p/11245512.html
2019-07-25 17:12:00
2228
转载 C#颜色转换
Html互转:string c1 = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.Red);System.Drawing.Color c2 = System.Drawing.ColorTranslator.FromHtml("#ff0000");转载于:https://www.cnblogs.co...
2019-07-24 10:43:00
137
转载 C#获取当前时间
//获取日期+时间DateTime.Now.ToString();// 2008-9-4 20:02:10DateTime.Now.ToLocalTime().ToString();// 2008-9-4 20:12:12//获取日期DateTime.Now.ToLongDateString().ToString();...
2019-07-23 18:46:00
69
转载 C#文本转换为Json格式
privatestringConvertJsonString(stringstr){//格式化json字符串JsonSerializer serializer =newJsonSerializer();TextReader tr =newStringReader(str);...
2019-07-16 17:34:00
645
转载 C#解决界面闪烁
添加缓冲: private void SetDoubleBuffer() { base.SetStyle( ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw ...
2019-07-15 15:00:00
463
转载 C# 文件过滤器
首先说明一个示例,分析一下Filter属性的构成:“ Excel文件|*.xls ”,前面的“Excel文件”成为标签,是一个可读的字符串,可以自定定义,“|*.xls”是筛选器,表示筛选文件夹中后缀名为.xls的文件,“*”表示匹配Excel文件名称的字符串。OK,下面说说我们经常要用到的几种情况:1. Filter是null或Empty,表示显示所有文件,并总会显示文件夹2. 需要筛...
2019-07-15 11:04:00
214
转载 C#拷贝文件
public void FileCopy(string source, string target) { using (FileStream fileRead = new FileStream(source, FileMode.Open, FileAccess.Read,FileShare.ReadWrite)) { ...
2019-07-15 10:56:00
271
转载 QByteArray详解
QByteArray在串口通讯中经常被使用,有一定必要较为全面详细的对QByteArray进行阐述。本文通过以下几个部分加以介绍:1. 初始化2. 访问与赋值3. 添加、删除、插入与替换操作4. 查找与比较5. 数据转换与处理1 初始化2 访问与赋值 访问QByteArray主要有4中方式,分别为[]、at()、data[]和constData[]。...
2019-07-15 09:51:00
571
转载 C#在txt类文件中追加内容
string path = "test.txt"; FileStream mystream = new FileStream(path, FileMode.OpenOrCreate); StreamWriter myWrite = new StreamWriter(mystream); myWrite.Write(str...
2019-07-15 09:37:00
1845
转载 C#取绝对值函数
System.Math.Abs(float value);System.Math.Abs(decimal value);System.Math.Abs(int value);System.Math.Abs(double value);System.Math.Abs(sbyte value);System.Math.Abs(long value);Sy...
2019-07-08 17:46:00
2413
转载 C#将字符串格式化为Json
privatestringConvertStringToJson(stringstr){//格式化json字符串JsonSerializer serializer =newJsonSerializer();TextReader tr =newStringReader(str);...
2019-07-05 11:43:00
825
转载 C#获取本机IP
public void GetIPAddress() { string resultIP = string.Empty; System.Net.IPAddress[] ips = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList; ...
2019-06-28 14:54:00
112
转载 C#解决窗体全屏遮住任务栏
this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;在初始话后添加这个即可实现,。。。。。。。。。。。。。。。转载于:https://www.cnblogs.com/LCLBook/p/11011260.html...
2019-06-12 18:00:00
1339
转载 C#XmlDocument输出字符串
XmlDocument xmlDoc = new XmlDocument();//假定该xmlDoc已经有内容; MemoryStream streamXml = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(streamXml, Encoding.UTF8); ...
2019-06-11 11:44:00
589
转载 C#拷贝整个文件夹以及子目录和其中文件
privatevoidCopyDirectory(stringsrcPath,stringdesPath){stringfolderName=srcdir.Substring(srcdir.LastIndexOf("\\")+1);stringdesfolderdir=desPa...
2019-06-10 13:33:00
977
转载 C#递归拷贝文件夹下文件以及文件夹
public bool CopyOldLabFilesToNewLab(string sourcePath, string savePath) { if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); ...
2019-05-27 16:40:00
257
转载 C# 获取文件名、目录、后缀、无后缀文件名、扩展名
string filePath = "C:\\1.txt";string str = "获取文件的全路径:" + Path.GetFullPath(filePath); //-->C:1.txtstr = "获取文件所在的目录:" + Path.GetDirectoryName(filePath); //-->C:Console.W...
2019-05-25 13:53:00
428
转载 C#递归得到特定文件夹下问件
List<String> listFile = new List<String>(); public void director(string path) { //绑定到指定的文件夹目录 DirectoryInfo dir = new DirectoryInfo(path); //检索表示当前目录的文件和子目录 ...
2019-05-25 12:00:00
103
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人