Пример #1
0
        public TextBox()
        {
            lblText = new Label () { ScissorTest = true };
            rcCursor = new System.Windows.Shapes.Rectangle ();
            rcBackground = new System.Windows.Shapes.Rectangle ();

            rcCursor.Visible = false;

            this.HorizontalAlignment = HorizontalAlignment.Stretch;
            this.VerticalAlignment = VerticalAlignment.Stretch;
            //this.Foreground = Color.White;
            this.BorderThickness = new Thickness (1);
            //this.BorderColor = new Color (1f, 1f, 1f, .1f);
            //this.Width = 520;
            //this.Height = 40;

            this.Children.Add (lblText);
            this.Children.Add (rcCursor);
            this.Children.Add (rcBackground);

            this.FontScale = .35f;
            this.Focusable = true;
            this.Text = String.Empty;

            this.rcBackground.Opacity = .3f;
            this.rcCursor.Visible = false;
        }
Пример #2
0
        public Namyong(Brush[] imgs, ILwin.ShowScreen screen, int xpos, int ypos, int dir)
        {
            Random rnd = new Random();

            namyongBr = imgs;
            this.screen = screen;

            this.dir = dir;
            this.ypos = ypos;
            this.xpos = xpos;

            speedTerm = Constants.NAMYONG_SPEED;

            balloon = new Balloon(Constants.IS_NAMYONG, screen);
            balloon.showBalloon(dir, xpos, ypos);

            //생성
            namyongRec = new System.Windows.Shapes.Rectangle();
            namyongRec.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            namyongRec.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            namyongRec.Width = Constants.NAYONG_WIDTH;
            namyongRec.Height = Constants.NAYONG_HEIGHT;
            namyongRec.Fill = namyongBr[dir];
            namyongRec.Margin = new Thickness(xpos, ypos, 0, 0);
            screen.sp.Children.Add(namyongRec);

            isGettingKeyword = false;
            isJumping = false;
            isComputingRAM = false;
        }
Пример #3
0
 public DirectControl()
 {
     rectangle = new System.Windows.Shapes.Rectangle();
     try
     {
         CreateDirectImage();
         //throw new Exception("Artificial exception");
     }
     catch (Exception e)
     {
         // In case of error, just display message on Control
         messageBlock = new TextBlock() { Margin = new Thickness(5), Foreground = Brushes.Red };
         messageBlock.Text = "Error initializing DirectX control: " +  e.Message;
         messageBlock.Text += "\rTry installing latest DirectX End-User Runtime";
         this.Children.Add(messageBlock);
         directImage = null;
         initializationFailed = true;
         return;
     }
     directImage.RenderRequested += new EventHandler(directImage_RenderRequested);
     this.Children.Add(rectangle);
     RecreateImage();
     this.IsVisibleChanged += new DependencyPropertyChangedEventHandler(DirectControl_IsVisibleChanged);
     frontBufferCheckTimer.Tick += new EventHandler(frontBufferCheckTimer_Tick);
     frontBufferCheckTimer.Interval = TimeSpan.FromSeconds(0.5);
     frontBufferCheckTimer.Start();
 }
Пример #4
0
		public Window () {
			this.WindowStartUpLocation = WindowStartUpLocation.CenterScreen;
            
            rcBackground = new System.Windows.Shapes.Rectangle();
			rcBackground.StrokeThickness = 1;
            rcBackground.Parent = this;
			rcBackground.RadiusX = 0;
			rcBackground.RadiusY = 0;

            rcBackground.SetBinding (
                System.Windows.Shapes.Rectangle.FillProperty, 
                new Binding("Background") { 
                    Source = this,
                    Mode = BindingMode.OneWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                });

            rcBackground.SetBinding (
                System.Windows.Shapes.Rectangle.StrokeProperty,
                new Binding("BorderBrush") {
                    Source = this,
                    Mode = BindingMode.OneWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                });
		}
Пример #5
0
            public Box(int row, int col, Grid containingGrid, IList<Box> boxList, TextBlock textBox, WebLayoutChangerAction action)
            {
                _boxList = boxList;
                _grid = containingGrid;
                _textBox = textBox;
                _action = action;

                Row = row;
                Column = col;

                TheBorder = new Border();
                TheBorder.Style = System.Windows.Application.Current.Resources[Key_ToolLayout_BoxBorderStyle] as Style;

                TheRectangle = new System.Windows.Shapes.Rectangle();
                TheRectangle.Style = System.Windows.Application.Current.Resources[Key_ToolLayout_BoxNormalStyle] as Style;

                TheBorder.Child = TheRectangle;
                TheBorder.SetValue(Grid.RowProperty, row);
                TheBorder.SetValue(Grid.ColumnProperty, Column);
            
                _grid.Children.Add(TheBorder);
                
                TheRectangle.MouseEnter += TheRectangle_MouseEnter;
                _grid.MouseLeave += Grid_MouseLeave;

                TheRectangle.MouseLeftButtonUp += TheRectangle_MouseLeftButtonUp;
            }
Пример #6
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!this.isMouseDown) return;

            double curx = e.GetPosition(null).X;
            double cury = e.GetPosition(null).Y;

            var r = new System.Windows.Shapes.Rectangle
            {
                Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(145, 0, 0)),
                StrokeThickness = 2,
                Fill = new SolidColorBrush(Colors.White),
                Width = Math.Abs(curx - this.x),
                Height = Math.Abs(cury - this.y)
            };

            cnv.Children.Clear();
            cnv.Children.Add(r);
            Canvas.SetLeft(r, this.x);
            Canvas.SetTop(r, this.y);

            if (e.LeftButton == MouseButtonState.Released)
            {
                cnv.Children.Clear();
                this.width = e.GetPosition(null).X - this.x;
                this.height = e.GetPosition(null).Y - this.y;
                this.CaptureScreen(this.x, this.y, this.width, this.height);
                this.x = this.y = 0;
                this.isMouseDown = false;
                this.Hide();
            }
        }
Пример #7
0
		public WpfSpinButton ()
		{
			Width = 25;
			Height = 25;
			Background = new SolidColorBrush (Colors.Transparent);
			Storyboard = new Storyboard { RepeatBehavior = RepeatBehavior.Forever, Duration = TimeSpan.FromMilliseconds (Duration) };

			for (int i = 0; i < 360; i += 30) {
				// Create the rectangle and centre it in our widget
				var rect = new WpfRectangle { Width = 2, Height = 8, Fill = new SolidColorBrush (Colors.Black), RadiusX = 1, RadiusY = 1, Opacity = Values[0] };
				WpfCanvas.SetTop (rect, (Height - rect.Height) / 2);
				WpfCanvas.SetLeft (rect, Width / 2);

				// Rotate the element by 'i' degrees, creating a circle out of all the elements
				var group = new TransformGroup ();
				group.Children.Add (new RotateTransform (i, 0.5, -6));
				group.Children.Add (new TranslateTransform (0, 10));
				rect.RenderTransform = group;

				// Set the animation
				var timeline = new DoubleAnimationUsingKeyFrames ();
				Storyboard.SetTarget (timeline, rect);
				Storyboard.SetTargetProperty (timeline, new PropertyPath ("Opacity"));

				var offset = Duration * (i / 360.0);
				for (int j = 0; j < StartTimes.Length; j++) {
					var start = (StartTimes[j] + offset) % Duration;
					timeline.KeyFrames.Add (new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan (TimeSpan.FromMilliseconds (start)), Value = Values[j] });
				}
				Storyboard.Children.Add (timeline);
				Children.Add (rect);
			}
		}
        /// <summary>
        /// Handles the LandmarksFound event of the Camera control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="LandmarksEventArgs"/> instance containing the event data.</param>
        private void Camera_LandmarksFound(object sender, LandmarksEventArgs e)
        {
            try
            {
                Dispatcher.Invoke(() =>
                    {
                        Children.Clear();

                        foreach (var landmark in e.Landmarks)
                        {
                            double scaleX = this.ActualWidth / e.Width;
                            double scaleY = this.ActualHeight / e.Height;
                            var rect = new System.Windows.Shapes.Rectangle
                            {
                                Stroke = new SolidColorBrush(Colors.Yellow),
                                StrokeThickness = 1,
                                Margin = new Thickness((landmark.Value.X - 1) * scaleX, (landmark.Value.Y - 1) * scaleY, 0, 0),
                                Width = 2 * scaleX,
                                Height = 2 * scaleY
                            };
                            Children.Add(rect);
                        }
                    });
            }
            catch (TaskCanceledException)
            {
                // Do nothing.
            }
        }
