private void horizontalCenterButton_Click(object sender, EventArgs e) { if (!CheckAllSelectedElementsEnabled(true)) { return; } var listSelectedElements = ElementManager.Instance.SelectedElements; if (listSelectedElements == null || listSelectedElements.Count == 0) { return; } var zLayout = LayoutManager.Instance.ActiveLayout; var dictionaryOriginalPositions = ElementManager.Instance.GetUndoRedoPoints(); foreach (var zElement in ElementManager.Instance.SelectedElements) { zElement.x = (zLayout.width - zElement.width) / 2; } ElementManager.ConfigureUserAction(dictionaryOriginalPositions, ElementManager.Instance.GetUndoRedoPoints()); ElementManager.Instance.FireElementBoundsUpdateEvent(); }
private void customAlignElementButton_Click(object sender, EventArgs e) { if (!CheckAllSelectedElementsEnabled(true)) { return; } var listSelectedElements = ElementManager.Instance.SelectedElements; if (listSelectedElements == null || listSelectedElements.Count == 0) { return; } const string VERTICAL_SPACING = "vertical_spacing"; const string APPLY_ELEMENT_WIDTHS = "apply_element_widths"; const string HORIZONTAL_SPACING = "horizontal_spacing"; const string APPLY_ELEMENT_HEIGHTS = "apply_element_heights"; var zQuery = new QueryPanelDialog("Custom Align Elements", 450, 150, false); zQuery.SetIcon(CardMakerInstance.ApplicationIcon); zQuery.AddNumericBox("Vertical Pixel Spacing", 0, int.MinValue, int.MaxValue, VERTICAL_SPACING); zQuery.AddCheckBox("Include Element Heights", false, APPLY_ELEMENT_HEIGHTS); zQuery.AddNumericBox("Horizontal Pixel Spacing", 0, int.MinValue, int.MaxValue, HORIZONTAL_SPACING); zQuery.AddCheckBox("Include Element Widths", false, APPLY_ELEMENT_WIDTHS); if (DialogResult.OK != zQuery.ShowDialog(CardMakerInstance.ApplicationForm)) { return; } var nVerticalSpace = (int)zQuery.GetDecimal(VERTICAL_SPACING); var nHorizontalSpace = (int)zQuery.GetDecimal(HORIZONTAL_SPACING); var bApplyElementWidths = zQuery.GetBool(APPLY_ELEMENT_WIDTHS); var bApplyElementHeights = zQuery.GetBool(APPLY_ELEMENT_HEIGHTS); var dictionaryOriginalPositions = ElementManager.Instance.GetUndoRedoPoints(); // apply the translation var nX = listSelectedElements[0].x; var nY = listSelectedElements[0].y; foreach (var zElement in listSelectedElements) { zElement.x = nX; zElement.y = nY; nX += bApplyElementWidths ? zElement.width : 0; nY += bApplyElementHeights ? zElement.height : 0; nX += nHorizontalSpace; nY += nVerticalSpace; } ElementManager.ConfigureUserAction(dictionaryOriginalPositions, ElementManager.Instance.GetUndoRedoPoints()); ElementManager.Instance.FireElementBoundsUpdateEvent(); }
private void cardCanvas_MouseUp(object sender, MouseEventArgs e) { CardMakerInstance.CanvasUserAction = false; if (null != m_listSelectedElements && m_bElementSelected) { ElementManager.ConfigureUserAction(m_dictionarySelectedUndo, ElementManager.Instance.GetUndoRedoPoints()); } m_dictionarySelectedUndo = null; m_listSelectedElements = null; m_zSelectedElement = null; m_bElementSelected = false; TranslationLockState = TranslationLock.Unset; }
private void customHoritonalAlignButton_Click(object sender, EventArgs e) { if (!CheckAllSelectedElementsEnabled(true)) { return; } var listSelectedElements = ElementManager.Instance.SelectedElements; if (listSelectedElements == null || listSelectedElements.Count == 0) { return; } const string HORIZONTAL_SPACING = "horizontal_spacing"; const string APPLY_ELEMENT_WIDTHS = "apply_element_widths"; const string ELEMENT_CENTERING = "element_centering"; var zQuery = new QueryPanelDialog("Custom Horizontal Align Elements", 450, 150, false); zQuery.SetIcon(CardMakerInstance.ApplicationIcon); zQuery.AddNumericBox("Horizontal Pixel Spacing", 0, int.MinValue, int.MaxValue, HORIZONTAL_SPACING); zQuery.AddCheckBox("Include Element Widths", false, APPLY_ELEMENT_WIDTHS); zQuery.AddPullDownBox("Vertical Centering", Enum.GetNames(typeof(ElementCenterAlign)), 0, ELEMENT_CENTERING); if (DialogResult.OK != zQuery.ShowDialog(CardMakerInstance.ApplicationForm)) { return; } var nHorizontalSpace = (int)zQuery.GetDecimal(HORIZONTAL_SPACING); var bApplyElementWidths = zQuery.GetBool(APPLY_ELEMENT_WIDTHS); var eCenterAlignment = (ElementCenterAlign)zQuery.GetIndex(ELEMENT_CENTERING); // determine the centering var nCenterY = 0; switch (eCenterAlignment) { case ElementCenterAlign.FirstElement: nCenterY = listSelectedElements[0].y + (listSelectedElements[0].height / 2); break; case ElementCenterAlign.Layout: nCenterY = LayoutManager.Instance.ActiveLayout.height / 2; break; } var dictionaryOriginalPositions = ElementManager.Instance.GetUndoRedoPoints(); // apply the translation var nX = listSelectedElements[0].x; for (var nIdx = 0; nIdx < listSelectedElements.Count; nIdx++) { var zElement = listSelectedElements[nIdx]; zElement.x = nX; nX += bApplyElementWidths ? zElement.width : 0; nX += nHorizontalSpace; switch (eCenterAlignment) { case ElementCenterAlign.FirstElement: if (0 < nIdx) { zElement.y = nCenterY - (zElement.width / 2); } break; case ElementCenterAlign.Layout: zElement.y = nCenterY - (zElement.width / 2); break; } } ElementManager.ConfigureUserAction(dictionaryOriginalPositions, ElementManager.Instance.GetUndoRedoPoints()); ElementManager.Instance.FireElementBoundsUpdateEvent(); }