/// enumと値を指定してProfileを変更 private void SetClippingValue(Clipping name, int value) { switch (name) { case Clipping.X: App.Profile.Current.ClippingXWithoutFit = value; break; case Clipping.Y: App.Profile.Current.ClippingYWithoutFit = value; break; case Clipping.Width: App.Profile.Current.ClippingWidthWithoutFit = value; break; case Clipping.Height: App.Profile.Current.ClippingHeightWithoutFit = value; break; default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
//------------------------------------------------------------------- /// enum->文字列 private string GetClippingValueString(Clipping name) { switch (name) { case Clipping.X: return(StringConverter.GetClippingXString(App.Profile.Current)); case Clipping.Y: return(StringConverter.GetClippingYString(App.Profile.Current)); case Clipping.Width: return(StringConverter.GetClippingWidthString(App.Profile.Current)); case Clipping.Height: return(StringConverter.GetClippingHeightString(App.Profile.Current)); default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
//=================================================================== // IBindingProfileの実装 //=================================================================== /// enumを指定して、イベントハンドラの実行なしにTextBox.Textを置き換える private void OverwriteText(Clipping name) { this.CanChangeProfile = false; var textBox = this.GetTextBox(name); textBox.Text = this.GetClippingValueString(name); if (textBox.IsKeyboardFocused) { textBox.Select(textBox.Text.Length, 0); } this.ResetError(name); this.CanChangeProfile = true; }
/// enum->ToolTip private ToolTip GetToolTip(Clipping name) { switch (name) { case Clipping.X: return(this.ClippingXToolTip); case Clipping.Y: return(this.ClippingYToolTip); case Clipping.Width: return(this.ClippingWidthToolTip); case Clipping.Height: return(this.ClippingHeightToolTip); default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
/// enum->TextBox private TextBox GetTextBox(Clipping name) { switch (name) { case Clipping.X: return(this.ClippingX); case Clipping.Y: return(this.ClippingY); case Clipping.Width: return(this.ClippingWidth); case Clipping.Height: return(this.ClippingHeight); default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
//=================================================================== // Clippingをキーとしたメソッド群 //=================================================================== /// TextBoxとToolTipの位置的な関連付け private void SetPlacementTarget(Clipping name) { this.GetToolTip(name).PlacementTarget = this.GetTextBox(name); }
/// 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); //--------------------------------------------------------------- }
/// enumを指定してTextBoxの警告状態設定 private void SetWarning(Clipping name, string message = null) { TextBoxError.SetWarning(this.GetTextBox(name), this.GetToolTip(name), message); }
/// enum->TextBox private TextBox GetTextBox(Clipping name) { switch (name) { case Clipping.X: return this.ClippingX; case Clipping.Y: return this.ClippingY; case Clipping.Width: return this.ClippingWidth; case Clipping.Height: return this.ClippingHeight; default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
/// 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を指定してTextBoxの警告状態設定 private void SetWarning(Clipping name, string message = null) { TextBoxError.SetWarning(this.GetTextBox(name), this.GetToolTip(name), message); }
//=================================================================== // Clippingをキーとしたメソッド群 //=================================================================== /// TextBoxとToolTipの位置的な関連付け private void SetPlacementTarget(Clipping name) { this.GetToolTip(name).PlacementTarget = this.GetTextBox(name); }
/// enumと値を指定してProfileを変更 private void SetClippingValue(Clipping name, int value) { switch (name) { case Clipping.X: App.Profile.Current.ClippingXWithoutFit = value; break; case Clipping.Y: App.Profile.Current.ClippingYWithoutFit = value; break; case Clipping.Width: App.Profile.Current.ClippingWidthWithoutFit = value; break; case Clipping.Height: App.Profile.Current.ClippingHeightWithoutFit = value; break; default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
//=================================================================== // 入力エラー処理 //=================================================================== /// enumを指定してTextBoxのエラー状態解除 private void ResetError(Clipping name) { TextBoxError.ResetError(this.GetTextBox(name), this.GetToolTip(name)); }
//=================================================================== // IBindingProfileの実装 //=================================================================== /// enumを指定して、イベントハンドラの実行なしにTextBox.Textを置き換える private void OverwriteText(Clipping name) { this.CanChangeProfile = false; var textBox = this.GetTextBox(name); textBox.Text = this.GetClippingValueString(name); if (textBox.IsKeyboardFocused) { textBox.Select(textBox.Text.Length, 0); } this.ResetError(name); this.CanChangeProfile = true; }
/// enum->ToolTip private ToolTip GetToolTip(Clipping name) { switch (name) { case Clipping.X: return this.ClippingXToolTip; case Clipping.Y: return this.ClippingYToolTip; case Clipping.Width: return this.ClippingWidthToolTip; case Clipping.Height: return this.ClippingHeightToolTip; default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
//=================================================================== // 入力エラー処理 //=================================================================== /// enumを指定してTextBoxのエラー状態解除 private void ResetError(Clipping name) { TextBoxError.ResetError(this.GetTextBox(name), this.GetToolTip(name)); }
//------------------------------------------------------------------- /// 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); //--------------------------------------------------------------- }
//------------------------------------------------------------------- /// enum->文字列 private string GetClippingValueString(Clipping name) { switch (name) { case Clipping.X: return StringConverter.GetClippingXString(App.Profile.Current); case Clipping.Y: return StringConverter.GetClippingYString(App.Profile.Current); case Clipping.Width: return StringConverter.GetClippingWidthString(App.Profile.Current); case Clipping.Height: return StringConverter.GetClippingHeightString(App.Profile.Current); default: Debug.Fail("switch"); throw new System.ArgumentException(); } }