Storyboard や、WPF で既に準備が整っているものを使用しないことで、かなりの効果を上げようとしています。
いくつかのイベント(クリックなど)でUI要素のサイズが2〜3秒間変更され、色が変化してぼやける滑らかな効果を作りたいです。これらすべてのアイテムを滑らかできれいな方法で作りたいと思っています。
エフェクトの各フレームをレンダリングするクラスを用意しました。
public static class ApplicationHelper
{
[SecurityPermissionAttribute(SecurityAction.Demand,
Flags=SecurityPermissionFlag.UnmanagedCode)]
public static void DoEvents(DispatcherPriority priority)
{
DispatcherFrame frame = new DispatcherFrame();
DispatcherOperation oper = Dispatcher.CurrentDispatcher.
BeginInvoke(priority,
new DispatcherOperationCallback(ExitFrameOperation),
frame);
Dispatcher.PushFrame(frame);
if (oper.Status != DispatcherOperationStatus.Completed)
{
oper.Abort();
}
}
private static object ExitFrameOperation(object obj)
{
((DispatcherFrame)obj).Continue = false;
return null;
}
[SecurityPermissionAttribute(SecurityAction.Demand,
Flags=SecurityPermissionFlag.UnmanagedCode)]
public static void DoEvents()
{
DoEvents(DispatcherPriority.Background);
}
}
ここでは、DispatcherTimer で動作させようとしています。
void vb1_click(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
DispatcherTimer dt = new DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 500);
dt.Tick += new System.EventHandler(dt_Tick);
dt.Start();
}
void dt_Tick(object sender, System.EventArgs e)
{
for(int i = 0; i < 20; i++)
{
this.vb2_blur_eff.Radius = (double)i;
ApplicationHelper.DoEvents();
}
}
主な問題は、私がそれを起動しているとき、私は待っているだけであり、最後の時間 (最後のフレームをレンダリングする必要があるとき) に、すべてのフレームで非常に速い速度で取得していますが、以前は何もありませんでした。
それを解決し、準備ができている/完了したものを使用せずに純粋なC#の方法で完璧な滑らかな効果を作る方法は?
ありがとうございました!