void RedrawNet(DressMatrix in_netType) { PAN_Net.Controls.Clear(); T_Amount.Text = string.Empty; if (in_netType.CellsX.Count == 1 && in_netType.CellsY.Count == 1) { T_Amount.ReadOnly = false; Width = _defaultWidth; Height = _defaultHeight; } else { T_Amount.ReadOnly = true; NetPanel net = new NetPanel(in_netType) { Parent = PAN_Net }; Width = Math.Max(_defaultWidth, net.TotalWidth); Height = Math.Max(_defaultHeight, net.TotalHeight + PAN_SkuWONet.Height); net.Size = new System.Drawing.Size(Math.Min(net.TotalHeight, PAN_Net.Width), PAN_Net.Height); if (_defaultWidth > net.TotalWidth) { net.Location = new System.Drawing.Point(_defaultWidth / 2 - net.TotalWidth / 2, 0); } net.ValueChanged += (s, e) => OnNetValueChange(); } }
void B_Delete_Click(object sender, EventArgs e) { if (MessageBox.Show(this, Resources.ASK_DELETE_OBJECT, Resources.WARNING_EXCLAMATION, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) { return; } DressMatrix o = GetObject(); if (o != null) { try { DressMatrix.Delete(o); } catch (SQLiteException ex) { //if (ex.ErrorCode == SQLiteErrorCode.Constraint) if (ex.ResultCode == SQLiteErrorCode.Constraint) { MessageBox.Show(this, Resources.UNABLE_DELETE_OBJECT_HAS_CHILDREN, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(this, string.Format(Resources.UNABLE_DELETE_OBJECT_TECHNICAL_CODE, ex.ErrorCode), Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } } Clear(); T_ReadId.Text = string.Empty; }
public NetPanel(DressMatrix in_netType) : this() { _netType = in_netType; Graphics g = CreateGraphics(); // 1. Measure sizes. NetUtil.MeasureNet(_netType, g, c_fieldWidth, out int maxWidthCapX, out int maxWidthCapY, out _widthCapX, out _widthCapY); // 2. Render labels. NetUtil.RenderLabels(_netType, this, maxWidthCapX, maxWidthCapY, _widthCapX, _widthCapY, c_labelWidthThreshold, c_height, c_gap, out _totalWidth, out _totalHeight); // 3. Render text labels of size chart. int xPos = maxWidthCapY + c_labelWidthThreshold * 2; for (int i = 0; i < _netType.CellsX.Count; i++) { int yPos = c_height + c_gap; for (int j = 0; j < _netType.CellsY.Count; j++) { TextBox tbox = new TextBox() { Parent = this, Location = new Point(xPos, yPos), Size = new Size(c_fieldWidth, c_height), Tag = new NetUtil.Value() { X = i, Y = j, NameX = _netType.CellsX[i], NameY = _netType.CellsY[j] } }; tbox.TextChanged += (s, e) => CellTextChanged((TextBox)s); tbox.GotFocus += (s, e) => ActiveCellChanged((TextBox)s); yPos += (c_gap + c_height); } xPos += (c_gap + maxWidthCapX); } foreach (Control ctrl in Controls) { if (ctrl is TextBox) { _textBoxBackColor = ctrl.BackColor; break; } } g.Dispose(); }
void B_Read_Click(object sender, EventArgs e) { DressMatrix o = GetObject(); if (o == null) { Clear(); return; } T_Name.Text = o.Name; T_CellsX.Text = o.CellsXAsString; T_CellsY.Text = o.CellsYAsString; }
public static void RenderLabels(DressMatrix in_netType, Control in_container, int in_maxWidthCapX, int in_maxWidthCapY, int[] in_widthCapX, int[] in_widthCapY, int in_labelWidthThreshold, int in_fieldHeight, int in_fieldGap, out int out_totalWidth, out int out_totalHeight, out Label[] out_labelsX, out Label[] out_labelsY) { int labelHeight; using (Graphics g = in_container.CreateGraphics()) labelHeight = (int)g.MeasureString("A", Label.DefaultFont).Height; out_labelsX = new Label[in_netType.CellsX.Count]; out_labelsY = new Label[in_netType.CellsY.Count]; int xPos = in_maxWidthCapY + in_labelWidthThreshold; for (int i = 0; i < in_netType.CellsX.Count; i++) { out_labelsX[i] = new Label() { Text = in_netType.CellsX[i], Parent = in_container, Location = new Point(xPos + in_maxWidthCapX / 2 - in_widthCapX[i] / 2, in_fieldGap), TextAlign = ContentAlignment.TopCenter, AutoSize = true, Tag = new LabelValueX() { X = i, NameX = in_netType.CellsX[i] } }; xPos += (in_fieldGap + in_maxWidthCapX); } out_totalWidth = xPos + in_fieldGap; // + in_maxWidthCapX + in_labelWidthThreshold; int yPos = in_fieldHeight + in_fieldGap + in_fieldHeight / 2 - labelHeight / 2; for (int i = 0; i < in_netType.CellsY.Count; i++) { out_labelsY[i] = new Label() { Text = in_netType.CellsY[i], Parent = in_container, Location = new Point(in_fieldGap + in_maxWidthCapY / 2 - in_widthCapY[i] / 2, yPos), TextAlign = ContentAlignment.TopCenter, AutoSize = true, Tag = new LabelValueY() { Y = i, NameY = in_netType.CellsY[i] } }; yPos += (in_fieldGap + in_fieldHeight); } out_totalHeight = yPos + in_fieldGap * 2 + in_fieldHeight; }
DressMatrix GetObject() { DressMatrix result = null; if (!int.TryParse(T_ReadId.Text, out int id)) { MessageBox.Show(Resources.INVALID_ID, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(result); } result = DressMatrix.Restore(id); if (result == null) { MessageBox.Show(Resources.OBJECT_NOT_FOUND, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(result); } return(result); }
void B_Save_Click(object sender, EventArgs e) { DressMatrix o; if (T_ReadId.Text == string.Empty) { o = new DressMatrix(); } else { o = GetObject(); } o.Name = T_Name.Text; o.CellsXAsString = T_CellsX.Text; o.CellsYAsString = T_CellsY.Text; o.Flush(); T_ReadId.Text = o.Id.ToString(); }
bool CreateNewArticle() { bool success = TryParsePrices(out int priceOfPurchase, out int priceOfSell); if (!success) { return(false); } _article = new Article() { Name = T_Name.Text.Trim(), Matrix = DressMatrix.Restore(((LiteBizItem)CB_NetType.SelectedItem).Value), PriceOfPurchase = priceOfPurchase, PriceOfSell = priceOfSell }; _article.Flush(); _skuInStock = SkuInStock.CreateNew(_article, Registry.CurrentPointOfSale); return(true); }
public PanelAddSku() { InitializeComponent(); PAN_SkuParams.Enabled = false; _defaultWidth = Width; _defaultHeight = Height; LB_Sku.Text = string.Format(Resources.SKU_IN_STOCK, Registry.CurrentPointOfSale.Name); LU_Search.Text = string.Format(Resources.CLICK_TO_VIEW_SELL_MOVE_SKU, Registry.CurrentPointOfSale.Name); Width = Math.Max(Math.Max(LB_Sku.Width, LU_Search.Width), Width); CB_NetType.Items.AddRange(LiteBizItem.FromTable(DressMatrix.ReadAll()).ToArray <LiteBizItem>()); if (CB_NetType.Items.Count != 0) { CB_NetType.SelectedIndex = 0; } _modified = false; }
public static void MeasureNet(DressMatrix in_netType, Graphics in_graphics, int in_fieldWidth, out int out_maxWidthCapX, out int out_maxWidthCapY, out int[] out_widthCapX, out int[] out_widthCapY) { // 1. Measure the width of the leftmost column with captions by Y. out_maxWidthCapY = 0; out_widthCapY = new int[in_netType.CellsY.Count]; for (int i = 0; i < in_netType.CellsY.Count; i++) { int width = (int)in_graphics.MeasureString(in_netType.CellsY[i], Label.DefaultFont).Width; out_widthCapY[i] = width; out_maxWidthCapY = Math.Max(out_maxWidthCapY, width); } // 2. Measure the width of every other column, taking the widthest caption by X, or // the standard TextBox width. out_maxWidthCapX = 0; out_widthCapX = new int[in_netType.CellsX.Count]; for (int i = 0; i < in_netType.CellsX.Count; i++) { int width = (int)in_graphics.MeasureString(in_netType.CellsX[i], Label.DefaultFont).Width; out_widthCapX[i] = width; out_maxWidthCapX = Math.Max(out_maxWidthCapX, width); } out_maxWidthCapX = Math.Max(out_maxWidthCapX, in_fieldWidth); }
void RedrawNet() { DressMatrix mtx = DressMatrix.Restore(((LiteBizItem)CB_NetType.SelectedItem).Value); RedrawNet(mtx); }
public static void RenderLabels(DressMatrix in_netType, Control in_container, int in_maxWidthCapX, int in_maxWidthCapY, int[] in_widthCapX, int[] in_widthCapY, int in_labelWidthThreshold, int in_fieldHeight, int in_fieldGap, out int out_totalWidth, out int out_totalHeight) => RenderLabels(in_netType, in_container, in_maxWidthCapX, in_maxWidthCapY, in_widthCapX, in_widthCapY, in_labelWidthThreshold, in_fieldHeight, in_fieldGap, out out_totalWidth, out out_totalHeight, out _, out _);