public override void AddChild(GUIElement child) { GridLayoutInfo info = new GridLayoutInfo(); for (int i = 0; i < Children.Count; i++) { var colInfo = ColSpanRows.Find((x) => x.StartRow == info.Row); if (colInfo != null) { info.Row += colInfo.Lenght; } else { info.Col++; if (info.Col >= Columns) { info.Col = 0; info.Row++; } } if (info.Row > Rows) { return; } } child.LayoutTag = info; base.AddChild(child); if (Inited) { Resize((int)LastParentSize.X, (int)LastParentSize.Y); } }
public static void Layout(IContainer container, IUFControl ctrl, uint x, uint y, int xspan, int yspan, Unit width, Unit height, bool isAutoSize) { IGridLayout gl = container.Layout as IGridLayout; if (gl == null) { return; } GridLayoutInfo glInfo = new GridLayoutInfo((uint)x, (uint)y, (uint)xspan, (uint)yspan, width, height); glInfo.AutoSize = isAutoSize; gl.Controls.Add((Control)ctrl, glInfo); }
// PersistData // Implements the LayoutModel.PersistData abstract method protected override void PersistData() { GridLayoutInfo layoutInfo = new GridLayoutInfo { Rows = Rows, Columns = Columns, RowsPercentage = RowPercents, ColumnsPercentage = ColumnPercents, CellChildMap = new int[Rows][], }; for (int row = 0; row < Rows; row++) { layoutInfo.CellChildMap[row] = new int[Columns]; for (int col = 0; col < Columns; col++) { layoutInfo.CellChildMap[row][col] = CellChildMap[row, col]; } } GridLayoutJson jsonObj = new GridLayoutJson { Uuid = "{" + Guid.ToString().ToUpper() + "}", Name = Name, Type = ModelTypeID, Info = layoutInfo, }; JsonSerializerOptions options = new JsonSerializerOptions { PropertyNamingPolicy = new DashCaseNamingPolicy(), }; try { string jsonString = JsonSerializer.Serialize(jsonObj, options); FileSystem.File.WriteAllText(Settings.AppliedZoneSetTmpFile, jsonString); } catch (Exception ex) { ShowExceptionMessageBox(ErrorPersistingGridLayout, ex); } }
// PersistData // Implements the LayoutModel.PersistData abstract method protected override void PersistData() { AddCustomLayout(this); GridLayoutInfo layoutInfo = new GridLayoutInfo { Rows = Rows, Columns = Columns, RowsPercentage = RowPercents, ColumnsPercentage = ColumnPercents, CellChildMap = new int[Rows][], }; for (int row = 0; row < Rows; row++) { layoutInfo.CellChildMap[row] = new int[Columns]; for (int col = 0; col < Columns; col++) { layoutInfo.CellChildMap[row][col] = CellChildMap[row, col]; } } GridLayoutJson jsonObj = new GridLayoutJson { Uuid = Uuid, Name = Name, Type = ModelTypeID, Info = layoutInfo, }; JsonSerializerOptions options = new JsonSerializerOptions { PropertyNamingPolicy = new DashCaseNamingPolicy(), }; string jsonString = JsonSerializer.Serialize(jsonObj, options); AddCustomLayoutJson(JsonSerializer.Deserialize <JsonElement>(jsonString)); SerializeCreatedCustomZonesets(); }
private string getLayoutXmlSaveName(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid) { try { if (xtraGrid.ParentForm == null) { return(null); } string layoutXmlName = getLayoutXmlSessionName(baseRule, xtraGrid); GridLayoutInfo layoutInfo = GetPivotGridActiveLayout(baseRule, xtraGrid); //add by aifang 2012-08-29 begin //判断状态保存日期是否大于动态列设置日期,如是,则生效,否则不生效。 DateTime dt = layoutInfo.CreateTime; var dynamicSetting = XtraGridDynamicHelper.Instance.GetXtraGridDynamicSettingInfo(baseRule); if (dynamicSetting != null) { if (dynamicSetting.LastModifyDate.Subtract(dt).TotalMilliseconds > 0) { layoutInfo = null; } } //end if (layoutInfo == null) { return(layoutXmlName + ".xml"); } else { return(layoutXmlName + "~" + layoutInfo.Name + ".xml"); } } catch (Exception ex) { MB.Util.TraceEx.Write(ex.Message, Util.APPMessageType.SysErrInfo); return(null); } }
public void DeletePivotGridLayout(MB.WinBase.IFace.IForm containerForm, PivotGridEx xtraGrid, GridLayoutInfo layoutInfo) { string name = getLayoutXmlSessionName(containerForm.ClientRuleObject, xtraGrid); if (layoutInfo != null) { name = name + "~" + layoutInfo.Name + ".xml"; } if (string.IsNullOrEmpty(name)) { return; } if (System.IO.File.Exists(LAYOUT_XML_PATH + name)) { System.IO.File.Delete(LAYOUT_XML_PATH + name); } }
public override void Resize(int x, int y) { LastParentSize.X = x; LastParentSize.Y = y; Inited = true; Rect.Resize(x, y); if (Columns == 0 || Rows == 0) { return; // must have at least one of each } PixelSize = Rect.GetPixelSize(); AvalableSize.X = PixelSize.X - (CellPadding * (Columns + 1)); AvalableSize.Y = PixelSize.Y - (CellPadding * (Rows + 1)); CellSize = new Vector2(AvalableSize.X / Columns, AvalableSize.Y / Rows); ColSpanSize = new Vector2(PixelSize.X - (CellPadding * 2), CellSize.Y); if (CellSize.X < 2 || CellSize.Y < 2) { return; // there isn't enough room to do anything } foreach (var child in Children) { GridLayoutInfo info = child.LayoutTag as GridLayoutInfo; if (info == null) { continue; } Vector2 thisCellSize = CellSize; var colInfo = ColSpanRows.Find((i) => i.StartRow == info.Row); if (colInfo != null) { thisCellSize.X = ColSpanSize.X; thisCellSize.Y = (ColSpanSize.Y * colInfo.Lenght) + (CellPadding * (colInfo.Lenght - 1)); } OriginLocation location = child.Rect.AnchorLocation; float itemHeight = thisCellSize.Y; if ((colInfo == null || colInfo.Lenght == 1) && (MaxChildSize > 0 && thisCellSize.Y > MaxChildSize)) // if the cell is larger than one high, they can't clamp it { itemHeight = MaxChildSize; location = OriginTools.GetMiddleAnhcor(location); } // compute where the child's origin needs to be for it's anchor relative to the cell Vector2 childOrigin = GetChildOrigin(GetCellOrigin(info.Row, colInfo != null ? 0 : info.Col, colInfo != null ? colInfo.Lenght : 1), thisCellSize, itemHeight, location); child.Rect.X.RelativeTo = RelativeLoc.Edge.Raw; child.Rect.X.Paramater = childOrigin.X; child.Rect.Y.RelativeTo = RelativeLoc.Edge.Raw; child.Rect.Y.Paramater = childOrigin.Y; child.Rect.Width.Mode = RelativeSize.SizeModes.Raw; child.Rect.Width.Paramater = thisCellSize.X; child.Rect.Height.Mode = RelativeSize.SizeModes.Raw; child.Rect.Height.Paramater = itemHeight; // have the child size itself and it's children to it's new location child.Resize(PixelSize); } }