/// <summary>
        /// Add a validation item context to a proper group
        /// </summary>
        /// <param name="itemContext"></param>
        private ValidationGroupContext AddToGroup(ValidationItemContextBase itemContext)
        {
            IValidationItem item = itemContext.ValidationItem;

            string groupName = null;

            //if (this.DisplayConfig.IsByDeviceType)
            groupName = item.DeviceType;
            //else
            //    groupName = item.Category;

            ValidationGroupContext group;

            if (!groupNameToContext.TryGetValue(groupName, out group))
            {
                group = new ValidationGroupContext(groupName);
                groupNameToContext.Add(groupName, group);

                group.IsExpandedChanged += new EventHandler(group_IsExpandedChanged);

                this.ValidationGroups.Add(group);
            }

            if (group.ValidationResultItems.Contains(itemContext) == false)
            {
                group.ValidationResultItems.Add(itemContext);
            }

            if (this.validationItem2ItemGroupViewModel.ContainsKey(item) == false)
            {
                this.validationItem2ItemGroupViewModel.Add(item, group);
            }

            return(group);
        }
        /// <summary>
        /// select the facility that owns the specified item;
        /// if item == null, it means to unselect all facilities
        /// </summary>
        public void OnItemClicked(ValidationItemContextBase item)
        {
            //this.clickedItem = item;

            //if (this.ValidationGroups == null)
            //    return;

            //foreach (ValidationGroupContext group in this.ValidationGroups)
            //{
            //    if (group.ValidationResultItems == null)
            //    {
            //        Debug.Assert(false);
            //        continue;
            //    }

            //    foreach (ValidationItemContextBase cxt in group.ValidationResultItems)
            //    {
            //        if (cxt == null)
            //            continue;

            //        if (item == null)
            //        {
            //            cxt.SetStatus(ItemStatus.Normal);
            //        }
            //        else if ((item.ValidationItem != null) &&
            //            (cxt.ValidationItem != null) &&
            //            (cxt.ValidationItem.FeatureFID == item.ValidationItem.FeatureFID))
            //        {
            //            if (cxt != item)
            //                cxt.SetStatus(ItemStatus.DeviceSelected);
            //            else
            //                cxt.SetStatus(ItemStatus.PrimarySelected);
            //        }
            //        else
            //        {
            //            cxt.SetStatus(ItemStatus.Normal);
            //        }
            //    }
            //}

            ////This is a special fix, in case the clicked item has no geometry. (Bug number: 14682)
            ////oldSelectedFids is a cache, telling us which fids were already selected on drawing, so that
            ////  if selection on drawing is not changed when ACAD says selection is changed, we don't update
            ////  validation item status;
            ////We need this cache, because you can click on a same validation items many times, and each
            ////  time ACAD will throw a selection changed event, though selection doesn't change at all.
            ////Now, as we already reset validation item status above, the cache becomes expired, because
            ////  validation item status are not consistent with selected Fids anymore
            //if (this.oldSelectedFids != null)
            //    this.oldSelectedFids.Clear();

            //this.SelectFeature(item);
        }
예제 #3
0
        static void OnIsMouseHoveredChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ValidationItemContextBase cxt = sender as ValidationItemContextBase;

            if ((cxt == null) ||
                (cxt.ValidationItem == null))
            {
                return;
            }

            cxt.OnIsMouseHoveredChanged();
        }
        static void OnSelectedBorderChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            PromptResultControl itemCtrl = sender as PromptResultControl;

            if (itemCtrl == null)
            {
                return;
            }

            ValidationItemContextBase cxt = itemCtrl.DataContext as ValidationItemContextBase;

            if (cxt == null)
            {
                return;
            }

            cxt.ItemSelectedBorderBrush = args.NewValue as Brush;
        }
        void PromptResultControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                ValidationItemContextBase item = this.DataContext as ValidationItemContextBase;
                if (item == null)
                {
                    return;
                }

                item.UpdateResolutionsButtonVisibility();
                item.UpdateGoToRuleButtonVisibility();
            }
            finally
            {
                this.Loaded -= this.PromptResultControl_Loaded;
            }
        }
        //private void btnGoToRule_Click(object sender, RoutedEventArgs e)
        //{
        //    ValidationItemContext itemContext = this.DataContext as ValidationItemContext;

        //    if (itemContext == null)
        //    {
        //        Debug.Assert(false);
        //        return;
        //    }

        //    // End any active command and launch the Rule Editor.
        //    string command = string.Format("^C^C^C_AUDRULECONFIG {0}\n", itemContext.RulePointPath); //NOXLATE
        //    CommandHelper.ExecuteCommand(command, false);
        //}


        //private void btnIgnore_Click(object sender, RoutedEventArgs e)
        //{
        //    ValidationItemContextBase item = this.DataContext as ValidationItemContextBase;
        //    if (item == null)
        //        return;

        //    item.IgnoreClicked();
        //}


        public void OnMouseUp()
        {
            ValidationItemContextBase item = this.DataContext as ValidationItemContextBase;

            if (item == null)
            {
                Debug.Assert(false);
                return;
            }

            if (item.Owner == null)
            {
                return;
            }

            //if (!item.Owner.IsSelectingOn)
            //    return;

            item.Owner.OnItemClicked(item);
        }