Пример #9
0
        public Daddy(Brush[] imgs, ILwin.ShowScreen screen, int xpos, int ypos, int dir)
        {
            Random rnd = new Random();

            daddyBr = imgs;
            this.screen = screen;

            this.dir = dir;
            this.ypos = ypos;
            this.xpos = xpos;

            this.speedTerm = Constants.DADDY_SPEED;

            balloon = new Balloon(Constants.IS_DADDY, screen);
            balloon.showBalloon(dir, xpos, ypos);


            //생성
            daddyRec = new System.Windows.Shapes.Rectangle();
            daddyRec.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            daddyRec.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            daddyRec.Width = Constants.DADDY_WIDTH;
            daddyRec.Height = Constants.DADDY_HEIGHT;
            daddyRec.Fill = daddyBr[dir];
            daddyRec.Margin = new Thickness(xpos, ypos, 0, 0);
            screen.sp.Children.Add(daddyRec);

            isGettingKeyword = false;
            isJumping = false;
            isComputingCPU = false;
        }
Пример #10
0
        public static void RotateRectangle(ShapeRectangle rec, double angle, PointF middle)
        {
            RotateTransform rt = new RotateTransform
            {
                CenterX = middle.X,
                CenterY = middle.Y,
                Angle = angle
            };

            rec.LayoutTransform = rt;
        }
 public Visual UpdateVisual(IRenderContext context, Visual oldVisual)
 {
     System.Windows.Shapes.Rectangle rectangle = oldVisual as System.Windows.Shapes.Rectangle;
     if (rectangle == null)
     {
         return(CreateVisual(context));
     }
     else
     {
         rectangle.SetValue(CanvasControl.CanvasControlArrangeRectProperty, new Rect(this.rect.X, this.rect.Y, this.rect.Width, this.rect.Height));
         return(rectangle);
     }
 }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraFaceAnnotation"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        public CameraFaceAnnotation(ICameraView view)
        {
            CameraView = view;

            _rectangle = new System.Windows.Shapes.Rectangle 
            {
                Stroke = new SolidColorBrush(Colors.Yellow),
                StrokeThickness = 1
            };
            this.Children.Add(_rectangle);

            view.Camera.FaceFound += Camera_FaceFound;
        }
        /// <summary>
        /// Handles drag and drop functionality for favourtie color rectangles.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FavoriteRect_DragLeave(object sender, DragEventArgs e)
        {
            if (_isEyedropperMode)
            {
                return;
            }

            System.Windows.Shapes.Rectangle rect = (System.Windows.Shapes.Rectangle)sender;
            if (rect != null)
            {
                SetFavoriteColorRectangle((int)rect.Tag, _previousFillColor);
            }
        }
        /// <summary>
        /// Adds a MouseUp listener to the sender object when it detects a MouseDown.
        /// The purpose of this is to simulate a click event on the Rectangle object.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ColorRectangle_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (_isEyedropperMode)
            {
                return;
            }

            // We remove the MouseUp event first before adding it to ensure that at anytime there's only
            // one listener for the MouseUp event.
            System.Windows.Shapes.Rectangle rect = (System.Windows.Shapes.Rectangle)sender;
            rect.MouseUp -= ColorRectangle_MouseUp;
            rect.MouseUp += ColorRectangle_MouseUp;
        }
Пример #15
0
        void SetupTopMarginBorder()
        {
            var cluster = (Cluster)_subgraph.GeometryObject;

            _topMarginRect = new WRectangle
            {
                Fill   = WBrushes.Transparent,
                Width  = Node.Width,
                Height = cluster.RectangularBoundary.TopMargin
            };
            PositionTopMarginBorder(cluster);
            SetZIndexAndMouseInteractionsForTopMarginRect();
        }
 private void BtnDown(object sender, MouseButtonEventArgs e)
 {
     rectangle        = new Rectangle();
     rectangle.Stroke = Brushes.AliceBlue;
     positionI        = e.GetPosition(dessin);
     Canvas.SetTop(rectangle, positionI.Y);
     Canvas.SetLeft(rectangle, positionI.X);
     dessin.Children.Add(rectangle);
     timer          = new DispatcherTimer();
     timer.Interval = TimeSpan.FromMilliseconds(30);
     timer.Tick    += UpdateRect;
     timer.Start();
 }
Пример #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentControl_MouseMove(object sender, MouseEventArgs e)
        {
            Rectangle rectangle = sender as Rectangle;

            if (rectangle == null)
            {
                return;
            }
            if (m_IsMouseLeftButtonDown)
            {
                DoImageMove(rectangle, e);
            }
        }
Пример #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraFaceAnnotation"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        public CameraFaceAnnotation(ICameraView view)
        {
            CameraView = view;

            _rectangle = new System.Windows.Shapes.Rectangle
            {
                Stroke          = new SolidColorBrush(Colors.Yellow),
                StrokeThickness = 1
            };
            this.Children.Add(_rectangle);

            view.Camera.FaceFound += Camera_FaceFound;
        }
Пример #19
0
 public Leaves()
 {
     Health         = 5;
     MinDamageToHit = 1;
     Texture        = Battle.leaves;
     Body           = new System.Windows.Shapes.Rectangle
     {
         Width  = standartSize,
         Height = standartSize,
         Fill   = HelpfulFunctions.BitmapToBrush(Texture)
     };
     Panel.SetZIndex(Body, 10);
 }
