float GetLimitLength(float orgLen, int idx, LineDir lineDir) { // float len = orgLen; float min, max; if (lineDir == LineDir.HORIZONTAL) { min = rowLineList[idx].minComputedValue; max = rowLineList[idx].maxComputedValue; } else { min = colLineList[idx].minComputedValue; max = colLineList[idx].maxComputedValue; } if (orgLen < min && min != -1) { len = min; } else if (orgLen > max && max != -1) { len = max; } return(len); }
public void SetAutoTableLine(int idx, LineDir lineDir) { TableLine tableLine = new TableLine(lineDir); tableLine.lineComputeMode = LineComputeMode.AUTO; tableLine.maxComputedValue = -1; tableLine.minComputedValue = -1; SetTableLine(idx, tableLine); }
public float GetLayoutSize(TableCellData cellData, LineDir lineDir) { Control ctrl = (Control)cellData.data; if (lineDir == LineDir.VERTICAL) { return(ctrl.Width); } return(ctrl.Height); }
void ModifyTableSize(LineDir lineDir, TableLine line, ref float usedLength, ref float tbLength) { if (matchType == MatchType.MatchParentSize || (matchType == MatchType.MatchParentHeight && lineDir == LineDir.HORIZONTAL) || (matchType == MatchType.MatchParentWidth && lineDir == LineDir.VERTICAL)) { return; } else if (usedLength > tbLength) { usedLength -= line.computeParam; line.computeParam = tbLength - usedLength; usedLength += line.computeParam; line.computedDistance = line.computeParam; } }
void ModifyTableSize(LineDir lineDir, TableLine line, ref float usedLength, ref float tbLength) { if (tableSizeType == TableSizeType.Fill || (tableSizeType == TableSizeType.VerticalFill && lineDir == LineDir.HORIZONTAL) || (tableSizeType == TableSizeType.HorizontalFill && lineDir == LineDir.VERTICAL)) { return; } else if (usedLength > tbLength) { usedLength -= line.computeParam; line.computeParam = tbLength - usedLength; usedLength += line.computeParam; line.computedDistance = line.computeParam; } }
public TableLine GetTableLine(int idx, LineDir lineDir) { List <TableLine> lineList; if (lineDir == LineDir.HORIZONTAL) { lineList = rowLineList; } else { lineList = colLineList; } if (idx >= lineList.Count) { return(null); } return(lineList[idx]); }
public void EnableTableAllLineAutoAdjustRichSize(bool isEnable, LineDir lineDir) { List <TableLine> lineList; int amount; if (lineDir == LineDir.HORIZONTAL) { lineList = rowLineList; amount = rowAmount; } else { lineList = colLineList; amount = colAmount; } for (int i = 0; i < lineList.Count; i++) { lineList[i].enableAutoAdjustRichSize = isEnable; } }
public void EnableTableLineAutoAdjustRichSize(int idx, bool isEnable, LineDir lineDir) { List <TableLine> lineList; int amount; if (lineDir == LineDir.HORIZONTAL) { lineList = rowLineList; amount = rowAmount; } else { lineList = colLineList; amount = colAmount; } if (idx < lineList.Count) { lineList[idx].enableAutoAdjustRichSize = isEnable; } }
// ------------------------------------------------- OnMouseUp private void OnMouseUp (object sender, MouseEventArgs mea) { if (mea .Button == MouseButtons .Right) { if (mover .Caught) { ptMouse_Up = mea .Location; if (mover .CaughtSource is Profile) { for (int i = 0; i < profile .Length; i++) { iDotToDel = profile [i] .InsideDot (mea .Location); if (0 < iDotToDel && iDotToDel < profile [i] .DotNumber - 1) { ContextMenuStrip = contextMenuOnDot; iProfilePressed = i; break; } } } else if (mover .CaughtSource is Scale) { dirTouched = area .InsideAnyVerScale (ptMouse_Up) ? LineDir .Ver : LineDir .Hor; ContextMenuStrip = contextMenuOnScale; } else { ContextMenuStrip = null; } } } mover .Release (); }
private void LayoutLinesArea(LineDir lineDir) { TableLine line; List <TableLine> lineList = null; //表行或列方向上的长度 float tbLength; if (lineDir == LineDir.HORIZONTAL) { lineList = rowLineList; tbLength = tbHeight; } else { lineList = colLineList; tbLength = tbWidth; } float usedLength = 0; float percent = 0; float tbRichHeight; float tbPerRichPercent; float tbPerRichHeight; int percentCount = 0; //自动调整富余尺寸的lines个数 int autoCount = 0; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; switch (line.lineComputeMode) { case LineComputeMode.AUTO: line.computeParam = ComputeLineAreaSize(i, lineDir); usedLength += line.computeParam; line.computedDistance = line.computeParam; if (line.enableAutoAdjustRichSize) { autoCount++; } break; case LineComputeMode.ABSOLUTE: usedLength += line.computeParam; line.computedDistance = line.computeParam; ModifyTableSize(lineDir, line, ref usedLength, ref tbLength); break; case LineComputeMode.PERCENTAGE: percentCount++; float n = percent + line.computeParam; if (n > 1f + 0.001f) { line.computeParam = 1f - percent; percent = 1f; for (int j = i + 1; j < lineList.Count; j++) { percentCount++; line = lineList[j]; line.computeParam = 0; line.computedDistance = 0; } break; } else { percent = n; } break; } } //计算表尺寸 //根据使用的长度即为表的长度 if (matchType != MatchType.FixedSize && matchType != MatchType.MatchParentSize && ((matchType != MatchType.MatchParentHeight && lineDir == LineDir.HORIZONTAL) || (matchType != MatchType.MatchParentWidth && lineDir == LineDir.VERTICAL))) { tbLength = usedLength; if (lineDir == LineDir.HORIZONTAL) { tbHeight = usedLength; } else { tbWidth = usedLength; } } //分配未使用的余量长度 //如果存在有百分比的lines,将把余量(tbRichHeight)平均分配到这些lines上 //否则如果存在自动调整尺寸的lines,将把余量(tbRichHeight)平均分配到这些lines上 if (percentCount > 0) { tbRichHeight = tbLength - usedLength; tbPerRichPercent = (1f - percent) / percentCount; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.PERCENTAGE) { line.computeParam += tbPerRichPercent; line.computedDistance = tbRichHeight * line.computeParam; } } } else if (autoCount > 0) { tbRichHeight = tbLength - usedLength; tbPerRichHeight = tbRichHeight / autoCount; float totalScaleHeight = 0; float totalParamHeight = 0; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.AUTO && line.enableAutoAdjustRichSize == true) { if (line.computeParam == 0) { line.computeParam = tbPerRichHeight; totalScaleHeight += tbPerRichHeight; } else { totalScaleHeight += line.computeParam; totalParamHeight += line.computeParam; } } } float realTotalHeight = totalParamHeight + tbRichHeight; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.AUTO && line.enableAutoAdjustRichSize == true) { if (totalScaleHeight > -0.0001 && totalScaleHeight < 0.0001) { line.computeParam = 0; line.computedDistance = 0; } else { line.computeParam = line.computeParam / totalScaleHeight * realTotalHeight; line.computedDistance = line.computeParam; } } } } }
public void SetLinesComputedValueRange(int idx, float minValue, float maxValue, LineDir lineDir) { if (lineDir == LineDir.HORIZONTAL) { rowLineList[idx].minComputedValue = minValue; rowLineList[idx].maxComputedValue = maxValue; } else { colLineList[idx].minComputedValue = minValue; colLineList[idx].maxComputedValue = maxValue; } }
public void DrawLine(LineDir NomLine, int Length, int offsetX, int offsetY) { int BuffDir = (int)NomLine; LengthL[BuffDir] = Length; if (LineF[BuffDir] == null) { LineF[BuffDir] = new Line(); LineF[BuffDir].X1 = center.X; LineF[BuffDir].Y1 = center.Y; LineF[BuffDir].StrokeThickness = depth; LineF[BuffDir].Stroke = Brushes.Black; LineF[BuffDir].HorizontalAlignment = HorizontalAlignment.Left; LineF[BuffDir].VerticalAlignment = VerticalAlignment.Top; LineF[BuffDir].RenderTransform = Trans; Perent.Children.Add(LineF[BuffDir]); } DrawName(); switch (NomLine) { case LineDir.LineT: LineF[BuffDir].X2 = center.X + offsetX; LineF[BuffDir].Y2 = center.Y - Length + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineL: LineF[BuffDir].X2 = center.X - Length + offsetX; LineF[BuffDir].Y2 = center.Y + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineR: LineF[BuffDir].X2 = center.X + Length + offsetX; LineF[BuffDir].Y2 = center.Y + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineB: LineF[BuffDir].X2 = center.X + offsetX; LineF[BuffDir].Y2 = center.Y + Length + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineTL: LineF[BuffDir].X2 = center.X - Length + offsetX; LineF[BuffDir].Y2 = center.Y - Length + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineTR: LineF[BuffDir].X2 = center.X + Length + offsetX; LineF[BuffDir].Y2 = center.Y - Length + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineBL: LineF[BuffDir].X2 = center.X - Length + offsetX; LineF[BuffDir].Y2 = center.Y + Length + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; case LineDir.LineBR: LineF[BuffDir].X2 = center.X + Length + offsetX; LineF[BuffDir].Y2 = center.Y + Length + offsetY; endLines[BuffDir] = new Point(LineF[BuffDir].X2, LineF[BuffDir].Y2); break; } }
public void EnableTableAllLineAutoAdjustRichSize(bool isEnable, LineDir lineDir) { table.EnableTableAllLineAutoAdjustRichSize(isEnable, lineDir); }
float ComputeLineAreaSize(int idx, LineDir lineDir) { Margin margin; Table ctable; float maxSize = 0; float size = 0; TableCellData cellData; int amount = 0; int rowIdx, colIdx; SizeF fixedSize; if (lineDir == LineDir.HORIZONTAL) { amount = colAmount; } else { amount = rowAmount; } for (int i = 0; i < amount; i++) { if (lineDir == LineDir.HORIZONTAL) { rowIdx = idx; colIdx = i; } else { rowIdx = i; colIdx = idx; } margin = GetCellMargin(rowIdx, colIdx); cellData = GetCellValueInfo(rowIdx, colIdx); if (cellData == null) { if (lineDir == LineDir.HORIZONTAL) { size = margin.top + margin.bottom; } else { size = margin.left + margin.right; } } else { switch (cellData.type) { case TableCellDataType.FixedSize: if (cellData.GetLayoutSize != null) { size = cellData.GetLayoutSize(cellData, lineDir); if (lineDir == LineDir.HORIZONTAL) { size += margin.top + margin.bottom; } else { size += margin.left + margin.right; } } else { fixedSize = cellData.fixedSize; if (lineDir == LineDir.HORIZONTAL) { size = fixedSize.Height + margin.top + margin.bottom; } else { size = fixedSize.Width + margin.left + margin.right; } } break; case TableCellDataType.Table: ctable = (Table)cellData.data; if (ctable == null) { continue; } if (cellData.GetLayoutSize != null) { size = cellData.GetLayoutSize(cellData, lineDir); if (lineDir == LineDir.HORIZONTAL) { size += margin.top + margin.bottom; } else { size += margin.left + margin.right; } } else { if (lineDir == LineDir.HORIZONTAL) { if (ctable.tbHeight == 0) { ctable.ReLayout(); } size = ctable.tbHeight + margin.top + margin.bottom; } else { if (ctable.tbWidth == 0) { ctable.ReLayout(); } size = ctable.tbWidth + margin.left + margin.right; } } break; } } maxSize = Math.Max(maxSize, size); } // return(GetLimitLength(maxSize, idx, lineDir)); }
float ComputeLineAreaSize(int idx, LineDir lineDir) { Margin margin; TableEx ctable; float maxSize = 0; float size = 0; CellValueInfo cellValueInfo; string str; SizeF strSize; int amount = 0; int rowIdx, colIdx; SizeF fixedSize; if (lineDir == LineDir.HORIZONTAL) { amount = colAmount; } else { amount = rowAmount; } for (int i = 0; i < amount; i++) { if (lineDir == LineDir.HORIZONTAL) { rowIdx = idx; colIdx = i; } else { rowIdx = i; colIdx = idx; } margin = GetCellMargin(rowIdx, colIdx); cellValueInfo = GetCellValueInfo(rowIdx, colIdx); if (cellValueInfo == null) { if (lineDir == LineDir.HORIZONTAL) { size = margin.top + margin.bottom; } else { size = margin.left + margin.right; } } else { switch (cellValueInfo.type) { case CellValueType.String: str = (string)cellValueInfo.value; if (g != null) { strSize = g.MeasureString(str, cellValueInfo.font); } else { strSize = TextRenderer.MeasureText(str, cellValueInfo.font); } if (lineDir == LineDir.HORIZONTAL) { size = strSize.Height + margin.top + margin.bottom; } else { size = strSize.Width + margin.left + margin.right; } break; case CellValueType.Image: Image image = (Image)cellValueInfo.value; if (image == null) { size = 0; break; } if (lineDir == LineDir.HORIZONTAL) { float h = image.Height; if (cellValueInfo.permmSizePx.Height > 0) { h = image.Height / cellValueInfo.permmSizePx.Height; } size = h + margin.top + margin.bottom; } else { float w = image.Width; if (cellValueInfo.permmSizePx.Width > 0) { w = image.Width / cellValueInfo.permmSizePx.Width; } size = w + margin.left + margin.right; } break; case CellValueType.FixedSize: fixedSize = cellValueInfo.fixedSize; if (lineDir == LineDir.HORIZONTAL) { size = fixedSize.Height + margin.top + margin.bottom; } else { size = fixedSize.Width + margin.left + margin.right; } break; case CellValueType.Table: ctable = (TableEx)cellValueInfo.value; if (ctable == null) { continue; } if (lineDir == LineDir.HORIZONTAL) { if (ctable.tbHeight == 0) { ctable.ReLayout(g); } size = ctable.tbHeight + margin.top + margin.bottom; } else { if (ctable.tbWidth == 0) { ctable.ReLayout(g); } size = ctable.tbWidth + margin.left + margin.right; } break; } } maxSize = Math.Max(maxSize, size); } // return(GetLimitLength(maxSize, idx, lineDir)); }
private void LayoutLinesArea(LineDir lineDir) { List <TableLine> lineList = null; float tbLength; if (lineDir == LineDir.HORIZONTAL) { lineList = rowLineList; tbLength = tbHeight; } else { lineList = colLineList; tbLength = tbWidth; } float usedLength = 0; float percent = 0; float tbRichHeight; float tbPerRichPercent; float tbPerRichHeight; int percentCount = 0; int autoCount = 0; TableLine line; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; switch (line.lineComputeMode) { case LineComputeMode.AUTO: line.computeParam = ComputeLineAreaSize(i, lineDir); usedLength += line.computeParam; line.computedDistance = line.computeParam; if (line.enableAutoAdjustParam) { autoCount++; } break; case LineComputeMode.ABSOLUTE: usedLength += line.computeParam; line.computedDistance = line.computeParam; ModifyTableSize(lineDir, line, ref usedLength, ref tbLength); break; case LineComputeMode.PERCENTAGE: percentCount++; float n = percent + line.computeParam; if (n > 1f + 0.001f) { line.computeParam = 1f - percent; percent = 1f; for (int j = i + 1; j < lineList.Count; j++) { percentCount++; line = lineList[j]; line.computeParam = 0; line.computedDistance = 0; } break; } else { percent = n; } break; } } if (tbLength == 0 && (tableSizeType == TableSizeType.Fill || (tableSizeType == TableSizeType.VerticalFill && lineDir == LineDir.HORIZONTAL) || (tableSizeType == TableSizeType.HorizontalFill && lineDir == LineDir.VERTICAL))) { tbLength = usedLength; if (lineDir == LineDir.HORIZONTAL) { tbHeight = usedLength; } else { tbWidth = usedLength; } } if (percentCount > 0) { tbRichHeight = tbLength - usedLength; tbPerRichPercent = (1f - percent) / percentCount; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.PERCENTAGE) { line.computeParam += tbPerRichPercent; line.computedDistance = tbRichHeight * line.computeParam; } } } else if (autoCount > 0) { tbRichHeight = tbLength - usedLength; tbPerRichHeight = tbRichHeight / autoCount; float totalScaleHeight = 0; float totalParamHeight = 0; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.AUTO && line.enableAutoAdjustParam == true) { if (line.computeParam == 0) { line.computeParam = Math.Abs(tbPerRichHeight); totalScaleHeight += Math.Abs(tbPerRichHeight); } else { totalScaleHeight += line.computeParam; totalParamHeight += line.computeParam; } } } float realTotalHeight = totalParamHeight + tbRichHeight; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.AUTO && line.computeParam != 0 && line.enableAutoAdjustParam == true) { line.computeParam = line.computeParam / totalScaleHeight * realTotalHeight; line.computedDistance = line.computeParam; } } } }
public void ComputeLinesArea(LineDir lineDir) { List <TableLine> lineList = null; float tbLength; if (lineDir == LineDir.HORIZONTAL) { lineList = rowLineList; tbLength = tbHeight; } else { lineList = colLineList; tbLength = tbWidth; } if (lineList.Count == 1) { return; } float usedLength = 0; float percent = 0; float tbRichHeight; float tbPerRichPercent; int percentCount = 0; TableLine line; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.ABSOLUTE) { usedLength += line.computeParam; if (usedLength > tbLength) { usedLength -= line.computeParam; line.computeParam = tbLength - usedLength; } line.computedDistance = line.computeParam; } if (line.lineComputeMode == LineComputeMode.PERCENTAGE) { percentCount++; float n = percent + line.computeParam; if (n > 1f + 0.001f) { line.computeParam = 1f - percent; percent = 1f; for (int j = i + 1; j < lineList.Count; j++) { percentCount++; line = lineList[j]; line.computeParam = 0; line.computedDistance = 0; } break; } else { percent = n; } } } tbRichHeight = tbLength - usedLength; tbPerRichPercent = (1f - percent) / percentCount; for (int i = 0; i < lineList.Count; i++) { line = lineList[i]; if (line.lineComputeMode == LineComputeMode.PERCENTAGE) { line.computeParam += tbPerRichPercent; line.computedDistance = tbRichHeight * line.computeParam; } } }
public TableLine(LineDir lineDir) { this.lineDir = lineDir; }
public void EnableTableLineAutoAdjustRichSize(int idx, bool isEnable, LineDir lineDir) { table.EnableTableLineAutoAdjustRichSize(idx, isEnable, lineDir); }