Exemple #1
0
        [Test] public void SimpleTest()
        {
            IResource email = _storage.NewResource("Email");

            _provider.SetProp(email.Id, _propSize, 100);

            IResourceList allEmails = _storage.GetAllResourcesLive("Email");

            allEmails.AttachPropertyProvider(_provider);

            Assert.IsTrue(allEmails.HasProp(_propSize));
            Assert.IsTrue(!allEmails.HasProp(_propSubject));

            Assert.AreEqual("100", allEmails.GetPropText(0, _propSize));
        }
Exemple #2
0
 private bool IsColumnEmpty(IResourceList resList, IResource res, int index)
 {
     int[] propIds = (int[])_mayBeEmptyPropIds [index];
     for (int j = 0; j < propIds.Length; j++)
     {
         if (resList.HasProp(res, propIds [j]))
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #3
0
        [Test] public void UnionTest()
        {
            IResource email = _storage.NewResource("Email");

            _provider.SetProp(email.Id, _propSize, 100);

            IResourceList allEmails = _storage.GetAllResourcesLive("Email");

            allEmails.AttachPropertyProvider(_provider);

            IResourceList allPersons = _storage.GetAllResourcesLive("Person");

            IResourceList unionList = allPersons.Union(allEmails);

            Assert.IsTrue(unionList.HasProp(_propSize));
            Assert.AreEqual("100", unionList.GetPropText(0, _propSize));
        }
Exemple #4
0
        protected override string GetItemText(object item, int width)
        {
            IResource res = (IResource)item;

            if (Core.State == CoreState.ShuttingDown)
            {
                return("");
            }

            string result = null;

            if (_propIds != null)
            {
                for (int i = 0; i < _propIds.Length; i++)
                {
                    int propID = _propIds [i];
                    if (_propToTextConverters != null && _propToTextConverters [i] != null)
                    {
                        if (res.HasProp(propID))
                        {
                            int widthInChars = 0;
                            if (OwnerControl != null && width > 0)
                            {
                                using (Graphics g = OwnerControl.CreateGraphics())
                                {
                                    widthInChars = width / OwnerControl.ControlPainter.MeasureText(g, "a", OwnerControl.Font).Width;
                                }
                            }

                            result = _propToTextConverters [i].GetPropertyText(res, propID, widthInChars);
                        }
                        else
                        {
                            result = null;
                        }
                    }
                    else if (propID == ResourceProps.DisplayName)
                    {
                        result = res.DisplayName;
                    }
                    else if (propID == ResourceProps.Type)
                    {
                        result = "";
                    }
                    else
                    {
                        if (_ownerList != null)
                        {
                            if (_ownerList.HasProp(res, propID))
                            {
                                result = _ownerList.GetPropText(res, propID);
                            }
                            else
                            {
                                result = null;
                            }
                        }
                        else
                        {
                            if (res.HasProp(propID))
                            {
                                result = res.GetPropText(propID);
                            }
                            else
                            {
                                result = null;
                            }
                        }
                    }
                    if (result != null)
                    {
                        break;
                    }
                }
            }
            if (result != null)
            {
                if (result.IndexOf('\n') >= 0)
                {
                    result = result.Replace('\n', ' ');
                }
                return(result);
            }
            return(String.Empty);
        }