?? flow.cs.svn-base
字號:
using System;
using System.Collections;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;
namespace Aspecto.FlowFX
{
public sealed class FlowNavigator
{
public FlowNavigator(FlowForm root)
{
stack = new Stack();
rootView(root);
}
private void rootView(FlowForm view)
{
this.root = view;
stack.Push(view);
}
[DllImport("coredll")]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder sb, int maxCount);
[DllImport("coredll.dll")]
private static extern bool IsWindow(IntPtr handle);
public void Back()
{
try
{
if (stack.Count > 1)
{
FlowForm f = ((FlowForm)stack.Pop());
f.FlowClose(false);
//was trying to find if the other window is behind the closed one because then
//there is no need to Activate it. Activating a window already in front causes it to forget
//which control was last focused so trying to avoid that.
//IntPtr i = GetWindow(f.Handle, GW.HWNDNEXT);
//StringBuilder sb = new StringBuilder(100);
//string ss = "";
//bool b = IsWindow(i);
//bool d = IsWindowVisible(i);
//while ( !IsWindow(i) || !IsWindowVisible(i))// sb.ToString()=="") // find next visible
//{
// i = GetWindow(i, GW.HWNDNEXT);
// GetWindowText(i, sb, 100);
//}
Activate();
}
}
catch (Exception)
{
//Model.LogException("Back", exception1);
}
}
[DllImport("coredll.dll")]
private static extern bool IsWindowVisible(IntPtr handle);
private void backHome()
{
try
{
if (stack.Count > 1)
{
((FlowForm)stack.Pop()).FlowClose(true);
}
else
Activate();
}
catch (Exception)
{
//Model.LogException("BackHome", exception1);
}
}
internal void ForceBack()
{
try
{
if (stack.Count > 1)
{
stack.Pop();
Activate();
}
}
catch (Exception)
{
//Model.LogException("ForceBack", exception1);
}
}
public void Forward(FlowForm view)
{
Forward(view,new NoEffect());
}
public void Forward(FlowForm view, Effect effect)
{
try
{
MainMenu menu = null;
if (Current != null)
{
menu = Current.Menu;
Current.Menu = null;
//Close the SIP so we don't need to bother dealing with drawing it on the fading in window
if (Device.PlatformType == PlatformType.PocketPC)
{
// Microsoft.WindowsCE.Forms.InputPanel ip = new Microsoft.WindowsCE.Forms.InputPanel();
// ip.Enabled = false;
// ip.Dispose();
}
}
FlowForm lastForm = Current;
stack.Push(view);
try
{
effect.Swap(lastForm, Current, true);
}
catch (Exception exx) {
MessageBox.Show(exx.Message);
} // if anything goes wrong when drawing the transition we don't care
lastForm.realText = lastForm.Text;
lastForm.Text = string.Empty;
DialogResult result1 = view.ShowDialog();
if (result1 != DialogResult.Abort)
{
try
{
effect.Swap(view, Current, false);
}
catch (Exception)
{ }
}
Current.Menu = menu; // easy way to redraw menu, however if sip is up...?
if (result1 == DialogResult.Abort)
{
backHome();
}
}
catch (Exception exception1)
{
//Model.LogException("Forward", exception1);
MessageBox.Show(exception1.Message);
}
}
public void HideAll()
{
try
{
object[] objArray1 = stack.ToArray();
for (int num1 = objArray1.Length - 1; num1 >= 0; num1--)
{
((FlowForm)objArray1[num1]).Hide();
}
}
catch (Exception)
{
//Model.LogException("HideAll", exception1);
}
}
public FlowForm Home()
{
backHome();
root.Activate(); // so we don't see other windows in the z-order flickering up, see backHome() for the real place the root is activated
return Current;
}
public void Invoke(EventHandler method)
{
try
{
if (root != null)
{
root.Invoke(method);
}
}
catch (ObjectDisposedException)
{
}
}
[DllImport("coredll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("coredll")]
private static extern IntPtr GetWindow(IntPtr ptr, GW GW);
public enum GW : int
{
/// <summary>
///
/// </summary>
HWNDFIRST = 0,
/// <summary>
///
/// </summary>
HWNDLAST = 1,
/// <summary>
///
/// </summary>
HWNDNEXT = 2,
/// <summary>
///
/// </summary>
HWNDPREV = 3,
/// <summary>
///
/// </summary>
OWNER = 4,
/// <summary>
///
/// </summary>
CHILD = 5
}
private void Activate()
{
try
{
FlowForm view1 = Current;
view1.Text = view1.realText;
view1.Activate(); // do it sync and the last focused control loses focus
if (view1 != null)
{
// view1.BeginInvoke(new EventHandler(activate)); // do it async so the last focused control on the form doesnt lose focus, but means if you go next form, home, back to app, then back it does the effect on the home screen
}
}
catch (Exception)
{
//Model.LogException("Show", exception1);
}
}
private void activate(Object src, EventArgs ea)
{
FlowForm view1 = Current;
IntPtr i = GetForegroundWindow();
if (i != view1.Handle) // check if there is anypoint in activating
view1.Activate();
}
public FlowForm Current
{
get
{
try
{
if (stack.Count == 0)
{
return null;
}
return (FlowForm)stack.Peek();
}
catch (Exception )
{
//Model.LogException("get_Current", exception1);
return null;
}
}
}
private FlowForm root;
private Stack stack;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -