Skip to content

Instantly share code, notes, and snippets.

View viko16's full-sized avatar
🎯
Focusing

viko16 viko16

🎯
Focusing
View GitHub Profile
@viko16
viko16 / iniClass.cs
Last active December 20, 2015 21:49
C# ini编辑类
class INIClass
{
public string inipath;
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
/// <summary>
@viko16
viko16 / HideTablePages.cs
Created August 10, 2013 12:51
tablecontrol 隐藏部分tabpage,按键后显示 #winform
TabPage[] tp=new TabPage[4];
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < tabControl1.TabPages.Count; i++)
{
tp[i] = tabControl1.TabPages[i];
}
for (int i = 1; i < tp.Length; i++)
{
tabControl1.TabPages.Remove(tp[i]);
@viko16
viko16 / CheckIsIp.cs
Last active December 20, 2015 21:49
巧妙验证是否ip
using System.Net;
try
{
IPAddress ipTest = IPAddress.Parse(txtBox1.Text);//string转化为ip地址
}
catch (Exception)
{
toolTip1.Show("ip有误", txtBox1, 2000); //2000是提示显示的时间,单位毫秒
}
@viko16
viko16 / CheckEmpty.cs
Created August 11, 2013 06:19
检查各个控件是否有空值 #winform
/// <summary>
/// 检查各个控件是否有空值
/// </summary>
/// <returns>无空值返回true</returns>
private Boolean CheckEmpty()
{
foreach (Control cur in this.Controls)
{
//if (cur is TextBox && cur.Text == "") /*两种方式皆可,下面的更好*/
if(cur is TextBox && string.IsNullOrEmpty(cur))
@viko16
viko16 / confirm_if_ok.cs
Created August 13, 2013 14:21
弹出确认框 #winform
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("是否确认?", "请确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
MessageBox.Show("ok");
}
}
@viko16
viko16 / confirmExit.cs
Created August 13, 2013 16:00
点击退出时需要确认 #winform
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("是否确认退出程序?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
// 关闭所有的线程
this.Dispose();
this.Close();
}
else
e.Cancel = true;
@viko16
viko16 / like_click_special.js
Last active December 21, 2015 12:09
QQ空间批量点赞 #javascript
function ilike() {
var j = document.getElementsByClassName("qz_like_btn_v3 _likeBtn c_tx ui_mr10");
var count = 0;
for (var i = count; i < j.length; i++) {
if (j[i].innerHTML.slice(0, 1) == "赞") {
j[i].click();
count++;
}
}
window.document.body.scrollTop = window.document.body.scrollHeight - 1000;
@viko16
viko16 / changePanelVisble.cs
Created August 29, 2013 16:47
切换panel的显示和隐藏 #winform
/// <summary>
/// 切换panel的显示效果
/// </summary>
/// <param name="panelname">panel的名字</param>
private void changeView(string panelname)
{
foreach (Control cn in this.Controls)
{
if (cn is Panel)
{
@viko16
viko16 / back-to-top.js
Last active August 16, 2017 04:26
js封装的回到顶端按钮 #javascript
/*!
* 简单的"回到顶端"按钮,javascript封装版
* wenhao(viko16) - v0.0.2 (2013-12-14 14:00:31+0800)
* Released under MIT license
* 需要先引入jquery框架
*/
$(document).ready(function() {
//在body结束前添加按钮
$('body').append('<a href="#" class="back-to-top">回到顶端</a>');
@viko16
viko16 / hanzi2dianzhen.js
Created November 28, 2013 17:17
如何在32*32的黑白屏幕上显示出文字 #javascript
var d = document, c = d.createElement('CANVAS');
c.height = c.width = 100;
var ctx = c.getContext('2d');
ctx.textBaseline = "top";
var hanzi2dianzhen = {
paintFont : function(char, size, font) {
ctx.clearRect(0, 0, c.width, c.height);
ctx.font = [size, 'px', ' ', font].join('');
ctx.fillText(char, 0, 0);
},