Пример #20
0
        //use task but send params through func , as final i would guess
        private void DoTakeScreenShot(System.Windows.Shapes.Rectangle rect)
        {
            var bounds = System.Windows.Forms.Screen.GetBounds(System.Drawing.Point.Empty);

            using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)rect.Width, (int)rect.Height))
            {
                using (var g = System.Drawing.Graphics.FromImage(bitmap))
                {
                    g.CopyFromScreen(RectStart, System.Drawing.Point.Empty, RectSize);
                    bitmap.Save(BitmapLocation, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
            }
        }
Пример #21
0
        private void get_Icons(string mod_name, ref entity.Brillo.Security security)
        {
            toolBarData t = new toolBarData();

            foreach (DataRow row in t.dtIconList_property.Select("modIcon = '" + mod_name + "'"))
            {
                toolIcon_Mini ico = new toolIcon_Mini();

                string _toolTip            = row["tooltip"].ToString();
                var    appLocTextExtension = new LocTextExtension("COGNITIVO:local:" + _toolTip + "").SetBinding(ico, toolIcon_Mini.icoNameProperty);
                ico.imgSource = row["img"].ToString();
                ico.Cursor    = Cursors.Hand;
                ico.btnColor  = Brushes.AliceBlue;
                ico.iColor    = Brushes.RoyalBlue;
                ico           = check_Icons(ico, _toolTip, ref security);

                if (ico != null && row["placement"].ToString() == "m")
                {
                    if (_toolTip == "Delete")
                    {
                        ico.btnColor = Brushes.Silver;
                        ico.iColor   = Brushes.Black;
                        System.Windows.Shapes.Rectangle rect;
                        rect        = new System.Windows.Shapes.Rectangle();
                        rect.Fill   = new SolidColorBrush(Colors.Gainsboro);
                        rect.Width  = 0.5;
                        rect.Margin = new Thickness(4);
                        stackMain.Children.Add(rect);
                        stackMain.Children.Add(ico);
                    }
                    else
                    {
                        stackMain.Children.Add(ico);
                    }
                }
                else if (ico != null && row["placement"].ToString() == "s")
                { //Then Secondary Stack
                    if (_toolTip == "Annul")
                    {
                        ico.btnColor = Brushes.Pink;
                        ico.iColor   = Brushes.Crimson;
                    }
                    else if (_toolTip == "Approve")
                    {
                        ico.btnColor = Brushes.PaleGreen;
                        ico.iColor   = Brushes.Green;
                    }
                    stackSide.Children.Add(ico);
                }
            }
        }
Пример #22
0
        private static FrameworkElement BuildQuote(HtmlElement item)
        {
            Grid grid = new Grid();

            grid.Margin = new Thickness(24, 12, 0, 6);

            var rect = new System.Windows.Shapes.Rectangle();

            rect.StrokeDashArray = new DoubleCollection {
                4, 6
            };
            rect.Stroke  = new SolidColorBrush(Colors.Gray);
            rect.Stretch = Stretch.Fill;
            grid.Children.Add(rect);

            StackPanel panel = new StackPanel();

            panel.Margin = new Thickness(12);
            grid.Children.Add(panel);

            SolidColorBrush gray = new SolidColorBrush(Colors.Gray);

            foreach (var div in item.Descendants())
            {
                //if ("quote" == div.Attributes["class"])
                //{
                //    var text = new TextBlock { Text = div.InnerHtml };
                //    text.Foreground = gray;
                //    text.FontStyle = FontStyles.Italic;
                //    panel.Children.Add(text);
                //}
                //else if ("text" == div.Attributes["class"])
                {
                    //foreach (var e in div.Descendants())
                    if (div != null)
                    {
                        FrameworkElement p = BuildParagraph(div);
                        if (p is TextBlock)
                        {
                            (p as TextBlock).Foreground = gray;
                        }
                        if (p is RichTextBox)
                        {
                            (p as RichTextBox).Foreground = gray;
                        }
                        panel.Children.Add(p);
                    }
                }
            }
            return(grid);
        }
        private void Add_Favorite_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;

            if (menuItem == null)
            {
                return;
            }
            System.Windows.Shapes.Rectangle rect  = ((ContextMenu)(menuItem.Parent)).PlacementTarget as System.Windows.Shapes.Rectangle;
            System.Windows.Media.Color      color = ((SolidColorBrush)rect.Fill).Color;
            HSLColor clickedColor = GraphicsUtil.DrawingColorFromMediaColor(color);

            dataSource.AddColorToFavorites(clickedColor);
        }
Пример #24
0
 public override System.Windows.Shapes.Shape GetAgentShape()
 {
     if (_shape == null)
     {
         _shape = new System.Windows.Shapes.Rectangle()
         {
             Width           = Size.X * 2.5,
             Height          = Size.Y * 2.5,
             Stroke          = System.Windows.Media.Brushes.Black,
             StrokeThickness = 0.1
         };
     }
     return(_shape);
 }
Пример #25
0
        public void Movie()
        {
            // Create a red rectangle that will be the target
            // of the animation.
            System.Windows.Shapes.Rectangle myRectangle = new System.Windows.Shapes.Rectangle();
            myRectangle.Width  = 200;
            myRectangle.Height = 200;
            Color           myColor = Color.FromArgb(255, 255, 0, 0);
            SolidColorBrush myBrush = new SolidColorBrush();

            myBrush.Color    = myColor;
            myRectangle.Fill = myBrush;
            //
            // Add the rectangle to the tree.
            System.Windows.Controls.Canvas LayoutRoot = new System.Windows.Controls.Canvas();
            LayoutRoot.Children.Add(myRectangle);
            //
            // Create two DoubleAnimations and set their properties.
            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
            DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();

            //
            // Create a duration of 2 seconds.
            myDoubleAnimation1.Duration = TimeSpan.FromSeconds(0.2);
            myDoubleAnimation2.Duration = TimeSpan.FromSeconds(0.2);
            //
            Storyboard sb = new Storyboard();

            sb.Duration = TimeSpan.FromSeconds(0.2);
            //
            sb.Children.Add(myDoubleAnimation1);
            sb.Children.Add(myDoubleAnimation2);
            //
            Storyboard.SetTarget(myDoubleAnimation1, myRectangle);
            Storyboard.SetTarget(myDoubleAnimation2, myRectangle);
            //
            // Set the attached properties of Canvas.Left and Canvas.Top
            // to be the target properties of the two respective DoubleAnimations
            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath(Canvas.LeftProperty));
            Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath(Canvas.TopProperty));
            //
            myDoubleAnimation1.To = 200;
            myDoubleAnimation2.To = 200;
            //
            // Make the Storyboard a resource.
            LayoutRoot.Resources.Add("sb", sb);
            //
            // Begin the animation.
            sb.Begin();
        }
Пример #26
0
        protected override void DrawCore(int column, int row, System.Drawing.Color color)
        {
            Canvas playArea = (Canvas)DrawingContext;

            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
            Canvas.SetTop(rect, row * 50);
            Canvas.SetLeft(rect, column * 50);
            rect.Height          = 48;
            rect.Width           = 48;
            rect.Stroke          = System.Windows.Media.Brushes.White;
            rect.StrokeThickness = 1;
            rect.Fill            = new SolidColorBrush(System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B));
            playArea.Children.Add(rect);
        }
Пример #27
0
 /// <summary>
 /// Show all the points in the sketch.
 /// </summary>
 public void showPoints()
 {
     foreach (Sketch.Point point in panel.InkSketch.Sketch.Points)
     {
         System.Windows.Shapes.Rectangle p1 = new System.Windows.Shapes.Rectangle();
         p1.Fill = System.Windows.Media.Brushes.Red;
         System.Windows.Controls.InkCanvas.SetTop(p1, point.Y);
         System.Windows.Controls.InkCanvas.SetBottom(p1, point.Y + 1);
         System.Windows.Controls.InkCanvas.SetLeft(p1, point.X);
         System.Windows.Controls.InkCanvas.SetRight(p1, point.X + 1);
         panel.InkCanvas.Children.Add(p1);
         p1.Visibility = System.Windows.Visibility.Visible;
     }
 }
Пример #28
0
        public Rectangle placeFood()
        {
            Random rand = new Random();

            xFood = rand.Next(28) * 20;
            yFood = rand.Next(19) * 20;

            Rectangle food = new Rectangle();

            food.Width  = _foodSize;
            food.Height = _foodSize;
            food.Fill   = new SolidColorBrush(Color.FromRgb(228, 112, 58));
            return(food);
        }
