/// <summary> /// true, if all data *except the two IDs* is equal (case insensitive) /// </summary> /// <param name="eqSystem"></param> /// <returns></returns> public bool EqualsED(EDStation eqStation) { bool retValue = false; if (eqStation != null) { if (ObjectCompare.EqualsNullable(this.Name, eqStation.Name) && ObjectCompare.EqualsNullable(this.MaxLandingPadSize, eqStation.MaxLandingPadSize) && ObjectCompare.EqualsNullable(this.DistanceToStar, eqStation.DistanceToStar) && ObjectCompare.EqualsNullable(this.Faction, eqStation.Faction) && ObjectCompare.EqualsNullable(this.Government, eqStation.Government) && ObjectCompare.EqualsNullable(this.Allegiance, eqStation.Allegiance) && ObjectCompare.EqualsNullable(this.State, eqStation.State) && ObjectCompare.EqualsNullable(this.Type, eqStation.Type) && ObjectCompare.EqualsNullable(this.HasBlackmarket, eqStation.HasBlackmarket) && ObjectCompare.EqualsNullable(this.HasCommodities, eqStation.HasCommodities) && ObjectCompare.EqualsNullable(this.HasRefuel, eqStation.HasRefuel) && ObjectCompare.EqualsNullable(this.HasRepair, eqStation.HasRepair) && ObjectCompare.EqualsNullable(this.HasRearm, eqStation.HasRearm) && ObjectCompare.EqualsNullable(this.HasOutfitting, eqStation.HasOutfitting) && ObjectCompare.EqualsNullable(this.HasShipyard, eqStation.HasShipyard) && ObjectCompare.EqualsNullable(this.ImportCommodities, eqStation.ImportCommodities) && ObjectCompare.EqualsNullable(this.ExportCommodities, eqStation.ExportCommodities) && ObjectCompare.EqualsNullable(this.ProhibitedCommodities, eqStation.ProhibitedCommodities) && ObjectCompare.EqualsNullable(this.Economies, eqStation.Economies)) { retValue = true; } } return(retValue); }
/// <summary> /// true, if all data *except the ID* is equal (case insensitive) /// </summary> /// <param name="eqSystem"></param> /// <returns></returns> public bool EqualsED(EDSystem eqSystem) { bool retValue = false; if (eqSystem != null) { if (ObjectCompare.EqualsNullable(this.Name, eqSystem.Name) && ObjectCompare.EqualsNullable(this.X, eqSystem.X) && ObjectCompare.EqualsNullable(this.Y, eqSystem.Y) && ObjectCompare.EqualsNullable(this.Z, eqSystem.Z) && ObjectCompare.EqualsNullable(this.Faction, eqSystem.Faction) && ObjectCompare.EqualsNullable(this.Population, eqSystem.Population) && ObjectCompare.EqualsNullable(this.Government, eqSystem.Government) && ObjectCompare.EqualsNullable(this.Allegiance, eqSystem.Allegiance) && ObjectCompare.EqualsNullable(this.State, eqSystem.State) && ObjectCompare.EqualsNullable(this.Security, eqSystem.Security) && ObjectCompare.EqualsNullable(this.PrimaryEconomy, eqSystem.PrimaryEconomy) && ObjectCompare.EqualsNullable(this.Power, eqSystem.Power) && ObjectCompare.EqualsNullable(this.PowerState, eqSystem.PowerState) && ObjectCompare.EqualsNullable(this.NeedsPermit, eqSystem.NeedsPermit) && ObjectCompare.EqualsNullable(this.UpdatedAt, eqSystem.UpdatedAt) && ObjectCompare.EqualsNullable(this.Simbad_Ref, eqSystem.Simbad_Ref)) { retValue = true; } } return(retValue); }
private void CallOnEditButtonClickEvent() { if (this.dataGridView.SelectedRows.Count != 1) { return; } if (this.OnEdit != null) { object value = dataGridView.SelectedRows[0].DataBoundItem; object oldValue; if (OnEdit(value, new CollectionEditorEventArgs(_bindingSource), out oldValue)) { CollectionEditEventArgs collectionEditEventArgs = new CollectionEditEventArgs(this._bindingSource, CollectionEditType.Edit, _bindingSource.IndexOf(value), value); collectionEditEventArgs.Members.Add(ObjectCompare.Compare(oldValue, value)); if (this.SupportCancel) { AddUndoUnit(collectionEditEventArgs); } if (this.OnEdited != null) { OnEdited(this, collectionEditEventArgs); } } } }
EntityDiff(Object obj1, Object obj2) { // Required for Windows Form Designer support InitializeComponent(); m_compareObjs = new ObjectCompare(obj1, obj2); Initialise(); }
EntityDiff(AcDb.ObjectId objId1, AcDb.ObjectId objId2, TransactionHelper tr) { // Required for Windows Form Designer support InitializeComponent(); Object obj1 = tr.Transaction.GetObject(objId1, OpenMode.ForRead); Object obj2 = tr.Transaction.GetObject(objId2, OpenMode.ForRead); m_compareObjs = new ObjectCompare(obj1, obj2); Initialise(); }
/// <summary> /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. /// </summary> /// <param name="x">First object to be compared</param> /// <param name="y">Second object to be compared</param> /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns> public int Compare(object x, object y) { int compareResult; ListViewItem listviewX, listviewY; // Cast the objects to be compared to ListViewItem objects listviewX = (ListViewItem)x; listviewY = (ListViewItem)y; // Compare the two items compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text); return(CompareResult(compareResult)); }
private void Edit() { if (dataGridViewEvent.SelectedRows.Count != 1) { return; } EventBase even = this.dataGridViewEvent.SelectedRows[0].DataBoundItem as EventBase; int index = this.EventList.IndexOf(even); //保持当前事件对象的副本,用于在编辑事件之后,进行Compare提取差异 EventBase oldEvent = even.Clone() as EventBase; //FormEventEditor.Event编辑后还是原对象的引用,在原对象基础上修改的 FormEventEditor formEventSet = new FormEventEditor(this._hostEntity, even); //这里暂时还能用using,因为窗体释放时,会把事件的编辑面板也释放掉,要另外处理这个问题 //using (FormEventEditor formEventSet = new FormEventEditor(this._entity, even)) //{ formEventSet.FormEntity = this.FormEntity; formEventSet.EventList = this.EventList; if (formEventSet.ShowDialog() == DialogResult.OK) { //CheckWarning IWarningable warningable = formEventSet.Event as IWarningable; if (warningable != null) { warningable.CheckWarning(); } _eventBindingList.ResetItem(index); EventUpdate(); if (this.OnEdited != null) { CollectionEditEventArgs args = new CollectionEditEventArgs(this.EventList, CollectionEditType.Edit, index, formEventSet.Event); args.Members.Inject(ObjectCompare.Compare(oldEvent, formEventSet.Event)); OnEdited(this, args); } } //} }
public override int Compare(TaskMgrListItem x, TaskMgrListItem y) { int compareResult = 0; compareResult = string.Compare(x.SubItems[SortColumn].Text, y.SubItems[SortColumn].Text); if (compareResult == 0) { compareResult = ObjectCompare.Compare(x.PID, y.PID); } if (Order == SortOrder.Ascending) { return(compareResult); } else if (Order == SortOrder.Descending) { return(-compareResult); } return(compareResult); }
/// <summary> /// 编辑事件 /// </summary> public void Edit() { EventTreeNode node = this.SelectedNode as EventTreeNode; //如果选择的不是事件,直接返回 if (node == null) { return; } //保持当前事件对象的副本,用于在编辑事件之后,进行Compare提取差异 EventBase oldEvent = null; if (EventChanged != null) { oldEvent = node.Event.Clone() as EventBase; } //FormEventEditor.Event编辑后还是原对象的引用,在原对象基础上修改的 FormEventEditor formEventSet = new FormEventEditor(node.Event.HostEntity, node.Event); formEventSet.FormEntity = node.Event.HostFormEntity; formEventSet.EventList = EventSupport.Events; if (formEventSet.ShowDialog() == DialogResult.OK) { EventSupport.EventUpdate(this); //直接重建树 //如果想根据改变的触发时机来修改当前事件的父节点,涉及到事件的顺序问题 //因为编辑的事件在移到新的触发时机下面时,不一定是最后一个 BuildTree(); //触发事件(如果有) if (EventChanged != null) { CollectionEditEventArgs args = new CollectionEditEventArgs(this.EventSupport.Events, CollectionEditType.Edit, this.EventSupport.Events.IndexOf(node.Event), node.Event); args.Members.Inject(ObjectCompare.Compare(oldEvent, node.Event)); EventChanged(args); } } }
public static List <EventActionData> GetConditionBlockFromNode(Node node) { if (node is NodeSetValue) { var source = node as NodeSetValue; var action = new SetValue(); action.target = new MemberData(source.target); action.value = new MemberData(source.value); return(new List <EventActionData>() { action }); } else if (node is MultipurposeNode) { var source = node as MultipurposeNode; if (source.CanGetValue() && source.ReturnType() == typeof(bool)) { var action = new MethodValidation(); action.target = new MultipurposeMember(source.target); return(new List <EventActionData>() { action }); } } else if (node is Nodes.ComparisonNode) { var source = node as Nodes.ComparisonNode; var action = new ObjectCompare(); action.targetA = new MultipurposeMember(source.targetA); action.targetB = new MultipurposeMember(source.targetB); action.operatorType = source.operatorType; return(new List <EventActionData>() { action }); } else if (node is Nodes.MultiANDNode) { var source = node as Nodes.MultiANDNode; var result = new List <EventActionData>(); foreach (var target in source.targets) { var action = new EqualityCompare(); action.target = new MultipurposeMember(target); action.value = new MemberData(true); result.Add(action); } return(result); } else if (node is Nodes.MultiORNode) { var source = node as Nodes.MultiORNode; var result = new List <EventActionData>(); foreach (var target in source.targets) { if (result.Count > 0) { result.Add(EventActionData.OrEvent); } var action = new EqualityCompare(); action.target = new MultipurposeMember(target); action.value = new MemberData(true); result.Add(action); } return(result); } else if (node is Nodes.NotNode) { var source = node as Nodes.NotNode; var action = new EqualityCompare(); action.target = new MultipurposeMember(source.target); MemberDataUtility.UpdateMultipurposeMember(action.target); action.value = new MemberData(false); return(new List <EventActionData>() { action }); } return(new List <EventActionData>()); }
protected override void ProcessDragDrop(TreeNode dragNode, TreeNode dropNode) { CollectionEditEventArgs[] eventArgs = new CollectionEditEventArgs[2]; EventTreeNode node = dragNode as EventTreeNode; int nodeOldIndex = this.EventSupport.Events.IndexOf(node.Event); EventBase oldEvent = null; if (EventOrderChanged != null) { oldEvent = node.Event.Clone() as EventBase; } #region 如果目标节点是触发时机 //如果目标节点是触发时机,把拖动的节点放到这个触发时机的最后面 //需要调用一次EventCollection.Down方法,同步事件序列的顺序 //并把拖动的事件的触发时机修改为目标节点同样的触发时机 if (dropNode.GetType().Equals(typeof(EventTimeTreeNode))) { //直接调用基类方法完成节点移动 base.MoveNode(dragNode, dropNode); //同步触发事件顺序 //拿到dragNode的前一个节点(如果有),调用一次Down方法 //改变触发时机 EventTimeTreeNode eventTimeNode = dragNode.Parent as EventTimeTreeNode; node.Event.EventTime = eventTimeNode.EventTime.Code; //确保拖动的事件在事件序列中处于当前触发时机中所有事件的最后 EventTreeNode eventNode = dragNode.PrevNode as EventTreeNode; if (eventNode != null) { this.EventSupport.Events.NextTo(node.Event, eventNode.Event); } } #endregion #region 如果目标节点是事件 //如果目标节点是事件,把拖动的事件放到这个事件的前面,需调用Up方法同步事件顺序 //并把拖动的事件的触发时机修改为目标节点同样的触发时机 else if (dropNode.GetType().Equals(typeof(EventTreeNode))) { //如果放在拖动节点的同级下一个节点,do nothing if (dropNode.NextNode == dragNode) { return; } //移动树节点 // Remove drag node from parent dragNode.Parent.Nodes.Remove(dragNode); // Add drag node to drop node dropNode.Parent.Nodes.Insert(dropNode.Index + 1, dragNode); EventTreeNode prevNode = dragNode.PrevNode as EventTreeNode; //改变触发时机 node.Event.EventTime = prevNode.Event.EventTime; //nextNode不可能为null,就是dragNode this.EventSupport.Events.NextTo(node.Event, prevNode.Event); } #endregion if (EventOrderChanged != null) { CollectionEditEventArgs args0 = new CollectionEditEventArgs(this.EventSupport.Events, CollectionEditType.Edit, this.EventSupport.Events.IndexOf(node.Event), node.Event); args0.Members.Inject(ObjectCompare.Compare(oldEvent, node.Event)); eventArgs[0] = args0; eventArgs[1] = new CollectionEditEventArgs(this.EventSupport.Events, CollectionEditType.Move, this.EventSupport.Events.IndexOf(node.Event), nodeOldIndex, node.Event); EventOrderChanged(eventArgs); } }
Compare() { m_compareObjs = new ObjectCompare(m_obj1, m_obj2); PopulateListView(); }