private void RenderFrame(object sender, EventArgs e)
        {
            if (InforOfSprites.visualis && i != ListUsers.Count())
            {
                sqare = (SqareVM)ListUsers[i].DataContext as SqareVM;

                Circle();
                Conditions();
                Motions();

                if (sqare.Znatch != 0)
                {
                    if (nnn == sqare.Znatch * 10)
                    {
                        nnn = 0;
                        i++;
                    }
                }
                if (sqare.Text == "Идти вперед")
                {
                    speed = 1;
                }
            }
            else
            {
                CompositionTarget.Rendering -= RenderFrame;
            }
        }
예제 #2
0
        private void ClonUserControl(Point point)
        {
            UserControl1 userControl = new UserControl1();

            SqareVM square = this.DataContext as SqareVM;

            userControl.DataContext = new SqareVM()
            {
                // Position = new Point(30, 70),
                PointWhike = square.PointWhike,
                Color      = square.Color,
                Id         = square.Id,
                Text       = square.Text,
                Width      = SizeText(square.Text)
            };

            Cache.NowModel.CurrentWindow.Compilar.Children.Add(userControl);

            if (point.Y > 160 && point.Y < 210)
            {
                Canvas.SetLeft(userControl, 60);
                Canvas.SetTop(userControl, 160);
            }
            else
            {
                Canvas.SetLeft(userControl, point.X);
                Canvas.SetTop(userControl, point.Y);
            }

            int SizeText(string scriptText)
            {
                return(scriptText.Length * 10 + 20);
            }
        }
예제 #3
0
 private void TransformElBotton(List <int> ListIndex)  // перемещение объектов в низ
 {
     for (int i = 0; i < ListIndex.Count(); i++)
     {
         SqareVM sqare = (SqareVM)InforOfSprites.ListUserControl[ListIndex[i]].DataContext as SqareVM;
         double  www   = Canvas.GetTop(InforOfSprites.ListUserControl[ListIndex[i]]) + userControl.ActualHeight - userControl.Increase.ActualHeight;
         Canvas.SetTop(InforOfSprites.ListUserControl[ListIndex[i]], www);
     }
 }
예제 #4
0
        private void ClonUserControl(Point point)  //клонирование
        {
            SqareVM      square       = sprites.DataContext as SqareVM;
            SqareVM      sq           = (SqareVM)square.Clone();
            UserControl1 userControl_ = RetUser(sq, point);

            Repositories.ListUserControl.Add(userControl_);
            Cache.NowModel.CurrentWindow.Compilar.Children.Add(userControl_);
            Canvas.SetLeft(userControl_, point.X);
            Canvas.SetTop(userControl_, point.Y);
        }
예제 #5
0
        // по нажатию на левую клавишу начинаем следить за мышью
        void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            StartUserControl = this;
            SqareVM square = this.DataContext as SqareVM;

            StartPoint = square.Position;

            relativeMousePos  = e.GetPosition(this) - new Point();
            MouseMove        += OnDragMove;
            LostMouseCapture += OnLostCapture;
            Mouse.Capture(this);
        }
예제 #6
0
 private int GetRealIndexSprites(Point pointEnd)
 {
     for (int i = 0; i < Repositories.ListUserControl.Count(); i++)
     {
         SqareVM sqare = Repositories.ListUserControl[i].DataContext as SqareVM;
         if (sqare.Position.Y == pointEnd.Y)
         {
             return(i);
         }
     }
     return(666);
 }
예제 #7
0
        private void ClonUserControl()  //клонирование
        {
            SqareVM      square       = userControl.DataContext as SqareVM;
            SqareVM      sq           = (SqareVM)square.Clone();
            UserControl1 userControl_ = RetUser();

            Cache.NowModel.CurrentWindow.Compilar.Children.Add(userControl_);
            //    InforOfSprites.ListUserControl.Insert(n,userControl_);

            Canvas.SetLeft(userControl_, posNow.X);
            Canvas.SetTop(userControl_, posNow.Y);

            userControl = userControl_;
        }
예제 #8
0
        private void textCount_LostFocus(object sender, RoutedEventArgs e)
        {
            var     element = this;
            SqareVM square  = element.DataContext as SqareVM;

            if (proverka(textCount.Text) && textCount.Text != null && textCount.Text != "")
            {
                int n = Convert.ToInt32(textCount.Text);
                square.Znatch = n;
            }
            else
            {
                MessageBox.Show("Введено неверное значение");
            }
        }
예제 #9
0
 private void CreateOffset(int index)
 {
     for (int i = 0; i < Repositories.ListUserControl.Count(); i++)
     {
         if (i == Repositories.ListUserControl.Count)
         {
         }
         else
         {
             SqareVM sqare = Repositories.ListUserControl[i].DataContext as SqareVM;
             if (sqare.Position.Y + Repositories.ListUserControl[i].ActualHeight >= Repositories.PointEnd[index].Y)
             {
                 CreateOffset(sprites.ActualHeight - 30, i);
             }
         }
     }
 }
