예제 #1
0
 private async Task Swing1()
 {
     var tasks = new Task[]
     {
         OuterGrid.AnimateAsync(new FlipEnjoyAnimation()),
         InnerGrid.AnimateAsync(new FlipEnjoyAnimation {
             Reverse = true
         }),
     };
     await Task.WhenAll(tasks);
 }
예제 #2
0
        private async void Image_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (!DrawSelectionBox)
            {
                return;
            }
            // Release the mouse capture and stop tracking it.
            DrawSelectionBox = false;
            OuterGrid.ReleaseMouseCapture();

            // Hide the drag selection box.
            SelectionBox.Visibility = Visibility.Collapsed;
            var l          = RenderImage.TranslatePoint(new Point(0, 0), OuterGrid);
            var mouseUpPos = e.GetPosition(OuterGrid);

            if (mouseUpPos.X < l.X || mouseUpPos.X > l.X + RenderImage.ActualWidth)
            {
                return;
            }


            if (!(DataContext is MandelbrotViewModel dc) || !dc.CanRender())
            {
                return;
            }
            var topLeft   = SelectionBox.TranslatePoint(new Point(0, 0), RenderImage);
            var downRight = topLeft;

            downRight.X += SelectionBox.Width;
            downRight.Y += SelectionBox.Height;

            var oldL = dc.LeftEdge;
            var oldR = dc.RightEdge;
            var oldD = dc.BottomEdge;
            var oldU = dc.UpperEdge;

            var newL = oldL + (oldR - oldL) * topLeft.X / dc.CurrentBitmap.PixelWidth *
                       MandelbrotViewModel.DpiScale;
            var newR = oldL + (oldR - oldL) * downRight.X / dc.CurrentBitmap.PixelWidth *
                       MandelbrotViewModel.DpiScale;
            var newU = oldU - (oldU - oldD) * topLeft.Y / dc.CurrentBitmap.PixelHeight *
                       MandelbrotViewModel.DpiScale;
            var newD = oldU - (oldU - oldD) * downRight.Y / dc.CurrentBitmap.PixelHeight *
                       MandelbrotViewModel.DpiScale;

            dc.LeftEdge   = newL;
            dc.RightEdge  = newR;
            dc.UpperEdge  = newU;
            dc.BottomEdge = newD;

            await dc.ExecuteRender();
        }
예제 #3
0
 private async Task Jump()
 {
     var tasks = new Task[]
     {
         OuterGrid.AnimateAsync(new JumpAnimation {
             Distance = -40
         }),
         InnerGrid.AnimateAsync(new JumpAnimation {
             Distance = -20
         }),
     };
     await Task.WhenAll(tasks);
 }
예제 #4
0
 private async Task Thinking1()
 {
     var tasks = new Task[]
     {
         OuterGrid.AnimateAsync(new FlipYAnimation {
             From = 0.0, To = 180, Duration = 0.4, Delay = 0.1
         }),
         InnerGrid.AnimateAsync(new FlipYAnimation {
             From = 0.0, To = 180, Duration = 0.5
         }),
     };
     await Task.WhenAll(tasks);
 }
예제 #5
0
 private async Task Exit1()
 {
     var tasks = new Task[]
     {
         OuterGrid.AnimateAsync(new BounceOutAnimation {
             ToDirection = ZDirection.Closer, Duration = 0.5
         }),
         InnerGrid.AnimateAsync(new BounceOutAnimation {
             ToDirection = ZDirection.Away, Duration = 0.5
         }),
     };
     await Task.WhenAll(tasks);
 }
예제 #6
0
 private async Task Rotation(bool forward, int repeatCount = -1)
 {
     bool forever = repeatCount < 0;
     var  tasks   = new Task[]
     {
         OuterGrid.AnimateAsync(new SlowRotateAnimation {
             Reverse = forward, Forever = forever, RepeatCount = repeatCount
         }),
         InnerGrid.AnimateAsync(new SlowRotateAnimation {
             Reverse = !forward, Forever = forever, RepeatCount = repeatCount
         }),
     };
     await Task.WhenAll(tasks);
 }
