/// <summary> /// Refresh all the objects involved in the operation /// </summary> public void RefreshObjects() { TreeListView tlv = this.SourceListView as TreeListView; if (tlv != null) { foreach (object model in this.SourceModels) { object parent = tlv.GetParent(model); if (!toBeRefreshed.Contains(parent)) { toBeRefreshed.Add(parent); } } } toBeRefreshed.AddRange(this.SourceModels); if (this.ListView == this.SourceListView) { toBeRefreshed.Add(this.TargetModel); this.ListView.RefreshObjects(toBeRefreshed); } else { this.SourceListView.RefreshObjects(toBeRefreshed); this.ListView.RefreshObject(this.TargetModel); } }
public static BsonDocumentBindable GetRootBindableDoc(TreeListView treeListViewData) { if (treeListViewData.SelectedItem == null) { return(null); } var model = treeListViewData.SelectedItem.RowObject; while (treeListViewData.GetParent(model) != null) { model = treeListViewData.GetParent(model); } return((BsonDocumentBindable)model); }
public static void ExpandToObject(this TreeListView tlv, object obj) { object parent = tlv.GetParent(obj); if (parent != null && !tlv.IsExpanded(parent)) { ExpandToObject(tlv, parent); tlv.Expand(parent); } }
public T GetFirstOrNullParentRecursivelyOfType <T>(object modelObject) where T : class { //get parent of node var parent = _tree.GetParent(modelObject); //if there is no parent if (parent == null) { return(default(T));//return null } //if parent is correct type return it var correctType = parent as T; if (correctType != null) { return(correctType); } //otherwise explore upwards on parent to get parent of correct type return(GetFirstOrNullParentRecursivelyOfType <T>(parent)); }
public static bool IsAncestor(this TreeListView tlv, object subject, object ancestorCandidate) { if (subject == null || ancestorCandidate == null) { return(false); } object subjectParent = tlv.GetParent(subject); if (subjectParent == ancestorCandidate) { return(true); } return(IsAncestor(tlv, subjectParent, ancestorCandidate)); }
public static void CreateContextualMenu(object obj, CellRightClickEventArgs args) { ContextMenuStrip menuStrip = new ContextMenuStrip(); List <BaseToolStripButton> items = new List <BaseToolStripButton>(); IVariable enclosingVariable = args.Model as IVariable; IValue value = DerefVariable(args.Model); StructureValue structureValue = value as StructureValue; if (structureValue != null) { Structure structureType = (Structure)structureValue.Type; foreach (StructureElement element in structureType.Elements) { if (element.Type is Structure) { IVariable subVariable = null; INamable tmp; if (structureValue.Val.TryGetValue(element.Name, out tmp)) { subVariable = tmp as IVariable; } if (subVariable == null || subVariable.Value == EfsSystem.Instance.EmptyValue || subVariable.Value is DefaultValue) { items.Add(new ToolStripAddStructureMember(args, structureValue, element)); } } } if (enclosingVariable != null) { StructureValue enclosingStructureValue = enclosingVariable.Enclosing as StructureValue; if (enclosingStructureValue != null) { items.Add(new ToolStripRemoveStructureMember(args, enclosingVariable)); } } TreeListView treeListView = (TreeListView)obj; object parent = treeListView.GetParent(args.Model); ListValue enclosingListValue = DerefVariable(parent) as ListValue; if (enclosingListValue != null) { items.Add(new ToolStripRemoveListEntry(args, enclosingListValue, structureValue)); } } ListValue listValue = value as ListValue; if (listValue != null) { if (enclosingVariable != null) { Collection collection = (Collection)enclosingVariable.Type; if (listValue.Val.Count < collection.getMaxSize()) { items.Add(new ToolStripAddValueInList(args, enclosingVariable)); } } } items.Sort((b1, b2) => String.Compare(b1.Text, b2.Text, StringComparison.Ordinal)); foreach (BaseToolStripButton menuItem in items) { menuStrip.Items.Add(menuItem); } args.MenuStrip = menuStrip; }
private void ChangeStatus(StatusTransfer val) { if (childs != null && childs.Count != 0) { foreach (var child in childs) { //set Started when item is Stop,Waiting if (val == StatusTransfer.Started && (child.status == StatusTransfer.Stop || child.status == StatusTransfer.Waiting || child.status == StatusTransfer.Error)) { child.status = val; TransferGroup pr = olv.GetParent(child) as TransferGroup; if (pr != null && (pr.status != StatusTransfer.Running || pr.status != StatusTransfer.Loading || pr.status != StatusTransfer.Remove)) { pr.status = val; } } else //set Stop child if (val == StatusTransfer.Stop && (child.status != StatusTransfer.Done || child.status != StatusTransfer.Error || child.status != StatusTransfer.Stop)) { child.status = val; } else //set Waiting child if (val == StatusTransfer.Waiting && child.status != StatusTransfer.Done) { child.status = val; } else if (val == StatusTransfer.Remove) { child.status = val; } } } if (parents != null && parents.Count != 0) { foreach (var parent in parents) { if (val == StatusTransfer.Started && (parent.status != StatusTransfer.Running)) { parent.status = val; } else if (val == StatusTransfer.Stop && (parent.status != StatusTransfer.Done | parent.status != StatusTransfer.Loading | parent.status != StatusTransfer.Stop)) { parent.status = val; } else if (val == StatusTransfer.Waiting && (parent.status != StatusTransfer.Done | parent.status != StatusTransfer.Remove)) { parent.status = val; } else if (val == StatusTransfer.Remove) { parent.status = val; } } } }