Exemplo n.º 1
0
        // creates object to be drawn on the map
        private Grid CreatePushpinObject()
        {
            //Creating a Grid element.
            Grid MyGrid = new Grid();
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.Background = new SolidColorBrush(Colors.Transparent);

            //Creating a Rectangle
            Rectangle MyRectangle = new Rectangle();
            MyRectangle.Fill = new SolidColorBrush(Color.FromArgb(0xF9, 0x00, 0x68, 0));
            MyRectangle.Height = 20;
            MyRectangle.Width = 20;
            MyRectangle.SetValue(Grid.RowProperty, 0);
            MyRectangle.SetValue(Grid.ColumnProperty, 0);

            //Adding the Rectangle to the Grid
            MyGrid.Children.Add(MyRectangle);

            //Creating a Polygon
            Polygon MyPolygon = new Polygon();
            MyPolygon.Points.Add(new Point(2, 0));
            MyPolygon.Points.Add(new Point(22, 0));
            MyPolygon.Points.Add(new Point(2, 40));
            MyPolygon.Stroke = new SolidColorBrush(Colors.Black);
            MyPolygon.Fill = new SolidColorBrush(Colors.Black);
            MyPolygon.SetValue(Grid.RowProperty, 1);
            MyPolygon.SetValue(Grid.ColumnProperty, 0);

            //Adding the Polygon to the Grid
            MyGrid.Children.Add(MyPolygon);
            return MyGrid;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Pan if the left mouse button is down.
        /// </summary>
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseDown)
            {
                //Point p = e.GetPosition(dockPanel);
                //Point2D mouseLocation = new Point2D(p.X, p.Y);
                //Vector2D delta = mouseLocation - mouseDownLocation;
                //translation =
                //    translationAtMouseClick +
                //        new Vector3D(
                //            delta.X * 2d / canvasProfile.ActualWidth,
                //            -delta.Y * 2d / canvasProfile.ActualHeight,
                //            0d);
                //UpdateRenderTransform();
                ////Point position = e.MouseDevice.GetPosition(myRgbRectangle);
                ////myRgbRectangle.SetValue(Canvas.LeftProperty,
                ////                                 Math.Min(position.X, _initialPoint.Y));
                ////myRgbRectangle.SetValue(Canvas.TopProperty,
                ////                                 Math.Min(position.Y, _initialPoint.X));

                ////myRgbRectangle.SetValue(Canvas.
                var newX = (startPt.X + (e.GetPosition(canvas).X - startPt.X));
                var newY = (startPt.Y + (e.GetPosition(canvas).Y - startPt.Y));
                System.Windows.Point offset = new System.Windows.Point((startPt.X - lastLoc.X), (startPt.Y - lastLoc.Y));
                CanvasTop  = newY - offset.Y;
                CanvasLeft = newX - offset.X;
                myRgbRectangle.SetValue(Canvas.TopProperty, CanvasTop);
                myRgbRectangle.SetValue(Canvas.LeftProperty, CanvasLeft);
            }
            if (!mouseDown)
            {
                return;
            }
        }
        public void Render()
        {
            NEATGenome genome = (NEATGenome)this.pop.BestGenome;
            Substrate substrate = SubstrateFactory.factorSandwichSubstrate(resolution, resolution);
            HyperNEATCODEC codec = new HyperNEATCODEC();
            NEATNetwork phenotype = (NEATNetwork)codec.Decode(this.pop, substrate, genome);

            TrialEvaluation trial = new TrialEvaluation(phenotype, this.testCase);
            IntPair actualPos = trial.Query(resolution);

            // clear what was there before
            GridCanvas.Children.Clear();

            //
            double boxWidth = GridCanvas.ActualWidth / resolution;
            double boxHeight = GridCanvas.ActualHeight / resolution;
            double delta = 2.0 / resolution;
            int index = 0;

            for (int row = 0; row < resolution; row++)
            {
                double y = -1 + (row * delta);
                double boxY = row * boxHeight;
                for (int col = 0; col < resolution; col++)
                {
                    double x = -1 + (col * delta);
                    double boxX = col * boxWidth;

                    Rectangle r = new Rectangle();
                    r.SetValue(Canvas.LeftProperty, boxX);
                    r.SetValue(Canvas.TopProperty, boxY);
                    r.Width = boxWidth;
                    r.Height = boxHeight;

                    if (this.testCase.GetPixel(x, y) > 0)
                    {
                        r.Fill = Brushes.Blue;
                    }
                    else
                    {
                        double d = trial.Output[index];
                        int c = trial.Normalize(d, 255);
                        SolidColorBrush b = new SolidColorBrush(Color.FromRgb(255, (byte)c, 255));
                        r.Fill = b;
                        r.Stroke = Brushes.Black;
                    }

                    GridCanvas.Children.Add(r);
                    index++;
                }
            }

            Rectangle target = new Rectangle();
            target.SetValue(Canvas.LeftProperty, actualPos.X * boxWidth);
            target.SetValue(Canvas.TopProperty, actualPos.Y * boxHeight);
            target.Width = boxWidth;
            target.Height = boxHeight;
            target.Fill = Brushes.Red;
            GridCanvas.Children.Add(target);
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();

            imagen = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + @"\Imagenes\imagen.jpg"));
            Rectangle rectangle = new Rectangle();
            rectangle.Width = 500;
            rectangle.Height = 500;
            rectangle.Fill = new ImageBrush(imagen);

            tablero = new Tablero(3, 3, imagen);

            foreach (Pieza p in tablero.Piezas)
            {
                Rectangle r = new Rectangle();
                r.Width = Canvas.Width / tablero.Filas;
                r.Height = Canvas.Height / tablero.Columnas;
                r.Fill = new ImageBrush(p.Imagen);
                r.Stroke = new SolidColorBrush(Colors.Black);
                r.StrokeThickness = 1;
                r.SetValue(Canvas.LeftProperty, Convert.ToDouble(p.Columna * (Canvas.Width / tablero.Filas)));
                r.SetValue(Canvas.TopProperty, Convert.ToDouble(p.Fila * (Canvas.Height / tablero.Columnas)));
                Canvas.Children.Add(r);
            }
        }
Exemplo n.º 5
0
        //Dibujado de rectángulo

        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Se crea el objeto tipo rectángulo, con las posiciones del ratón y se añade a la colección
        /// Children.
        /// </summary>
        ///
        /// <remarks>   Fidi, 11/16/2019. </remarks>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void DrawRectangle()
        {
            System.Windows.Shapes.Rectangle newRectangle = new System.Windows.Shapes.Rectangle();
            newRectangle.Stroke = Brushes.Black;
            newRectangle.Fill   = (SolidColorBrush)rectColor.Fill;
            if (end.X >= start.X)
            {
                newRectangle.SetValue(InkCanvas.LeftProperty, start.X);
                newRectangle.Width = end.X - start.X;
            }
            else
            {
                newRectangle.SetValue(InkCanvas.LeftProperty, end.X);
                newRectangle.Width = start.X - end.X;
            }

            if (end.Y >= start.Y)
            {
                newRectangle.SetValue(InkCanvas.TopProperty, start.Y - 50);
                newRectangle.Height = end.Y - start.Y;
            }
            else
            {
                newRectangle.SetValue(InkCanvas.TopProperty, end.Y - 50);
                newRectangle.Height = start.Y - end.Y;
            }
            canvasMain.Children.Add(newRectangle);
        }
Exemplo n.º 6
0
 //Returns rectangle, which can be drawn somewhere.
 private System.Windows.Shapes.Rectangle getPointToDraw(Models.Point p)
 {
     System.Windows.Shapes.Rectangle res = new System.Windows.Shapes.Rectangle();
     res.Width = res.Height = 4;
     res.Fill  = System.Windows.Media.Brushes.Red;
     res.SetValue(Canvas.LeftProperty, p.X * bimage.Width);
     res.SetValue(Canvas.TopProperty, p.Y * bimage.Height);
     return(res);
 }