Пример #29
0
        private void Form2_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown)
            {
                Debug.WriteLine("Mouse Move!");
                // 1. 通过一个矩形来表示目前截图区域
                System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
                double dx = e.X;
                double dy = e.Y;

                Debug.WriteLine("Move At X:{0} Y:{1}", dx, dy);

                double          rectWidth  = Math.Abs(dx - x);
                double          rectHeight = Math.Abs(dy - y);
                SolidColorBrush brush      = new SolidColorBrush(Colors.White);
                rect.Width           = (int)rectWidth;
                rect.Height          = (int)rectHeight;
                rect.Fill            = brush;
                rect.Stroke          = brush;
                rect.StrokeThickness = 1;

                this.rect.Width  = Convert.ToInt32(rect.Width);
                this.rect.Height = Convert.ToInt32(rect.Height);

                if (dx < x)
                {
                    this.rect.X = Convert.ToInt32(dx);
                    this.rect.Y = Convert.ToInt32(dy);

                    // Canvas.SetLeft(rect, dx);
                    // Canvas.SetTop(rect, dy);

                    //this.Invalidate(new Region(new Rectangle((int)dx, (int)dy, (int)rect.Width, (int)rect.Height)));
                }
                else
                {
                    this.rect.X = Convert.ToInt32(x);
                    this.rect.Y = Convert.ToInt32(y);
                    // Canvas.SetLeft(rect, x);
                    // Canvas.SetTop(rect, y);
                    //this.Invalidate(new Region(new Rectangle((int)x, (int)y, (int)rect.Width, (int)rect.Height)));
                }

                ClearBackgroup();
                DrawRect();

                // CaptureCanvas.Children.Clear();
                // CaptureCanvas.Children.Add(rect);
            }
        }
Пример #30
0
        private System.Windows.Shapes.Rectangle AddSelection(Rect rect)
        {
            var rectangle = new System.Windows.Shapes.Rectangle();

            rectangle.Width  = rect.Width;
            rectangle.Height = rect.Height;
            rectangle.Fill   = new SolidColorBrush(System.Windows.Media.Color.FromArgb(50, 255, 0, 0));

            this.canvas.Children.Add(rectangle);
            Canvas.SetLeft(rectangle, rect.X);
            Canvas.SetTop(rectangle, rect.Y);

            return(rectangle);
        }
Пример #31
0
        private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (this._isMouseDown)
            {
                _currentPos = e.GetPosition(null);

                // Value for drawing rectangles outside of capture area
                var rectOffset = 1;

                var backRect = new System.Windows.Shapes.Rectangle();
                var rect     = new System.Windows.Shapes.Rectangle();

                _whiteBrush.Freeze();
                backRect.Stroke          = _whiteBrush;
                backRect.StrokeDashArray = new DoubleCollection()
                {
                    5, 0
                };

                _blackBrush.Freeze();
                rect.Stroke          = _blackBrush;
                rect.StrokeDashArray = new DoubleCollection()
                {
                    5, 5
                };

                _x = Math.Min(_currentPos.X, _startPos.X);
                _y = Math.Min(_currentPos.Y, _startPos.Y);

                _width         = Math.Max(_currentPos.X, _startPos.X) - _x + 1;
                backRect.Width = rect.Width = _width + rectOffset * 2;

                _height         = Math.Max(_currentPos.Y, _startPos.Y) - _y + 1;
                backRect.Height = rect.Height = _height + rectOffset * 2;

                canvas.Children.Clear();
                canvas.Children.Add(backRect);
                canvas.Children.Add(rect);

                Canvas.SetLeft(backRect, _x - rectOffset);
                Canvas.SetTop(backRect, _y - rectOffset);
                Canvas.SetLeft(rect, _x - rectOffset);
                Canvas.SetTop(rect, _y - rectOffset);

                if (e.LeftButton == MouseButtonState.Released)
                {
                    lock (_mouseLock) { FinishDrawing(); }
                }
            }
        }
Пример #32
0
        public override void Draw(Canvas canvas)
        {
            System.Windows.Shapes.Rectangle ellipse = new System.Windows.Shapes.Rectangle
            {
                Fill   = new SolidColorBrush(FigureColor),
                Stroke = new SolidColorBrush(LineColor),
                Width  = Width,
                Height = Height
            };
            Canvas.SetTop(ellipse, Top);
            Canvas.SetLeft(ellipse, Left);

            canvas.Children.Add(ellipse);
        }
Пример #33
0
        /// <summary>
        /// Draw a single pixel on the canvas.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void AddPixel(double x, double y, int size, Canvas c)
        {
            Point     p   = new Point(x * size, y * size);
            Rectangle rec = c.InputHitTest(p) as Rectangle;

            if ((_brush && c.Name == "canvas") || (_brushImg && c.Name == "canvasImg"))
            {
                rec.Fill = new SolidColorBrush(Colors.Black);
            }
            else
            {
                rec.Fill = new SolidColorBrush(Colors.White);
            }
        }
        private void LeftClickOnRectangle(Rectangle rect)
        {
            rect.RaiseEvent(
                new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left)
            {
                RoutedEvent = UIElement.MouseDownEvent
            });

            rect.RaiseEvent(
                new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left)
            {
                RoutedEvent = UIElement.MouseUpEvent
            });
        }
        private void Set_Main_Color_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;

            if (menuItem == null)
            {
                return;
            }
            System.Windows.Shapes.Rectangle rect  = ((ContextMenu)(menuItem.Parent)).PlacementTarget as System.Windows.Shapes.Rectangle;
            System.Windows.Media.Color      color = ((SolidColorBrush)rect.Fill).Color;
            Color selectedColor = Color.FromArgb(color.A, color.R, color.G, color.B);

            dataSource.SelectedColor = new HSLColor(selectedColor);
        }
Пример #36
0
 private void MyLoaded(Object sender, RoutedEventArgs e)
 {
     if (loaded == true)
     {
         return;
     }
     //if (Util.IsDesignTime == true) this.Text = this.Text; //Forza la visualizzazione corretta della scritta per far posto alla checkbox.
     try
     {
         rctOverText = (System.Windows.Shapes.Rectangle) this.Template.FindName("rctOverText", this);
         rctOverText.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(rctMouseHand_MouseLeftButtonUp);
     }
     finally
     { loaded = true; }
 }
Пример #37
0
        public Screen(System.Windows.Controls.Image screen, System.Windows.Shapes.Rectangle screenEdge)
        {
            _bitmap = new WriteableBitmap(CreateBitmapImage());

            _bitmapRect = new Int32Rect(0, 0, Width, Height);

            _screen         = screen;
            _screen.Width   = Width;
            _screen.Height  = Height;
            _screen.Stretch = Stretch.Fill;
            _screen.Source  = _bitmap;

            screenEdge.Width  = Width;
            screenEdge.Height = Height;
        }
Пример #38
0
        public override void Draw(Canvas canvas)
        {
            var rectangle = new System.Windows.Shapes.Rectangle()
            {
                Height          = Height,
                Width           = Width,
                Stroke          = Color,
                StrokeThickness = Thickness,
                Tag             = Tag
            };

            Tag = rectangle.GetHashCode();
            StartPoint(rectangle, canvas);
            canvas.Children.Add(rectangle);
        }
Пример #39
0
        private void ShowColorPicker(object sender, MouseButtonEventArgs args)
        {
            activeRectangle = sender as Rectangle;

            if (GridColorPicker.Visibility == Visibility.Collapsed)
            {
                GridColorPicker.Visibility = Visibility.Visible;
                TabControlColors.IsEnabled = false;
            }
            else
            {
                GridColorPicker.Visibility = Visibility.Collapsed;
                TabControlColors.IsEnabled = true;
            }
        }
Пример #40
0
            public ColorBoxMenuItem(Brush brush)
            {
                Padding = new Thickness(0.0);
                Margin  = new Thickness(0.0);

                Icon = new System.Windows.Shapes.Rectangle()
                {
                    Height = 10,
                    Width  = 10,
                    Fill   = brush,
                    Stroke = Brushes.Black,
                };

                CommandParameter = brush;
            }
