private void btnColor_Click(object sender, EventArgs e) { var listSelectedElements = ElementManager.Instance.SelectedElements; if (null == listSelectedElements) { MessageBox.Show(this, "Please select at least one enabled Element."); return; } var zRGB = new RGBColorSelectDialog(); var btnClicked = (Button)sender; var zPanel = (Panel)btnClicked.Tag; zRGB.UpdateColorBox(zPanel.BackColor); if (DialogResult.OK != zRGB.ShowDialog()) { return; } var colorRedo = zRGB.Color; var listActions = UserAction.CreateActionList(); foreach (var zElement in listSelectedElements) { var zElementToChange = zElement; var colorUndo = Color.White; if (btnClicked == btnElementBorderColor) { colorUndo = zElement.GetElementBorderColor(); } else if (btnClicked == btnElementOutlineColor) { colorUndo = zElement.GetElementOutlineColor(); } else if (btnClicked == btnElementFontColor || btnClicked == btnElementShapeColor) { colorUndo = zElement.GetElementColor(); } listActions.Add(bRedo => { SetColorValue(btnClicked, bRedo ? colorRedo : colorUndo, zElementToChange); UpdatePanelColors(zElementToChange); }); } Action <bool> actionChangeColor = bRedo => { listActions.ForEach(action => action(bRedo)); LayoutManager.Instance.FireLayoutUpdatedEvent(true); }; UserAction.PushAction(actionChangeColor); // perform the action as a redo now actionChangeColor(true); }
private void HandleElementValueChange(object sender, EventArgs e) { if (null == ElementManager.Instance.GetSelectedElement() || !m_bFireElementChangeEvents || CardMakerInstance.ProcessingUserAction) { return; } var listSelectedElements = ElementManager.Instance.SelectedElements; if (null != sender && null != listSelectedElements) { var zControl = (Control)sender; var listActions = UserAction.CreateActionList(); foreach (var zElement in listSelectedElements) { object zUndoValue = null; object zRedoValue = null; var zElementToChange = zElement; PopulateUndoRedoValues(zControl, zElementToChange, ref zRedoValue, ref zUndoValue); listActions.Add(bRedo => AssignValueByControl(zControl, zElementToChange, bRedo ? zRedoValue : zUndoValue, false)); } Action <bool> actionElementChange = bRedo => { CardMakerInstance.ProcessingUserAction = true; listActions.ForEach(action => action(bRedo)); CardMakerInstance.ProcessingUserAction = false; LayoutManager.Instance.FireLayoutUpdatedEvent(true); }; UserAction.PushAction(actionElementChange); // perform the action as a redo now actionElementChange(true); } }
private void btnNullBackgroundColor_Click(object sender, EventArgs e) { // TODO: this and the above method are 80% the same... var listSelectedElements = ElementManager.Instance.SelectedElements; if (null == listSelectedElements) { MessageBox.Show(this, "Please select at least one enabled Element."); return; } var btnClicked = (Button)sender; var colorRedo = CardMakerConstants.NoColor; var listActions = UserAction.CreateActionList(); foreach (var zElement in listSelectedElements) { var zElementToChange = zElement; var colorUndo = zElementToChange.GetElementBackgroundColor(); listActions.Add(bRedo => { if (null != LayoutManager.Instance.ActiveDeck) { LayoutManager.Instance.ActiveDeck.ResetMarkupCache(zElementToChange.name); } SetColorValue(btnClicked, bRedo ? colorRedo : colorUndo, zElementToChange); UpdatePanelColors(zElementToChange); }); } Action <bool> actionChangeColor = bRedo => { listActions.ForEach(action => action(bRedo)); LayoutManager.Instance.FireLayoutUpdatedEvent(true); }; UserAction.PushAction(actionChangeColor); // perform the action as a redo now actionChangeColor(true); }
private void HandleFontSettingChange(object sender, EventArgs e) { if (!m_bFireElementChangeEvents || !m_bFireFontChangeEvents || CardMakerInstance.ProcessingUserAction) { return; } var listElements = ElementManager.Instance.SelectedElements; if (null != listElements) { var listActions = UserAction.CreateActionList(); var zControl = (Control)sender; foreach (var zElement in listElements) { var zElementToChange = zElement; if (!CardMakerInstance.ProcessingUserAction && null != sender) { object zRedoValue = null; object zUndoValue = null; // The current value on the element can be used for an undo if (PopulateUndoRedoValues(zControl, zElementToChange, ref zRedoValue, ref zUndoValue)) { listActions.Add(bRedo => { AssignValueByControl(zControl, zElementToChange, bRedo ? zRedoValue : zUndoValue, false); if (null != LayoutManager.Instance.ActiveDeck) { LayoutManager.Instance.ActiveDeck.ResetMarkupCache(zElementToChange.name); } }); } else { FontStyle eFontStyle = (checkBoxBold.Checked ? FontStyle.Bold : FontStyle.Regular) | (checkBoxItalic.Checked ? FontStyle.Italic : FontStyle.Regular) | (checkBoxStrikeout.Checked ? FontStyle.Strikeout : FontStyle.Regular) | (checkBoxUnderline.Checked ? FontStyle.Underline : FontStyle.Regular); var zFont = new Font(m_listFontFamilies[comboFontName.SelectedIndex], (int)numericFontSize.Value, eFontStyle); var fontRedo = zFont; var fontUndo = zElementToChange.GetElementFont(); fontUndo = fontUndo ?? DrawItem.DefaultFont; listActions.Add(bRedo => { var fontValue = bRedo ? fontRedo : fontUndo; zElementToChange.SetElementFont(fontValue); // only affect the controls if the current selected element matches that of the element to change if (zElementToChange == ElementManager.Instance.GetSelectedElement()) { comboFontName.Text = fontValue.Name; SetupElementFont(fontValue); } if (null != LayoutManager.Instance.ActiveDeck) { LayoutManager.Instance.ActiveDeck.ResetMarkupCache(zElementToChange.name); } }); } } } Action <bool> actionChangeFont = bRedo => { CardMakerInstance.ProcessingUserAction = true; listActions.ForEach(action => action(bRedo)); CardMakerInstance.ProcessingUserAction = false; if (0 < numericLineSpace.Value) { checkFontAutoScale.Checked = false; } LayoutManager.Instance.FireLayoutUpdatedEvent(true); }; UserAction.PushAction(actionChangeFont); // perform the action as a redo now actionChangeFont(true); } }