예제 #7
0
    private void LoadDataGrid(bool IsResetPageIndex, bool IsSort)
    {
        objReturnOrder = new tblReturnOrder();
        objDataTable   = objReturnOrder.LoadReturnReportOuterGrid();

        if (IsResetPageIndex)
        {
            if (OuterGrid.PageCount > 0)
            {
                OuterGrid.PageIndex = 0;
            }
        }

        OuterGrid.DataSource = null;
        OuterGrid.DataBind();
        lblCount.Text        = 0.ToString();
        hdnSelectedIDs.Value = "";

        if (objDataTable.Rows.Count <= 0)
        {
            DInfo.ShowMessage("No data found", Enums.MessageType.Information);
            return;
        }
        else
        {
            if (ddlPerPage.SelectedItem.Text.ToLower() == "all")
            {
                OuterGrid.AllowPaging = false;
            }
            else
            {
                OuterGrid.AllowPaging = true;
                OuterGrid.PageSize    = Convert.ToInt32(ddlPerPage.SelectedItem.Text);
            }

            lblCount.Text = objDataTable.Rows.Count.ToString();
            if (IsSort)
            {
                objDataTable = SortDatatable(objDataTable, ViewState["SortColumn"].ToString(), (appFunctions.Enum_SortOrderBy)ViewState["SortOrder"], IsSort);
            }
            OuterGrid.DataSource = objDataTable;
            OuterGrid.DataBind();
        }
        objReturnOrder = null;
    }
예제 #8
0
        private void Image_MouseMove(object sender, MouseEventArgs e)
        {
            if (DrawSelectionBox)
            {
                var mousePos = e.GetPosition(OuterGrid);
                var l        = RenderImage.TranslatePoint(new Point(0, 0), OuterGrid);

                if (mousePos.X < l.X || mousePos.X > l.X + RenderImage.ActualWidth)
                {
                    DrawSelectionBox = false;
                    OuterGrid.ReleaseMouseCapture();
                    SelectionBox.Visibility = Visibility.Collapsed;
                    return;
                }

                if (MouseDownPos.X < mousePos.X)
                {
                    Canvas.SetLeft(SelectionBox, MouseDownPos.X);
                    SelectionBox.Width = mousePos.X - MouseDownPos.X;
                }
                else
                {
                    Canvas.SetLeft(SelectionBox, mousePos.X);
                    SelectionBox.Width = MouseDownPos.X - mousePos.X;
                }

                if (MouseDownPos.Y < mousePos.Y)
                {
                    Canvas.SetTop(SelectionBox, MouseDownPos.Y);
                    SelectionBox.Height = mousePos.Y - MouseDownPos.Y;
                }
                else
                {
                    Canvas.SetTop(SelectionBox, mousePos.Y);
                    SelectionBox.Height = MouseDownPos.Y - mousePos.Y;
                }
            }
        }
예제 #9
0
        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var mousePos = e.GetPosition(OuterGrid);
            var l        = RenderImage.TranslatePoint(new Point(0, 0), OuterGrid);

            if (mousePos.X < l.X)
            {
                return;
            }
            // Capture and track the mouse.
            DrawSelectionBox = true;
            MouseDownPos     = e.GetPosition(OuterGrid);
            OuterGrid.CaptureMouse();

            // Initial placement of the drag selection box.
            Canvas.SetLeft(SelectionBox, MouseDownPos.X);
            Canvas.SetTop(SelectionBox, MouseDownPos.Y);
            SelectionBox.Width  = 0;
            SelectionBox.Height = 0;

            // Make the drag selection box visible.
            SelectionBox.Visibility = Visibility.Visible;
        }
예제 #10
0
        private async Task Abashed1()
        {
            var tasks = new Task[]
            {
                OuterGrid.AnimateAsync(new FlipXAnimation {
                    From = 0.0, To = 240, Duration = 1
                }),
                InnerGrid.AnimateAsync(new FlipXAnimation {
                    From = 0.0, To = 120, Duration = 1
                }),
            };
            await Task.WhenAll(tasks);

            tasks = new Task[]
            {
                OuterGrid.AnimateAsync(new FlipXAnimation {
                    From = 240, To = 0, Duration = 0.3
                }),
                InnerGrid.AnimateAsync(new FlipXAnimation {
                    From = 120, To = 0, Duration = 0.3
                }),
            };
            await Task.WhenAll(tasks);
        }
예제 #11
0
 private void Storyboard_Completed(object sender, EventArgs e)
 {
     OuterGrid.BeginAnimation(EffectProperty, null);
     OuterGrid.Effect = null;
 }