Пример #41
0
        //rectangle rotate
        private void Rect_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            System.Windows.Shapes.Rectangle current = (sender as System.Windows.Shapes.Rectangle);
            Angle += 90;
            RotateTransform rotate = new RotateTransform(Angle, current.Width / 2, current.Height / 2);

            current.RenderTransform = rotate;

            if (Angle == 360)
            {
                Angle = 0;
            }

            // System.Diagnostics.Debug.WriteLine("angle = {0}", Angle);
        }
Пример #42
0
		public override void Invalidate () {
			base.Invalidate ();
			if (this.IsInitialized) {
				if (rcBackground == null ) {
					rcBackground = new System.Windows.Shapes.Rectangle( );
					rcBackground.Parent = this;
					rcBackground.Initialize ();
				}
				rcBackground.Stroke = this.BorderBrush;
				rcBackground.Fill = this.Background;
				rcBackground.StrokeThickness = this.BorderThickness.Left;
				rcBackground.RadiusX = this.CornerRadiusX;
				rcBackground.RadiusY = this.CornerRadiusY;
				rcBackground.Invalidate ();
			}
		}
    public static void InitializeFrom(this Border nativeControl, Abstractions.RoundedBoxView formsControl)
    {
      if (nativeControl == null || formsControl == null)
        return;

      nativeControl.Height = formsControl.HeightRequest;
      nativeControl.Width = formsControl.WidthRequest;
      nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
      nativeControl.UpdateBorderColor(formsControl.BorderColor);
      
      var rectangle = new Rectangle();

      rectangle.InitializeFrom(formsControl);

      nativeControl.Child = rectangle;
    }
Пример #44
0
    /// <summary>
    /// Sets up a new run method manager.
    /// </summary>
    /// <param name="runNextStep">
    /// Conditional delegate which returns true as long as there is 
    /// additional work.
    /// </param>
    /// <param name="dispatcher">An instance of the dispatcher to use.</param>
    public FastRunDispatcher(Func<bool> runNextStep, Dispatcher dispatcher)
      : base(runNextStep)
    {
      // Last attempt to setup the dispatcher
      if (dispatcher == null)
      {
        FrameworkElement element = new System.Windows.Shapes.Rectangle();
        dispatcher = element.Dispatcher;
      }

      if (dispatcher == null)
      {
        throw new ArgumentNullException("dispatcher");
      }

      _dispatcher = dispatcher;
    }
Пример #45
0
        public void CreateOrUpdateVisualRepresentation()
        {
            if (_firstTimeDrawing)
            {
            	// First time it loops through, creates and colors the rectangles.
                for (int y = 0; y < ImageHeight; y++)
                {
                    for (int x = 0; x < ImageWidth; x++)
                    {
                        int[] coordinates = {x, y};

                        System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle()
                        {
                            Height = 10,
                            Width = 10,
                            Tag = coordinates,
                            Fill = DecideColor(_pixelsCurrentlyActive[y, x])
                        };
                        BuildingBlockContainer.Children.Add(rect);
                    }
                }
                _firstTimeDrawing = false;
            }
            else
            {
                foreach (System.Windows.Shapes.Rectangle rect in BuildingBlockContainer.Children)
                {
                    if (rect is System.Windows.Shapes.Rectangle)
                    {
                        System.Windows.Shapes.Rectangle rectangle = rect as System.Windows.Shapes.Rectangle;
                        int[] coordinates = rectangle.Tag as int[];
                        if (coordinates != null)
                        {
                            rectangle.Fill = DecideColor(_pixelsCurrentlyActive[coordinates[1], coordinates[0]]);
                        }
                        else
                        {
                            throw new GeneralInternalException("The rectangles coordinates could not be found.");
                        }
                        
                    }
                }
            }
        }
Пример #46
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var icon = (sender as Button).DataContext as IconWrapper;

            var grid = new Grid {Height = 36, Width = 36, Background = Brushes.White};
            var visual = new Rectangle {Fill = icon.Icon};
            grid.Children.Add(visual);
            var renderBitmap = new RenderTargetBitmap(36, 36, 96d, 96d, PixelFormats.Pbgra32);

            var size = new Size(36, 36);
            grid.Measure(size);
            grid.Arrange(new Rect(size));

            // Update the layout for the surface. This should flush out any layout queues that hold a reference.

            renderBitmap.Render(grid);

            Clipboard.SetImage(renderBitmap);
        }
