private void CreateSize(bool isMeter) { if (checkActive()) { MessageBox.Show(err, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { app.ActiveDocument.Unit = cdrUnit.cdrCentimeter; ShapeRange orSh = app.ActiveSelectionRange; Size s = new Size(orSh.SizeWidth, orSh.SizeHeight); int point = 0; int space = (int)(Math.Sqrt(s.x) / 2); if (s.x < 200) { point = (int)s.x * 2; } else { point = (int)s.x; } string width, height; if (isMeter) { width = Math.Round(s.x / 100, 2).ToString() + "m"; height = Math.Round(s.y / 100, 2).ToString() + "m"; } else { width = Math.Round(s.x, 1).ToString() + "cm"; height = Math.Round(s.y, 1).ToString() + "cm"; } Shape sizeHeight = app.ActiveLayer.CreateArtisticText(0, 0, width); sizeHeight.Text.FontProperties.Size = point; Shape sizeWidth = app.ActiveLayer.CreateArtisticText(0, 0, height); sizeWidth.Text.FontProperties.Size = point; orSh.Add(sizeHeight); orSh.AlignAndDistribute(cdrAlignDistributeH.cdrAlignDistributeHAlignCenter, cdrAlignDistributeV.cdrAlignDistributeVAlignTop, cdrAlignShapesTo.cdrAlignShapesToLastSelected, cdrDistributeArea.cdrDistributeToSelection, false); sizeHeight.Move(0, space + sizeHeight.SizeHeight); orSh.Remove(2); orSh.Add(sizeWidth); orSh.AlignAndDistribute(cdrAlignDistributeH.cdrAlignDistributeHAlignRight, cdrAlignDistributeV.cdrAlignDistributeVAlignCenter, cdrAlignShapesTo.cdrAlignShapesToLastSelected, cdrDistributeArea.cdrDistributeToSelection, false); sizeWidth.Move(space + sizeWidth.SizeWidth, 0); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.Source, "Lỗi"); } }