Exemplo n.º 7
0
        public detail()
        {
            InitializeComponent();
            List<Stand> tab = (List<Stand>)PhoneApplicationService.Current.State["stands"];
            int index = (int)PhoneApplicationService.Current.State["index"];

            //MessageBox.Show(index.ToString());
            Stand item = tab[index];

            station_id.Text = "Station n°" + item.Id;
            add.Text = item.Add.ToString();
            ab.Text = "Places : " + item.Ab.ToString();
            ap.Text = "Velos : " + item.Ap.ToString();
            ac.Text = "Capacité disponible : " + item.Ac.ToString();
            tc.Text = "Capacité totale: : " + item.Tc.ToString();

            GeoCoordinate loc = new GeoCoordinate();
            //Location loc = new Location();
            loc.Longitude = item.Lng;
            loc.Latitude = item.Lat;

            Map Carte = new Map();
            Carte.Center = loc;
            Carte.ZoomLevel = 17.0;

            Pushpin pin = new Pushpin();
            pin.GeoCoordinate = loc;
            //pin.Location = loc;
            ContentMap.Children.Add(Carte);

            ImageBrush imgBrush = new ImageBrush();
            imgBrush.Stretch = System.Windows.Media.Stretch.UniformToFill;
            imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));

            Grid MyGrid = new Grid();
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.Background = new SolidColorBrush(Colors.Transparent);

            Rectangle MyRectangle = new Rectangle();
            MyRectangle.Fill = imgBrush;
            MyRectangle.Height = 52;
            MyRectangle.Width = 85;
            MyRectangle.SetValue(Grid.RowProperty, 0);
            MyRectangle.SetValue(Grid.ColumnProperty, 0);

            MyGrid.Children.Add(MyRectangle);

            MapLayer layer = new MapLayer();
            MapOverlay overlay = new MapOverlay();
            overlay.GeoCoordinate = pin.GeoCoordinate;
            overlay.Content = MyGrid;
            layer.Add(overlay);

            //Carte.Children.Add(pin);
            Carte.Layers.Add(layer);
        }
Exemplo n.º 8
0
 private void erstelleKran()
 {
     this.kran = new Rectangle();
     this.kran.Fill = Brushes.Black;
     this.kran.Width = this.schlittenBreite;
     this.kran.Height = this.schlittenHoehe;
     kran.SetValue(Canvas.TopProperty, yKoordiante);
     kran.SetValue(Canvas.LeftProperty, xKoordinate);
     draufSicht.Children.Add(kran);
 }
        public void MonitorControl(Panel panel)
        {
            Monitor = new Rectangle {Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0))};
			Monitor.SetValue(Grid.RowSpanProperty, int.MaxValue - 1);
			Monitor.SetValue(Grid.ColumnSpanProperty, int.MaxValue - 1);

            Monitor.ManipulationStarted += MonitorManipulationStarted;
            Monitor.ManipulationDelta += MonitorManipulationDelta;

            panel.Children.Add(Monitor);
        }
Exemplo n.º 10
0
 public Shapes.Rectangle ToShape(Brush stroke = null, double strokeThickness = 0, Brush fill = null)
 {
     Shapes.Rectangle rect = new Shapes.Rectangle();
     rect.Width           = DimensionX;
     rect.Height          = DimensionY;
     rect.Stroke          = (stroke == null) ? Brushes.Black : stroke;
     rect.StrokeThickness = strokeThickness;
     rect.Fill            = (fill == null) ? Brushes.Black : fill;
     rect.SetValue(Canvas.LeftProperty, TopLeft.X);
     rect.SetValue(Canvas.TopProperty, TopLeft.Y);
     return(rect);
 }
        /// <summary>
        /// 画界面
        /// </summary>
        public void Init()
        {
            midiBase = new MidiBase();
            //填充乐器数据
            foreach (string item in Enum.GetNames(typeof(MidiToneType)))
            {
                MidiTypeCb.Items.Add(item);
            }

            //画格子
            for (int i = 0; i < 56; i++)
            {
                ColumnDefinition col = new ColumnDefinition();

                KeyGrid.ColumnDefinitions.Add(col);
            }

            for (int i = 0; i < 48; i++)
            {
                Rectangle rect = new Rectangle();
                rect.SetValue(Grid.ColumnSpanProperty, 2);

                int tem = i % 12;         //计算余数,
                int tem1 = i / 12;
                int tem2 = tem > 4 ? 1 : 0;

                rect.SetValue(Grid.ColumnProperty, tem1 * 14 + tem + tem2);
                rect.MouseDown += Rect_MouseDown;
                rect.MouseUp += Rect_MouseUp;
                rect.MouseMove += Rect_MouseMove;
                //判断是黑键还是白键
                string name;
                if (tem ==1 || tem ==3 || tem ==6 || tem ==8 || tem ==10)
                {
                    name = "black" + i.ToString("00");
                    rect.Fill = new SolidColorBrush(Colors.Black);
                    rect.SetValue(Grid.ZIndexProperty, 1);                //通过zindex改变黑白键的显示顺序
                }
                else
                {
                    name = "white" + i.ToString("00");
                    rect.Fill = new SolidColorBrush(Colors.White);
                    rect.SetValue(Grid.RowSpanProperty, 2);
                    rect.SetValue(Grid.ZIndexProperty, 0);
                }
                rect.Name = name;                               //做标记,包含黑白键和音阶信息

                KeyGrid.Children.Add(rect);

                KeyGrid.RegisterName(name, rect);               //必须这样注册才能用 findname找到
            }
        }
Exemplo n.º 12
0
 public void LoadEventMark(MapEventMaster mem) {
     int markSize = 16;
     var rec = new Rectangle {
         Width = markSize,
         Height = markSize,
         Stroke = Brushes.Red,
         StrokeThickness = 5,
         SnapsToDevicePixels = true
     };
     rec.SetValue(Canvas.LeftProperty, (mem.icon_pos_x - markSize/2)*SCALE_PARAMETER + LEFT_OFFSET);
     rec.SetValue(Canvas.TopProperty, (mem.icon_pos_y - markSize/2)*SCALE_PARAMETER + TOP_OFFSET);
     rec.SetValue(Grid.ZIndexProperty, 129);
     AreaCanvas.Children.Add(rec);
 }
 public override void RenderIntensityMap()
 {
     for (int i = 0; i < HeatMapSource.Columns; i++)
     {
         for (int j = 0; j < HeatMapSource.Rows; j++)
         {
             byte intensity = worstCaseHeatPoints[i, j];
             Rectangle r = new Rectangle();
             r.SetValue(Grid.ColumnProperty, i + 1);
             r.SetValue(Grid.RowProperty, HeatMapSource.Rows - j);
             r.Fill = new SolidColorBrush(Color.FromRgb((byte)Math.Abs(intensity), (byte)Math.Abs(intensity), (byte)Math.Abs(intensity)));
             this.HeatMapGrid.Children.Add(r);
         }
     }
 }
Exemplo n.º 14
0
        internal void SetIcon(System.Windows.Media.ImageSource imageSource)
        {
            var rect = new Rectangle();
            rect.Width = 32;
            rect.Height = 32;
            rect.UseLayoutRounding = true;
            rect.Fill = Brushes.White;
            rect.OpacityMask = new ImageBrush(imageSource) { Stretch = Stretch.None };
            rect.SetValue(Canvas.LeftProperty, 6.5);
            rect.SetValue(Canvas.TopProperty, 6.5);

            Canvas c = new Canvas();
            c.Children.Add(rect);

            this.Content = c;
        }
Exemplo n.º 15
0
 private void Stage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount == 1)
     {
         _initMousePoint = e.GetPosition(Stage);
         var strokeDashArry = new DoubleCollection {
             2, 2
         };
         if (!Stage.Children.Contains(_selectedArea))
         {
             Stage.Children.Add(_selectedArea);
         }
         _selectedArea.SetValue(Canvas.TopProperty, _initMousePoint.Y);
         _selectedArea.SetValue(Canvas.LeftProperty, _initMousePoint.X);
     }
 }
