// 표시 설정
int panelTotalCount = 4;
int panelRowCount = 3;
// 초기 패널 크기 설정
int initPanelWidth = 200;
int initPanelHeight = 200;
// 메인 패널 크기 설정
int mainPanelWidth = 400;
int mainPanelHeight = 300;
// 서브패널 크기 설정
int subPanelWidth = 200;
int subPanelHeight = 40;
// 시간 설정
int time = 500;
int keyNum = 0;
string currentPanel = "";
string beforePanel = "";
...
// 선택 패널 크기 확장
void btnSize_Click(object sender, RoutedEventArgs e)
{
if (currentPanel == "")
{
currentPanel = (sender as Button).Name;
}
else
{
beforePanel = currentPanel;
currentPanel = (sender as Button).Name;
}
...
for (int i = 0; i < LayoutRoot.Children.Count; i++)
{
...
if ((((sender as Button).Parent as Grid).Parent as UCPanel).Name !=
(LayoutRoot.Children[i] as UCPanel).Name)
{
// 선택되지 않은 나머지 패널 값 설정
if ((LayoutRoot.Children[i] as UCPanel).btnSize.Name == beforePanel)
{
(LayoutRoot.Children[i] as UCPanel).btnSize.Click
-= new RoutedEventHandler(Page_Click);
(LayoutRoot.Children[i] as UCPanel).btnSize.Click
+= new RoutedEventHandler(btnSize_Click);
...
}
}
else
{
(sender as Button).Click -= new RoutedEventHandler(btnSize_Click);
(sender as Button).Click += new RoutedEventHandler(Page_Click);
...
}
}
}
// 초기 정렬
void Page_Click(object sender, RoutedEventArgs e)
{
(sender as Button).Click -= new RoutedEventHandler(Page_Click);
(sender as Button).Click += new RoutedEventHandler(btnSize_Click);
currentPanel = "";
sb = new Storyboard();
for (int i = 0; i < LayoutRoot.Children.Count; i++)
{
int index = int.Parse((LayoutRoot.Children[i] as UCPanel).Name.Split('_')[1].ToString());
ani1 = new DoubleAnimation();
ani2 = new DoubleAnimation();
ani3 = new DoubleAnimation();
ani4 = new DoubleAnimation();
ani1.Duration = duration;
ani2.Duration = duration;
ani3.Duration = duration;
ani4.Duration = duration;
ani1.To = initPanelWidth;
ani2.To = initPanelHeight;
ani3.To = (initPanelWidth + 10) * (index / panelRowCount) + 10;
ani4.To = (initPanelHeight + 10) * (index % panelRowCount) + 10;
Storyboard.SetTarget(ani1, LayoutRoot.Children[i] as UCPanel);
Storyboard.SetTarget(ani2, LayoutRoot.Children[i] as UCPanel);
Storyboard.SetTarget(ani3, LayoutRoot.Children[i] as UCPanel);
Storyboard.SetTarget(ani4, LayoutRoot.Children[i] as UCPanel);
Storyboard.SetTargetProperty(ani1, new PropertyPath("(Width)"));
Storyboard.SetTargetProperty(ani2, new PropertyPath("(Height)"));
Storyboard.SetTargetProperty(ani3, new PropertyPath("(Canvas.Top)"));
Storyboard.SetTargetProperty(ani4, new PropertyPath("(Canvas.Left)"));
sb.Duration = duration;
sb.Children.Add(ani1);
sb.Children.Add(ani2);
sb.Children.Add(ani3);
sb.Children.Add(ani4);
ani1 = null;
ani2 = null;
ani3 = null;
ani4 = null;
}
LayoutRoot.Resources.Add("selectedPanel" + keyNum++, sb);
sb.Completed += new EventHandler(sb_Completed);
sb.Begin();
}
|