/// <summary> /// Invoked when the value of the adjustable has changed. /// </summary> public virtual void AdjustmentValueChanged(AdjustmentEvent e) { Adjustable adj = e.Adjustable; int value = e.Value; ScrollPanePeer peer = (ScrollPanePeer)Scroller.Peer_Renamed; if (peer != null) { peer.SetValue(adj, value); } Component c = Scroller.GetComponent(0); switch (adj.Orientation) { case Adjustable_Fields.VERTICAL: c.Move(c.Location.x, -(value)); break; case Adjustable_Fields.HORIZONTAL: c.Move(-(value), c.Location.y); break; default: throw new IllegalArgumentException("Illegal adjustable orientation"); } }
private void Processor() { while (true) { this._adjustmentResetEvent.WaitOne(); if (this._closing) { return; } lock (this._adjustmentEvents) { while (this._adjustmentEvents.Count > 0) { var adjustmentEvent = this._adjustmentEvents.Pop(); var adjustmentValue = this.UpdateImageProperty(adjustmentEvent.Type, adjustmentEvent.Diff, adjustmentEvent.Value); this.UpdateAdjustmentControls(adjustmentEvent.Type, adjustmentValue); } this._lastAdjustment = null; this._imageBuilder.UpdateImage(); } } }
private void AddEvent(ImageAdjustmentType type, Int32 diff, Int32 value) { lock (this._adjustmentEvents) { if ((this._lastAdjustment != null) && (type == this._lastAdjustment.Type)) { Trace.WriteLine($"Skip {value}"); this._lastAdjustment.Diff = 0; this._lastAdjustment.Value = value; } else { Trace.WriteLine($"Add {value}"); this._lastAdjustment = new AdjustmentEvent() { Type = type, Diff = diff, Value = value }; this._adjustmentEvents.Push(this._lastAdjustment); } } this._adjustmentTimer.Stop(); this._adjustmentTimer.Start(); }
/// <summary> /// is invoked when the adjustment has changed. /// </summary> /// <param id="rEvent">The r event.</param> void XAdjustmentListener.adjustmentValueChanged(AdjustmentEvent rEvent) { if (rEvent != null && rEvent.Source is XControl) { XControlModel sbModel = ((XControl)rEvent.Source).getModel(); var Orientation = OoUtils.GetProperty(rEvent.Source, "Orientation"); int o = (Orientation is int) ? (int)Orientation : -1; // the value of a scroll bar is the topmost point of the // scroller. That means the size of the scroller (VisibleSize) // is some kind of margin to the bottom of the scroll region. // Is is not possible to scroll down to the ScrollValueMax. // The maximum value that is reachable is // ScrollValueMax - VisibleSize ! // so the unreachable rest rest (VisibleSize) has to be // distributed proportionally to the already traveled // scroll way (ScrollValue) int step = OoUtils.GetIntProperty(sbModel, "ScrollValue"); int vissize = OoUtils.GetIntProperty(sbModel, "VisibleSize"); int max = OoUtils.GetIntProperty(sbModel, "ScrollValueMax"); int scrollable_size = max - vissize; double scrolledRatio = (double)step / (double)scrollable_size; double offset = (double)vissize * scrolledRatio; step += (int)offset; switch (o) { case 0: // horizontal scrollHorizontal(step); break; case 1: // vertical scrollVertical(step); break; default: break; } //switch (rEvent.Type) //{ // case AdjustmentType.ADJUST_ABS: // System.Diagnostics.Debug.WriteLine("The event has been triggered by dragging the thumb..."); // break; // case AdjustmentType.ADJUST_LINE: // System.Diagnostics.Debug.WriteLine("The event has been triggered by a single line move.."); // break; // case AdjustmentType.ADJUST_PAGE: // System.Diagnostics.Debug.WriteLine("The event has been triggered by a block move..."); // break; //} //System.Diagnostics.Debug.WriteLine("The value of the scrollbar is: " + rEvent.Value); } }
/// <summary> /// Sets the value of this scrollbar to the specified value. /// <para> /// If the value supplied is less than the current minimum or /// greater than the current maximum, then one of those values is /// substituted, as appropriate. Also, creates and dispatches /// the AdjustementEvent with specified type and value. /// /// </para> /// </summary> /// <param name="v"> the new value of the scrollbar </param> /// <param name="type"> the type of the scrolling operation occurred </param> private void SetTypedValue(int v, int type) { v = System.Math.Max(v, Minimum_Renamed); v = System.Math.Min(v, Maximum_Renamed - VisibleAmount_Renamed); if (v != Value_Renamed) { Value_Renamed = v; // Synchronously notify the listeners so that they are // guaranteed to be up-to-date with the Adjustable before // it is mutated again. AdjustmentEvent e = new AdjustmentEvent(this, AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, type, Value_Renamed, IsAdjusting); AdjustmentListener.AdjustmentValueChanged(e); } }
/// <summary> /// is invoked when the adjustment has changed. /// </summary> /// <param name="_adjustmentEvent">The _adjustment event.</param> public void adjustmentValueChanged(AdjustmentEvent _adjustmentEvent) { switch (_adjustmentEvent.Type) { case AdjustmentType.ADJUST_ABS: // adjustment is originated by dragging the thumb. System.Diagnostics.Debug.WriteLine("The event has been triggered by dragging the thumb..."); break; case AdjustmentType.ADJUST_LINE: // adjustment is originated by a line jump. // A line jump can, for example, be caused by a click on one of the pointer buttons. System.Diagnostics.Debug.WriteLine("The event has been triggered by a single line move.."); break; case AdjustmentType.ADJUST_PAGE: // adjustment is originated by a page jump. // A page jump can, for example, be caused by a click in the background area of the scrollbar (neither one of the pointer buttons, nor the thumb). System.Diagnostics.Debug.WriteLine("The event has been triggered by a block move..."); break; } System.Diagnostics.Debug.WriteLine("The value of the scrollbar is: " + _adjustmentEvent.Value); }
/// <summary> /// Handles the adjustmentValueChanged event by invoking the /// adjustmentValueChanged methods on listener-a and listener-b. </summary> /// <param name="e"> the adjustment event </param> public virtual void AdjustmentValueChanged(AdjustmentEvent e) { ((AdjustmentListener)a).AdjustmentValueChanged(e); ((AdjustmentListener)b).AdjustmentValueChanged(e); }
/// <summary> /// Converts a new event to an old one (used for compatibility). /// If the new event cannot be converted (because no old equivalent /// exists) then this returns null. /// /// Note: this method is here instead of in each individual new /// event class in java.awt.event because we don't want to make /// it public and it needs to be called from java.awt. /// </summary> internal virtual Event ConvertToOld() { Object src = Source; int newid = Id; switch (Id) { case KeyEvent.KEY_PRESSED: case KeyEvent.KEY_RELEASED: KeyEvent ke = (KeyEvent)this; if (ke.ActionKey) { newid = (Id == KeyEvent.KEY_PRESSED? Event.KEY_ACTION : Event.KEY_ACTION_RELEASE); } int keyCode = ke.KeyCode; if (keyCode == KeyEvent.VK_SHIFT || keyCode == KeyEvent.VK_CONTROL || keyCode == KeyEvent.VK_ALT) { return(null); // suppress modifier keys in old event model. } // no mask for button1 existed in old Event - strip it out return(new Event(src, ke.When, newid, 0, 0, Event.GetOldEventKey(ke), (ke.Modifiers & ~InputEvent.BUTTON1_MASK))); case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: case MouseEvent.MOUSE_MOVED: case MouseEvent.MOUSE_DRAGGED: case MouseEvent.MOUSE_ENTERED: case MouseEvent.MOUSE_EXITED: MouseEvent me = (MouseEvent)this; // no mask for button1 existed in old Event - strip it out Event olde = new Event(src, me.When, newid, me.X, me.Y, 0, (me.Modifiers & ~InputEvent.BUTTON1_MASK)); olde.ClickCount = me.ClickCount; return(olde); case FocusEvent.FOCUS_GAINED: return(new Event(src, Event.GOT_FOCUS, null)); case FocusEvent.FOCUS_LOST: return(new Event(src, Event.LOST_FOCUS, null)); case WindowEvent.WINDOW_CLOSING: case WindowEvent.WINDOW_ICONIFIED: case WindowEvent.WINDOW_DEICONIFIED: return(new Event(src, newid, null)); case ComponentEvent.COMPONENT_MOVED: if (src is Frame || src is Dialog) { Point p = ((Component)src).Location; return(new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0)); } break; case ActionEvent.ACTION_PERFORMED: ActionEvent ae = (ActionEvent)this; String cmd; if (src is Button) { cmd = ((Button)src).Label; } else if (src is MenuItem) { cmd = ((MenuItem)src).Label; } else { cmd = ae.ActionCommand; } return(new Event(src, 0, newid, 0, 0, 0, ae.Modifiers, cmd)); case ItemEvent.ITEM_STATE_CHANGED: ItemEvent ie = (ItemEvent)this; Object arg; if (src is List) { newid = (ie.StateChange == ItemEvent.SELECTED? Event.LIST_SELECT : Event.LIST_DESELECT); arg = ie.Item; } else { newid = Event.ACTION_EVENT; if (src is Choice) { arg = ie.Item; } // Checkbox else { arg = Convert.ToBoolean(ie.StateChange == ItemEvent.SELECTED); } } return(new Event(src, newid, arg)); case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED: AdjustmentEvent aje = (AdjustmentEvent)this; switch (aje.AdjustmentType) { case AdjustmentEvent.UNIT_INCREMENT: newid = Event.SCROLL_LINE_DOWN; break; case AdjustmentEvent.UNIT_DECREMENT: newid = Event.SCROLL_LINE_UP; break; case AdjustmentEvent.BLOCK_INCREMENT: newid = Event.SCROLL_PAGE_DOWN; break; case AdjustmentEvent.BLOCK_DECREMENT: newid = Event.SCROLL_PAGE_UP; break; case AdjustmentEvent.TRACK: if (aje.ValueIsAdjusting) { newid = Event.SCROLL_ABSOLUTE; } else { newid = Event.SCROLL_END; } break; default: return(null); } return(new Event(src, newid, Convert.ToInt32(aje.Value))); default: break; } return(null); }