Exemplo n.º 16
0
        private void Activate(Point2D item)
        {
            if (Map == null || Map.Layers == null)
            {
                return;
            }
            DrawLayer = new ElementsLayer();
            Map.Layers.Add(DrawLayer);
            rectangle = new Rectangle();
            rectangle.Stroke = this.Stroke;
            rectangle.StrokeThickness = this.StrokeThickness;
            rectangle.StrokeMiterLimit = this.StrokeMiterLimit;
            rectangle.StrokeDashOffset = this.StrokeDashOffset;
            rectangle.StrokeDashArray = this.StrokeDashArray;
            rectangle.StrokeDashCap = this.StrokeDashCap;
            rectangle.StrokeEndLineCap = this.StrokeEndLineCap;
            rectangle.StrokeLineJoin = this.StrokeLineJoin;
            rectangle.StrokeStartLineCap = this.StrokeStartLineCap;
            rectangle.Opacity = this.Opacity;
            rectangle.Fill = this.Fill;

            rectangle.SetValue(ElementsLayer.BBoxProperty , new Rectangle2D(item , item));
            DrawLayer.Children.Add(rectangle);

            isActivated = true;
            isDrawing = true;
        }
Exemplo n.º 17
0
        private void InitializePadAndBall()
        {
            ResourceDictionary resource = ((ResourceDictionary)((MyApplication)Application.Current).MyResources["resPadAnBall"]);

            pad            = new System.Windows.Shapes.Rectangle();
            pad.Visibility = Visibility.Hidden;
            pad.Style      = resource["Pad"] as Style;
            canvasField.Children.Add(pad);
            pad.SetValue(Canvas.TopProperty, Convert.ToDouble(510));
            pad.SetValue(Canvas.LeftProperty, Convert.ToDouble(290));

            ball            = new System.Windows.Shapes.Ellipse();
            ball.Visibility = Visibility.Hidden;
            ball.Style      = resource["Ball"] as Style;
            canvasField.Children.Add(ball);
        }
        private void LoadMapOnView()
        {
            if (currentMap != null)
            {
                mapCanvas.Children.Clear();
                mapCanvas.Width = (currentMap.Breedte * blokscale) + 10;
                mapCanvas.Height = (currentMap.Hoogte * blokscale) + 10;
                for (int i = 0; i < currentMap.Hoogte; i++)
                {
                    for (int j = 0; j < currentMap.Breedte; j++)
                    {
                        Rectangle blok = new Rectangle();
                        blok.Stroke = new SolidColorBrush(Colors.Black);
                        blok.StrokeThickness = 0.3;
                        blok.Width = blokscale;
                        blok.Height = blokscale;
                        switch (currentMap.GetElement(j, i))
                        {
                            case 0:
                                blok.Fill = new SolidColorBrush(Colors.LightGray);
                                break;
                            case 1:
                                blok.Fill = new SolidColorBrush(Colors.Red);
                                break;
                            case 2:
                                blok.Fill = new SolidColorBrush(Colors.Green);
                                break;
                            case 3:
                                blok.Fill = new SolidColorBrush(Colors.Orange);
                                break;
                            case 4:
                                blok.Fill = new SolidColorBrush(Colors.Yellow);
                                break;
                            default:
                                blok.Fill = new SolidColorBrush(Colors.Black);
                                break;

                        }
                        blok.SetValue(Canvas.LeftProperty, (double)(blokscale * (j + 1)));
                        blok.SetValue(Canvas.TopProperty, (double)(blokscale * (i + 1)));

                        mapCanvas.Children.Add(blok);
                    }
                }
            }
        }
Exemplo n.º 19
0
 public static void Draw(UIElementCollection children)
 {
     foreach (var option in selections)
     {
         var rect = new Rectangle();
         rect.Width = option.intersection.Width;
         rect.Height = option.intersection.Height;
         rect.SetValue(Canvas.LeftProperty, option.intersection.X);
         rect.SetValue(Canvas.TopProperty, option.intersection.Y);
         rect.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
         rect.StrokeThickness = 1;
         rect.Fill = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0));
         children.Add(rect);
         option.Advance();
         children.Add(option.label);
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// Método para generar el tablero en pantalla
        /// </summary>
        /// <param name="tablero"></param>
        public void GeneraTablero(Tablero tablero)
        {
            TableroReinas.ColumnDefinitions.Clear();
            TableroReinas.RowDefinitions.Clear();
            TableroReinas.Children.Clear();
            for (int i = 0; i < tablero.NumeroReinas; i++)
            {
                TableroReinas.ColumnDefinitions.Add(new ColumnDefinition() { Width = CellSize });
                TableroReinas.RowDefinitions.Add(new RowDefinition() { Height = CellSize });
            }

            for (int i = 0; i < tablero.NumeroReinas; i++)
            {
                for (int j = 0; j < tablero.NumeroReinas; j++)
                {
                    Rectangle r = new Rectangle();
<<<<<<< HEAD
                    r.SetValue(Grid.RowProperty, j);
                    r.SetValue(Grid.ColumnProperty, i);

                    if (((i * tablero.NumeroReinas) + j) % 2 == 0)
=======
                    r.SetValue(Grid.RowProperty, i);
                    r.SetValue(Grid.ColumnProperty, j);

                    if ((i  + j) % 2 == 0)
>>>>>>> Práctica 6 completa
                        r.Fill = new SolidColorBrush(Colors.Black);
                    else
                        r.Fill = new SolidColorBrush(Colors.White);

                    TableroReinas.Children.Add(r);

                    if (tablero.Reinas[i, j] == 1)
                    {
                        Ellipse c = new Ellipse();
                        c.Fill = new SolidColorBrush(Color.FromArgb(255, 164, 16, 52));
                        c.SetValue(Grid.ColumnProperty, j);
                        c.SetValue(Grid.RowProperty, i);
                        TableroReinas.Children.Add(c);
                    }

                }
            }
        }
Exemplo n.º 21
0
        public Rectangle createHighlight()
        {
            Point mouse      = Mouse.GetPosition(view.pbxMap);
            int   col        = (Convert.ToInt32(mouse.X) - this.myMap.boardXPos) / this.myMap.myCellSize;
            int   row        = (Convert.ToInt32(mouse.Y) - this.myMap.boardYPos) / this.myMap.myCellSize;
            int   startOfRow = this.myMap.boardYPos + row * this.myMap.myCellSize;
            int   startOfCol = this.myMap.boardXPos + col * this.myMap.myCellSize;

            System.Windows.Shapes.Rectangle myRect = new System.Windows.Shapes.Rectangle();
            myRect.Fill    = System.Windows.Media.Brushes.MediumSeaGreen;
            myRect.Opacity = .4;
            myRect.SetValue(Canvas.TopProperty, Convert.ToDouble(startOfRow));
            myRect.SetValue(Canvas.LeftProperty, Convert.ToDouble(startOfCol));
            myRect.Height           = myMap.myCellSize;
            myRect.Width            = myMap.myCellSize;
            myRect.IsHitTestVisible = false;
            return(myRect);
        }
Exemplo n.º 22
0
 private void inputImage_MouseMove(object sender, MouseEventArgs e)
 {
     if (isSelecting)
     {
         System.Windows.Point movePos = new System.Windows.Point(e.GetPosition(inputImage).X, e.GetPosition(inputImage).Y);
         inputImageCanvas.Children.Clear();
         System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
         rectangle.SetValue(Canvas.LeftProperty, (double)startPos.X); //Math.Min(startPos.X, endPos.X)
         rectangle.SetValue(Canvas.TopProperty, (double)startPos.Y);  //Math.Min(startPos.Y, endPos.Y)
         rectangle.Width  = Math.Abs(movePos.X - startPos.X);
         rectangle.Height = Math.Abs(movePos.Y - startPos.Y);
         rectangle.Stroke = new SolidColorBrush()
         {
             Color = Colors.Red, Opacity = 0.75f
         };
         rectangle.StrokeThickness = 3;
         inputImageCanvas.Children.Add(rectangle);
     }
 }
Exemplo n.º 23
0
        public SudokuSquare(int id, int x, int y)
        {
            Rectangle rectangle = new Rectangle();
            rectangle.Width = 40;
            rectangle.Height = 37;

            rectangle.SetValue(Canvas.TopProperty, Convert.ToDouble(y));
            rectangle.SetValue(Canvas.LeftProperty, Convert.ToDouble(x));

            GradientStopCollection gradients = new GradientStopCollection();

            Label label = new Label();
            label.Height = 37;
            label.Width = 40;
            label.FontSize = 25;

            label.SetValue(Canvas.TopProperty, Convert.ToDouble(y - 5));
            label.SetValue(Canvas.LeftProperty, Convert.ToDouble(x + 7));
            label.Name = "B" + (id).ToString();
        }