예제 #12
0
        public bool ApplyRules()
        {
            bool needOuter = false;

            for (int y = 0; y < 5; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    int adjacentCount = 0;


                    if (InnerGrid != null)
                    {
                        if (x == 2)
                        {
                            if (y == 1)
                            {
                                adjacentCount += InnerGrid.TopEdgeCount(Selector.Source);
                            }
                            else if (y == 3)
                            {
                                adjacentCount += InnerGrid.BottomEdgeCount(Selector.Source);
                            }
                        }
                        if (y == 2)
                        {
                            if (x == 1)
                            {
                                adjacentCount += InnerGrid.LeftEdgeCount(Selector.Source);
                            }
                            else if (x == 3)
                            {
                                adjacentCount += InnerGrid.RightEdgeCount(Selector.Source);
                            }
                        }
                    }
                    if (OuterGrid != null)
                    {
                        if (x == 0)
                        {
                            adjacentCount += OuterGrid.CheckForBug(1, 2) ? 1 : 0;
                        }
                        if (x == 4)
                        {
                            adjacentCount += OuterGrid.CheckForBug(3, 2) ? 1 : 0;
                        }
                        if (y == 0)
                        {
                            adjacentCount += OuterGrid.CheckForBug(2, 1) ? 1 : 0;
                        }
                        if (y == 4)
                        {
                            adjacentCount += OuterGrid.CheckForBug(2, 3) ? 1 : 0;
                        }
                    }
                    if (x == 2 && y == 2 && InnerGrid != null)
                    {
                        // recurse in
                        InnerGrid.ApplyRules();
                    }
                    else
                    {
                        if (!(x == 2 && y == 2))
                        {
                            // count adjacent bugs
                            adjacentCount += (x > 0 && _grids[srcIndex][x - 1, y] == '#') ? 1 : 0;
                            adjacentCount += (x < 5 - 1 && _grids[srcIndex][x + 1, y] == '#') ? 1 : 0;
                            adjacentCount += (y > 0 && _grids[srcIndex][x, y - 1] == '#') ? 1 : 0;
                            adjacentCount += (y < 5 - 1 && _grids[srcIndex][x, y + 1] == '#') ? 1 : 0;
                        }
                    }

                    char newState = _grids[srcIndex][x, y];

                    if (_grids[srcIndex][x, y] == '#')
                    {
                        if (adjacentCount != 1)
                        {
                            newState = '.';
                        }
                    }
                    else
                    {
                        if (adjacentCount == 1 || adjacentCount == 2)
                        {
                            newState = '#';
                        }
                    }

                    _grids[dstIndex][x, y] = newState;
                }
            }

            if (CountAroundInnerSpot(_grids[dstIndex]) > 0 && InnerGrid == null)
            {
                // allocate a new inner grid
                InnerGrid           = new RecursiveGrid(Depth + 1, InitializeGrid(new char[5, 5])); // dumb - need an empty constructor
                InnerGrid.OuterGrid = this;
            }

            // see if we need to grow outward - if so, return true & outer control will allocate a new one
            needOuter = EdgeCount(Selector.Destination) > 0;

            return(needOuter && OuterGrid == null);
        }
예제 #13
0
        public async Task Do(BoxtanaAction boxtanaAction)
        {
            if (AnimationManager.IsAnimating(OuterGrid) ||
                AnimationManager.IsAnimating(InnerGrid))
            {
                AnimationManager.PauseAnimations(InnerGrid);
                AnimationManager.PauseAnimations(OuterGrid);
                var tasks = new Task[]
                {
                    OuterGrid.AnimateAsync(new SlowResetAnimation()),
                    InnerGrid.AnimateAsync(new SlowResetAnimation()),
                };
                await Task.WhenAll(tasks);

                AnimationManager.StopAnimations(InnerGrid);
                AnimationManager.StopAnimations(OuterGrid);
                AnimationManager.StopAnimations(Inner);
                AnimationManager.StopAnimations(Outer);
            }

            switch (boxtanaAction)
            {
            case BoxtanaAction.Entrance:
                await Entrance1();

                break;

            case BoxtanaAction.Exit:
                await Exit1();

                break;

            case BoxtanaAction.Abashed:
                await Abashed1();

                break;

            case BoxtanaAction.Thinking:
                await Thinking1();

                break;

            case BoxtanaAction.RandomWait:
                await RandomWait(3);

                break;

            case BoxtanaAction.Swing:
                await Swing1();

                break;

            case BoxtanaAction.RotateRight:
                await Rotation(true);

                break;

            case BoxtanaAction.RotateLeft:
                await Rotation(false);

                break;

            case BoxtanaAction.Pulse:
                await Pulse();

                break;

            case BoxtanaAction.Color:
                await Color1();

                break;

            case BoxtanaAction.Jump:
                await Jump();

                break;
            }
        }