Пример #1
0
        public void StartAnimate(int reciverID, PacketType packetType)
        {
            Thread thread = new Thread(() =>
            {
                lock (sender.MyArrows)
                {
                    Arrow ar = GetArrow(reciverID);

                    if (ar != null)
                    {
                        lock (ar)
                        {
                            if (ar.Visibility == Visibility.Hidden)
                            {
                                if (Settings.Default.ShowAnimation)
                                {
                                    Action actionx = () => ar.BeginAnimation(packetType);
                                    sender.Dispatcher.Invoke(actionx);
                                    Action action1 = () => ar.Visibility = Visibility.Visible;
                                    sender.Dispatcher.Invoke(action1);
                                }
                                else
                                {
                                    Action action1 = () => ar.Visibility = Visibility.Visible;
                                    sender.Dispatcher.Invoke(action1);
                                    sender.Dispatcher.Invoke(() => ar.Stroke          = new SolidColorBrush(Colors.Black));
                                    sender.Dispatcher.Invoke(() => ar.StrokeThickness = 1);
                                    sender.Dispatcher.Invoke(() => ar.HeadHeight      = 1);
                                    sender.Dispatcher.Invoke(() => ar.HeadWidth       = 1);
                                }
                            }
                            else
                            {
                                if (Settings.Default.ShowAnimation)
                                {
                                    Action actionx = () => ar.BeginAnimation(packetType);
                                    sender.Dispatcher.Invoke(actionx);
                                    sender.Dispatcher.Invoke(() => ar.HeadHeight = 1);
                                    sender.Dispatcher.Invoke(() => ar.HeadWidth  = 1);
                                }
                                else
                                {
                                    sender.Dispatcher.Invoke(() => ar.Stroke          = new SolidColorBrush(Colors.Black));
                                    sender.Dispatcher.Invoke(() => ar.StrokeThickness = 1);
                                    sender.Dispatcher.Invoke(() => ar.HeadHeight      = 1);
                                    sender.Dispatcher.Invoke(() => ar.HeadWidth       = 1);
                                }
                            }
                        }
                    }
                }
            }
                                       );

            thread.Start();
            thread.Priority = ThreadPriority.Highest;
        }
Пример #2
0
        // When the sensor open the channel to transmit the data.
        private void OpenChanel(int reciverID, long PID)
        {
            Thread thread = new Thread(() =>
            {
                lock (MyArrows)
                {
                    Arrow ar = GetArrow(reciverID);
                    if (ar != null)
                    {
                        lock (ar)
                        {
                            if (ar.Visibility == Visibility.Hidden)
                            {
                                if (Settings.Default.ShowAnimation)
                                {
                                    Action actionx = () => ar.BeginAnimation(PID);
                                    Dispatcher.Invoke(actionx);
                                    Action action1 = () => ar.Visibility = Visibility.Visible;
                                    Dispatcher.Invoke(action1);
                                }
                                else
                                {
                                    Action action1 = () => ar.Visibility = Visibility.Visible;
                                    Dispatcher.Invoke(action1);
                                    Dispatcher.Invoke(() => ar.Stroke          = new SolidColorBrush(Colors.Black));
                                    Dispatcher.Invoke(() => ar.StrokeThickness = 1);
                                    Dispatcher.Invoke(() => ar.HeadHeight      = 1);
                                    Dispatcher.Invoke(() => ar.HeadWidth       = 1);
                                }
                            }
                            else
                            {
                                if (Settings.Default.ShowAnimation)
                                {
                                    int cid        = Convert.ToInt16(PID % PublicParamerters.RandomColors.Count);
                                    Action actionx = () => ar.BeginAnimation(PID);
                                    Dispatcher.Invoke(actionx);
                                    Dispatcher.Invoke(() => ar.HeadHeight = 1);
                                    Dispatcher.Invoke(() => ar.HeadWidth  = 1);
                                }
                                else
                                {
                                    Dispatcher.Invoke(() => ar.Stroke          = new SolidColorBrush(Colors.Black));
                                    Dispatcher.Invoke(() => ar.StrokeThickness = 1);
                                    Dispatcher.Invoke(() => ar.HeadHeight      = 1);
                                    Dispatcher.Invoke(() => ar.HeadWidth       = 1);
                                }
                            }
                        }
                    }
                }
            }
                                       );

            thread.Start();
            thread.Priority = ThreadPriority.Highest;
        }
Пример #3
0
        private void Border_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            GridLengthAnimation glaLeft  = new GridLengthAnimation();
            GridLengthAnimation glaRight = new GridLengthAnimation();
            DoubleAnimation     rotation = new DoubleAnimation();
            DoubleAnimation     appear   = new DoubleAnimation();
            DoubleAnimation     hide     = new DoubleAnimation();

            glaLeft.Duration      = TimeSpan.FromMilliseconds(500);
            glaLeft.BeginTime     = TimeSpan.FromMilliseconds(500);
            glaRight.Duration     = TimeSpan.FromMilliseconds(500);
            glaRight.BeginTime    = TimeSpan.FromMilliseconds(500);
            rotation.Duration     = TimeSpan.FromMilliseconds(500);
            rotation.FillBehavior = FillBehavior.HoldEnd;
            rotation.BeginTime    = TimeSpan.FromMilliseconds(500);
            appear.Duration       = TimeSpan.FromMilliseconds(250);
            appear.FillBehavior   = FillBehavior.HoldEnd;
            appear.BeginTime      = TimeSpan.FromMilliseconds(500);
            appear.BeginTime      = TimeSpan.FromMilliseconds(750);
            appear.From           = 0;
            appear.To             = 1;
            hide.Duration         = TimeSpan.FromMilliseconds(250);
            hide.FillBehavior     = FillBehavior.HoldEnd;
            hide.From             = 1;
            hide.To = 0;

            if (IsLeftOpen == false)
            {
                //To SignIn
                glaLeft.From = new GridLength(1, GridUnitType.Star);
                glaLeft.To   = new GridLength(0, GridUnitType.Star);

                glaRight.From = new GridLength(0, GridUnitType.Star);
                glaRight.To   = new GridLength(1, GridUnitType.Star);

                rotation.From = 225;
                rotation.To   = 45;

                foreach (Border border in Container.Children)
                {
                    if (border.Tag?.ToString() == "SignIn")
                    {
                        border.BeginAnimation(OpacityProperty, hide);
                    }
                    else if (border.Tag?.ToString() == "SignUp")
                    {
                        border.BeginAnimation(OpacityProperty, appear);
                    }
                }
            }

            else
            {
                //To SignUp
                glaLeft.From = new GridLength(0, GridUnitType.Star);
                glaLeft.To   = new GridLength(1, GridUnitType.Star);

                glaRight.From = new GridLength(1, GridUnitType.Star);
                glaRight.To   = new GridLength(0, GridUnitType.Star);

                rotation.From = 45;
                rotation.To   = 225;

                foreach (Border border in Container.Children)
                {
                    if (border.Tag?.ToString() == "SignIn")
                    {
                        border.BeginAnimation(OpacityProperty, appear);
                    }
                    else if (border.Tag?.ToString() == "SignUp")
                    {
                        border.BeginAnimation(OpacityProperty, hide);
                    }
                }
            }

            Arrow.BeginAnimation(RotateTransform.AngleProperty, rotation);
            SignInColumn.BeginAnimation(ColumnDefinition.WidthProperty, glaLeft);
            SignUpColumn.BeginAnimation(ColumnDefinition.WidthProperty, glaRight);

            IsLeftOpen = !IsLeftOpen;
        }