Exemplo n.º 24
0
 void canvasField_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.GetPosition(canvasField).X < 580)
     {
         pad.SetValue(Canvas.LeftProperty, e.GetPosition(canvasField).X);
         if (IsBallOnPad)
         {
             ball.SetValue(Canvas.LeftProperty, e.GetPosition(canvasField).X + 15);
         }
     }
 }
Exemplo n.º 25
0
        public Star(double size)
        {
            double op = GlobalValue.OPACITY;

            Rectangle e = new Rectangle();
            e.Width = size;
            e.Height = size;

            if (GlobalValue.IsRColor == null)
                e.Fill = new SolidColorBrush(Color.FromArgb(255, (byte)(128 + (128 * GlobalValue.random.NextDouble())),
                            (byte)(128 + (128 * GlobalValue.random.NextDouble())),
                            (byte)(128 + (128 * GlobalValue.random.NextDouble()))));
            else
                e.Fill = new SolidColorBrush(Color.FromArgb(255, GlobalValue.IsRColor.Color.R,
                    GlobalValue.IsRColor.Color.G, GlobalValue.IsRColor.Color.B));
            e.Opacity = op;
            e.SetValue(Canvas.LeftProperty, -e.Width / 2);
            e.SetValue(Canvas.TopProperty, -e.Height / 2);
            this.Children.Add(e);
        }
Exemplo n.º 26
0
 void DrawMap()
 {
     Tiles.Children.Clear();
     for (var c = 0; c < Model.Width; c++) {
         Tiles.ColumnDefinitions.Add(new ColumnDefinition());
     }
     for (var r = 0; r < Model.Width; r++) {
         Tiles.RowDefinitions.Add(new RowDefinition());
     }
     for (var c = 0; c < Model.Width; c++) {
         for (var r = 0; r < Model.Width; r++) {
             var tile = new Rectangle();
             tile.Fill = new SolidColorBrush(Colors.Black);
             tile.Margin = new Thickness(1); ;
             tile.SetValue(Grid.RowProperty, r);
             tile.SetValue(Grid.ColumnProperty, c);
             Tiles.Children.Add(tile);
         }
     }
 }
Exemplo n.º 27
0
 private void BackGoundImages()
 {
     ImageBrush image = new ImageBrush();
     image.ImageSource = new BitmapImage(new Uri(BACKGROUND, UriKind.Relative));
     int mi = (int)Math.Ceiling(Width / TILESIZE);
     int mj = (int)Math.Ceiling(Height / TILESIZE);
     for (int i = 0; i < mi; i++)
         for (int j = 0; j < mj; j++)
         {
             Rectangle r = new Rectangle();
             r.Width = TILESIZE * 2;
             r.Height = TILESIZE * 2;
             r.Fill = image;
             r.SetValue(Canvas.LeftProperty, (double)i * TILESIZE * 2);
             r.SetValue(Canvas.TopProperty, (double)j * TILESIZE * 2);
             canvas.Children.Add(r);
         }
     RectangleGeometry rg = new RectangleGeometry();
     rg.Rect = new Rect(new Point(), new Size(Width, Height));
     this.Clip = rg;
 }
Exemplo n.º 28
0
 public void erstelle_Lager(double x, double y)
 {
     Rectangle lager = new Rectangle();
     lager.Fill = Brushes.Red;
     lager.Width = 45.0;
     lager.Height = 15.0;
     lager.SetValue(Canvas.TopProperty, y);
     lager.SetValue(Canvas.LeftProperty, x);
     lager.Stroke = Brushes.Black;
     lager.StrokeThickness = 1;
     this.Children.Add(lager);
 }
Exemplo n.º 29
0
        public SelectionTool(MoonlightController controller)
            : base(controller)
        {
            SelectionRect = new Rectangle();
            SelectionRect.Opacity = 0.2;
            SelectionRect.Fill = new SolidColorBrush(Colors.Blue);
            SelectionRect.Stroke = new SolidColorBrush(Colors.Black);
            SelectionRect.StrokeThickness = 1.0;
            SelectionRect.SetValue(Canvas.ZIndexProperty, int.MaxValue);

            undo = new UndoGroup();
        }
        private void DrawItem(Result item, Double ScaleXY, Double ScaleYZ)
        {
            var mix = item.CentrePointX - (item.ModelSizeX / 2);
            var max = item.CentrePointX + (item.ModelSizeX / 2);
            var miy = item.CentrePointY - (item.ModelSizeY / 2);
            var may = item.CentrePointY + (item.ModelSizeY / 2);
            var miz = item.CentrePointZ - (item.ModelSizeZ / 2);
            var maz = item.CentrePointZ + (item.ModelSizeZ / 2);

            var modelBrush = PickBrush();

            //XY
            var rXY = new Rectangle
            {
                Stroke = modelBrush,
                StrokeThickness = 2
            };

            rXY.SetValue(Canvas.LeftProperty, ((mix - minX) * ScaleXY));
            rXY.Width = item.ModelSizeX * ScaleXY;
            rXY.SetValue(Canvas.BottomProperty, ((miy-minY) * ScaleXY));
            rXY.Height = item.ModelSizeY * ScaleXY;

            XYcanvas.Children.Add(rXY);
            //YZ
            var rYZ = new Rectangle
            {
                Stroke = modelBrush,
                StrokeThickness = 2
            };

            rYZ.SetValue(Canvas.LeftProperty, ((miy - minY) * ScaleYZ));
            rYZ.Width = item.ModelSizeY * ScaleYZ;
            rYZ.SetValue(Canvas.BottomProperty, ((miz - minZ) * ScaleYZ));
            rYZ.Height = item.ModelSizeZ * ScaleYZ;

            YZcanvas.Children.Add(rYZ);
        }
Exemplo n.º 31
0
        private void Switch_2(int row, int col)
        {
            block_row = row;
            block_col = col;
            int width = 32;

            paint.Children.Clear();
            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    System.Windows.Shapes.Rectangle pixel = new System.Windows.Shapes.Rectangle();
                    pixel.Fill   = new SolidColorBrush(this.colors[(int)this.sight_row * 128 + row * 16 + i, (int)this.sight_col * 128 + col * 16 + j]);
                    pixel.Stroke = new SolidColorBrush(this.colors[(int)this.sight_row * 128 + row * 16 + i, (int)this.sight_col * 128 + col * 16 + j]);
                    pixel.Width  = width;
                    pixel.Height = width;
                    pixel.SetValue(Canvas.LeftProperty, j * width + 0.0);
                    pixel.SetValue(Canvas.TopProperty, i * width + 0.0);
                    paint.Children.Add(pixel);
                }
            }
            this.mode = 2;
        }
