コード例 #1
0
        public static void UserControl_ManipulationDelta(this IEComponent component, object sender, ManipulationDeltaRoutedEventArgs e)
        {
            var left = Canvas.GetLeft((UIElement)sender) + e.Delta.Translation.X;
            var top  = Canvas.GetTop((UIElement)sender) + e.Delta.Translation.Y;

            Canvas.SetLeft((UIElement)sender, left);
            Canvas.SetTop((UIElement)sender, top);
            (sender as IEComponent).ChildrenPositionUpdate();
        }
コード例 #2
0
        public static void UserControl_ManipulationCompleted(this IEComponent component, object sender, ManipulationCompletedRoutedEventArgs e)
        {
            var currentPositionComponentOnCanvas = CustomVisualTreeHelper.PositionElementOnKernelCanvas(sender as UIElement);
            var left = Math.Round(currentPositionComponentOnCanvas.X); // Убрать Round?
            var top  = Math.Round(currentPositionComponentOnCanvas.Y);

            // Выравнивание элемента по центру
            var centerComponentOnCanvas = GetCenterComponentOnCanvas(sender as UIElement);

            var step   = 20;
            var deltaX = Math.Round(centerComponentOnCanvas.X) % step;

            if (deltaX < step / 2)
            {
                left -= deltaX;
            }
            else
            {
                left += (step - deltaX);
            }

            var deltaY = Math.Round(centerComponentOnCanvas.Y) % step;

            if (deltaY < step / 2)
            {
                top -= deltaY;
            }
            else
            {
                top += (step - deltaY);
            }
            // *
            // Проверка на выход из границ Canvas
            left = left < 0 ? 0 : left;
            top  = top < 0 ? 0 : top;
            // *

            Canvas.SetLeft((UIElement)sender, left);
            Canvas.SetTop((UIElement)sender, top);

            if (IsIntersectOnCanvas(sender as UIElement))
            {
                Canvas.SetLeft((UIElement)sender, (sender as IEComponent).OldPositionComponentOnCanvas.X);
                Canvas.SetTop((UIElement)sender, (sender as IEComponent).OldPositionComponentOnCanvas.Y);
            }

            (sender as IEComponent).ChildrenPositionUpdate();
        }
コード例 #3
0
        public static void RemoveEComponent(this IEComponent src, IEComponent ec)
        {
            Dictionary <Type, IEComponent> ecs;

            if (goecs.TryGetValue(ec.go, out ecs))
            {
                Type type = ec.GetECType();
                if (ecs.ContainsKey(type))
                {
                    ecs.Remove(type);
                }

                if (ecs.Count == 0)
                {
                    goecs.Remove(ec.go);
                }
            }
        }
コード例 #4
0
        public static T GetEComponent <T>(this IEComponent src) where T : IEComponent
        {
            Dictionary <Type, IEComponent> ecs;

            IEComponent result = null;

            if (src.go != null)
            {
                if (goecs.TryGetValue(src.go, out ecs))
                {
                    Type type = typeof(T);
                    if (ecs.TryGetValue(type, out result))
                    {
                        return((T)result);
                    }
                }
            }
            return((T)result);
        }
コード例 #5
0
        public static void AddEComponent(this IEComponent src, IEComponent ec)
        {
            Dictionary <Type, IEComponent> ecs;

            if (!goecs.TryGetValue(ec.go, out ecs))
            {
                ecs = new Dictionary <Type, IEComponent>();
                goecs.Add(ec.go, ecs);
            }

            Type type = ec.GetECType();

            if (ecs.ContainsKey(type))
            {
                ecs[type] = ec;
            }
            else
            {
                ecs.Add(type, ec);
            }
        }
コード例 #6
0
 public static void UserControl_ManipulationStarted(this IEComponent component, object sender, ManipulationStartedRoutedEventArgs e)
 {
     (sender as IEComponent).OldPositionComponentOnCanvas = CustomVisualTreeHelper.PositionElementOnKernelCanvas(sender as UIElement);
 }
コード例 #7
0
ファイル: EBehaviour.cs プロジェクト: PenpenLi/abcabcabc.mg
 public void RemoveEC(IEComponent component)
 {
     this.RemoveEComponent(component);
 }
コード例 #8
0
ファイル: EBehaviour.cs プロジェクト: PenpenLi/abcabcabc.mg
 public void AddEC(IEComponent component)
 {
     this.AddEComponent(component);
 }