Esempio n. 1
0
        public override void UpdateParent(string propertyName, IDataObject parentObj)
        {
            switch (propertyName)
            {
            case "Owner":
            {
                var __oldValue = (Zetbox.App.Base.IdentityNHibernateImpl)OurContext.AttachAndWrap(this.Proxy.Owner);
                var __newValue = (Zetbox.App.Base.IdentityNHibernateImpl)parentObj;
                NotifyPropertyChanging("Owner", __oldValue, __newValue);
                this.Proxy.Owner = __newValue == null ? null : __newValue.Proxy;
                NotifyPropertyChanged("Owner", __oldValue, __newValue);
            }
            break;

            case "Type":
            {
                var __oldValue = (Zetbox.App.Base.ObjectClassNHibernateImpl)OurContext.AttachAndWrap(this.Proxy.Type);
                var __newValue = (Zetbox.App.Base.ObjectClassNHibernateImpl)parentObj;
                NotifyPropertyChanging("Type", __oldValue, __newValue);
                this.Proxy.Type = __newValue == null ? null : __newValue.Proxy;
                NotifyPropertyChanged("Type", __oldValue, __newValue);
            }
            break;

            default:
                base.UpdateParent(propertyName, parentObj);
                break;
            }
        }
Esempio n. 2
0
        public override void ReloadReferences()
        {
            // Do not reload references if the current object has been deleted.
            // TODO: enable when MemoryContext uses MemoryDataObjects
            //if (this.ObjectState == DataObjectState.Deleted) return;
            base.ReloadReferences();

            // fix direct object references

            if (_fk_Owner.HasValue)
            {
                this.Owner = ((Zetbox.App.Base.IdentityNHibernateImpl)OurContext.FindPersistenceObject <Zetbox.App.Base.Identity>(_fk_Owner.Value));
            }
            else
            {
                this.Owner = null;
            }

            if (_fk_guid_Type.HasValue)
            {
                this.Type = ((Zetbox.App.Base.ObjectClassNHibernateImpl)OurContext.FindPersistenceObject <Zetbox.App.Base.ObjectClass>(_fk_guid_Type.Value));
            }
            else
            if (_fk_Type.HasValue)
            {
                this.Type = ((Zetbox.App.Base.ObjectClassNHibernateImpl)OurContext.FindPersistenceObject <Zetbox.App.Base.ObjectClass>(_fk_Type.Value));
            }
            else
            {
                this.Type = null;
            }
        }
Esempio n. 3
0
 public virtual void PrepareDefault(Zetbox.App.Base.ObjectClass cls)
 {
     // base.PrepareDefault();
     if (OnPrepareDefault_Template != null)
     {
         OnPrepareDefault_Template(this, cls);
     }
     else
     {
         throw new NotImplementedException("No handler registered on method Template.PrepareDefault");
     }
 }
Esempio n. 4
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!_initialized)
            {
                return(Binding.DoNothing);
            }
            try
            {
                Zetbox.App.GUI.Icon icon = null;
                if (value is Zetbox.App.Base.ObjectClass)
                {
                    Zetbox.App.Base.ObjectClass objClass = (Zetbox.App.Base.ObjectClass)value;
                    icon = objClass.DefaultIcon;
                }
                else if (value is Zetbox.App.GUI.Icon)
                {
                    icon = (Zetbox.App.GUI.Icon)value;
                }
                else if (value is IDataObject)
                {
                    IDataObject obj = (IDataObject)value;
                    icon = obj.GetObjectClass(FrozenContext).DefaultIcon;
                }
                else if (value is Zetbox.Client.Presentables.ViewModel)
                {
                    icon = ((Zetbox.Client.Presentables.ViewModel)value).Icon;
                }

                if (icon == null)
                {
                    return(Binding.DoNothing);
                }
                else
                {
                    // Not initialized yet
                    if (icon.ObjectState == DataObjectState.New)
                    {
                        return(Binding.DoNothing);
                    }

                    BitmapImage bmp;
                    if (!_cache.TryGetValue(icon.ExportGuid, out bmp))
                    {
                        var realIcon = Context.FindPersistenceObject <Zetbox.App.GUI.Icon>(icon.ExportGuid);
                        if (realIcon.Blob == null)
                        {
                            Logging.Log.WarnFormat("Icon#{0} has no associated request", realIcon.ID);
                            return(Binding.DoNothing);
                        }
                        bmp = new BitmapImage();
                        bmp.BeginInit();
                        bmp.StreamSource = realIcon.Blob.GetStream();
                        bmp.EndInit();
                        _cache[icon.ExportGuid] = bmp;
                    }
                    return(bmp);
                }
            }
            catch (Exception ex)
            {
                Logging.Facade.Info("Error while loading Icon", ex);
                return(Binding.DoNothing);
            }
        }