Exemplo n.º 32
0
        private void DrawUserDrawnBox(int whichImage, System.Windows.Point mousePosition)
        {
            mouseBox = new System.Windows.Shapes.Rectangle()
            {
                Width           = Math.Abs(mousePosition.X - mouseDownPoint.X),
                Height          = Math.Abs(mousePosition.Y - mouseDownPoint.Y),
                Stroke          = brushColor,
                StrokeThickness = 3,
                Opacity         = 0.5
            };
            mouseBox.SetValue(Canvas.LeftProperty, (mousePosition.X < mouseDownPoint.X) ? mousePosition.X : mouseDownPoint.X);
            mouseBox.SetValue(Canvas.TopProperty, (mousePosition.Y < mouseDownPoint.Y) ? mousePosition.Y : mouseDownPoint.Y);

            // keep refeshing the image of the box
            switch (whichImage)
            {
            case 0:
                camRect0.Children.Clear();
                camRect0.Children.Add(mouseBox);
                break;

            case 1:
                camRect1.Children.Clear();
                camRect1.Children.Add(mouseBox);
                break;

            case 2:
                camRect2.Children.Clear();
                camRect2.Children.Add(mouseBox);
                break;

            case 3:
                camRect3.Children.Clear();
                camRect3.Children.Add(mouseBox);
                break;
            }
        }
        private void ScreenSelectorCanvasOnMouseDown(object sender, MouseButtonEventArgs mouseButtonEventArgs)
        {
            ScreenSelectorCanvas.MouseDown -= ScreenSelectorCanvasOnMouseDown;
            ScreenSelectorCanvas.MouseMove += ScreenSelectorCanvasOnMouseMove;
            ScreenSelectorCanvas.MouseUp += ScreenSelectorCanvasOnMouseUp;

            _selectionRectangle = new Rectangle
            {
                StrokeThickness = 2,
                Stroke = new SolidColorBrush(Colors.Red),
                Fill= new SolidColorBrush(Colors.Transparent)
            };
            _startPosition = mouseButtonEventArgs.GetPosition(ScreenSelectorCanvas);

            _selectionRectangle.SetValue(LeftProperty, _startPosition.X);
            _selectionRectangle.SetValue(TopProperty, _startPosition.Y);
            _selectionRectangle.Width = 0;
            _selectionRectangle.Height = 0;

            ScreenSelectorCanvas.Children.Add(_selectionRectangle);
            _rectangleTextBlockTransform = new TranslateTransform();
            RectangleTextBlock.RenderTransform = _rectangleTextBlockTransform;
            RectangleTextBlock.Visibility = Visibility.Visible;
        }
Exemplo n.º 34
0
 protected void AddSelectionRectangle()
 {
     selection = new Rectangle() { Visibility = Visibility.Visible, ClipToBounds = true, Width = 0, Height = 0, 
         VerticalAlignment = VerticalAlignment.Top };
     SolidColorBrush selectionBrush = new SolidColorBrush() { Color = Brushes.Aquamarine.Color, Opacity = 0.5 };
     selection.Fill = selectionBrush;
     selection.StrokeDashOffset = 5; selection.StrokeThickness = 0.99;
     SolidColorBrush selectionBrush2 = new SolidColorBrush() { Color = Color.FromArgb(255, 0, 0, 0) };
     selection.Stroke = selectionBrush2;
     selection.HorizontalAlignment = HorizontalAlignment.Left;
     DoubleCollection strokeDashArray1 = new DoubleCollection(2);
     strokeDashArray1.Add(3); strokeDashArray1.Add(3);
     selection.StrokeDashArray = strokeDashArray1;
     Canvas.Children.Add(selection);
     selection.SetValue(Canvas.ZIndexProperty, 1000);
 }
Exemplo n.º 35
0
        private void Activate(Point2D item)
        {
            if (this.map == null || this.map.Layers == null)
            {
                return;
            }
            DrawLayer = new ElementsLayer();
            this.map.Layers.Add(DrawLayer);
            rectangle = new Rectangle();
            

            rectangle.SetValue(ElementsLayer.BBoxProperty , new Rectangle2D(item , item));
            DrawLayer.Children.Add(rectangle);

            isActivated = true;
            isDrawing = true;
        }
        public HighlightImage()
        {
            InitializeComponent();

            myRectangles = new List<Rectangle>();

            for(int i = 0; i < SLICES; i++)
            {
                Rectangle r = new Rectangle();
                r.SetValue(Grid.ColumnProperty, i);
                r.Fill = Brushes.Gold;
                r.Opacity = 0.0;
                myRectangles.Add(r);

                innerGrid.Children.Add(r);
            }
        }
Exemplo n.º 37
0
        public void CompendiumMapDepthMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _isLeftMouseButtonDown = true;
            _selectionStartPoint = translateTransform.Inverse.Transform(e.GetPosition(caller));
            _selectionStartPoint = scaleTransform.Inverse.Transform(_selectionStartPoint);
            if (_selectionRectangle != null)
            {
                caller.uxMapSurface.Children.Remove(_selectionRectangle);
                _selectionRectangle = null;
            }
            if (e.ClickCount != 2)
            {
                _selectionRectangle = new Rectangle();
                _selectionRectangle.Stroke = new SolidColorBrush(Colors.Black);
                _selectionRectangle.StrokeThickness = 1.0;
                _selectionRectangle.Opacity = 0.7;
                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(2);
                dashArray.Add(4);
                _selectionRectangle.StrokeDashArray = dashArray;
                _selectionRectangle.SetValue(Canvas.LeftProperty, _selectionStartPoint.X);
                _selectionRectangle.SetValue(Canvas.TopProperty, _selectionStartPoint.Y);
                caller.uxMapSurface.Children.Add(_selectionRectangle);
            }

            ViewManager.CommitNodeName();
        }
        private void OnMouseClick(object sender, MouseEventArgs e)
        {
            TextBlock tb = (TextBlock)sender;

            Rectangle bg = new Rectangle();
            bg.SetValue<string>(Canvas.NameProperty, tb.Name + "_highlight");
            bg.Width = tb.ActualWidth;
            bg.Height = tb.ActualHeight;
            bg.SetValue<double>(Canvas.TopProperty, (double)tb.GetValue(Canvas.TopProperty));
            bg.SetValue<double>(Canvas.LeftProperty, (double)tb.GetValue(Canvas.LeftProperty));
            bg.SetValue<int>(Canvas.ZIndexProperty, (int)tb.GetValue(Canvas.ZIndexProperty) - 1);
            bg.Fill = new SolidColorBrush(Colors.LightGray);

            ((Canvas)tb.Parent).Children.Add(bg);
        }