예제 #7
0
        static void OnValidationItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ValidationItemContextBase cxt = sender as ValidationItemContextBase;

            if (cxt == null)
            {
                return;
            }

            cxt.FeatureIdentifier = String.Empty;
            if (args.NewValue != null)
            {
                IValidationItem validationItem = args.NewValue as IValidationItem;

                object o = validationItem.FeatureItem;
                if (o != null)
                {
                    cxt.FeatureIdentifier = o.ToString();
                }
            }
        }
        public void OnMouseHoverChanged(bool isInside)
        {
            ValidationItemContextBase item = this.DataContext as ValidationItemContextBase;

            if (item == null)
            {
                //maybe because of the item is ignored
                return;
            }

            if (item.Owner == null)
            {
                Debug.Assert(false);
                return;
            }

            //if (!item.Owner.IsSelectingOn)
            //    return;

            item.IsMouseHovered = isInside;
        }
        /// <summary>
        /// Validation item set changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void validationItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            Dictionary <string, ValidationGroupContext> affectedGroups = new Dictionary <string, ValidationGroupContext>();

            if (e.NewItems != null)
            {
                foreach (var obj in e.NewItems)
                {
                    IValidationItem item = obj as IValidationItem;
                    if (item == null)
                    {
                        continue;
                    }

                    ValidationGroupContext    group   = this.CreateValidationItemContext(item);
                    ValidationItemContextBase itemCxt = this.validationItem2ItemViewModel[item];
                    Debug.Assert(itemCxt != null);

                    int indexToInsert = -1;
                    if (!this.BindingList.Contains(group))
                    {
                        this.BindingList.Add(group);
                        if (group.IsExpanded)
                        {
                            indexToInsert = this.BindingList.IndexOf(group) + 1;
                        }
                    }
                    else
                    {
                        if (group.IsExpanded && itemCxt.IsVisible)
                        {
                            //note that when calling group.GetVisibleChildrenCount, itemCxt is already counted
                            indexToInsert = this.BindingList.IndexOf(group) + group.GetVisibleChildrenCount();
                        }
                    }

                    if ((indexToInsert >= 0) && itemCxt.IsVisible)
                    {
                        this.BindingList.Insert(indexToInsert, itemCxt);
                    }

                    if (affectedGroups.ContainsKey(group.SortingName) == false)
                    {
                        affectedGroups.Add(group.SortingName, group);
                    }
                }
            }

            bool toClearClickedItem = false;

            if (e.OldItems != null)
            {
                foreach (var obj in e.OldItems)
                {
                    IValidationItem item = obj as IValidationItem;
                    if (item == null)
                    {
                        continue;
                    }

                    //if ((this.clickedItem != null) &&
                    //    Object.ReferenceEquals(this.clickedItem.ValidationItem, item))
                    //{
                    //    toClearClickedItem = true;
                    //}

                    ValidationGroupContext group = this.validationItem2ItemGroupViewModel[item];
                    if (group == null)
                    {
                        continue;
                    }

                    ValidationItemContextBase itemCxt = this.validationItem2ItemViewModel[item];
                    if (itemCxt == null)
                    {
                        continue;
                    }

                    group.ValidationResultItems.Remove(itemCxt);
                    this.validationItem2ItemViewModel.Remove(item);
                    this.validationItem2ItemGroupViewModel.Remove(item);
                    if (this.BindingList.Contains(itemCxt))
                    {
                        this.BindingList.Remove(itemCxt);
                    }

                    if (affectedGroups.ContainsKey(group.SortingName) == false)
                    {
                        affectedGroups.Add(group.SortingName, group);
                    }
                }
            }

            foreach (var group in affectedGroups)
            {
                if (group.Value.ValidationResultItems.Count == 0)
                {
                    ValidationGroupContext groupCxt = group.Value;
                    this.RemoveGroup(groupCxt);
                }
                else
                {
                    group.Value.UpdateHeader();
                }
            }

            ValidationManager validationManager = this.ValidationManager;

            if (validationManager == null)
            {
                return;
            }

            //this.UpdateDisplayConfigSettings(validationManager.ValidationItemCount);

            //if (toClearClickedItem && (this.clickedItem != null))
            //    this.OnItemClicked(null);

            base.OnPropertyChanged("HasResolveItems");
        }