Пример #47
0
 public void InitializeComponent()
 {
     if (_contentLoaded) {
         return;
     }
     System.Windows.Application.LoadComponent(this, new System.Uri("MainPage.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.secondHand = ((System.Windows.Shapes.Rectangle)(this.FindName("secondHand")));
     this.secondHandTransform = ((System.Windows.Media.RotateTransform)(this.FindName("secondHandTransform")));
     this.minuteHand = ((System.Windows.Shapes.Rectangle)(this.FindName("minuteHand")));
     this.minuteHandTransform = ((System.Windows.Media.RotateTransform)(this.FindName("minuteHandTransform")));
     this.hourHand = ((System.Windows.Shapes.Rectangle)(this.FindName("hourHand")));
     this.hourHandTransform = ((System.Windows.Media.RotateTransform)(this.FindName("hourHandTransform")));
     this.clockStoryboard = ((System.Windows.Media.Animation.Storyboard)(this.FindName("clockStoryboard")));
     this.hourAnimation = ((System.Windows.Media.Animation.DoubleAnimation)(this.FindName("hourAnimation")));
     this.minuteAnimation = ((System.Windows.Media.Animation.DoubleAnimation)(this.FindName("minuteAnimation")));
     this.secondAnimation = ((System.Windows.Media.Animation.DoubleAnimation)(this.FindName("secondAnimation")));
     _contentLoaded = true;
 }
Пример #48
0
        public flyingBox(Brush[] boxBr, ILwin.ShowScreen screen, int xpos, int ypos, int dir)
        {
            Random rnd = new Random();

            this.boxBr = boxBr;
            this.screen = screen;

            this.dir = dir;
            this.ypos = ypos;
            this.xpos = xpos;
            //위치 선정
            

            //생성
            boximg = new System.Windows.Shapes.Rectangle();
            boximg.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            boximg.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            boximg.Width = boximg.Height = 120;     //이미지의 너비다.
            boximg.Fill = boxBr[dir];
            boximg.Margin = new Thickness(xpos, ypos, 0, 0);
            screen.sp.Children.Add(boximg);


        }
Пример #49
0
        public dyn3DPreview()
        {
            InPortData.Add(new PortData("IN", "Incoming geometry objects.", typeof(object)));
            OutPortData.Add(new PortData("OUT", "Watch contents, passed through", typeof(object)));

            NodeUI.RegisterAllPorts();

            //get rid of right click delete
            //this.MainContextMenu.Items.Clear();

            MenuItem mi = new MenuItem();
            mi.Header = "Zoom to Fit";
            mi.Click +=new RoutedEventHandler(mi_Click);

            NodeUI.MainContextMenu.Items.Add(mi);

            //take out the left and right margins
            //and make this so it's not so wide
            NodeUI.inputGrid.Margin = new Thickness(10, 10, 10, 10);

            isScreenShot = true;

            if (isScreenShot)
            {
                NodeUI.topControl.Width = 800;
                NodeUI.topControl.Height = 500;
            }
            else
            {
                NodeUI.topControl.Width = 400;
                NodeUI.topControl.Height = 300;
            }

            //this.elementShine.Visibility = System.Windows.Visibility.Hidden;
            //this.elementRectangle.Visibility = System.Windows.Visibility.Hidden;

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            view = new HelixViewport3D();
            view.DataContext = this;
            view.CameraRotationMode = CameraRotationMode.Turntable;
            view.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            view.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            //RenderOptions.SetEdgeMode(view,EdgeMode.Aliased);
            RenderOptions.SetEdgeMode(view, EdgeMode.Unspecified);
            view.ShowViewCube = false;

            //view.IsHitTestVisible = true;
            view.ShowFrameRate = true;

            view.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseRightButtonUp);
            view.PreviewMouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_PreviewMouseRightButtonDown);

            fixedPoints = new PointsVisual3D { Color = Colors.Red, Size = 8 };
            view.Children.Add(fixedPoints);

            points = new PointsVisual3D { Color = Colors.Black, Size = 4 };
            view.Children.Add(points);

            // a list of 10 colors to be used for
            // mapping analysis results
            colors.Add(Colors.Black); //01
            colors.Add(Colors.LightBlue); //02
            colors.Add(Colors.Blue); //03
            colors.Add(Colors.Purple); //04
            colors.Add(Colors.LightGreen); //05
            colors.Add(Colors.GreenYellow); //06
            colors.Add(Colors.Yellow); //07
            colors.Add(Colors.Orange); //08
            colors.Add(Colors.OrangeRed); //09
            colors.Add(Colors.Red); //10
            colors.Add(Colors.Black);//11 for naked lines and curves

            FixedPoints = new Point3DCollection();
            Points = new List<Point3DCollection>();
            for (int i = 0; i < colors.Count(); i++)
            {
                Points.Add(new Point3DCollection());
            }

            linesList = new List<LinesVisual3D>();
            for (int i = 0; i < colors.Count(); i++)
            {
                LinesVisual3D lines = new LinesVisual3D { Color = colors[i], Thickness = 1 };

                linesList.Add(lines);
                view.Children.Add(lines);
            }

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            backgroundRect.RadiusX = 10;
            backgroundRect.RadiusY = 10;
            backgroundRect.IsHitTestVisible = false;
            BrushConverter bc = new BrushConverter();
            Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");
            backgroundRect.Stroke = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250,250,216));
            backgroundRect.Fill = backgroundBrush;
            NodeUI.inputGrid.Children.Add(backgroundRect);
            NodeUI.inputGrid.Children.Add(view);

            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }
        private void ExecuteSelectImageCommand()
        {
            testItemController.MinimizeTestItemEditorWindow();

            Window window = new Window();
            window.Height = SystemParameters.VirtualScreenHeight;
            window.Width = SystemParameters.VirtualScreenWidth;
            bool doPicture = false;

            Canvas canvas = new Canvas();
            canvas.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 100,100,100));
            Rectangle rectangle = new Rectangle();
            rectangle.StrokeThickness = 2;
            rectangle.Stroke = Brushes.Red;
            rectangle.Height = 0;
            rectangle.Width = 0;
            Canvas.SetTop(rectangle, 0);
            Canvas.SetLeft(rectangle, 0);
            System.Drawing.Point point = new System.Drawing.Point();

            GlobalHooker hooker = new GlobalHooker();
            MouseHookListener listener = new MouseHookListener(hooker);

            bool isMouseDown = false;
            bool isComplete = false;
            System.Drawing.Point topLeft = new System.Drawing.Point();
            System.Drawing.Point bottomRight = new System.Drawing.Point();

            listener.MouseDown += (o, args) =>
            {
                isMouseDown = true;
                topLeft = System.Windows.Forms.Cursor.Position;
            };

            listener.MouseUp += (o, args) =>
            {

                isMouseDown = false;
                bottomRight = System.Windows.Forms.Cursor.Position;
                isComplete = true;
            };

            listener.Enabled = true;

            Task task = new Task(() =>
            {
                listener.Enabled = true;

                while (!isComplete)
                {
                    Thread.Sleep(250);
                    while (isMouseDown)
                    {
                        point = System.Windows.Forms.Cursor.Position;

                        Rect bounds = new Rect(new Point(topLeft.X, topLeft.Y), new Point(point.X, point.Y));

                        Thread.Sleep(100);
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            rectangle.Width = bounds.Width;
                            rectangle.Height = bounds.Height;
                            Canvas.SetTop(rectangle, bounds.Y);
                            Canvas.SetLeft(rectangle, bounds.X);
                        }));
                    }
                }

            });

            canvas.Children.Add(rectangle);
            window.Left = 0;
            window.Top = 0;

            window.Content = canvas;
            window.WindowStyle = new WindowStyle();
            window.ShowInTaskbar = false;
            window.AllowsTransparency = true;

            Bitmap screenshot = new Bitmap(1,1);

            BitmapImage bitmapImage = new BitmapImage();

            window.Topmost = true;

            Task waitTask = new Task(() =>
            {
                Thread.Sleep(3000);
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    using (MemoryStream memory = new MemoryStream())
                    {
                        screenshot = Camera.Capture(0, ScreenCaptureMode.Screen);
                        screenshot.Save(memory, ImageFormat.Png);
                        memory.Position = 0;

                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = memory;
                        bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                        bitmapImage.EndInit();
                    }

                    window.Background = new ImageBrush(bitmapImage);

                    window.Show();
                }));

            });

            task.ContinueWith(t =>
            {
                System.Drawing.Rectangle systemRect = new System.Drawing.Rectangle(topLeft.X, topLeft.Y,
                    bottomRight.X-topLeft.X, bottomRight.Y-topLeft.Y);

                Bitmap tempBitmap = new Bitmap(systemRect.Width, systemRect.Height);

                using (Graphics g = Graphics.FromImage(tempBitmap))
                {
                    g.DrawImage(screenshot, new System.Drawing.Rectangle(0, 0, tempBitmap.Width, tempBitmap.Height),
                        systemRect, GraphicsUnit.Pixel);
                }

                Image = tempBitmap;

                TestItem testItem = testItemController.CurrentTestItem;
                OperationParameter operationParameter = testItem.Operation.GetParameterNamed("Image");
                operationParameter.Value = Image;

                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    window.Close();
                    Thread.Sleep(500);
                    testItemController.RestoreTestItemEditorWindow();
                    Thread.Sleep(500);
                    testItemController.RestoreTestItemEditorWindow();
                }));

            });

            waitTask.Start();
            waitTask.ContinueWith(t => task.Start());

            window.Closed += (o, args) =>
            {
                doPicture = false;
                task.Dispose();
            };
        }