Exemplo n.º 39
0
        /// <summary>
        /// Produces the graphics for displaying fingering
        /// </summary>
        /// <param name="note"></param>
        /// <param name="instrument"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        private void Fingering(int note, int instrument, long startTime, long endTime, int fretNumber, int stringNumber)
        {
            string noteString = "";
            TextBlock textBlock = new TextBlock();
            textBlock.FontSize = 20;
            textBlock.FontWeight = FontWeights.Light;
            textBlock.TextAlignment = TextAlignment.Left;
            textBlock.Foreground = new SolidColorBrush(Colors.White);
            Canvas.SetZIndex(textBlock, (int)99);
            Rectangle r = new Rectangle();
            r.StrokeThickness = 0;

            if (instrument == 41) { //VIOLIN
                int margin = 300;
                int padding = 30;
                textBlock.Height = 50;
                textBlock.Width = 60;
                r.Width = 46;

                int[,] violin = new int[4, 2] { { 55, 61 }, { 62, 68 }, { 69, 75 }, { 76, 83 } };
                int[] ctrl_violin = { 0, 6, 2, 0, 10 };
                for (int i = violin.GetLength(0); i > 0; i--) {
                    if (note >= violin[i - 1, 0] && note <= violin[i - 1, 1]) {
                        textBlock.Text = Convert.ToString(note - violin[i - 1, 0]);
                        r.Fill = new SolidColorBrush(color[ctrl_violin[i]]);
                        r.Stroke = new SolidColorBrush(border[ctrl_violin[i]]);
                        textBlock.SetValue(Canvas.LeftProperty, (margin + (i * (r.Width + padding))));
                        r.SetValue(Canvas.LeftProperty, (double)(margin + (i * (r.Width + padding))));
                    }
                }
                r.Height = (endTime - startTime) * multiplier;
                textBlock.SetValue(Canvas.TopProperty, (double)((-1 * startTime * multiplier) - 35));
                r.SetValue(Canvas.BottomProperty, (double)(startTime) * multiplier);
                subcanv.Children.Add(r);
                subcanv.Children.Add(textBlock);
            }
            else if (instrument >= 25 && instrument <= 32) { //GUITAR
                int margin = 170;
                int padding = 10;
                textBlock.Height = 50;
                textBlock.Width = 50;
                r.Height = 46;
                int[,] guitar = new int[6, 2] { { 64, 80 }, { 59, 63 }, { 55, 58 }, { 50, 54 }, { 45, 49 }, { 40, 44 } };
                int[] ctrl_guitar = { 1, 8, 9, 10, 0, 2, 6 }; // color data begins at index 1

                // replaces loop above, makes use of given string and fret numbers
                textBlock.Text = fretNumber.ToString();
                textBlock.SetValue(Canvas.TopProperty, (8 + margin + (stringNumber * (r.Height + padding))));
                r.Fill = new SolidColorBrush(color[ctrl_guitar[stringNumber + 1]]);
                r.Stroke = new SolidColorBrush(border[ctrl_guitar[stringNumber + 1]]);
                r.SetValue(Canvas.TopProperty, (margin + (stringNumber * (r.Height + padding))));

                r.Width = (endTime - startTime) * multiplier;
                textBlock.SetValue(Canvas.LeftProperty, (double)((startTime * multiplier) + 3));
                r.SetValue(Canvas.LeftProperty, (double)(startTime) * multiplier);
                subcanv.Children.Add(r);
                subcanv.Children.Add(textBlock);
            }
            else if (instrument >= 33 && instrument <= 40) { //BASS
                int margin = 200;
                int padding = 10;
                textBlock.Height = 50;
                textBlock.Width = 50;
                r.Height = 46;

                int[,] bass = new int[4, 2] { { 28, 32 }, { 33, 37 }, { 38, 42 }, { 43, 47 } };
                int[] ctrl_bass = { 1, 6, 2, 0, 10 };
                for (int i = bass.GetLength(0); i > 0; i--) {
                    if (note >= bass[i - 1, 0] && note <= bass[i - 1, 1]) {
                        textBlock.Text = Convert.ToString(note - bass[i - 1, 0]);
                        r.Fill = new SolidColorBrush(color[ctrl_bass[i]]);
                        r.Stroke = new SolidColorBrush(border[ctrl_bass[i]]);
                        textBlock.SetValue(Canvas.TopProperty, (5 + margin + ((i - 1) * (r.Height + padding))));
                        r.SetValue(Canvas.TopProperty, (double)(margin + ((i - 1) * (r.Height + padding))));
                    }
                }
                r.Width = (endTime - startTime) * multiplier;
                textBlock.SetValue(Canvas.LeftProperty, (double)((startTime * multiplier) - 14));
                r.SetValue(Canvas.LeftProperty, (double)(startTime) * multiplier);
                subcanv.Children.Add(r);
                subcanv.Children.Add(textBlock);
            }
            else if (instrument == 74) { //FLUTE
                int margin = 40;
                int padding = 30;
                if (note == 50)
                    noteString = "01111001110";
                else if (note == 51)
                    noteString = "01111001111";
                else if (note == 52 || note == 64)
                    noteString = "01111001101";
                else if (note == 53)
                    noteString = "01111001001";
                else if (note == 54 || note == 66)
                    noteString = "01111000011";
                else if (note == 55 || note == 67)
                    noteString = "01111000001";
                else if (note == 56 || note == 68)
                    noteString = "01111010001";
                else if (note == 57 || note == 69)
                    noteString = "01110000001";
                else if (note == 58)
                    noteString = "01100001001";
                else if (note == 59 || note == 71)
                    noteString = "01100000001";
                else if (note == 60 || note == 72)
                    noteString = "00100000001";
                else if (note == 61 || note == 73)
                    noteString = "00000000001";
                else if (note == 62)
                    noteString = "01011001110";
                else if (note == 63)
                    noteString = "01011001111";
                else if (note == 70)
                    noteString = "10100000001";
                else if (note == 74)
                    noteString = "01011000001";
                else if (note == 75)
                    noteString = "01111011111";
                else if (note == 76)
                    noteString = "01110001101";
                else if (note == 77)
                    noteString = "01101001001";
                else if (note == 78)
                    noteString = "01101000011";
                else if (note == 79)
                    noteString = "00111000001";
                else if (note == 80)
                    noteString = "00011010001";
                else if (note == 81)
                    noteString = "01010001001";

                Rectangle[] rect = new Rectangle[noteString.Length];
                for (int i = 0; i < noteString.Length; i++) {
                    rect[i] = new Rectangle();
                }

                int rWidth = 46;
                for (int i = 0; i < noteString.Length; i++) {
                    if (i == 0)
                        rect[i].SetValue(Canvas.LeftProperty, (double)(margin + rWidth));
                    else
                        rect[i].SetValue(Canvas.LeftProperty, (double)(margin + ((i + 1) * (rWidth + padding))));
                    rect[i].Width = rWidth;
                    if (noteString[i] == '1' && noteString.Length > 3) {
                        rect[i].Fill = new SolidColorBrush(color[i]);
                        rect[i].Stroke = new SolidColorBrush(border[i]);
                    }
                    rect[i].StrokeThickness = 2;
                    rect[i].Height = (endTime - startTime) * multiplier;
                    rect[i].SetValue(Canvas.BottomProperty, (double)(startTime) * multiplier);
                    subcanv.Children.Add(rect[i]);
                }
            }
        }
Exemplo n.º 40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="endTime"></param>
 /// <param name="bpm"></param>
 /// <param name="count"></param>
 private void DrawGridLines(long endTime, int bpm, int count)
 {
     int runner = 0;
     for (double i = 0; i < (endTime + 1000); i = i + (multiplier) + (bpm / count)) {
         Rectangle r = new Rectangle();
         if (hInst == 0) {
             r.Width = 1280;
             if (runner % count == 0) {
                 r.Fill = new SolidColorBrush(Color.FromRgb(221, 221, 221));
                 r.SetValue(Canvas.TopProperty, (double)-i * scrollSpeed);
                 r.Height = 3;
             }
             else {
                 r.Fill = new SolidColorBrush(Color.FromRgb(255, 222, 222));
                 r.SetValue(Canvas.TopProperty, (double)-i * scrollSpeed);
                 r.Height = 1;
             }
         }
         else {
             r.Height = 326;
             r.SetValue(Canvas.TopProperty, (double)170);
             int left = (int)(((i * scrollSpeed) / 9) * 9) + 1;
             if (runner % count == 0) {
                 r.Fill = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                 r.SetValue(Canvas.LeftProperty, (double)left);
                 r.Width = 8;
             }
             else {
                 r.Fill = new SolidColorBrush(Color.FromRgb(230, 230, 230));
                 r.SetValue(Canvas.LeftProperty, (double)left);
                 r.Width = 8;
             }
         }
         gridlines.Children.Add(r);
         runner++;
     }
 }
Exemplo n.º 41
0
        private void Switch_1(int row, int col)
        {
            sight_row = row;
            sight_col = col;
            block_row = null;
            block_col = null;
            int BigWidth = 64;

            byte[] bytes = new byte[49152];
            paint.Children.Clear();
            for (int i = 0; i < 128; i++)
            {
                for (int j = 0; j < 128; j++)
                {
                    /*
                     * System.Windows.Shapes.Rectangle pixel = new System.Windows.Shapes.Rectangle();
                     * pixel.Fill = new SolidColorBrush(this.colors[col * 128 + i, row * 128 + j]);
                     * pixel.Stroke = new SolidColorBrush(this.colors[col * 128 + i, row * 128 + j]);
                     * pixel.Width = width;
                     * pixel.Height = width;
                     * pixel.SetValue(Canvas.LeftProperty, j * width + 0.0);
                     * pixel.SetValue(Canvas.TopProperty, i * width + 0.0);
                     * paint.Children.Add(pixel);
                     */
                    bytes[49151 - (i * 128 + (127 - j)) * 3] = this.colors[row * 128 + i, col * 128 + j].R;
                    bytes[49150 - (i * 128 + (127 - j)) * 3] = this.colors[row * 128 + i, col * 128 + j].G;
                    bytes[49149 - (i * 128 + (127 - j)) * 3] = this.colors[row * 128 + i, col * 128 + j].B;
                }
            }

            int      stride = 384;
            GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
            int      scan0  = (int)handle.AddrOfPinnedObject();

            scan0 += 127 * stride;
            Bitmap bitmap = new Bitmap(128, 128, -stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, (IntPtr)scan0);

            handle.Free();

            System.Windows.Controls.Image img = new System.Windows.Controls.Image();
            MemoryStream Ms = new MemoryStream();

            bitmap.Save(Ms, System.Drawing.Imaging.ImageFormat.Bmp);
            Ms.Position = 0;
            BitmapImage ObjBitmapImage = new BitmapImage();

            ObjBitmapImage.BeginInit();
            ObjBitmapImage.StreamSource = Ms;
            ObjBitmapImage.EndInit();
            img.Source  = ObjBitmapImage;
            img.Width   = 512;
            img.Height  = 512;
            img.Stretch = Stretch.Uniform;
            paint.Children.Add(img);
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    System.Windows.Shapes.Rectangle pixel = new System.Windows.Shapes.Rectangle();
                    pixel.Fill   = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 255, 255));
                    pixel.Width  = BigWidth;
                    pixel.Height = BigWidth;
                    pixel.SetValue(Canvas.LeftProperty, j * BigWidth + 0.0);
                    pixel.SetValue(Canvas.TopProperty, i * BigWidth + 0.0);
                    pixel.SetValue(Panel.ZIndexProperty, 1);
                    pixel.MouseEnter        += RectangleEnter;
                    pixel.MouseMove         += RectangleEnter;
                    pixel.MouseLeave        += RectangleLeave;
                    pixel.MouseLeftButtonUp += RectanglePress;
                    paint.Children.Add(pixel);
                }
            }
            this.mode = 1;
        }
