using System;
using System.Drawing;
public static class DisplayFusionFunction {
public static int target_transparency = 90;
public static void Run (IntPtr windowHandle) {
//if we couldn't get the window then exit
if (windowHandle == IntPtr.Zero)
return;
int current_transparency = (int) Math.Floor (BFS.Window.GetTransparency (windowHandle));
if (current_transparency != target_transparency - 1) {
BFS.Window.SetAlwaysOnTop(windowHandle, true);
SetTrans (current_transparency, target_transparency, windowHandle);
} else {
BFS.Window.SetAlwaysOnTop(windowHandle, false);
SetTrans (current_transparency, 100, windowHandle);
}
}
private static void SetTrans (int origin, int target, IntPtr windowHandle) {
// INCREASE FOR SLOWER ANIMATION, DECEREASE FOR FASTER
int animation_rate_factor = 2;
// Tries to keep the time it takes for the animation to complete constant,
// regardless of how big the difference between origin and target is.
// So going from 10 to 100 would approx. take the same time as from 90 to 100. (based on animation_rate_factor)
uint thread_wait = (uint) (animation_rate_factor * 100 / (Math.Abs (origin - target)));
if (origin < 90) {
for (int i = origin; i <= target; i++) {
BFS.General.ThreadWait (thread_wait);
BFS.Window.SetTransparency (windowHandle, i);
}
} else {
for (int i = origin; i >= target; i--) {
BFS.General.ThreadWait (thread_wait);
BFS.Window.SetTransparency (windowHandle, i);
}
}
BFS.Window.SetTransparency (windowHandle, target);
}
}