예제 #10
0
        private List <int> CheckPosition()  //возвращает список индексо элементов из списка, если в этом месте уже есть элемент
        {
            List <int> ListIndex = new List <int>();

            for (int i = 0; i < InforOfSprites.ListUserControl.Count(); i++)
            {
                SqareVM sqare = InforOfSprites.ListUserControl[i].DataContext as SqareVM;
                if (posNow.Y > sqare.Position.Y && InforOfSprites.ListUserControl[i].ActualHeight + sqare.Position.Y > posNow.Y)
                {
                    if (InforOfSprites.ListUserControl[i].ActualHeight > 40)
                    {
                        ListIndex.Add(i);
                    }
                }
            }

            return(ListIndex);
        }
예제 #11
0
        private UserControl1 RetUser()  // установление данных
        {
            SqareVM      square         = userControl.DataContext as SqareVM;
            UserControl1 userControlnew = new UserControl1();

            userControlnew.DataContext = new SqareVM()
            {
                Position   = posNow,
                PointWhike = square.PointWhike,
                Color      = square.Color,
                Id         = square.Id,
                Text       = square.Text,
                Width      = square.Width,
                HeightFor  = square.HeightFor,
                HeighDown  = square.HeighDown
            };

            return(userControlnew);
        }
        private void RenderEndlesse(object sender, EventArgs e)  //бесконечный цикл
        {
            if (InforOfSprites.visualis)
            {
                if (i == IndexCirce)
                {
                    i = IndexCirecleEnd;
                }

                if (sqare.Znatch != 0)
                {
                    if (nnn == sqare.Znatch * 10)
                    {
                        nnn = 0;
                        i--;
                    }
                }
                else
                {
                    i--;
                }



                sqare = (SqareVM)ListUsers[i].DataContext as SqareVM;

                if (sqare.Text == "Идти вперед")
                {
                    speed = 3;
                }
                Motions();
                Conditions();
                Circle();
            }
            else
            {
                CompositionTarget.Rendering -= RenderEndlesse;
            }
        }
예제 #13
0
        public UserControl1 RetUser(SqareVM square, Point point)  // установление данных
        {
            UserControl1 userControl = new UserControl1();

            userControl.DataContext = new SqareVM()
            {
                Position   = point,
                PointWhike = square.PointWhike,
                Color      = square.Color,
                Id         = square.Id,
                Text       = square.Text,
                Width      = SizeText(square.Text),
                HeightFor  = square.HeightFor,
                HeighDown  = square.HeighDown
            };
            int SizeText(string scriptText)
            {
                return(scriptText.Length * 10 + 20);
            }

            return(userControl);
        }
예제 #14
0
        private void CreateVoid()
        {
            SqareVM sqaren = (SqareVM)userControl.DataContext as SqareVM;

            if (InforOfSprites.ListUserControl != null && sqaren.Text != "Когда запущен")
            {
                List <int> ListIndex = CheckPosition();
                if (ListIndex.Count() == 0)
                {
                    posNow = new Point(InforOfSprites.StartX, InforOfSprites.StartY);
                    InforOfSprites.StartY += userControl.ActualHeight - userControl.Increase.ActualHeight;
                    ClonUserControl();
                    userControl.Increase.Height = 0;
                    InforOfSprites.ListUserControl.Insert(InforOfSprites.ListUserControl.Count(), userControl);
                }
                else
                {
                    ListIndex.Sort();

                    int n = ListIndex.Last();

                    SqareVM sqare = (SqareVM)InforOfSprites.ListUserControl[n].DataContext as SqareVM;

                    if (userControl.ActualHeight > 50)
                    {
                        posNow = new Point(sqare.Position.X + 20, sqare.Position.Y + InforOfSprites.ListUserControl[n].ActualHeight - InforOfSprites.ListUserControl[n].BOTTON.ActualHeight);
                        InforOfSprites.StartY += userControl.ActualHeight;

                        TransforElNow(ListIndex);
                        ListIndex = GetListElBottom(n);
                        TransformElBotton(ListIndex);

                        ClonUserControl();
                        userControl.Increase.Height = 0;
                        InforOfSprites.ListUserControl.Insert(++n, userControl);
                    }
                    else
                    {
                        posNow = new Point(sqare.Position.X + 20, sqare.Position.Y + InforOfSprites.ListUserControl[n].ActualHeight - InforOfSprites.ListUserControl[n].BOTTON.ActualHeight);
                        InforOfSprites.StartY += userControl.ActualHeight;

                        TransforElNow(ListIndex);
                        ListIndex = GetListElBottom(n);
                        TransformElBotton(ListIndex);

                        ClonUserControl();
                        InforOfSprites.ListUserControl.Insert(++n, userControl);
                    }
                }
            }
            else
            {
                if (sqaren.Text == "Когда запущен" && InforOfSprites.ListUserControl == null)
                {
                    InforOfSprites.ListUserControl = new List <UserControl1>();
                    InforOfSprites.StartX          = posNow.X;
                    InforOfSprites.StartY          = posNow.Y + userControl.ActualHeight;
                    ClonUserControl();
                    InforOfSprites.ListUserControl.Insert(InforOfSprites.ListUserControl.Count(), userControl);
                }
            }
        }