Exemplo n.º 42
0
        private void FillData(string[,] mynotes, uint splitposition, int showoneindex, string headertxt)
        {
            int rows = mynotes.GetLength(0);
            int cols = mynotes.GetLength(1);

            ///// Filling textblock /// if text takes priority over index
            if (collapsedText != null && collapsedText.Length > 0) //27Jun2013 text to set
            {
                notes.Text = collapsedText.Trim();                 //"+ " + collapsedText + " [Double-Click to Expand]";
            }
            else /// text from particular index
            {
                if (showoneindex < 0 || showoneindex > rows)
                {
                    collapsedText = mynotes[0, 0] + " " + mynotes[0, 1]; // +"[Double-Click to Expand]";
                }
                else
                {
                    collapsedText = mynotes[showoneindex, 0] + " " + mynotes[showoneindex, 1]; // +"[Double-Click to Expand]";
                }
                notes.Text = collapsedText.Trim();                                             // "+ " + collapsedText + "[Double-Click to Expand]"; ;
            }
            //// Filling Header text /////
            heading.Text = headertext;

            //// checking if splitposition is valid or not ////
            if (splitposition < 1 || splitposition >= cols)
            {
                TextBlock errortb = new TextBlock();
                errortb.Text       = "Split-bar position should be, between 0 and max. no. of columns in your supplied string.";
                errortb.Foreground = Brushes.CornflowerBlue;
                splitgrid.Children.Add(errortb);
                return;
            }
            //Creating no of rows/cols in grid
            RowDefinition rd = null; ///// ROWS /////

            for (int i = 0; i < rows; i++)
            {
                rd = new RowDefinition(); //rd.Height =GridLength.Auto;

                splitgrid.RowDefinitions.Add(rd);
            }
            ColumnDefinition cd = null;

            for (int i = 0; i <= cols; i++)  ///// COLS /////
            {
                cd = new ColumnDefinition(); //cd.Width = GridLength.Auto;
                if (i > splitposition)       //i == (cols - 1) || i == cols)
                {
                    cd.Width = new GridLength(rightpart, GridUnitType.Star);
                }
                else if (i == splitposition)
                {
                    cd.Width = new GridLength(.1, GridUnitType.Star);
                }
                else
                {
                    cd.Width = new GridLength(leftpart + .3, GridUnitType.Star);
                }
                splitgrid.ColumnDefinitions.Add(cd);
            }


            /// Filling grid ///
            TextBlock tb = null;
            Viewbox   vb = null;
            int       ci;//col index for mynotes only, during reading data from it.

            for (int r = 0; r < rows; r++)
            {
                ci = 0;
                for (int c = 0; c <= cols; c++)
                {
                    if (c != splitposition)
                    {
                        tb              = new TextBlock(); //tb.Background = Brushes.Blue;
                        tb.Text         = mynotes[r, ci]; ci++;
                        tb.TextWrapping = TextWrapping.Wrap;

                        tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                        ///////////// Setting Margin /////////////
                        //vb = new Viewbox(); vb.Height = 12; vb.Width = 100;//vb.Stretch = Stretch.Uniform;
                        tb.Margin = new Thickness(7);

                        /////////// Setting which row col will contain this textblock(UIElement) ///////////
                        tb.SetValue(Grid.RowProperty, r);
                        tb.SetValue(Grid.ColumnProperty, c);
                        //vb.Child = tb;

                        splitgrid.Children.Add(tb);
                    }
                    else
                    {
                        System.Windows.Shapes.Rectangle rec = new System.Windows.Shapes.Rectangle();
                        rec.Width = .2; //rec.Height = 3; rec.Margin = new Thickness(1, 1, 1, 1);
                        rec.Fill  = Brushes.Black;
                        rec.SetValue(Grid.RowProperty, r);
                        rec.SetValue(Grid.ColumnProperty, c);
                        splitgrid.Children.Add(rec);
                    }
                }
            }
            //splitgrid.ShowGridLines = true;
        }
Exemplo n.º 43
0
        private void Switch_0()
        {
            sight_row = null;
            sight_col = null;
            block_row = null;
            block_col = null;
            int    row_adjust = row * 128;
            int    col_adjust = colume * 128;
            double top        = row_adjust > col_adjust ? 512.0 * (row_adjust - col_adjust) / row_adjust / 2 : 0;
            double left       = col_adjust > row_adjust ? 512.0 * (col_adjust - row_adjust) / col_adjust / 2 : 0;
            double width      = row_adjust > col_adjust ? 512.0 / (double)row_adjust : 512.0 / (double)col_adjust;
            double BigWidth   = width * 128.0;

            byte[] bytes = new byte[3 * row_adjust * col_adjust];
            paint.Children.Clear();
            for (int i = 0; i < col_adjust; i++)
            {
                for (int j = 0; j < row_adjust; j++)
                {
                    bytes[3 * row_adjust * col_adjust - (i * row_adjust + (row_adjust - j - 1)) * 3 - 1] = this.colors[i, j].R;
                    bytes[3 * row_adjust * col_adjust - (i * row_adjust + (row_adjust - j - 1)) * 3 - 2] = this.colors[i, j].G;
                    bytes[3 * row_adjust * col_adjust - (i * row_adjust + (row_adjust - j - 1)) * 3 - 3] = this.colors[i, j].B;
                }
            }

            int      stride = row_adjust * 3;
            GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
            int      scan0  = (int)handle.AddrOfPinnedObject();

            scan0 += (col_adjust - 1) * stride;
            Bitmap bitmap = new Bitmap(row_adjust, col_adjust, -stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, (IntPtr)scan0);

            handle.Free();

            System.Windows.Controls.Image img = new System.Windows.Controls.Image();
            MemoryStream Ms = new MemoryStream();

            bitmap.Save(Ms, System.Drawing.Imaging.ImageFormat.Bmp);
            Ms.Position = 0;
            BitmapImage ObjBitmapImage = new BitmapImage();

            ObjBitmapImage.BeginInit();
            ObjBitmapImage.StreamSource = Ms;
            ObjBitmapImage.EndInit();
            img.Source  = ObjBitmapImage;
            img.Width   = 512;
            img.Height  = 512;
            img.Stretch = Stretch.Uniform;
            paint.Children.Add(img);
            for (int i = 0; i < colume; i++)
            {
                for (int j = 0; j < row; j++)
                {
                    System.Windows.Shapes.Rectangle pixel = new System.Windows.Shapes.Rectangle();
                    pixel.Fill   = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 255, 255));
                    pixel.Width  = BigWidth;
                    pixel.Height = BigWidth;
                    pixel.SetValue(Canvas.LeftProperty, left + j * BigWidth);
                    pixel.SetValue(Canvas.TopProperty, top + i * BigWidth);
                    pixel.SetValue(Panel.ZIndexProperty, 1);
                    pixel.MouseEnter        += RectangleEnter;
                    pixel.MouseMove         += RectangleEnter;
                    pixel.MouseLeave        += RectangleLeave;
                    pixel.MouseLeftButtonUp += RectanglePress;
                    paint.Children.Add(pixel);
                }
            }
            this.mode = 0;
        }