Пример #51
0
        public ComboBoxItemColor(string colorName)
        {
            ColorName = colorName;
            System.Drawing.Color color = System.Drawing.Color.FromName(ColorName);
            ColorDrawing = color;
            ColorMedia = Color.FromArgb(color.A, color.R, color.G, color.B);

            var r = new System.Windows.Shapes.Rectangle
            {
                Width = 14,
                Height = 14,
                VerticalAlignment = VerticalAlignment.Center,
                Fill = new SolidColorBrush(ColorMedia),
                Stroke = new SolidColorBrush(Colors.Black),
                StrokeThickness = 1
            };

            if (color.A == 0)
            {
                r.Fill = new LinearGradientBrush
                {
                    GradientStops = new GradientStopCollection(1)
                };
            }

            var l = new Label
            {
                Height = 16,
                VerticalAlignment = VerticalAlignment.Center,
                VerticalContentAlignment = VerticalAlignment.Center,
                Padding = new Thickness(0),
                Content = ColorName,
                Margin = new Thickness(5, 0, 0, 0)
            };

            var sp = new StackPanel
            {
                Height = 16,
                Orientation = Orientation.Horizontal
            };
            sp.Children.Add(r);
            sp.Children.Add(l);

            Content = sp;
        }
        private void UpperOrLowerPictureTap(object sender, GestureEventArgs e)
        {
            var timerValue = int.Parse(TimeTextBlock.Text);

            if (timerValue >= App.ViewModel.TimeDetuctValue) {
                TimeTextBlock.Text = (timerValue - App.ViewModel.TimeDetuctValue).ToString(CultureInfo.InvariantCulture);
                DeductTimeTextBlock.Text = "-" + App.ViewModel.TimeDetuctValue;
                RadAnimationManager.Play(DeductTimeTextBlock, TimerDeductAnimation(), () => DeductTimeTextBlock.Text = string.Empty);
            }
            _wrongSoundEffect.Play();

            var point = e.GetPosition(sender as UIElement);

            var r1 = new Rectangle { Fill = new SolidColorBrush(Colors.Red) { Opacity = 1 }, Width = 16, Height = 16 };
            Canvas.SetLeft(r1, point.X - 8);
            Canvas.SetTop(r1, point.Y - 8);
            UpperPictureCanvas.Children.Add(r1);

            var r2 = new Rectangle { Fill = new SolidColorBrush(Colors.Red) { Opacity = 1 }, Width = 16, Height = 16 };
            Canvas.SetLeft(r2, point.X - 8);
            Canvas.SetTop(r2, point.Y - 8);
            LowerPictureCanvas.Children.Add(r2);

            RadAnimationManager.Play(r1, _tapWrongAnimation, () => UpperPictureCanvas.Children.Remove(r1));
            RadAnimationManager.Play(r2, _tapWrongAnimation, () => LowerPictureCanvas.Children.Remove(r2));
        }
Пример #53
0
        private void ShowColorPicker(object sender, MouseButtonEventArgs args)
        {
            activeRectangle = sender as Rectangle;

            if (GridColorPicker.Visibility == Visibility.Collapsed)
            {
                GridColorPicker.Visibility = Visibility.Visible;
                TabControlColors.IsEnabled = false;
            }
            else
            {
                GridColorPicker.Visibility = Visibility.Collapsed;
                TabControlColors.IsEnabled = true;
            }
        }
Пример #54
0
        /// <summary>
        /// 根据相应的饼图数据生成饼图标签
        /// </summary>
        /// <param name="ienumerable">饼图数据集合</param>
        private void SetPieMark2(IEnumerable<AircraftSeattingStatisticByYear> ienumerable, Grid grid)
        {
            RadPieChart radpiechart = grid.Children[0] as RadPieChart;
            StackPanel stackpanel = (grid.Children[1] as ScrollViewer).Content as StackPanel;

            radpiechart.Series[0].SliceStyles.Clear();
            stackpanel.Children.Clear();
            if (ienumerable == null)
            {
                return;
            }
            foreach (var item in ienumerable)
            {
                Setter setter = new Setter();
                setter.Property = System.Windows.Shapes.Shape.FillProperty;
                setter.Value = item.Color;
                Style style = new Style();
                style.TargetType = typeof(System.Windows.Shapes.Path);
                style.Setters.Add(setter);
                radpiechart.Series[0].SliceStyles.Add(style);

                StackPanel barpanel = new StackPanel();
                barpanel.MouseLeftButtonDown += PiePanel_MouseLeftButtonDown2;
                barpanel.Orientation = Orientation.Horizontal;
                System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                rectangle.Width = 15;
                rectangle.Height = 15;
                rectangle.Fill = new SolidColorBrush(commonmethod.GetColor(item.Color));
                TextBlock textblock = new TextBlock();
                textblock.Text = item.AirlineName;
                textblock.Style = this._view.Resources.FirstOrDefault(p => p.Key.ToString() == "legendItemStyle").Value as Style;
                barpanel.Children.Add(rectangle);
                barpanel.Children.Add(textblock);
                stackpanel.Children.Add(barpanel);
            }
        }
Пример #55
0
        /// <summary>
        /// Draws a rectangle
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="pen"></param>
        /// <param name="brush"></param>

        public void DrawRectangle(Rect frame, Pen pen = null, NGraphics.Brush brush = null)
        {
            var rectangleEl = new System.Windows.Shapes.Rectangle();
            var offset = pen != null ? pen.Width : 0.0;
            rectangleEl.Width = frame.Width + offset;
            rectangleEl.Height = frame.Height + offset;

            if (brush != null)
                rectangleEl.Fill = GetBrush(brush);

            if (pen != null)
            {
                rectangleEl.Stroke = GetStroke(pen);
                rectangleEl.StrokeThickness = pen.Width;
            }

            rectangleEl.RenderTransform = Conversions.GetTransform(CurrentTransform);
            _canvas.Children.Add(rectangleEl);
            Canvas.SetLeft(rectangleEl, frame.X - offset / 2.0);
            Canvas.SetTop(rectangleEl, frame.Y - offset / 2.0);
        }
        private void CreateExplodeAnimation(double x, double y)
        {
            _bombPoppingSoundEffect.Play();

            Canvas bombingCanvas, effectCanvas;
            if (y < 360) {
                bombingCanvas = UpperPictureCanvas;
                effectCanvas = UpperEffectCanvas;
            }
            else {
                bombingCanvas = LowerPictureCanvas;
                effectCanvas = LowerEffectCanvas;
                y = y - 400;
            }

            var bombCircles = new List<Image>();

            for (int i = 0; i < 10; i++) {
                var bitmap = new BitmapImage(new Uri("/PhotoHuntAsianBeauty3;component/Images/diff_wrong.png", UriKind.RelativeOrAbsolute));
                var smokeImg = new Image {Source = bitmap, Width = 100, Height = 100};
                Canvas.SetLeft(smokeImg, x - 50 + (_random.Next(100) - 50));
                Canvas.SetTop(smokeImg, y - 50 + (_random.Next(100) - 50));
                bombCircles.Add(smokeImg);
                bombingCanvas.Children.Add(smokeImg);
            }

            var r = new Rectangle {
                Width = bombingCanvas.ActualWidth,
                Height = bombingCanvas.ActualHeight,
                Fill = new SolidColorBrush(Colors.White)
            };
            effectCanvas.Children.Add(r);

            var smokeBound = new Rect(x - 100, y - 100, 200, 200);
            SelectAnswer(smokeBound);

            RadAnimationManager.Play(r, BombFadeAnimation(), () => {
                effectCanvas.Children.Remove(r);
                bombCircles.ForEach( e => RadAnimationManager.Play(e, _bombFadeAnimation, () => bombingCanvas.Children.Remove(e)));
            });
        }
 private void PlayCountDownAnimation(TextBlock tb, RadAnimation scaleAndFade, Rectangle cover)
 {
     RadAnimationManager.Play(tb, scaleAndFade, () => Dispatcher.BeginInvoke(() => {
         var num = (int)tb.Tag;
         if (num == 3) {
             var chapter = StageUnlockManager.Instance.ChapterOfStage(_stage);
             var stageName = LocalizedResources.Stage(chapter.StageNumber(_stage));
             tb.Text = stageName;
             tb.Tag = 2;
             PlayCountDownAnimation(tb, scaleAndFade, cover);
         }
         else if (num == 2) {
             tb.Text = LocalizedResources.LocalizedStringResource.Ready;
             tb.Tag = 1;
             tb.FontSize = 60;
             PlayCountDownAnimation(tb, scaleAndFade, cover);
         }
         else {
             tb.Text = LocalizedResources.LocalizedStringResource.Go;
             tb.Tag = 0;
             tb.FontSize = 120;
             GameStart();
             RadAnimationManager.Play(tb, scaleAndFade, () => tb.Text = string.Empty);
             RadAnimationManager.Play(cover, new RadFadeAnimation {
                 StartOpacity = 1,
                 EndOpacity = 0,
                 Duration = TimeSpan.FromSeconds(1),
                 FillBehavior = AnimationFillBehavior.HoldEnd
             }, () => {
                 tb.Visibility = Visibility.Collapsed;
                 cover.Visibility = Visibility.Collapsed;
             });
         }
     }));
 }
        private void PlaySelectedAnimation(int row, int col)
        {
            var r1 = new Rectangle { Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 } };
            Grid.SetRow(r1, row);
            Grid.SetColumn(r1, col);
            UpperPictureGrid.Children.Add(r1);

            var r1Inner = new Rectangle {Fill = new SolidColorBrush(Colors.Red) {Opacity = 0.3}};
            r1Inner.RenderTransform = new ScaleTransform { CenterX = 8.0, CenterY = 8.0, ScaleX = 0.5, ScaleY = 0.5 };
            Grid.SetRow(r1Inner, row);
            Grid.SetColumn(r1Inner, col);
            UpperPictureGrid.Children.Add(r1Inner);

            var r2 = new Rectangle { Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 } };
            Grid.SetRow(r2, row);
            Grid.SetColumn(r2, col);
            LowerPictureGrid.Children.Add(r2);

            var r2Inner = new Rectangle { Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.3 } };
            r2Inner.RenderTransform = new ScaleTransform { CenterX = 8.0, CenterY = 8.0, ScaleX = 0.5, ScaleY = 0.5 };
            Grid.SetRow(r2Inner, row);
            Grid.SetColumn(r2Inner, col);
            LowerPictureGrid.Children.Add(r2Inner);

            RadAnimationManager.Play(r1, _tapAnimation);
            RadAnimationManager.Play(r2, _tapAnimation);
        }
