Exemplo n.º 1
0
 public void Apply(ApplyDelegate fn, string pattern)
 {
     foreach (var o in FindChildrenByRegex(pattern))
     {
         fn(o);
     }
 }
Exemplo n.º 2
0
 public void Put(ApplyDelegate op, object parameter)
 {
     Op        = op;
     Parameter = parameter;
     Interlocked.Increment(ref Version);
     ThreadId = Thread.CurrentThread.ManagedThreadId;
 }
Exemplo n.º 3
0
        public object Apply(ApplyDelegate op, object parameter)
        {
            requests.Value.Put(op, parameter);
            Eval();
            var threadId = Thread.CurrentThread.ManagedThreadId;

            return(state.Board[threadId].Result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Mandatory constructor.
        /// </summary>
        public BasicImageOperation(GetOriginatorDelegate getOriginatorDelegate, ApplyDelegate applyDelegate)
        {
            Platform.CheckForNullReference(getOriginatorDelegate, "getOriginatorDelegate");
            Platform.CheckForNullReference(applyDelegate, "applyDelegate");

            _getOriginatorDelegate = getOriginatorDelegate;
            _applyDelegate         = applyDelegate;
        }
Exemplo n.º 5
0
		/// <summary>
		/// Mandatory constructor.
		/// </summary>
		public BasicImageOperation(GetOriginatorDelegate getOriginatorDelegate, ApplyDelegate applyDelegate)
		{
			Platform.CheckForNullReference(getOriginatorDelegate, "getOriginatorDelegate");
			Platform.CheckForNullReference(applyDelegate, "applyDelegate");

			_getOriginatorDelegate = getOriginatorDelegate;
			_applyDelegate = applyDelegate;
		}
Exemplo n.º 6
0
        private ApplyDelegate CreateSetterGeneric <TItem>(object self, MethodInfo setter)
            where TItem : IMergeable <TItem>
        {
            var setterTypedDelegate = (Func <string, FieldInfo <TItem>, ComplexRelationship>)
                                      Delegate.CreateDelegate(typeof(Func <string, FieldInfo <TItem>, ComplexRelationship>), self, setter);
            ApplyDelegate res = (key, obj, del, exp, expMs) => setterTypedDelegate(key, new FieldInfo <TItem>((TItem)obj, del, exp, expMs));

            return(res);
        }
Exemplo n.º 7
0
        public void SetDatas(object[] datas, int focusIndex, ApplyDelegate onApply)
        {
            if (m_Template == null)
            {
                return;
            }
            if (mScrollRect == null)
            {
                mScrollRect = GetComponent <ScrollRect>();
                RectTransform tItem    = m_Template.transform as RectTransform;
                Rect          itemRect = tItem.rect;
                mItemSize = new Vector2(itemRect.width, itemRect.height);
            }
            mDatas   = datas;
            mOnApply = onApply;
            int count = datas.Length;

            mItemHead.index = -1;
            mItemEnd.index  = count;
            RectTransform content      = mScrollRect.content;
            Rect          viewportRect = mScrollRect.viewport.rect;

            if (m_Direction == eDirection.Vertical)
            {
                float width = content.rect.width - m_Padding.x - m_Padding.x;
                mColumns = Mathf.Max(Mathf.FloorToInt((width + m_Margin.x) / (mItemSize.x + m_Margin.x)), 1);
                mRows    = Mathf.CeilToInt(count / (float)mColumns);
                float height = mRows * (mItemSize.y + m_Margin.y) - m_Margin.y + m_Padding.y + m_Padding.y;
                content.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
                mScrollRect.vertical = !m_AutoDisableScroll || height > viewportRect.height;
            }
            else
            {
                float height = content.rect.height - m_Padding.y - m_Padding.y;
                mRows    = Mathf.Max(Mathf.FloorToInt((height + m_Margin.y) / (mItemSize.y + m_Margin.y)), 1);
                mColumns = Mathf.CeilToInt(count / (float)mRows);
                float width = mColumns * (mItemSize.x + m_Margin.x) - m_Margin.x + m_Padding.x + m_Padding.x;
                content.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
                mScrollRect.horizontal = !m_AutoDisableScroll || width > viewportRect.width;
            }
            if (focusIndex >= 0)
            {
                Vector2 pos = content.anchoredPosition;
                if (m_Direction == eDirection.Vertical)
                {
                    int r = Mathf.FloorToInt(focusIndex / (float)mColumns);
                    pos.y = Mathf.Clamp(r * (mItemSize.y + m_Margin.y), 0f, Mathf.Max(content.rect.height - viewportRect.height, 0f));
                }
                else
                {
                    int c = Mathf.FloorToInt(focusIndex / (float)mRows);
                    pos.x = Mathf.Clamp(-c * (mItemSize.x + m_Margin.x), Mathf.Min(viewportRect.width - content.rect.width, 0f), 0f);
                }
                content.anchoredPosition = pos;
            }
            Flush();
        }
Exemplo n.º 8
0
        public static T Apply <T, P>(this T parameter, P feature, string property, ApplyDelegate <T> dlg)
            where T : IActor, new() where P : IActor
        {
            if (dlg(parameter))
            {
                var t = feature;
                parameter.GetType().GetProperty(property).SetValue(parameter, t);
            }

            return(parameter);
        }
Exemplo n.º 9
0
 public void ApplyRGBAInternal(byte[] data)
 {
     if (iCapture.Dispatcher.CheckAccess())
     {
         var d = new ApplyDelegate(ApplyRGBAInternal);
         iCapture.Source.Dispatcher.Invoke(d, data);
     }
     else
     {
         ApplyRGBAToPictureBox(iCapture, data);
         Refresh();
     }
 }
Exemplo n.º 10
0
 public void ApplyRGBAInternal(byte[] data)
 {
     if (CaptureBox.InvokeRequired)
     {
         var d = new ApplyDelegate(ApplyRGBAInternal);
         CaptureBox.Invoke(d, data);
     }
     else
     {
         ApplyRGBAToPictureBox(CaptureBox, data);
         Refresh();
     }
 }
Exemplo n.º 11
0
 public void ApplyDataImpl(byte[] data)
 {
     if (CaptureBox.InvokeRequired)
     {
         var d = new ApplyDelegate(ApplyDataImpl);
         CaptureBox.Invoke(d, data);
     }
     else
     {
         ApplyModeDelegate(CaptureBox, data);
         Refresh();
     }
 }
Exemplo n.º 12
0
        public Polyline Apply(ApplyDelegate f)
        {
            Polyline new_line = new Polyline();

            for (int i = 0; i < _points.Count; i++)
            {
                new_line.Add(f((Position)_points[i]));
            }

            return new_line;
        }
Exemplo n.º 13
0
 /// <summary>
 /// Mandatory constructor.
 /// </summary>
 public VoiLutImageOperation(ApplyDelegate applyDelegate)
     : base(GetVoiLutManager, applyDelegate)
 {
 }
 /// <summary>
 /// Mandatory constructor.
 /// </summary>
 public SpatialTransformImageOperation(ApplyDelegate applyDelegate)
     : base(GetTransform, applyDelegate)
 {
 }
Exemplo n.º 15
0
        public ShaderParameter(string name, string glslType, int size)
        {
            Name = name;
            Count = size;
            Slot = -1;

            if (glslType.StartsWith("mat") || glslType.Substring(1, 3) == "mat")
                Class = EffectParameterClass.Matrix;
            else if (glslType.StartsWith("vec") || glslType.Substring(1, 3) == "vec")
                Class = EffectParameterClass.Vector;
            else if (glslType.StartsWith("sampler"))
                Class = EffectParameterClass.Sampler;
            else
                Class = EffectParameterClass.Scalar;

            switch (Class)
            {
                case EffectParameterClass.Matrix:
                {
                    char m = glslType[glslType.Length - 1];
                    char n = m;

                    if (glslType[glslType.Length - 2] == 'x')
                        n = glslType[glslType.Length - 3];

                    switch (glslType[0])
                    {
                        case 'm':
                            Type = EffectParameterType.Single;
                            break;
                        case 'd':
                            Type = EffectParameterType.Double;
                            break;
                    }

                    RowCount = (n - '0');
                    ColumnCount = (m - '0');
                }
                    break;
                case EffectParameterClass.Vector:
                    switch (glslType[0])
                    {
                        case 'm':
                            Type = EffectParameterType.Single;
                            size = 4;
                            break;
                        case 'd':
                            Type = EffectParameterType.Double;
                            size = 4;
                            break;
                        case 'i':
                            Type = EffectParameterType.Int32;
                            break;
                        case 'b':
                            Type = EffectParameterType.Bool;
                            break;
                    }

                    RowCount = 1;
                    ColumnCount = glslType[glslType.Length - 1] - '0';
                    break;
                case EffectParameterClass.Sampler:
                    switch (glslType[glslType.Length - 2])
                    {
                        case '1':
                            Type = EffectParameterType.Texture1D;
                            break;
                        case '2':
                            Type = EffectParameterType.Texture2D;
                            break;
                        case '3':
                            Type = EffectParameterType.Texture3D;
                            break;
                        default:
                            if (glslType == "sampleCube")
                                Type = EffectParameterType.TextureCube;
                            else
                                throw new NotSupportedException();
                            break;
                    }
                    RowCount = 1;
                    ColumnCount = 1;
                    break;
                default:
                    switch (glslType)
                    {
                        case "int":
                        case "uint":
                            Type = EffectParameterType.Int32;
                            break;
                        case "bool":
                            Type = EffectParameterType.Bool;
                            break;
                        case "float":
                            Type = EffectParameterType.Single;
                            break;
                        case "double":
                            Type = EffectParameterType.Double;
                            break;
                        default:
                            throw new NotSupportedException();
                    }
                    RowCount = 1;
                    ColumnCount = 1;
                    break;
            }

            unsafe
            {
                if (Count == 0)
                {
                    if (RowCount > 1)
                    {
                        switch (Type)
                        {
                            case EffectParameterType.Single:
                                switch (RowCount)
                                {
                                    case 3:
                                        Apply = ApplyMatrix3F;
                                        break;
                                    case 4:
                                        Apply = ApplyMatrix4F;
                                        break;
                                }
                                break;
                            case EffectParameterType.Double:
                                switch (RowCount)
                                {
                                    case 3:
                                        Apply = ApplyMatrix3D;
                                        break;
                                    case 4:
                                        Apply = ApplyMatrix4D;
                                        break;
                                }
                                break;
                        }
                    }
                    else
                    {
                        switch (Type)
                        {
                            case EffectParameterType.Bool:
                                switch (ColumnCount)
                                {
                                    case 1:
                                        Apply = Apply1B;
                                        break;
                                    case 2:
                                        Apply = Apply2B;
                                        break;
                                    case 3:
                                        Apply = Apply3B;
                                        break;
                                    case 4:
                                        Apply = Apply4B;
                                        break;
                                }
                                break;
                            case EffectParameterType.Texture1D:
                            case EffectParameterType.Texture2D:
                            case EffectParameterType.Texture3D:
                            case EffectParameterType.TextureCube:
                            case EffectParameterType.Int32:
                                switch (ColumnCount)
                                {
                                    case 1:
                                        Apply = Apply1I;
                                        break;
                                    case 2:
                                        Apply = Apply2I;
                                        break;
                                    case 3:
                                        Apply = Apply3I;
                                        break;
                                    case 4:
                                        Apply = Apply4I;
                                        break;
                                }
                                break;
                            case EffectParameterType.Single:
                                switch (ColumnCount)
                                {
                                    case 1:
                                        Apply = Apply1F;
                                        break;
                                    case 2:
                                        Apply = Apply2F;
                                        break;
                                    case 3:
                                        Apply = Apply3F;
                                        break;
                                    case 4:
                                        Apply = Apply4F;
                                        break;
                                }
                                break;
                            case EffectParameterType.Double:
                                switch (ColumnCount)
                                {
                                    case 1:
                                        Apply = Apply1D;
                                        break;
                                    case 2:
                                        Apply = Apply2D;
                                        break;
                                    case 3:
                                        Apply = Apply3D;
                                        break;
                                    case 4:
                                        Apply = Apply4D;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }

            ByteSize = RowCount * ColumnCount * (Type == EffectParameterType.Double ? 8 : 4);
        }
Exemplo n.º 16
0
 public static T Apply <T>(this T obj, ApplyDelegate <T> func)
 {
     func(ref obj);
     return(obj);
 }
		/// <summary>
		/// Mandatory constructor.
		/// </summary>
		public ImageSpatialTransformImageOperation(ApplyDelegate applyDelegate)
			: base(applyDelegate)
		{
		}
Exemplo n.º 18
0
			public ResetImageOperation(ApplyDelegate applyDelegate)
				: base(i => new MemorableAdapter(i), applyDelegate) {}
Exemplo n.º 19
0
		/// <summary>
		/// Mandatory constructor.
		/// </summary>
		public LayerOpacityOperation(ApplyDelegate applyDelegate)
			: base(GetLayerOpacityManager, applyDelegate) {}
Exemplo n.º 20
0
 /// <summary>
 /// Mandatory constructor.
 /// </summary>
 public LayerOpacityOperation(ApplyDelegate applyDelegate)
     : base(GetLayerOpacityManager, applyDelegate)
 {
 }
Exemplo n.º 21
0
		/// <summary>
		/// Mandatory constructor.
		/// </summary>
		public VoiLutImageOperation(ApplyDelegate applyDelegate)
			: base(GetVoiLutManager, applyDelegate)
		{
		}
 /// <summary>
 /// Mandatory constructor.
 /// </summary>
 public ImageSpatialTransformImageOperation(ApplyDelegate applyDelegate)
     : base(applyDelegate)
 {
 }
Exemplo n.º 23
0
		/// <summary>
		/// Mandatory constructor.
		/// </summary>
		public SpatialTransformImageOperation(ApplyDelegate applyDelegate)
			: base(GetTransform, applyDelegate)
		{
		}
Exemplo n.º 24
0
 public ResetImageOperation(ApplyDelegate applyDelegate)
     : base(i => new MemorableAdapter(i), applyDelegate)
 {
 }