Skip to content

Instantly share code, notes, and snippets.

View HamGuy's full-sized avatar
🎯
Focusing

HamGuy HamGuy

🎯
Focusing
View GitHub Profile
#include "pch.h"
#include "NativeCameraInterface.h"
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Phone::Media::Capture;
// Called each time a preview frame is available
void NativeCameraInterface::Native::CameraCapturePreviewSink::OnFrameAvailable(
using Microsoft.Phone.Controls;
using System;
using System.Windows.Controls.Primitives;
/// <summary>
/// This class detects the pull gesture on a LongListSelector. How does it work?
///
/// This class listens to the change of manipulation state of the LLS, to the MouseMove event
/// (in WP, this event is triggered when the user moves the finger through the screen)
/// and to the ItemRealized/Unrealized events.
@HamGuy
HamGuy / ClipToBounds
Created July 17, 2013 08:09
ClipToBounds Attached Property
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Media;
namespace Microsoft.Phone.Controls.Primitives
@HamGuy
HamGuy / ExtendedListBox
Created July 17, 2013 15:32
ExtendedListBox
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace HamGuyToolkit.Controls
{
# -*- coding: utf-8 -*-
import encodings.utf_8
import math
import urllib, urllib2
import random
import re
from xml.dom import minidom
from LevenshteinDistance import LevenshteinDistance
from grabber import LyricProviderBase
@HamGuy
HamGuy / ExitConfirm.cs
Created July 30, 2013 03:05
Confirm while exit
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("Are you sure?", "Exit?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
while (NavigationService.BackStack != null & NavigationService.BackStack.Count() > 0)
NavigationService.RemoveBackEntry();
}
else
e.Cancel = true;
base.OnBackKeyPress(e);
@HamGuy
HamGuy / Custom font
Created July 30, 2013 03:20
Using custom font in windows phone
1.Add the font file to the project.
2.Set the build action to "Content".
3.Set the copy option to "Copy if Newer".
Useage:
XAML:
FontFamily="Fonts/pendule_ornamental.ttf#pendule ornamental"
Code-Behind:
@HamGuy
HamGuy / 隐藏软键盘.cs
Created July 31, 2013 09:28
Windows Phone开发 TextBox的回车事件 关闭软键盘 单行的TextBox,如果用户按回车键,说明输入已经完成,但Windows Phone并不会自动隐藏软键盘盘.单行的TextBox在按回车键后会触发TextInput事件,而TextBox在失去焦点后,软键盘就会隐藏,所以重写这个事件的方法,把焦点转移到其他控件上即可:
private void textBox1_TextInput(object sender, TextCompositionEventArgs e)
{
System.Diagnostics.Debug.WriteLine(textBox1.Text);
this.Focus();
//转移焦点到整个页面,TextBox失去焦点后,就会隐藏软键盘
}
@HamGuy
HamGuy / ios5check.c
Created August 13, 2013 06:27
ios check
需要添加一张启动图片,大小:640*1136,添加后默认命名为Default-568h@2x.png。
图片适配,对于高清的1136图片,命名同样使用@2x,只是改名图片名称,如image-1-os5.png,image-1-os5@2x.png,
在代码中判断iphone5?(image-1):(image-1-os5),没有@22x这种。
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
view.frame = CGRectMake(0, 0, 320, 416+(iphone5?88:0))
AViewController *aViewContrller = [[AViewController alloc] initWithNibName:(iPhone5?@"AViewController-5":@"AViewController") bundle:nil];
UIViewAutoresizingFlexibleTopMargin:与superView上边界保持动态距离(按比例)
@HamGuy
HamGuy / AutiEventTest.cpp
Created August 28, 2013 03:35
Win32下多线程同步技术
#include <iostream>
#include <windows.h>
#include <process.h>
int g_Count;
const int THREAD_NUM =10;
CRITICAL_SECTION g_csSubThread;
HANDLE g_Event;
unsigned int __stdcall ThreadFunc(PVOID pM)