public void setComponentAt(IvyComponent comp, int r, int c) { if (r >= 0 && r < rows && c >= 0 && c < cols) { grid[r, c] = comp; Grid.SetColumn(comp.getComponent(), c); Grid.SetRow(comp.getComponent(), r); Grid.SetColumnSpan(comp.getComponent(), comp.getColSpan()); Grid.SetRowSpan(comp.getComponent(), comp.getRowSpan()); //TODO: mettre le bon parametre /*if(comp.getWidthType() == DimensionParameters.FILL && comp.getHeightType() == DimensionParameters.FILL){ * constr.fill = GridBagConstraints.BOTH; * } * else if(comp.getWidthType() == DimensionParameters.FILL){ * constr.fill = GridBagConstraints.HORIZONTAL; * } * else if(comp.getHeightType() == DimensionParameters.FILL){ * constr.fill = GridBagConstraints.VERTICAL; * }*/ gridComp.Children.Add(comp.getComponent()); } }
public static IvyComponent parseXML(string fileName) { names = new List <string>(); lock (names) { XmlDocument document = new XmlDocument(); IvyComponent comp = null; try { document.Load(fileName); comp = parseXMLComponent(document.DocumentElement); } catch (Exception e) { //TODO System.Windows.MessageBox.Show(e.ToString()); System.Windows.MessageBox.Show(e.StackTrace); } return(comp); } }
private void addComponent(IvyComponent comp) { if (comp is IvyContainer) { IvyContainer cont = (IvyContainer)comp; List<IvyComponent> children = cont.getChildren(); if (children != null) { foreach (IvyComponent child in children) { addComponent(child); } } } if (comp.hasName()) { if (components.ContainsKey(comp.getName())) { //Ne devrait pas arriver throw new DuplicateNameException(); } components.Add(comp.getName(), comp); } }
public static IvyComponent parseXMLComponent(XmlNode e) { IvyComponent comp = null; if (e.Name.Equals("Grid")) { comp = parseXMLGrid(e); } else if (e.Name.Equals("Button")) { comp = parseXMLButton(e); } else if (e.Name.Equals("Label")) { comp = parseXMLLabel(e); } else if (e.Name.Equals("List")) { comp = parseXMLList(e); } return(comp); }
public void addComponent(IvyComponent comp) { setComponentAt(comp, comp.getRow(), comp.getCol()); }
public void setComponentAt(IvyComponent comp, int r, int c) { if (r >= 0 && r < rows && c >= 0 && c < cols) { grid[r, c] = comp; Grid.SetColumn(comp.getComponent(), c); Grid.SetRow(comp.getComponent(), r); Grid.SetColumnSpan(comp.getComponent(), comp.getColSpan()); Grid.SetRowSpan(comp.getComponent(), comp.getRowSpan()); //TODO: mettre le bon parametre /*if(comp.getWidthType() == DimensionParameters.FILL && comp.getHeightType() == DimensionParameters.FILL){ constr.fill = GridBagConstraints.BOTH; } else if(comp.getWidthType() == DimensionParameters.FILL){ constr.fill = GridBagConstraints.HORIZONTAL; } else if(comp.getHeightType() == DimensionParameters.FILL){ constr.fill = GridBagConstraints.VERTICAL; }*/ gridComp.Children.Add(comp.getComponent()); } }
private static bool getComponentAttributes(IvyComponent comp, XmlAttribute attr) { String value = attr.Value; if (attr.Name.Equals("name")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (names.Contains(value)) { throw new DuplicateNameException(); } comp.setName(value); } else if (attr.Name.Equals("width")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (value.Equals("*")) { comp.setWidthType(IvyComponent.DimensionParameters.FILL); } else if (value.Equals("auto")) { comp.setWidthType(IvyComponent.DimensionParameters.AUTO); } else { comp.setWidthType(IvyComponent.DimensionParameters.FIXED); try { comp.setWidth(int.Parse(value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } } else if (attr.Name.Equals("height")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (value.Equals("*")) { comp.setHeightType(IvyComponent.DimensionParameters.FILL); } else if (value.Equals("auto")) { comp.setHeightType(IvyComponent.DimensionParameters.AUTO); } else { comp.setHeightType(IvyComponent.DimensionParameters.FIXED); try { comp.setHeight(int.Parse(value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } } else if (attr.Name.Equals("margin")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } String[] marginValues = value.Split(','); for (int i = 0; i < marginValues.Length; i++) { marginValues[i] = marginValues[i].Trim(); } if (marginValues.Length == 1) { try { comp.setMargin(int.Parse(marginValues[0])); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (marginValues.Length == 2) { try { comp.setMargin(int.Parse(marginValues[0]), int.Parse(marginValues[1])); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (marginValues.Length == 4) { try { comp.setMargin(int.Parse(marginValues[0]), int.Parse(marginValues[1]), int.Parse(marginValues[2]), int.Parse(marginValues[3])); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else { throw new InvalidAttributeValueException(); } } else if (attr.Name.Equals("row")) { try { comp.setRow(int.Parse(attr.Value)); } catch (Exception e) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("col")) { try { comp.setCol(int.Parse(attr.Value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("rowSpan")) { try { comp.setRowSpan(int.Parse(attr.Value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("colSpan")) { try { comp.setColSpan(int.Parse(attr.Value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("border")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (value.Equals("none")) { comp.setBorderType(IvyComponent.Border.NONE); } else if (value.Equals("squared")) { comp.setBorderType(IvyComponent.Border.SQUARED); } else if (value.Equals("rounded")) { comp.setBorderType(IvyComponent.Border.ROUNDED); } else { throw new InvalidAttributeValueException(); } } else if (attr.Name.Equals("borderColor")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } /* TODO */ } else if (attr.Name.Equals("backgroundColor")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } try { comp.setBackgroundColor((SolidColorBrush) new BrushConverter().ConvertFromString(value)); } catch (Exception ex) { throw new InvalidAttributeException(); } } else if (attr.Name.Equals("backgroundImage")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } try { comp.setBackgroundImage(value); } catch (Exception ex) { throw new NoSuchResourceException(); } } else if (attr.Name.Equals("visible")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } try { comp.setVisible(bool.Parse(value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else { return(false); } return(true); }
private static bool getComponentAttributes(IvyComponent comp, XmlAttribute attr) { String value = attr.Value; if (attr.Name.Equals("name")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (names.Contains(value)) { throw new DuplicateNameException(); } comp.setName(value); } else if (attr.Name.Equals("width")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (value.Equals("*")) { comp.setWidthType(IvyComponent.DimensionParameters.FILL); } else if (value.Equals("auto")) { comp.setWidthType(IvyComponent.DimensionParameters.AUTO); } else { comp.setWidthType(IvyComponent.DimensionParameters.FIXED); try { comp.setWidth(int.Parse(value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } } else if (attr.Name.Equals("height")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (value.Equals("*")) { comp.setHeightType(IvyComponent.DimensionParameters.FILL); } else if (value.Equals("auto")) { comp.setHeightType(IvyComponent.DimensionParameters.AUTO); } else { comp.setHeightType(IvyComponent.DimensionParameters.FIXED); try { comp.setHeight(int.Parse(value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } } else if (attr.Name.Equals("margin")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } String[] marginValues = value.Split(','); for (int i = 0; i < marginValues.Length; i++) { marginValues[i] = marginValues[i].Trim(); } if (marginValues.Length == 1) { try { comp.setMargin(int.Parse(marginValues[0])); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (marginValues.Length == 2) { try { comp.setMargin(int.Parse(marginValues[0]), int.Parse(marginValues[1])); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (marginValues.Length == 4) { try { comp.setMargin(int.Parse(marginValues[0]), int.Parse(marginValues[1]), int.Parse(marginValues[2]), int.Parse(marginValues[3])); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else { throw new InvalidAttributeValueException(); } } else if (attr.Name.Equals("row")) { try { comp.setRow(int.Parse(attr.Value)); } catch (Exception e) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("col")) { try { comp.setCol(int.Parse(attr.Value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("rowSpan")) { try { comp.setRowSpan(int.Parse(attr.Value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("colSpan")) { try { comp.setColSpan(int.Parse(attr.Value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else if (attr.Name.Equals("border")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } if (value.Equals("none")) { comp.setBorderType(IvyComponent.Border.NONE); } else if (value.Equals("squared")) { comp.setBorderType(IvyComponent.Border.SQUARED); } else if (value.Equals("rounded")) { comp.setBorderType(IvyComponent.Border.ROUNDED); } else { throw new InvalidAttributeValueException(); } } else if (attr.Name.Equals("borderColor")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } /* TODO */ } else if (attr.Name.Equals("backgroundColor")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } try { comp.setBackgroundColor((SolidColorBrush)new BrushConverter().ConvertFromString(value)); } catch (Exception ex) { throw new InvalidAttributeException(); } } else if (attr.Name.Equals("backgroundImage")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } try { comp.setBackgroundImage(value); } catch (Exception ex) { throw new NoSuchResourceException(); } } else if (attr.Name.Equals("visible")) { value = attr.Value; if (value == string.Empty) { throw new EmptyAttributeValueException(); } try { comp.setVisible(bool.Parse(value)); } catch (Exception ex) { throw new InvalidAttributeTypeException(); } } else { return false; } return true; }
public void addComponent(IvyComponent comp) { setComponentAt(comp, comp.getRow(), comp.getCol()); }
public void addComponent(IvyComponent comp) { components.Add(comp); list.Items.Add(comp.getComponent()); }
public void addComponent(IvyComponent comp) { components.Add(comp); list.Items.Add(comp.getComponent()); }