/// ClippingHeight: LostFocus private void ClippingHeight_LostFocus(object sender, RoutedEventArgs e) { var target = Clipping.Height; var dependent = ClippingInputCorrector.GetDependent(target); this.OverwriteText(target); this.ResetError(dependent); }
/// enumを指定してレイアウト要素の内容を訂正後に変更する private void Correct(Clipping target) { var dependent = ClippingInputCorrector.GetDependent(target); // Parse int value; if (!int.TryParse(this.GetTextBox(target).Text, out value)) { this.OverwriteText(target); this.ResetError(dependent); return; } // Window Check if (!App.Profile.Current.IsWindowValid) { this.OverwriteText(target); this.ResetError(dependent); return; } // Correct ClientRect changed; var result = ClippingInputCorrector.TryChange( App.Profile.Current, target, value, out changed); // 訂正の必要がない=TextChangedで設定済み if (result == ClippingInputCorrector.TryResult.NothingChanged) { return; } // Update Profile App.Profile.Open(); App.Profile.Current.ClippingXWithoutFit = changed.X; App.Profile.Current.ClippingWidthWithoutFit = changed.Width; App.Profile.Current.ClippingYWithoutFit = changed.Y; App.Profile.Current.ClippingHeightWithoutFit = changed.Height; App.Profile.Close(); //--------------------------------------------------------------- // Notify self if (result.HasFlag(ClippingInputCorrector.TryResult.TargetChanged)) { this.OverwriteText(target); } else { this.ResetError(target); } if (result.HasFlag(ClippingInputCorrector.TryResult.DependentChanged)) { this.OverwriteText(dependent); } else { this.ResetError(dependent); } // Notify other controls Commands.CurrentLayoutElementVisualChanged.Execute(null, this); //--------------------------------------------------------------- }
//------------------------------------------------------------------- /// enumを指定してレイアウト要素の内容を変更する private void Change(Clipping target) { var dependent = ClippingInputCorrector.GetDependent(target); // Parse int value; if (!int.TryParse(this.GetTextBox(target).Text, out value)) { this.SetError(target, "must be integer"); this.ResetError(dependent); return; } // Window Check if (!App.Profile.Current.IsWindowValid) { this.SetError(target, "Target window is invalid"); this.ResetError(dependent); return; } // Correct ClientRect changed; var result = ClippingInputCorrector.TryChange( App.Profile.Current, target, value, out changed); // Error表示 switch (result) { case ClippingInputCorrector.TryResult.NothingChanged: { this.ResetError(target); this.ResetError(dependent); break; } case ClippingInputCorrector.TryResult.TargetChanged: { this.SetWarning(target, "Return/Enter: Correct Value"); this.ResetError(dependent); return; } case ClippingInputCorrector.TryResult.DependentChanged: case ClippingInputCorrector.TryResult.BothChanged: { this.SetWarning(target, "Return/Enter: Correct Value"); this.SetWarning(dependent); return; } default: Debug.Fail("switch"); throw new System.ArgumentException(); } // 成功: そのまま書き換え(Textは変更しない) App.Profile.Open(); this.SetClippingValue(target, value); App.Profile.Close(); //--------------------------------------------------------------- // Notify self // Notify other controls Commands.CurrentLayoutElementVisualChanged.Execute(null, this); //--------------------------------------------------------------- }