public NextVar(T value, BeforeDelegate <T> before, OnChangeDelegate <T> onChange, AfterDelegate <T> after) { val = value; BeforeChange = before; OnChange = onChange; AfterChange = after; }
public void RemoveAction(params OnChangeDelegate <T>[] actions) { for (int i = 0; i < actions.Length; i++) { OnChange -= actions[i]; } }
public void Bind(object source, PropertyInfo piSource, object destination, PropertyInfo piDest, IBinderConverter converter, SynchronizationContext applyBindingContext) { weakSrc = new WeakReference(source); weakDst = new WeakReference(destination); _Converter = converter; _PropNameSource = piSource.Name; _PropNameDest = piDest.Name; gethandler = GetSetUtils.CreateGetHandler <TValueSource>(piSource); //le set handler devrait être sur le type destination if (_Converter != null) { _CurrentChanged = OnValueChanged1; sethandlerDest = GetSetUtils.CreateSetHandler <TValueDest>(piDest); } else { _CurrentChanged = OnValueChanged; sethandler = GetSetUtils.CreateSetHandler <TValueSource>(piDest); } DataBinder.AddNotify <TValueSource>(source, piSource.Name, gethandler, _CurrentChanged, applyBindingContext); }
/// <summary> /// it for intermediate notifications, to rebind /// </summary> /// <param name="current">concerned object</param> /// <param name="pathitem">real property name</param> /// <param name="onchanged">delegate to call, when propertyname changed</param> private void AddNotify(object current, string pathitem, OnChangeDelegate <object> onchanged) { PropertyInfo pi = current.GetType().GetProperty(pathitem); GetHandlerDelegate <object> gethandler = GetSetUtils.CreateGetHandler <object>(pi); DataBinder.AddNotify <object>(current, pathitem, gethandler, onchanged, null); }
public BasicState(int i, object eVal, string eName) { idx = i; OnEnter = null; OnExit = null; CanEnter = DefaultEnter; enumValue = eVal; enumName = eName; }
public void AddAction(OnChangeDelegate <T> action, bool executeNow) { OnChange += action; if (executeNow) { action(val, val); } }
public void AddChangeListener(OnChangeDelegate deleg) { if (OnChange == null) { OnChange = deleg; } else { OnChange += deleg; } }
public NextVar(T value, OnChangeDelegate <T> onChange) { val = value; OnChange = onChange; }
public OneNotify(GetHandlerDelegate <T> getter, OnChangeDelegate <T> onchanged) { _OnGet = getter; _OnChanged = onchanged; }
public void OnChange(OnChangeDelegate onChangeDelegate) { this.onChangeDelegate = onChangeDelegate; }
/** * Adds a change callback */ public static void AddChangeCallback(OnChangeDelegate callback) { GetInstance().changeCallbacks.Add(callback); }
/// <summary> /// gestion de la notification sur INotifyPropertyChanged /// </summary> /// <typeparam name="T">type de la propriété observée</typeparam> /// <param name="source">source</param> /// <param name="propName">property à observer</param> /// <param name="gethandler">"get" a appeler a chaque changements</param> /// <param name="OnValueChange">la déléguée à appelée après chaque changed de la source</param> internal static void AddNotify <T>(object source, string propName, GetHandlerDelegate <T> gethandler, OnChangeDelegate <T> OnValueChange, SynchronizationContext applyBindingContext) { INotifyPropertyChanged inotify = source as INotifyPropertyChanged; if (inotify != null) { EqualityWeakReference weak = new EqualityWeakReference(inotify); //le but est ici de ne s'abonner qu'une fois Dictionary <string, IOneNotify> dico = null; if (!_SourceChanged.TryGetValue(weak, out dico)) { dico = new Dictionary <string, IOneNotify>(); _SourceChanged.Add(weak, dico); inotify.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { //je minimise le nombre de get, en founissant la valeur qui à changé if (dico.ContainsKey(e.PropertyName)) { dico[e.PropertyName].Fire(weak); } }; } ///plusieurs abonnement si nécessaire pour une propriété binding de 1 prop vers plusieurs dest OneNotify <T> binding = null; if (dico.ContainsKey(propName)) { binding = (OneNotify <T>)dico[propName]; binding._OnChanged = (OnChangeDelegate <T>)Delegate.Combine(binding._OnChanged, OnValueChange); } else { binding = new OneNotify <T>(gethandler, OnValueChange); binding._ApplyBindingContext = applyBindingContext; binding.PropertyName = propName; dico[propName] = binding; } } else if (source != null) { //try with old mode "PropertyName"Changed event string eventName = string.Format("{0}Changed", propName); EventInfo evInfo = source.GetType().GetEvent(eventName); if (evInfo != null) { EqualityWeakReference weak = new EqualityWeakReference(source); //le but est ici de ne s'abonner qu'une fois Dictionary <string, IOneNotify> dico = null; if (!_SourceChanged.TryGetValue(weak, out dico)) { dico = new Dictionary <string, IOneNotify>(); _SourceChanged.Add(weak, dico); } ///plusieurs abonnement si nécessaire pour une propriété binding de 1 prop vers plusieurs dest OneNotify <T> binding = null; if (dico.ContainsKey(propName)) { binding = (OneNotify <T>)dico[propName]; binding._OnChanged = (OnChangeDelegate <T>)Delegate.Combine(binding._OnChanged, OnValueChange); } else { binding = new OneNotify <T>(gethandler, OnValueChange); binding.PropertyName = propName; binding._ApplyBindingContext = applyBindingContext; binding._PropertyChangedEvent = delegate { binding.Fire(weak); }; dico[propName] = binding; evInfo.AddEventHandler(source, binding._PropertyChangedEvent); } } } }
public NextVar(T value, BeforeDelegate <T> before, OnChangeDelegate <T> onChange) { val = value; BeforeChange = before; OnChange = onChange; }
public void BindPropertyPath(object source, int index) { if (source == null) { return; } PathItem pathitem = _Items[index]; bool isArray = pathitem.IsArray; PropertyInfo pi = source.GetType().GetProperty(pathitem.PropertyName); if (pi == null) { CheckPropertyInfo(true, _PropertyPath, pathitem.PropertyName, source.GetType()); } if (index == _Items.Count - 1) { pathitem.Source = new EqualityWeakReference(source); if (_OnfinalBind != null) { _OnfinalBind(index, pi, source); } pathitem.IsBind = true; if (pathitem.IsArray && _factory != null) { OnChangeDelegate <object> onchanged = delegate(object value) { if (pathitem.Source.IsAlive) { object target = pathitem.Source.Target; RemoveNotify(index); BindPropertyPath(target, index); } }; pathitem.OnChanged = onchanged; //Add notification on source changed AddNotify(source, pathitem.PropertyName, onchanged); } } else { EqualityWeakReference weakSource = new EqualityWeakReference(source); int currentIndex = index + 1; OnChangeDelegate <object> onchanged = null; if (_factory != null) { onchanged = _factory(currentIndex, weakSource); } pathitem.Source = weakSource; pathitem.OnChanged = onchanged; pathitem.IsBind = true; //Add notification on source changed AddNotify(source, pathitem.PropertyName, onchanged); source = pi.GetValue(source, null); if (isArray) { source = BindToArray(source, currentIndex, pathitem); } BindPropertyPath(source, currentIndex); } }
protected override void Dispose(bool disposing) { if (this.m_TouchScrollingTimer != null) { this.m_TouchScrollingTimer.Dispose(); this.m_TouchScrollingTimer = null; } if (this.m_dbConnector != null) { this.m_dbConnector.Dispose(); this.m_dbConnector = null; } if (this.m_rcRows != null) { this.m_rcRows.Parent = null; } this.m_rcRows = null; if (this.m_tsCurrent != null) { this.m_tsCurrent.Changed -= new GridEventHandler(this.OnChange); this.m_tsCurrent.Parent = null; } this.m_tsCurrent = null; BackBufferManager.Release(); if (this.m_alLinks != null) { this.m_alLinks.Clear(); } this.m_alLinks = null; if (this.m_alTooltips != null) { this.m_alTooltips.Clear(); } this.m_alTooltips = null; if (this.m_alButtons != null) { this.m_alButtons.Clear(); } this.m_alButtons = null; Utility.Dispose(); Resco.Controls.AdvancedList.Mapping.DisposeEmptyMapping(); RowTemplate.DisposeDefaultRowTemplate(); ImageCache.GlobalCache.Clear(); if (sBrushes != null) { sBrushes.Clear(); } sBrushes = null; this.RemoveActiveHandlers(); if (this.m_rHeader != null) { this.m_rHeader.Parent = null; } this.m_rHeader = null; if (this.m_rFooter != null) { this.m_rFooter.Parent = null; } this.m_rFooter = null; this.OnChangeHandler = null; this.OnRowRemovedHandler = null; if (this.m_gradientBackColor != null) { this.m_gradientBackColor.PropertyChanged -= new EventHandler(this.m_gradientBackColor_PropertyChanged); } this.m_gradientBackColor = null; if (sPen != null) { sPen.Dispose(); } sPen = null; if (sPixel != null) { sPixel.Dispose(); } sPixel = null; GC.Collect(); base.Dispose(disposing); }
public AdvancedList() { this.OnChangeHandler = new OnChangeDelegate(this.OnChangeSafe); this.OnRowRemovedHandler = new OnRowRemovedDelegate(this.OnRowRemovedSafe); this.m_templateIndex = 0; this.m_selectedTemplateIndex = 0; this.m_activeTemplateIndex = -1; this.m_alternateTemplateIndex = -1; this.m_dbConnector = new Resco.Controls.AdvancedList.DataConnector(); this.m_connector = this.m_dbConnector; this.m_rcRows = new RowCollection(this); this.m_rcRows.Changed += new GridEventHandler(this.OnChange); this.m_tsCurrent = new TemplateSet(); this.m_tsCurrent.Parent = this; this.m_tsCurrent.Changed += new GridEventHandler(this.OnChange); BackBufferManager.AddRef(); this.m_colorKey = Color.FromArgb(0xff, 0, 0xff); this.m_brushKey = new SolidBrush(this.m_colorKey); this.m_imgAttr = new ImageAttributes(); this.m_imgAttr.SetColorKey(this.m_colorKey, this.m_colorKey); base.BackColor = SystemColors.ControlDark; this.m_BackColor = new SolidBrush(this.BackColor); this.m_vScrollWidth = 0; this.m_iScrollWidth = 13; this.ButtonClick = null; this.LinkClick = null; this.CellClick = null; this.RowSelect = null; this.HeaderClick = null; this.ActiveRowChanged = null; this.Scroll = null; this.m_rHeader = new Resco.Controls.AdvancedList.HeaderRow(); this.m_rHeader.Parent = this.m_rcRows; this.m_rFooter = new Resco.Controls.AdvancedList.HeaderRow(); this.m_rFooter.Parent = this.m_rcRows; this.m_iActualRowIndex = 0; this.m_iTopmostRowOffset = 0; this.m_iDocumentHeight = 0; this.m_iExpectedRows = -1; this.m_iVScrollPrevValue = 0; this.m_toolTipType = Resco.Controls.AdvancedList.ToolTipType.Triangle; using (Graphics graphics = base.CreateGraphics()) { TooltipWidth = (int) (DefaultTooltipWidth * (graphics.DpiX / 96f)); point1 = new Point(0, 0); point2 = new Point(0, -TooltipWidth); point3 = new Point(-TooltipWidth, 0); this.m_ToolTip = null; this.m_scaleFactorY = graphics.DpiY / 96f; } this.m_Timer = new Timer(); this.m_Timer.Enabled = false; this.m_Timer.Interval = 500; this.m_Timer.Tick += new EventHandler(this.OnTimerTick); this.m_bShowingToolTip = false; this.m_iSelectedCellIndex = -1; this.m_TouchScrollingTimer = new Timer(); this.m_TouchScrollingTimer.Enabled = false; this.m_TouchScrollingTimer.Interval = 50; this.m_TouchScrollingTimer.Tick += new EventHandler(this.OnTouchScrollingTimerTick); this.m_bStartingTouchScroll = false; this.m_bEnableTouchScrolling = false; this.m_TouchAutoScrollDiff = 0; this.m_touchSensitivity = 8; this.m_touchScrollDirection = Resco.Controls.AdvancedList.TouchScrollDirection.Inverse; this.m_nRowsLoaded = 0; this.m_nRowsInserted = 0; this.m_bFocusOnClick = false; this.m_gradientBackColor = new GradientColor(FillDirection.Horizontal); this.m_gradientBackColor.PropertyChanged += new EventHandler(this.m_gradientBackColor_PropertyChanged); }
public AdvancedComboBox() { this.OnChangeHandler = new OnChangeDelegate(this.OnChangeSafe); this.OnItemRemovedHandler = new OnItemRemovedDelegate(this.OnItemRemovedSafe); base.AutoScroll = false; base.Size = new Size(100, 0x12); this.m_dbConnector = new Resco.Controls.AdvancedComboBox.DataConnector(); this.m_connector = this.m_dbConnector; this.m_bKeyNavigation = true; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.m_list = new AdvancedList(this); this.m_list.Capture = false; this.m_list.Visible = false; this.m_list.TouchScrolling = false; this.m_list.BorderStyle = this.BorderStyle;//.set_BorderStyle(this.BorderStyle); this.m_list.Size = new Size(0, 0); this.m_list.ItemSelect += new ItemEventHandler(this.OnItemSelect); this.m_list.Changed += new ComboBoxEventHandler(this.OnChange); this.SelectedIndexChanged = null; this.SelectedValueChanged = null; this.ValueMemberChanged = null; this.DisplayMemberChanged = null; this.m_items = new ItemCollection(this); this.m_items.Changed += new ComboBoxEventHandler(this.OnChange); this.m_iExpectedItems = -1; this.m_nItemsLoaded = 0; this.m_nItemsInserted = 0; this.m_selectedItemIndex = -1; this.m_iSelectedCellIndex = -1; this.m_valueMember = ""; this.m_displayMember = ""; this.m_tsCurrent = new TemplateSet(); this.m_tsCurrent.Parent = this; this.m_tsCurrent.Changed += new ComboBoxEventHandler(this.OnChange); this.m_textBoxTemplateIndex = 0; this.m_templateIndex = 0; this.m_selectedTemplateIndex = 0; this.m_alternateTemplateIndex = -1; this.m_grBackBuffer = null; this.m_backBuffer = null; this.m_colorKey = Color.FromArgb(0xff, 0, 0xff); this.m_brushKey = new SolidBrush(this.m_colorKey); this.m_imgAttr = new ImageAttributes(); this.m_imgAttr.SetColorKey(this.m_colorKey, this.m_colorKey); this.UpdateDoubleBuffering(); base.BackColor = SystemColors.ControlLight; this.m_BackColor = new SolidBrush(this.BackColor); this.m_Timer = new Timer(); this.m_Timer.Enabled = false; this.m_Timer.Interval = 500; this.m_Timer.Tick += new EventHandler(this.OnTimerTick); this.m_bShowingToolTip = false; point1 = new Point(0, 0); point2 = new Point(0, -TooltipWidth); point3 = new Point(-TooltipWidth, 0); this.CalculateTextBoxArea(); }
public NextVar(T value, AfterDelegate <T> after, OnChangeDelegate <T> onChange) { val = value; OnChange = onChange; AfterChange = after; }
public void Dispose() { _OnChanged = null; }