/// <summary> /// Initializes a new instance of the <see cref="GridDesignerMain" /> class. /// </summary> /// <param name="databaseUri">The database Uri.</param> /// <param name="currentLayoutTypeValue">The current layout type value.</param> /// <param name="numberOfCell">The number of cell.</param> /// <param name="cellAttributes">The cell attributes.</param> public GridDesignerMain([NotNull] DatabaseUri databaseUri, [CanBeNull] string currentLayoutTypeValue, int numberOfCell, [NotNull] string cellAttributes) { InitializeComponent(); this.InitializeDialog(); Site.RequestCompleted completed = delegate(string response) { LayoutType currentLayoutType = null; var layoutTypes = new List <LayoutType>(); var root = response.ToXElement(); if (root != null) { foreach (var element in root.Elements()) { var layoutType = GetLayoutTypeFromItem(element); if (layoutType != null) { layoutTypes.Add(layoutType); if (layoutType.Name.Equals(currentLayoutTypeValue)) { currentLayoutType = layoutType; } } } } InitializeGridDesigner(layoutTypes, currentLayoutType, numberOfCell, cellAttributes); }; databaseUri.Site.Execute("Layouts.GetGridDesignerLayouts", completed, databaseUri.DatabaseName.Name); }
/// <summary> /// Gets the layout type from item. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> private static LayoutType GetLayoutTypeFromItem(XElement element) { var layoutType = new LayoutType(); Console.Write("ID:" + element.GetAttributeValue("id")); Guid guid; if (!Guid.TryParse(element.GetAttributeValue("id"), out guid)) { return(null); } layoutType.Id = guid; layoutType.Name = element.GetAttributeValue("name"); layoutType.Large = int.Parse(element.GetAttributeValue("large")); layoutType.Medium = int.Parse(element.GetAttributeValue("medium")); layoutType.Small = int.Parse(element.GetAttributeValue("small")); layoutType.XSmall = int.Parse(element.GetAttributeValue("xsmall")); return(layoutType); }
/// <summary> /// Initializes the controls and properties. /// </summary> private void InitializeControlsAndProperties([NotNull] List <LayoutType> layoutTypes, [CanBeNull] LayoutType currentLayoutType, int componentNumberOfCell, [NotNull] string componentCellAttributes) { LayoutTypes = layoutTypes; if (componentNumberOfCell == 0) { componentNumberOfCell = 9; } var componentLayoutType = currentLayoutType; if (componentLayoutType == null) { componentLayoutType = layoutTypes[0]; } foreach (var layoutType in layoutTypes) { LayoutType.Items.Add(new ComboBoxItem { Content = layoutType.Name, Tag = layoutType.Id, IsSelected = layoutType.Id.Equals(componentLayoutType.Id) }); } CurrentLayoutType = componentLayoutType; TotalCells = componentNumberOfCell; PreviewSize.SelectedIndex = 0; NumberOfCells.Text = TotalCells.ToString(CultureInfo.InvariantCulture); CurrentPreviewSize = (Sizes)Enum.Parse(typeof(Sizes), ((ComboBoxItem)PreviewSize.SelectedItem).Tag.ToString(), true); CurrentPreviewSizeIndex = (int)CurrentPreviewSize; SetGridColumnsNumber(); SetGridSize(); SetSizesLabels(); LoadData(componentCellAttributes); }
/// <summary> /// Formats the type of the layout. /// </summary> /// <param name="layoutType">Type of the layout.</param> /// <returns></returns> private string FormatLayoutType(LayoutType layoutType) { return(layoutType.Large + "-" + layoutType.Medium + "-" + layoutType.Small + "-" + layoutType.XSmall); }
/// <summary> /// Initializes the grid designer. /// </summary> /// <param name="cellAttributes">The cell attributes.</param> /// <param name="currentLayoutType">The current layout type.</param> /// <param name="layoutTypes">The layout types.</param> /// <param name="numberOfCell">The number of cell.</param> private void InitializeGridDesigner(List <LayoutType> layoutTypes, [CanBeNull] LayoutType currentLayoutType, int numberOfCell, string cellAttributes) { InitializeControlsAndProperties(layoutTypes, currentLayoutType, numberOfCell, cellAttributes); InitializeGrid(); InitializeEvents(); }