public FormSaveSettings(string saveLocation, FormWorld world) { InitializeComponent(); this.saveLocation = saveLocation; this.world = world; var saveUri = new Uri(saveLocation); foreach (var tileset in world.Tilesets) { string relative = saveUri.MakeRelativeUri(new Uri(tileset.Filename)).ToString(); Node node = new Node(Path.GetFileName(tileset.Filename)) { CheckBoxVisible = true, Checked = tileset.ShouldBuild }; Cell cell = new Cell() { Text = tileset.BuildLocation != null ? tileset.BuildLocation : Path.Combine(Path.GetDirectoryName(relative), Path.GetFileNameWithoutExtension(relative)), Editable = true }; node.Cells[0].Editable = false; node.Cells.Add(cell); tilesetFilesList.Nodes.Add(node); } }
public PropertyNode CreatePropertyNode(PropertyDescriptor item, object targetComponent, IPropertyGridLocalizer localizer, PropertySettings settings, bool isMultiObject) { PropertyNode node = null; if (item.PropertyType == typeof(Color)) node = new PropertyNodeColor(item); else if (item.PropertyType == typeof(bool)) node = new PropertyCheckBoxNode(item); else if (settings != null && settings.PropertyNodeType == ePropertyNodeType.RadioButtonList) node = new PropertyOptionListNode(item); else node = new PropertyNode(item); node.IsMultiObject = isMultiObject; node.NodesIndent = _ChildPropertiesIndent; node.ImageAlignment = eCellPartAlignment.FarCenter; string name = localizer.GetPropertyName(item.Name); if (string.IsNullOrEmpty(name)) name = item.DisplayName; node.Text = name; node.TargetComponent = targetComponent; Cell cell = new Cell(); cell.Selectable = false; node.Cells.Add(cell); node.PropertySettings = settings; return node; }
protected override void OnBeforeCellCheck(Cell cell, AdvTreeCellBeforeCheckEventArgs e) { if (this.IsReadOnly && e.Action != eTreeAction.Code) e.Cancel = true; else { if (e.Action != eTreeAction.Code) { bool newValue = (e.NewCheckState == System.Windows.Forms.CheckState.Checked); e.Cancel = !ApplyValue(newValue, null); } } base.OnBeforeCellCheck(cell, e); }
/// <summary> /// Adds a temporary property to the list /// </summary> void addProperty(string name = newPropertyText, string value = "", bool valueEditable = false) { Node node = new Node(name) { ContextMenu = propertyMenu }; Cell cell = new Cell(value) { Editable = valueEditable }; node.Cells.Add(cell); propertiesList.Nodes.Add(node); }
/// <summary> /// Removes specified object from the collection. /// </summary> /// <param name="value"></param> public void Remove(Cell value) { List.Remove(value); }
/// <summary> /// Returns whether collection contains specified object. /// </summary> /// <param name="value">Object to look for.</param> /// <returns>true if object is part of the collection, otherwise false.</returns> public bool Contains(Cell value) { return List.Contains(value); }
private static void LoadCells(Node parentNode, XmlElement xmlCells) { foreach(XmlNode xmlChild in xmlCells.ChildNodes) { if(xmlChild.Name==XmlCellName && xmlChild is XmlElement) { Cell cell=new Cell(); parentNode.Cells.Add(cell); ElementSerializer.Deserialize(cell, xmlChild as XmlElement); // Load images if any foreach(XmlElement xmlImage in xmlChild.ChildNodes) { if(xmlImage.Name==XmlCellImagesName) { ElementSerializer.Deserialize(cell.Images, xmlImage); break; } } } } }
/// <summary> /// Sets selected cell and provides information on the action that caused the selection change. /// </summary> /// <param name="value">New selected cell.</param> /// <param name="actionSource">Action source.</param> public void SetSelectedCell(Cell value, eTreeAction actionSource) { AdvTree tree = this.TreeControl; if (!this.IsSelected && value != null) { if (tree != null) tree.SelectedNode = this; } Cell previousSelectedCell = null; Cell selectedCell = null; foreach (Cell cell in m_Cells) { if (cell.IsSelected) previousSelectedCell = cell; if (cell == value && cell.CanSelect) { selectedCell = cell; cell.SetSelected(true, actionSource); } else cell.SetSelected(false, actionSource); } if (tree != null) { tree.InvalidateNode(this); if (value == null || previousSelectedCell != null && value != previousSelectedCell) { tree.InvokeCellUnselected(new AdvTreeCellEventArgs(actionSource, previousSelectedCell)); } if (selectedCell != null && previousSelectedCell != selectedCell) { tree.InvokeCellSelected(new AdvTreeCellEventArgs(actionSource, selectedCell)); } } }
/// <summary> /// Initializes a new instance of the AdvTreeCellBeforeCheckEventArgs class. /// </summary> /// <param name="newCheckState"></param> public AdvTreeCellBeforeCheckEventArgs(eTreeAction action, Cell cell, CheckState newCheckState) : base(action, cell) { NewCheckState = newCheckState; }
/// <summary> /// Returns index of the object inside of the collection. /// </summary> /// <param name="value">Reference to the object.</param> /// <returns>Index of the object.</returns> public int IndexOf(Cell value) { return List.IndexOf(value); }
/// <summary> /// Adds new object to the collection. /// </summary> /// <param name="cell">Object to add.</param> /// <returns>Index of newly added object.</returns> public int Add(Cell cell) { return List.Add(cell); }
protected override void OnClear() { if (m_ParentNode != null && m_ParentNode.Site != null && m_ParentNode.Site.DesignMode && this.List.Count>0) { if (this[0].Site == null) _RootCell = this[0]; } base.OnClear(); }
/// <summary> /// Copies collection into the specified array. /// </summary> /// <param name="array">Array to copy collection to.</param> /// <param name="index">Starting index.</param> public void CopyTo(Cell[] array, int index) { List.CopyTo(array, index); }
/// <summary>Makes a copy of a Cell.</summary> public virtual Cell Copy() { // TODO: Make sure that new properties are copied Cell c=new Cell(); c.CheckBoxAlignment=this.CheckBoxAlignment; c.CheckBoxVisible=this.CheckBoxVisible; c.CheckBoxStyle = this.CheckBoxStyle; if (this.CheckBoxThreeState) c.CheckState = this.CheckState; else c.Checked=this.Checked; c.Cursor=this.Cursor; c.Enabled=this.Enabled; c.ImageAlignment=this.ImageAlignment; c.SetCellImages(this.Images.Copy()); c.Layout=this.Layout; c.StyleDisabled=this.StyleDisabled; c.StyleMouseDown=this.StyleMouseDown; c.StyleMouseOver=this.StyleMouseOver; c.StyleNormal=this.StyleNormal; c.StyleSelected=this.StyleSelected; c.Tag=this.Tag; c.Text=this.Text; c.Editable = this.Editable; c.EditorType = this.EditorType; return c; }
/// <summary> /// Initializes new instance of CellImages class. /// </summary> /// <param name="parentCell">Reference to parent cell.</param> public CellImages(Cell parentCell) { m_ParentCell=parentCell; }
/// <summary> /// Default constructor for event data. /// </summary> /// <param name="action">Type of the action event is raised for.</param> /// <param name="cell">Cell that event is raised for.</param> public AdvTreeCellEventArgs(eTreeAction action, Cell cell) { this.Action=action; this.Cell=cell; }
/// <summary> /// Initializes new instance of CellEditEventArgs class. /// </summary> /// <param name="cell">Reference to Cell this event is raised for.</param> /// <param name="action">Indicates the action that caused the event.</param> /// <param name="newText">Indicates new text of the cell if it applies to given event.</param> public CellEditEventArgs(Cell cell, eTreeAction action, string newText) { this.Action=action; this.Cell=cell; this.NewText=newText; }
/// <summary> /// Copies contained items to the Cell array. /// </summary> /// <param name="array">Array to copy to.</param> internal void CopyTo(Cell[] array) { List.CopyTo(array,0); }
internal static ColumnHeader GetCellColumnHeader(AdvTree tree, Cell cell) { int index = -1; if (cell.Parent != null) index = cell.Parent.Cells.IndexOf(cell); if (cell.Parent != null && cell.Parent.Parent != null && cell.Parent.Parent.NodesColumns.Count > 0 && index < cell.Parent.Parent.NodesColumns.Count) { return cell.Parent.Parent.NodesColumns[index]; } if (tree != null && tree.Columns.Count > 0 && index < tree.Columns.Count) return tree.Columns[index]; return null; }
protected override void OnClearComplete() { base.OnClearComplete(); if (_RootCell != null) { this.Add(_RootCell); _RootCell = null; } }
/// <summary> /// Ensures that the cell is visible, expanding nodes and scrolling the control as necessary. /// </summary> /// <param name="reference">Cell to be made visible.</param> public static void EnsureVisible(Cell cell) { Node parentNode = cell.Parent; if (parentNode == null) return; AdvTree tree = parentNode.TreeControl; if (tree == null) return; EnsureVisible(parentNode, false); Rectangle r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, cell, tree.NodeDisplay.Offset); if (tree != null && tree.AutoScroll) { if (tree.Zoom != 1) { r = tree.GetScreenRectangle(r); } Rectangle treeClientRectangle = tree.GetInnerRectangle(); if (tree.VScrollBar != null) treeClientRectangle.Width -= tree.VScrollBar.Width; if (tree.HScrollBar != null) treeClientRectangle.Height -= tree.HScrollBar.Height; if (!treeClientRectangle.Contains(r)) { Point p = tree.NodeDisplay.Offset; p.Y = tree.AutoScrollPosition.Y; if (r.X < treeClientRectangle.X) p.X -= r.X; else if (r.X > treeClientRectangle.Right) p.X += (r.Right - treeClientRectangle.Right); // Scroll it to show the cell if (!tree.IsLayoutPending) tree.AutoScrollPosition = p; } } }
/// <summary> /// Inserts new object into the collection. /// </summary> /// <param name="index">Position of the object.</param> /// <param name="value">Object to insert.</param> public void Insert(int index, Cell value) { List.Insert(index, value); }
/// <summary>Default Constructor.</summary> public Node() { m_Cells.SetParentNode(this); m_ParentConnectorPoints = new ConnectorPointsCollection(); m_ParentConnectorPoints.SetParentNode(this); Cell defaultCell = new Cell(); this.Cells.Add(defaultCell); }
/// <summary> /// Initializes a new instance of the CustomCellEditorEventArgs class. /// </summary> /// <param name="cell"></param> public CustomCellEditorEventArgs(Cell cell) { Cell = cell; }
/// <summary> /// Default constructor for event data. /// </summary> /// <param name="action">Type of the action event is raised for.</param> /// <param name="cell">Cell that event is raised for.</param> public TreeCellCancelEventArgs(eTreeAction action, Cell cell):base(action,cell) { }