Пример #59
0
        private void RenderGraph()
        {
            ClearRenderTargetBitmap(_heatMapGraph, Brushes.White);

            const double xAxisOffset = 250;
            const double yAxisOffset = 500;
            const double topOffset = 50;
            const double rightOffset = 250;

            var xAxisLength = _heatMapGraph.PixelWidth - (int)xAxisOffset - (int)rightOffset;
            var yAxisLength = _heatMapGraph.PixelHeight - (int)yAxisOffset - (int)topOffset;
            const double axisThickness = 10;
            var axisPen = new Pen(Brushes.Black, axisThickness);
            var axisTickPen = new Pen(Brushes.Black, axisThickness / 2);

            DrawHeatMap();
            var heatMapRect = new Rectangle
            {
                Fill = new ImageBrush(_heatMap) { Stretch = Stretch.Uniform },
                Effect = _heatMapColourEffect
            };

            var heatMapRectSize = new Size(xAxisLength, yAxisLength);

            heatMapRect.Measure(heatMapRectSize);
            heatMapRect.Arrange(new Rect(new Point(xAxisOffset + 5, topOffset), heatMapRectSize));

            _heatMapGraph.Render(heatMapRect);

            var heatMapKeyWidth = xAxisLength;
            const int heatMapKeyHeight = 100;

            var heatMapKeyRect = new Rectangle
            {
                Fill = new ImageBrush(DrawHeatKey(heatMapKeyWidth, heatMapKeyHeight)),
                Effect = _heatMapColourEffect
            };

            var heatMapKeySize = new Size(heatMapKeyWidth, heatMapKeyHeight);

            heatMapKeyRect.Measure(heatMapKeySize);
            heatMapKeyRect.Arrange(new Rect(new Point(xAxisOffset + 5, _heatMapGraph.PixelHeight - yAxisOffset + topOffset + 150), heatMapKeySize));

            _heatMapGraph.Render(heatMapKeyRect);

            var drawingVisual = new DrawingVisual();
            var textTypeFace = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
            const double headerFontSize = 80d;
            const double fontSize = 40d;
            const int numberOfTicks = 10;
            var fontBrush = Brushes.Black;
            using (var context = drawingVisual.RenderOpen())
            {
                //Y Axis
                context.DrawLine(axisPen, new Point(xAxisOffset, topOffset), new Point(xAxisOffset, topOffset + yAxisLength));
                //X Axis
                context.DrawLine(axisPen, new Point(xAxisOffset - 5, topOffset + yAxisLength), new Point(xAxisOffset + xAxisLength + 5, topOffset + yAxisLength));

                context.DrawText(new FormattedText(MinValue.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, textTypeFace, headerFontSize, fontBrush), new Point(xAxisOffset + 5, _heatMapGraph.PixelHeight - yAxisOffset + topOffset + 250));
                context.DrawText(new FormattedText(MaxValue.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, textTypeFace, headerFontSize, fontBrush), new Point(xAxisOffset + 5 + xAxisLength, _heatMapGraph.PixelHeight - yAxisOffset + topOffset + 250));

                context.DrawText(new FormattedText("Time", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, textTypeFace, headerFontSize, fontBrush), new Point(xAxisOffset + (xAxisLength / 2), topOffset + yAxisLength + 60));

                var dateDistance = (MaxTimestamp - MinTimestamp).Ticks / numberOfTicks;
                for (var i = 0; i < numberOfTicks; i++)
                {
                    var date = MinTimestamp + new TimeSpan(i * dateDistance);
                    var xValue = (1 - ((MaxTimestamp - date).TotalSeconds / (MaxTimestamp - MinTimestamp).TotalSeconds)) * xAxisLength + xAxisOffset;
                    context.DrawLine(axisTickPen, new Point(xValue, topOffset + yAxisLength), new Point(xValue, topOffset + yAxisLength + 20));
                    context.DrawText(new FormattedText(date.ToString("yyyy/MM/dd HH:mm"), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, textTypeFace, fontSize, fontBrush), new Point(xValue, topOffset + yAxisLength + 10));
                }

                context.PushTransform(new RotateTransform(90));

                context.DrawText(new FormattedText("Depth", CultureInfo.InvariantCulture, FlowDirection.LeftToRight, textTypeFace, headerFontSize, fontBrush), new Point((topOffset + (yAxisLength / 2)), -headerFontSize * 2));

                context.Pop();

                if (_depths != null)
                    foreach (var depthYValue in _depths)
                    {
                        context.DrawText(new FormattedText(depthYValue.Depth.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, textTypeFace, fontSize, fontBrush), new Point(xAxisOffset - 100, topOffset + (depthYValue.YValue / _heatMap.PixelHeight) * yAxisLength));
                        context.DrawLine(axisTickPen, new Point(xAxisOffset - 25, topOffset + (depthYValue.YValue / _heatMap.PixelHeight) * yAxisLength + (axisTickPen.Thickness / 2)), new Point(xAxisOffset, topOffset + (depthYValue.YValue / _heatMap.PixelHeight) * yAxisLength + (axisTickPen.Thickness / 2)));
                    }
            }

            _heatMapGraph.Render(drawingVisual);
        }
Пример #60
0
 public override System.Windows.Shapes.Shape GetAgentShape()
 {
     if (_shape == null)
     {
         _shape = new System.Windows.Shapes.Rectangle()
         {
             Width = Size.X * 2.5,
             Height = Size.Y * 2.5,
             Stroke = System.Windows.Media.Brushes.Black,
             StrokeThickness = 0.1
         };
     }
     return _shape;
 }