Ejemplo n.º 1
0
 //holding in a form such as List <EDOID>, not as List<string>, makes it possible to identify whether the ID of any part. It would be easier to debug.
 private static void CollectIds(IIDPropertiesProvider obj, List <string> ids)
 {
     foreach (string propertyName in obj.IdProperties)
     {
         string id = (string)PropertyPathHelper.GetValue(obj, propertyName);
         ids.Add(id);
     }
 }
Ejemplo n.º 2
0
        protected long GetNumericMember(object item)
        {
            if (item is FlagControlItem == true)
            {
                return((item as FlagControlItem).Value);
            }

            var value = PropertyPathHelper.GetValue(item, this.NumericMemberPath);

            return(Convert.ToInt64(value));
        }
Ejemplo n.º 3
0
        public void Filter(string text)
        {
            string lowerText = text.ToLower();

            objects.Clear();
            foreach (T obj in allObjects)
            {
                string objValue = (string)PropertyPathHelper.GetValue(obj, DisplayMemberPath) as string;
                if (string.IsNullOrEmpty(lowerText) || (objValue != null && objValue.ToLower().Contains(lowerText)))
                {
                    objects.Add(obj);
                }
            }
        }
Ejemplo n.º 4
0
        private static RenameResult RenameId(IIDPropertiesProvider obj, string propertyName, List <string> ids)
        {
            RenameResult result = new RenameResult(propertyName);
            string       id     = (string)PropertyPathHelper.GetValue(obj, propertyName);

            if (ids.Contains(id))
            {
                string newId = IDUtils.NewGuid();
                PropertyPathHelper.SetValue(obj, propertyName, newId);
                result.OldId = id;
                result.NewId = newId;
                return(result);
            }
            return(result);
        }
Ejemplo n.º 5
0
        private string GetDisplayMember(object item)
        {
            string text = string.Empty;

            if (item is ContentControl)
            {
                text = (item as ContentControl).Content.ToString();
            }
            else
            {
                text = PropertyPathHelper.GetValue(item, this.DisplayMemberPath).ToString();
            }

            if (text.IndexOf(' ') >= 0)
            {
                return("\"" + text + "\"");
            }

            return(text);
        }
Ejemplo n.º 6
0
        protected override void OnAttached()
        {
            base.OnAttached();

            AssociatedObject.SelectionChanged += (s, e) =>
            {
                if (e.AddedItems.Count > 0)
                {
                    if (previousSelection == null)
                    {
                        previousSelection = AssociatedObject.SelectedItem;
                        if (defaultValue == null)
                        {
                            var binding = GetBinding();
                            Debug.Assert(binding != null, "Cannot find ItemsSource binding. Did you configure it in the target Listbox?");
                            if (binding == null)
                            {
                                return;
                            }
                            defaultValue = PropertyPathHelper.GetValue(binding.ResolvedSource, binding.ResolvedSourcePropertyName);
                        }
                        var list = AssociatedObject.ItemsSource as IList;
                        Debug.Assert(list != null, "ItemsSource data source is not an IList, cannot change it.");
                        if (list == null)
                        {
                            return;
                        }
                        try
                        {
                            list.Insert(0, defaultValue);
                        }
                        catch (Exception ex)
                        {
#if DEBUG
                            throw ex;
#else
                            VsOutputLogger.WriteLine(String.Format(CultureInfo.CurrentCulture, "Could not add default empty item to the bound ItemsSource data source - the collection does not allow insertion (or the type does not match). {0}", ex));
#endif
                        }
                    }
                    else if (AssociatedObject.SelectedIndex == 0)
                    {
                        var list = AssociatedObject.ItemsSource as IList;
                        Debug.Assert(list != null, "ItemsSource data source is not an IList, cannot change it.");
                        Debug.Assert(list.Count > 0, "ItemsSource data source is empty, something went wrong.");
                        if (list == null || list.Count == 0)
                        {
                            return;
                        }
                        if (list[0] == defaultValue)
                        {
                            list.RemoveAt(0);
                        }
                    }
                }
                if (e.RemovedItems.Count > 0)
                {
                    if (e.RemovedItems[0] == defaultValue)
                    {
                        previousSelection             = null;
                        AssociatedObject.SelectedItem = null;
                    }
                }
            };
        }
Ejemplo n.º 7
0
 private object GetCommentMember(object item)
 {
     return(PropertyPathHelper.GetValue(item, this.CommentMemberPath));
 }