/// <summary> /// Disconnects everything inside this class /// </summary> public virtual void Disconnect() { /* lastItems = null; UnsetDragFunctionality(); onListCellDescription = null; if (listadaptor != null) { listadaptor.OnListChanged -= DSChanged; listadaptor.OnElementAdded -= DSElementAdded; listadaptor.OnElementChanged -= DSElementChanged; listadaptor.OnElementRemoved -= DSElementRemoved; listadaptor.OnTargetChange -= ListTargetChanged; listadaptor.Disconnect(); listadaptor = null; }*/ if (CurrentSelection != null) { CurrentSelection.Disconnect(); currentSelection = null; } if (adaptor != null) { adaptor.Disconnect(); adaptor = null; } internalModel.Disconnect(); internalModel = null; // cachedItems = null; }
/// <summary> /// Called when ItemsDataSource changes /// </summary> /* private void ListTargetChanged (IAdaptor aAdaptor) { cachedItems = null; if (ItemsDataSource == null) CurrentSelection.Target = null; else { // if ((ItemsDataSource is IAdaptor) == false) // return; object check = ConnectionProvider.ResolveTargetForObject(ItemsDataSource); if (check != lastItems) { lastItems = check; check = ItemsDataSource; ItemsDataSource = null; ItemsDataSource = check; } } Adaptor.CheckControl(); }*/ /// <summary> /// Creates adaptors associated with this IconView /// </summary> internal virtual void CreateAdaptors() { // Allocate selection adaptor currentSelection = new GtkAdaptor(); // currentSelection.OnDataChange += SelectedObjectChanged; internalModel.ClearSelection += delegate() { if (CurrentSelection != null) CurrentSelection.Target = null; }; // Create and connect ListAdaptor with this TreeView /* listadaptor = new GtkListAdaptor(false, null, this, false); listadaptor.OnListChanged += DSChanged; listadaptor.OnElementAdded += DSElementAdded; listadaptor.OnElementChanged += DSElementChanged; listadaptor.OnElementRemoved += DSElementRemoved; listadaptor.OnTargetChange += ListTargetChanged;*/ // listadaptor.OnTargetChange += ItemsTargetChanged; // Create Adaptor adaptor = new GtkControlAdaptor (this, false); adaptor.DisableMappingsDataTransfer = true; internalModel.CheckControl += delegate() { if (adaptor != null) adaptor.CheckControl(); }; // columnadaptor = new GtkAdaptor(); }
/// <summary> /// Called when ItemsDataSource changes /// </summary> /* private void ListTargetChanged (IAdaptor aAdaptor) { cachedItems = null; if (ItemsDataSource == null) CurrentSelection.Target = null; else { // if ((ItemsDataSource is IAdaptor) == false) // return; object check = ConnectionProvider.ResolveTargetForObject(ItemsDataSource); if (check != lastItems) { lastItems = check; check = ItemsDataSource; ItemsDataSource = null; ItemsDataSource = check; } } Adaptor.CheckControl(); }*/ /// <summary> /// Creates adaptors associated with this IconView /// </summary> internal virtual void CreateAdaptors () { // Allocate selection adaptor currentSelection = new GtkAdaptor (); internalModel.ClearSelection += delegate() { if (CurrentSelection != null) CurrentSelection.Target = null; }; // Create Adaptor adaptor = new GtkControlAdaptor (this, false); adaptor.DisableMappingsDataTransfer = true; internalModel.CheckControl += delegate() { if (adaptor != null) adaptor.CheckControl (); }; }
/// <summary> /// Disconnects everything inside this class /// </summary> public virtual void Disconnect () { if (CurrentSelection != null) { CurrentSelection.Disconnect (); currentSelection = null; } if (adaptor != null) { adaptor.Disconnect (); adaptor = null; } internalModel.Disconnect (); internalModel = null; }
/// <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; }