protected override void OnCellEndEdit(DataGridViewCellEventArgs e) { String nowText = this.CurrentCell.Value as String; CellTextChangedEventArgs args = new CellTextChangedEventArgs(BeforeText, nowText, Now.Col, Now.Row, this.Rows[Now.Row], this.Rows[Now.Row].Cells[Now.Col] as DataGridViewTextBoxCell); if (_isEditActivated) { if (BeforeText.Equals(nowText) == false) { if (E_TextChanged != null) { E_TextChanged(this, args); } if (args.IsCancel) { if (EditingControl != null) { this.EditingControl.Text = BeforeText; } Cell(Now).Value = BeforeText; } } if (E_TextEditFinished != null) { E_TextEditFinished(this, args); } _isEditActivated = false; } base.OnCellEndEdit(e); }
private void ResetAnimation() { Timer?.Stop(); Timer = null; TopBar.BeginAnimation(WidthProperty, null); BottomBar.BeginAnimation(WidthProperty, null); BottomBar.BeginAnimation(MarginProperty, null); BeforeText.BeginAnimation(OpacityProperty, null); AfterText.BeginAnimation(OpacityProperty, null); ChangeText.BeginAnimation(OpacityProperty, null); BeforeLine.BeginAnimation(OpacityProperty, null); BeforeLine.BeginAnimation(Line.X1Property, null); BeforeLine.BeginAnimation(Line.X2Property, null); AfterLine.BeginAnimation(OpacityProperty, null); AfterLine.BeginAnimation(Line.X1Property, null); AfterLine.BeginAnimation(Line.X2Property, null); AfterLine.BeginAnimation(Line.Y1Property, null); }
public void Animate() { if (BeforeValue <= AfterValue) { TopBar.Fill = new SolidColorBrush(GetColor(BeforeValue)); var BeforeValueAnimation = new DoubleAnimation() { From = 0, To = 300 * BeforeValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }; BeforeValueAnimation.Completed += delegate { BeforeText.Margin = new Thickness(300 * BeforeValue - BeforeText.ActualWidth / 2, 0, 0, 0); BeforeText.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.5) }; Timer.Tick += delegate { StartChangeColor.Color = Color.FromArgb(0, 50, 205, 50); EndChangeColor.Color = Color.FromArgb(150, 50, 205, 50); BottomBar.Margin = new Thickness(300 * BeforeValue, 20, 0, 0); var AfterValueAnimation = new DoubleAnimation() { From = 0, To = 300 * (AfterValue - BeforeValue), Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }; AfterValueAnimation.Completed += delegate { AfterText.Foreground = new SolidColorBrush(GetColor(AfterValue)); AfterText.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); ChangeText.Foreground = Brushes.LimeGreen; ChangeText.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); }; BottomBar.BeginAnimation(WidthProperty, AfterValueAnimation); //TopBar.Fill = TopBar.Fill.Clone(); //((SolidColorBrush)TopBar.Fill).BeginAnimation(SolidColorBrush.ColorProperty, // new ColorAnimation() // { // From = ((SolidColorBrush)TopBar.Fill).Color, // To = GetColor(AfterValue), // Duration = TimeSpan.FromSeconds(0.5), // EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } // }); AfterLine.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); AfterLine.BeginAnimation(Line.X1Property, new DoubleAnimation() { From = 300 * BeforeValue, To = 300 * AfterValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); AfterLine.BeginAnimation(Line.X2Property, new DoubleAnimation() { From = 300 * BeforeValue, To = 300 * AfterValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); if (BeforeText.Margin.Left + BeforeText.ActualWidth + 5 >= 300 * AfterValue - AfterText.ActualWidth / 2) { AfterText.Margin = new Thickness(300 * AfterValue - AfterText.ActualWidth / 2, -10, 0, 0); AfterLine.BeginAnimation(Line.Y1Property, new DoubleAnimation() { From = 15, To = 5, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); } else { AfterText.Margin = new Thickness(300 * AfterValue - AfterText.ActualWidth / 2, 0, 0, 0); } Timer.Stop(); }; Timer.Start(); }; TopBar.BeginAnimation(WidthProperty, BeforeValueAnimation); BeforeLine.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); BeforeLine.BeginAnimation(Line.X1Property, new DoubleAnimation() { From = 0, To = 300 * BeforeValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); BeforeLine.BeginAnimation(Line.X2Property, new DoubleAnimation() { From = 0, To = 300 * BeforeValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); } else { TopBar.Fill = new SolidColorBrush(GetColor(BeforeValue)); var BeforeValueAnimation = new DoubleAnimation() { From = 0, To = 300 * BeforeValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }; BeforeValueAnimation.Completed += delegate { BeforeText.Margin = new Thickness(300 * BeforeValue - BeforeText.ActualWidth / 2, 0, 0, 0); BeforeText.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.5) }; Timer.Tick += delegate { StartChangeColor.Color = Color.FromArgb(150, 255, 0, 0); EndChangeColor.Color = Color.FromArgb(0, 0, 0, 0); var AfterValueAnimation = new ThicknessAnimation() { From = new Thickness(300 * BeforeValue, 20, 0, 0), To = new Thickness(300 * AfterValue, 20, 0, 0), Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }; AfterValueAnimation.Completed += delegate { AfterText.Foreground = new SolidColorBrush(GetColor(AfterValue)); AfterText.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); ChangeText.Foreground = Brushes.Red; ChangeText.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); }; BottomBar.BeginAnimation(WidthProperty, new DoubleAnimation() { From = 0, To = 300 * (BeforeValue - AfterValue), Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); BottomBar.BeginAnimation(MarginProperty, AfterValueAnimation); TopBar.Fill = TopBar.Fill.Clone(); ((SolidColorBrush)TopBar.Fill).BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation() { From = ((SolidColorBrush)TopBar.Fill).Color, To = GetColor(AfterValue), Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); TopBar.BeginAnimation(WidthProperty, new DoubleAnimation() { From = 300 * BeforeValue, To = 300 * AfterValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); AfterLine.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); AfterLine.BeginAnimation(Line.X1Property, new DoubleAnimation() { From = 300 * BeforeValue, To = 300 * AfterValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); AfterLine.BeginAnimation(Line.X2Property, new DoubleAnimation() { From = 300 * BeforeValue, To = 300 * AfterValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); if (BeforeText.Margin.Left - 5 <= 300 * AfterValue + AfterText.ActualWidth / 2) { AfterText.Margin = new Thickness(300 * AfterValue - AfterText.ActualWidth / 2, -10, 0, 0); AfterLine.BeginAnimation(Line.Y1Property, new DoubleAnimation() { From = 15, To = 5, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut } }); } else { AfterText.Margin = new Thickness(300 * AfterValue - AfterText.ActualWidth / 2, 0, 0, 0); } Timer.Stop(); }; Timer.Start(); }; TopBar.BeginAnimation(WidthProperty, BeforeValueAnimation); BeforeLine.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); BeforeLine.BeginAnimation(Line.X1Property, new DoubleAnimation() { From = 0, To = 300 * BeforeValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); BeforeLine.BeginAnimation(Line.X2Property, new DoubleAnimation() { From = 0, To = 300 * BeforeValue, Duration = TimeSpan.FromSeconds(0.5), EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut } }); } }
/* * protected override void OnCellMouseClick(DataGridViewCellMouseEventArgs e) * { * try * { * if (e.RowIndex >= 0 && e.ColumnIndex >= 0) * { * Now.Set(e.RowIndex, e.ColumnIndex); * if (Before.Col >= 0 && Before.Row >= 0) * { * * this.Rows[Before.Row].Cells[Before.Col].Selected = false; * } * Before.Set(Now); * this.CurrentCell = this.Rows[e.RowIndex].Cells[e.ColumnIndex]; * this.CurrentCell.Selected = true; * } * } * catch { } * base.OnCellMouseClick(e); * } */ protected override void OnCellLeave(DataGridViewCellEventArgs e) {//cell을 떠나는 경우는 CurrentCell이 있는 경우이다. //있을 수 있는경우의 수는, 세 가지이다. //마우스로 인하여 이전에서 옮겨지는 경우, Before가 의미가 없어진다. //키보드의 방향키로 인해 위치가 옮겨지는 경우, 역시 Before의 의미가 없다. //Enter로 그 자신의 위치로 다시 옮겨지는 경우에만 Before가 의미가 있다. if (_goBack) { Before.Set(e.RowIndex, e.ColumnIndex); } if (this.EditingControl != null && _isEditActivated) //편집모드였다가 나갈 때는 값이 갱신되었다면 이벤트를 호출시킨다. { String nowText = this.EditingControl.Text.ToString(); // this.CurrentCell.Value.ToString(); this.CurrentCell.Value = nowText; if (_isEditActivated) { CellTextChangedEventArgs args = new CellTextChangedEventArgs(BeforeText, nowText, Before.Col, Before.Row, this.Rows[Before.Row], this.Rows[Before.Row].Cells[Before.Col] as DataGridViewTextBoxCell); if (BeforeText.Equals(nowText) == false) { if (E_TextChanged != null) { E_TextChanged(this, args); } if (args.IsCancel) { this.EditingControl.Text = BeforeText; } } if (E_TextEditFinished != null) { E_TextEditFinished(this, args); } _isEditActivated = false; } } /* * if (this.EditingControl == null && _isEditing) * { * if (ActionOnEnterInEditMode == EnterActions.EditNextColumn) * { * * } * else if (ActionOnEnterInEditMode == EnterActions.EditNextRow) * { * } * else //ActionOnEnterInEditMode == EnterActions.EditOnThePosition * { * * return; * } * } */ /* * if (Now.Row >= 0 && Now.Col >= 0) * { * * if (this.CurrentCell!=null && this.CurrentCell is DataGridViewTextBoxCell) * { * if (_isEditing && this.EditingControl!=null) * { * String nowText = this.EditingControl.Text.ToString();// this.CurrentCell.Value.ToString(); * this.CurrentCell.Value = nowText; * if (_isEditActivated) * { * CellTextChangedEventArgs args = new CellTextChangedEventArgs(BeforeText, nowText, Before.Col, Before.Row, this.Rows[Before.Row], this.Rows[Before.Row].Cells[Before.Col] as DataGridViewTextBoxCell); * if (BeforeText.Equals(nowText) == false) * { * if (E_TextChanged != null) E_TextChanged(this, args); * * } * if (E_TextEditFinished != null) E_TextEditFinished(this, args); * _isEditActivated = false; * } * } * } * if(_posAfterEdit!=_posAfterEdit) Before.Set(Now); * * } * else * { * Before.Set(e.RowIndex, e.ColumnIndex); * } */ base.OnCellLeave(e); }