Exemple #1
0
        protected override void OnKeyPressInternal(IPointer cursor, KeyCodes code,
                                                   KeyboardModifiers modifiers, InputEventModifier eventModifiers)
        {
            base.OnKeyPressInternal(cursor, code, modifiers, eventModifiers);

            // We are focused.
            animationState.TransistTo(CommonStyleStates.Focused);

            if (code == KeyCodes.C && (modifiers & KeyboardModifiers.LCtrl) != 0)
            {
                if (selectedRange.Y < selectedRange.X)
                {
                    return;
                }

                // We have a copy event.
                Action3 <Label, Vector2i, StringBuilder> t = onTextCopy;
                StringBuilder b = new StringBuilder(SelectedText);

                // Events may alter copy or react on it.
                if (t != null)
                {
                    t(this, selectedRange, b);
                }

                // We add copy to cursor.
                AttachedData attachedData = new AttachedData();
                attachedData.ApplicationID  = Guid.Empty; //< FIXME
                attachedData.Data           = b.ToString();
                attachedData.Representation = null;

                // We attach data.
                cursor.AttachData(attachedData);
            }
        }
        private IDeviceBitmap GetOrCreateDeviceBitmap(IDeviceResourceFactory factory, SizeInt32 desiredPixelSize)
        {
            base.VerifyAccess();
            IDeviceBitmap result = null;
            int           num    = Int32Util.Pow2RoundUp(desiredPixelSize.Width);
            int           num2   = Int32Util.Pow2RoundUp(desiredPixelSize.Height);
            int           width  = Math.Max(Math.Max(num, num2), 0x100);
            SizeInt32     num5   = new SizeInt32(width, width);

            while (this.deviceBitmapPool.TryDequeue(out result))
            {
                SizeInt32 pixelSize = result.PixelSize;
                if (((pixelSize.Width >= num5.Width) && (pixelSize.Width <= (num5.Width * 2))) && ((pixelSize.Height >= num5.Height) && (pixelSize.Height <= (num5.Height * 2))))
                {
                    break;
                }
                DisposableUtil.Free <IDeviceBitmap>(ref result);
            }
            if (result == null)
            {
                result = factory.CreateDeviceBitmap(desiredPixelSize, maskBitmapProperties);
                AttachedData.SetValue(result, isPooledBitmapAttachedKey, BooleanUtil.GetBoxed(true));
            }
            return(result);
        }
Exemple #3
0
        public void DetachData(AttachedData data)
        {
            lock (syncRoot)
            {
                attachedData.Remove(data);
            }

            OnChanged();
        }
Exemple #4
0
        public void AttachData(AttachedData data)
        {
            lock (syncRoot)
            {
                attachedData.Add(data);
            }

            OnChanged();
        }
        private void ReturnOrFreeDeviceBitmap(ref IDeviceBitmap deviceBitmap)
        {
            object obj2;

            if (((deviceBitmap != null) && AttachedData.TryGetValue(deviceBitmap, isPooledBitmapAttachedKey, out obj2)) && ((bool)obj2))
            {
                this.deviceBitmapPool.Enqueue(deviceBitmap);
                deviceBitmap = null;
            }
            DisposableUtil.Free <IDeviceBitmap>(ref deviceBitmap);
        }