コード例 #1
0
 /// <summary>
 /// Disconnects on adaptors OnTargetChange
 /// </summary>
 public void Disconnect()
 {
     if (dataCache != null)
     {
         dataCache.Disconnect();
     }
     dataCache = null;
     if (controlCache != null)
     {
         controlCache.Disconnect();
     }
     controlCache = null;
     if (IsSubItem == true)
     {
         MasterItem.Submappings.RemoveMapping(this);
     }
     else
     if (submappings != null)
     {
         submappings.Disconnect();
     }
     submappings = null;
     masterItem  = null;
     if (Adaptor != null)
     {
         Adaptor.TargetChanged -= TargetChanged;
         adaptor.Target         = null;
     }
     adaptor = null;
 }
コード例 #2
0
        /// <summary>
        /// Creates Mapped property
        /// </summary>
        /// <param name="aMasterItem">
        /// Master item <see cref="MappedProperty"/>
        /// </param>
        /// <param name="aItem">
        /// Item <see cref="SMappedItem"/>
        /// </param>
        public MappedProperty(MappedProperty aMasterItem, SMappedItem aItem)
        {
            if (aMasterItem == null)
            {
                throw new ExceptionMasterItemIsNull();
            }
            masterItem = aMasterItem;
            isSubItem  = true;
            adaptor    = new WeakReference(masterItem.Adaptor);

/*			if (Adaptor.IsBoundaryAdaptor == true)
 *                              throw new Exception ("You can't set Boundary Mapping to non-Boundary adaptor >> Name=" + aItem.Name + " Target=" + aItem.MappedItem);*/
            Name = aItem.Name;
            BoundingClassName = aItem.ClassName;
            mappingTarget     = aItem.MappedItem;
            originalRWFlags   = aItem.RWFlags;
            RWFlags           = aItem.RWFlags;
//			aMasterItem.Submappings.AddMapping(this);
        }
コード例 #3
0
        /// <summary>
        /// Removes submapping from the original mapping, accessible trough Submappings
        /// </summary>
        public void RemoveMapping(MappedProperty aProp)
        {
            if ((aProp == null) || (submappings == null))
            {
                return;
            }
            int  pos    = -1;
            bool exists = false;

            for (int i = 0; i < submappings.Length; i++)
            {
                if (submappings[i] == aProp)
                {
                    exists = true;
                    pos    = i;
                    break;
                }
            }
            if (exists == true)
            {
                if (submappings.Length == 1)
                {
                    submappings[0] = null;
                    submappings    = null;
                    return;
                }

                object[] nsub = new object [submappings.Length];
                int      j    = 0;
                for (int i = 0; i < submappings.Length; i++)
                {
                    if (i != pos)
                    {
                        nsub[j] = submappings[i];
                        j++;
                    }
                }
                (submappings[pos] as MappedProperty).Disconnect();
                FastDisconnect();
                submappings = nsub;
            }
        }
コード例 #4
0
		/// <summary>
		/// Adds submapping to the original mapping, accessible trough Submappings
		/// </summary>
		public void AddMapping (MappedProperty aProp)
		{
			if (Size == 0) {
				object[] nsub;
				if (submappings == null) {
					nsub = new object [1];
				}
				else {
					nsub = new object [submappings.Length];
					submappings.CopyTo(nsub, 0);
				}
				nsub[nsub.Length-1] = aProp;
				FastDisconnect();
				submappings = nsub;
			}
			else {
				submappings[bpos] = aProp;
				bpos++;
			}
		}
コード例 #5
0
 /// <summary>
 /// Adds submapping to the original mapping, accessible trough Submappings
 /// </summary>
 public void AddMapping(MappedProperty aProp)
 {
     if (Size == 0)
     {
         object[] nsub;
         if (submappings == null)
         {
             nsub = new object [1];
         }
         else
         {
             nsub = new object [submappings.Length];
             submappings.CopyTo(nsub, 0);
         }
         nsub[nsub.Length - 1] = aProp;
         FastDisconnect();
         submappings = nsub;
     }
     else
     {
         submappings[bpos] = aProp;
         bpos++;
     }
 }