Exemplo n.º 44
0
        /// <summary>
        /// 绘制刻度
        /// </summary>
        /// <param name="size"></param>
        private void PaintCalibration(Size size)
        {
            try
            {
                var width = size.Width; // _canvas 有margin 所以要减去
                var height = size.Height;

                var value = Value;
                var maximum = Maximum;
                var minimum = Minimum;
                if (value < minimum)
                {
                    value = minimum;
                }
                if (value > maximum)
                {
                    value = maximum;
                }
                value -= minimum;

                var scale = Scale;

                if (scale < 1)
                {
                    scale = 1;
                }

                var x1 = width * 0.0781710914454277d;
                var y1 = height * 0.1312910284463895d;
                var x2 = width - x1;
                var y2 = height * 0.512035010940919d;
                var gap = width * 0.0176991150442478d;
                var cellWidth = ((x2 - x1) + gap) / scale;

                _calibrationCanvas.Children.Clear();

                var lineBrush1 = new SolidColorBrush(Color.FromArgb(0xff, 0x7C, 0x73, 0x63));
                var lineBrush2 = new SolidColorBrush(Colors.White);
                var fillBrush = new SolidColorBrush(Colors.Black);
                for (int i = 0; i < scale; i++)
                {

                    var line1 = new Line();
                    line1.X1 = x1 + i * cellWidth;
                    line1.X2 = line1.X1 + cellWidth - gap;
                    line1.Y1 = line1.Y2 = y1;
                    line1.Stroke = lineBrush1;
                    _calibrationCanvas.Children.Add(line1);

                    var line2 = new Line();
                    line2.X1 = line2.X2 = line1.X1;
                    line2.Y1 = y1;
                    line2.Y2 = y2;
                    line2.Stroke = lineBrush1;
                    _calibrationCanvas.Children.Add(line2);

                    var line3 = new Line();
                    line3.X1 = line1.X1;
                    line3.X2 = line1.X2;
                    line3.Y1 = line3.Y2 = y2;
                    line3.Stroke = lineBrush2;
                    _calibrationCanvas.Children.Add(line3);

                    var line4 = new Line();
                    line4.X1 = line4.X2 = line1.X2;
                    line4.Y1 = y1;
                    line4.Y2 = y2;
                    line4.Stroke = lineBrush2;
                    _calibrationCanvas.Children.Add(line4);
                }

                var valueScale = (int)Math.Ceiling(value * scale / (maximum - minimum));

                for (int i = 0; i < valueScale; i++)
                {
                    var rect = new Rectangle();
                    rect.SetValue(Canvas.LeftProperty, x1 + i * cellWidth);
                    rect.SetValue(Canvas.TopProperty, y1);
                    rect.Width = cellWidth - gap - 1d;
                    rect.Height = y2 - y1 - 1d;
                    rect.Fill = fillBrush;
                    _calibrationCanvas.Children.Add(rect);
                }
            }
            catch { }
        }
Exemplo n.º 45
0
        private void PaintMap()
        {
            tbMapSize.Text = string.Format("{0}x{1}", scenario.Map.GetMap().GetLength(0), scenario.map.GetMap().GetLength(1));
            pnlMap.Width   = scenario.map.GetMap().GetLength(0);
            pnlMap.Height  = scenario.map.GetMap().GetLength(1);
            if (_showMapMask)
            {
                //ImageBrush brush = new ImageBrush(scenario.Image);
                ImageBrush brush = new ImageBrush(scenario.Map.GetLayerMask(0));
                pnlMap.Background = brush;
            }
            if (_showBackgroundImage)
            {
                try
                {
                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(Properties.Settings.Default.ScenarioPath + "image.jpg")));
                    pnlMap.Background = brush;
                }
                catch
                {
                    pnlMap.Background = Brushes.LightPink;
                }
            }
            if ((_showBackgroundImage | _showMapMask) == false)
            {
                pnlMap.Background = Brushes.White;
            }

            for (int i = 0; i < pnlMap.Children.Count; i++)
            {
                if (!(pnlMap.Children[i] is Shape))
                {
                    pnlMap.Children.RemoveAt(i);
                    i--;
                }
            }
            if (_showWalls)
            {
                for (int n = 0; n < scenario.ServicesList.Count; n++)
                {
                    if (scenario.ServicesList[n] is TurnstileService)
                    {
                        var fig = (scenario.ServicesList[n] as TurnstileService).TurnstileGeometry;
                        System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
                        path.Data            = new PathGeometry(new PathFigure[] { fig });
                        path.Stroke          = Brushes.LightGray;
                        path.StrokeThickness = 2.0;
                        pnlMap.Children.Add(path);
                    }
                    if (scenario.ServicesList[n] is QueueService)
                    {
                        foreach (var point in (scenario.ServicesList[n] as QueueService).InputPoints)
                        {
                            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
                            rect.SetValue(Canvas.LeftProperty, (double)point.X - 1);
                            rect.SetValue(Canvas.TopProperty, (double)point.Y - 1);
                            rect.Width  = point.PointWidth * 2;
                            rect.Height = point.PointHeight * 2;
                            //rect.Stroke = Brushes.Pink;
                            rect.Fill = Brushes.LimeGreen;
                            //rect.StrokeThickness = 2.0D;
                            pnlMap.Children.Add(rect);
                        }
                    }
                }
                for (int n = 0; n < scenario.paintObjectList.Count; n++)
                {
                    PaintObject obj = scenario.paintObjectList[n];
                    if (obj.GetName() == "path")
                    {
                        string data = obj.GetAttributeValue("data");
                        System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
                        path.Data = Geometry.Parse(data);
                        SVSObjectStyle style = obj.GetStyle();
                        path.Fill   = new System.Windows.Media.SolidColorBrush(Color.FromArgb(style.FillColor.A, style.FillColor.R, style.FillColor.G, style.FillColor.B));
                        path.Stroke = new System.Windows.Media.SolidColorBrush(Color.FromArgb(style.BorderColor.A, style.BorderColor.R, style.BorderColor.G, style.BorderColor.B));
                        //path.Stroke = new System.Windows.Media.SolidColorBrush(Colors.Black);
                        path.StrokeThickness = (double)style.BorderSize;
                        System.Drawing.Drawing2D.Matrix m = obj.GetTransformMatrix();
                        Matrix matrix = new Matrix((double)m.Elements[0], (double)m.Elements[1], (double)m.Elements[2], (double)m.Elements[3], (double)m.OffsetX, (double)m.OffsetY);
                        path.RenderTransform = new MatrixTransform(matrix);
                        pnlMap.Children.Add(path);
                    }
                    if (obj.GetName() == "rect")
                    {
                        double         x     = PaintObject.StringToDoubleConvertor(obj.GetAttributeValue("x"));
                        double         y     = PaintObject.StringToDoubleConvertor(obj.GetAttributeValue("y"));
                        double         w     = PaintObject.StringToDoubleConvertor(obj.GetAttributeValue("width"));
                        double         h     = PaintObject.StringToDoubleConvertor(obj.GetAttributeValue("height"));
                        SVSObjectStyle style = obj.GetStyle();

                        Rectangle rect = new Rectangle();
                        rect.SetValue(Canvas.LeftProperty, x);
                        rect.SetValue(Canvas.TopProperty, y);
                        rect.Width           = w;
                        rect.Height          = h;
                        rect.Fill            = new System.Windows.Media.SolidColorBrush(Color.FromArgb(style.FillColor.A, style.FillColor.R, style.FillColor.G, style.FillColor.B));
                        rect.Stroke          = new System.Windows.Media.SolidColorBrush(Color.FromArgb(style.BorderColor.A, style.BorderColor.R, style.BorderColor.G, style.BorderColor.B));
                        rect.StrokeThickness = (double)style.BorderSize;
                        System.Drawing.Drawing2D.Matrix m = obj.GetTransformMatrix();
                        Matrix matrix = new Matrix((double)m.Elements[0], (double)m.Elements[1], (double)m.Elements[2], (double)m.Elements[3], (double)m.OffsetX, (double)m.OffsetY);
                        rect.RenderTransform = new MatrixTransform(matrix);
                        pnlMap.Children.Add(rect);
                    }
                }
            }
        }