コード例 #6
0
		/// <summary>
		/// Removes submapping from the original mapping, accessible trough Submappings
		/// </summary>
		public void RemoveMapping (MappedProperty aProp)
		{
			if ((aProp == null) || (submappings == null))
				return;
			int pos = -1;
			bool exists = false;
			for (int i=0; i<submappings.Length; i++)
				if (submappings[i] == aProp) {
					exists = true;
					pos = i;
					break;
				}
			if (exists == true) {
				if (submappings.Length == 1) {
					submappings[0] = null;
					submappings = null;
					return;
				}
				
				object[] nsub = new object [submappings.Length];
				int j = 0;
				for (int i=0; i<submappings.Length; i++)
					if (i != pos) {
						nsub[j] = submappings[i];
						j++;
					}
				(submappings[pos] as MappedProperty).Disconnect();
				FastDisconnect();
				submappings = nsub;
			}
		}
コード例 #7
0
		/// <summary>
		/// Disconnects on adaptors OnTargetChange
		/// </summary>
		public void Disconnect()
		{
			if (dataCache != null)
				dataCache.Disconnect();
			dataCache = null;
			if (controlCache != null)
				controlCache.Disconnect();
			controlCache = null;
			if (IsSubItem == true)
				MasterItem.Submappings.RemoveMapping (this);
			else
				if (submappings != null)
					submappings.Disconnect();
			submappings = null;
			masterItem = null;
			if (Adaptor != null)
			{
				Adaptor.TargetChanged -= TargetChanged;
				adaptor.Target = null;
			}
			adaptor = null;
		}
コード例 #8
0
		/// <summary>
		/// Creates Mapped property
		/// </summary>
		/// <param name="aMasterItem">
		/// Master item <see cref="MappedProperty"/>
		/// </param>
		/// <param name="aItem">
		/// Item <see cref="SMappedItem"/>
		/// </param>
		public MappedProperty (MappedProperty aMasterItem, SMappedItem aItem)
		{
			if (aMasterItem == null)
				throw new ExceptionMasterItemIsNull();
			masterItem = aMasterItem;
			isSubItem = true;
			adaptor = new WeakReference (masterItem.Adaptor);
/*			if (Adaptor.IsBoundaryAdaptor == true)
				throw new Exception ("You can't set Boundary Mapping to non-Boundary adaptor >> Name=" + aItem.Name + " Target=" + aItem.MappedItem);*/ 
			Name = aItem.Name;
			BoundingClassName = aItem.ClassName;
			mappingTarget = aItem.MappedItem;
			originalRWFlags = aItem.RWFlags;
			RWFlags = aItem.RWFlags;
//			aMasterItem.Submappings.AddMapping(this);
		}
コード例 #9
0
        /// <summary>
        /// Обновляет данные виджета
        /// </summary>
        private void ResetLayout()
        {
            onInit = true;
            comboListStore.Clear ();

            if (ItemsDataSource == null)
                return;

            if (ItemsDataSource is IEnumerable == false)
                throw new NotSupportedException (string.Format("ItemsDataSource only supports IEnumerable types, specified was {0}", ItemsDataSource));

            //Заполняем специальные поля
            if(ShowSpecialStateAll)
            {
                AppendEnumItem (typeof(SpecialComboState).GetField ("All"));
            }
            if(ShowSpecialStateNot)
            {
                AppendEnumItem (typeof(SpecialComboState).GetField ("Not"));
            }

            if (String.IsNullOrWhiteSpace (ColumnMappings) && ItemsDataSource is IList)
            {
                var list = ItemsDataSource as IList;
                if(list.Count > 0)
                {
                    var example = list [0];
                    if (example.GetType ().GetProperty ("Name") != null)
                        columnMappings = "Name";
                    if (example.GetType ().GetProperty ("Title") != null)
                        columnMappings = "Title";
                }
            }

            if (String.IsNullOrWhiteSpace (ColumnMappings))
            {
                logger.Warn ("Свойство ColumnMappings пустое, заполение комбобокса {0} пропущено.", Name);
                onInit = false;
                return;
            }

            //FIXME Временное решение, нужно сделать через биндинг
            Adaptor tempAdaptor = new Adaptor ();
            MappedProperty mp = new MappedProperty (tempAdaptor, columnMappings);
            foreach (object subject in (ItemsDataSource as IEnumerable)) {
                tempAdaptor.Target = subject;
                comboListStore.AppendValues (mp.Value, subject);
            }

            if (ShowSpecialStateAll || ShowSpecialStateNot)
                Active = 0;
            onInit = false;
        }