Пример #1
0
        private void canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_startOfDragPosition.HasValue)
            {
                return;
            }

            var mousePosition = e.GetPosition(canvas);

            var ratio = canvas.ActualHeight / canvas.ActualWidth;

            var x1 = _startOfDragPosition.Value.X;
            var y1 = _startOfDragPosition.Value.Y;
            var x2 = mousePosition.X;
            var y2 = mousePosition.Y;

            var dragWidth = mousePosition.X - _startOfDragPosition.Value.X;

            var dragHeight = GetDragHeight(dragWidth, ratio, y2, y1);

            _dragRectangle.Stroke = SystemColors.WindowFrameBrush;

            _dragRectangle.Width  = Math.Abs(dragWidth);
            _dragRectangle.Height = Math.Abs(dragHeight);

            _dragRectangle.SetValue(Canvas.LeftProperty, Min(x1, x2));
            _dragRectangle.SetValue(Canvas.TopProperty, Min(y1, y2));

            _dragRectangle.Visibility = Visibility.Visible;
        }
Пример #2
0
 public override void OnMouseDown(Object sender, MouseEventArgs e)
 {
     isDrawig             = true;
     square               = new Square(new Point(e.GetPosition(canvas).X, e.GetPosition(canvas).Y), new Point(e.GetPosition(canvas).X, e.GetPosition(canvas).Y));
     squareForDraw        = new System.Windows.Shapes.Rectangle();
     squareForDraw.Stroke = Brushes.Red;
     squareForDraw.SetValue(Canvas.LeftProperty, square.GetFirstPoint().getX());
     squareForDraw.SetValue(Canvas.TopProperty, square.GetFirstPoint().getY());
     canvas.Children.Add(squareForDraw);
 }
Пример #3
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            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);

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            //_watchView = new WatchView();
            _watchView             = new Watch3DView(GUID.ToString());
            _watchView.DataContext = this;

            _watchView.Width  = _watchWidth;
            _watchView.Height = _watchHeight;
            _watchView.View.Camera.Position      = _camPosition;
            _watchView.View.Camera.LookDirection = _lookDirection;

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            backgroundRect.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            backgroundRect.IsHitTestVisible    = false;
            var bc          = new BrushConverter();
            var strokeBrush = (Brush)bc.ConvertFrom("#313131");

            backgroundRect.Stroke          = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            var backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240));

            backgroundRect.Fill = backgroundBrush;

            nodeUI.grid.Children.Add(backgroundRect);
            nodeUI.grid.Children.Add(_watchView);
            backgroundRect.SetValue(Grid.RowProperty, 2);
            backgroundRect.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.SetValue(Grid.RowProperty, 2);
            _watchView.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.Margin            = new Thickness(5, 0, 5, 5);
            backgroundRect.Margin        = new Thickness(5, 0, 5, 5);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }
 public Visual CreateVisual(IRenderContext context)
 {
     System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
     rectangle.Stroke          = Brushes.Black;
     rectangle.StrokeThickness = 2;
     rectangle.SetValue(CanvasControl.CanvasControlArrangeRectProperty, new Rect(this.rect.X, this.rect.Y, this.rect.Width, this.rect.Height));
     return(rectangle);
 }
Пример #5
0
        public static void CreateSingleSlideViewRect(Grid gSlideBox, Border bViewInfoBorder, Grid gViewInfo)
        {
            Dictionary <string, string> dictionary      = new Dictionary <string, string>();
            MultiScaleImage             multiScaleImage = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage;
            Border         obj            = gSlideBox.FindName("bGridBox") as Border;
            ZoomableCanvas zoomableCanvas = gSlideBox.FindName("zcGrid") as ZoomableCanvas;

            obj.Visibility = Visibility.Visible;
            System.Windows.Size imageSize = multiScaleImage.Source.ImageSize;
            zoomableCanvas.Width  = imageSize.Width;
            zoomableCanvas.Height = imageSize.Height;
            dictionary            = multiScaleImage.Source.sbcCurrentSlide.GetAllViewInfo();
            System.Drawing.Size viewSize = multiScaleImage.Source.sbcCurrentSlide.GetViewSize();
            string[]            array    = new string[7];
            foreach (string value in dictionary.Values)
            {
                array = value.Split(new string[1]
                {
                    "|"
                }, StringSplitOptions.RemoveEmptyEntries);
                System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                ViewRectInfo viewRectInfo = new ViewRectInfo();
                viewRectInfo.fXMotorPos = float.Parse(array[3]);
                viewRectInfo.fYMotorPos = float.Parse(array[4]);
                viewRectInfo.fZMotorPos = float.Parse(array[5]);
                if (float.Parse(array[6]) == 1f)
                {
                    viewRectInfo.strAutoFocus = GlobalVariable.listCurrentLanguage[116];
                    rectangle.Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(byte.MaxValue, 0, 0));
                    rectangle.SetValue(Panel.ZIndexProperty, 2);
                }
                else
                {
                    viewRectInfo.strAutoFocus = GlobalVariable.listCurrentLanguage[117];
                    rectangle.Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(57, 176, 181));
                }
                rectangle.DataContext = viewRectInfo;
                System.Windows.Point pPixelPoint = new System.Windows.Point(float.Parse(array[1]), float.Parse(array[2]));
                System.Windows.Point point       = multiScaleImage.ScanPixelToSlideRatio(pPixelPoint);
                rectangle.HorizontalAlignment = HorizontalAlignment.Left;
                rectangle.VerticalAlignment   = VerticalAlignment.Top;
                rectangle.StrokeThickness     = 1.0;
                rectangle.Width      = (float)viewSize.Width;
                rectangle.Height     = (float)viewSize.Height;
                rectangle.Margin     = new Thickness(point.X * imageSize.Width, point.Y * imageSize.Height, 0.0, 0.0);
                rectangle.Fill       = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, byte.MaxValue, byte.MaxValue, byte.MaxValue));
                rectangle.MouseMove += delegate(object sender, MouseEventArgs e)
                {
                    if (bViewInfoBorder.Visibility != Visibility.Collapsed)
                    {
                        ViewRectInfo dataContext = (sender as System.Windows.Shapes.Rectangle).DataContext as ViewRectInfo;
                        gViewInfo.DataContext = dataContext;
                    }
                };
                zoomableCanvas.Children.Add(rectangle);
            }
        }
Пример #6
0
        public override void OnMouseMove(Object sender, MouseEventArgs e)
        {
            if (isDrawig)
            {
                rectagle.setSecondPoint(new Point(e.GetPosition(canvas).X, e.GetPosition(canvas).Y));
                if (rectagle.GetSecondPoint().getX() < rectagle.GetFirstPoint().getX())
                {
                    rectangleForDraw.SetValue(Canvas.LeftProperty, rectagle.GetSecondPoint().getX());
                }
                if (rectagle.GetSecondPoint().getY() < rectagle.GetFirstPoint().getY())
                {
                    rectangleForDraw.SetValue(Canvas.TopProperty, rectagle.GetSecondPoint().getY());
                }

                rectangleForDraw.Width  = Math.Abs(rectagle.GetFirstPoint().getX() - rectagle.GetSecondPoint().getX());
                rectangleForDraw.Height = Math.Abs(rectagle.GetFirstPoint().getY() - rectagle.GetSecondPoint().getY());
            }
        }
Пример #7
0
        public override void OnMouseMove(Object sender, MouseEventArgs e)
        {
            if (isDrawig)
            {
                square.setSecondPoint(new Point(e.GetPosition(canvas).X, e.GetPosition(canvas).Y));
                if (square.GetSecondPoint().getX() < square.GetFirstPoint().getX())
                {
                    squareForDraw.SetValue(Canvas.LeftProperty, square.GetSecondPoint().getX());
                }
                if (square.GetSecondPoint().getY() < square.GetFirstPoint().getY())
                {
                    squareForDraw.SetValue(Canvas.TopProperty, square.GetSecondPoint().getY());
                }

                squareForDraw.Width  = Math.Abs(square.GetFirstPoint().getX() - square.GetSecondPoint().getX());
                squareForDraw.Height = squareForDraw.Width;
            }
        }
 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);
     }
 }
Пример #9
0
        private void BtnExportXaml_Click(object sender, EventArgs e)
        {
            Image  pic     = il32.Images[pnlPictures.SelectedIndex];
            string newName = $"Image";

            newName = newName + ".Xaml";
            try
            {
                string xamlOutputText = string.Empty;
                string xamlOutput     = string.Empty;

                previewTarget = new System.Windows.Controls.Canvas
                {
                    Background = Brushes.Transparent
                };
                Rectangle rectangle = null;
                Bitmap    bitmap    = new Bitmap(pic);
                previewTarget.Height = bitmap.Height;
                previewTarget.Width  = bitmap.Width;


                for (int y = 0; y < bitmap.Height; ++y)
                {
                    for (int x = 0; x < bitmap.Width; ++x)
                    {
                        System.Drawing.Color pixel = bitmap.GetPixel(x, y);
                        rectangle = new Rectangle
                        {
                            Fill = new SolidColorBrush(Color.FromArgb(pixel.A, pixel.R, pixel.G, pixel.B))
                        };
                        rectangle.Height = rectangle.Width = 1.0;
                        rectangle.SetValue(System.Windows.Controls.Canvas.LeftProperty, (double)x);
                        rectangle.SetValue(System.Windows.Controls.Canvas.TopProperty, (double)y);
                        rectangle.SnapsToDevicePixels = true;
                        previewTarget.Children.Add(rectangle);

                        Application.DoEvents();
                    }
                }

                Application.DoEvents();

                XmlWriterSettings settings = new XmlWriterSettings
                {
                    Indent           = true,
                    IndentChars      = "\t",
                    ConformanceLevel = ConformanceLevel.Fragment
                };
                StringBuilder output = new StringBuilder();
                XamlWriter.Save(previewTarget, XmlWriter.Create(output, settings));
                xamlOutputText                   = output.ToString();
                saveFileDialog1.Filter           = "Xaml Files(*.Xaml)|*.Xaml|All files (*.*)|*.*";
                saveFileDialog1.FilterIndex      = 1;
                saveFileDialog1.RestoreDirectory = true;
                saveFileDialog1.FileName         = newName;
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    TextWriter writeFile = new StreamWriter(saveFileDialog1.FileName);
                    writeFile.Write(xamlOutputText);
                    writeFile.Flush();
                    writeFile.Close();
                    writeFile = null;
                }
            }
            catch
            {
                MessageBox.Show("Failed to save Xaml to Xaml format.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MessageBox.Show("Xaml file saved to " + newName,
                            "Xaml Saved", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Пример #10
0
        private void DrawMap() {
            if (CurrentMapTable == null) {
                MapGrid.Children.Add(new TextBlock()
                {
                    Text = "No map data, import GAME first.",
                    FontWeight = FontWeights.Bold,
                    HorizontalAlignment = HorizontalAlignment.Right
                });
                MapToolbarToggleButton.IsChecked = true;
                return;
            }
            //make offset to 0~CurrentMapTable.W, always positive
            int offsetRemain = (Offset%CurrentMapTable.W + CurrentMapTable.W)%CurrentMapTable.W;
            for (int row = 0; row < CurrentMapTable.Rows.Count; row++) {
                int offsetedRowIndex = (row + offsetRemain) %CurrentMapTable.W;
                MapRow r = CurrentMapTable[offsetedRowIndex];
                MapGrid.RowDefinitions.Add(new RowDefinition() {
                    Height = new GridLength(25)
                });
                for (int col = 0; col < r.Cells.Count; col++) {
                    MapCell c = r[col];
                    if (row == 0) {
                        MapGrid.ColumnDefinitions.Add(new ColumnDefinition() {
                            Width = new GridLength(25)
                        });
                    }
                    TextBlock tb = new TextBlock() {
                        Text = c.Text,
                        Foreground = c.Foreground,
                        FontWeight = c.fontWeight
                    };
                    System.Windows.Shapes.Rectangle rec = new System.Windows.Shapes.Rectangle() {
                        Fill = new LinearGradientBrush() {
                            StartPoint = new Point(0, 1),
                            EndPoint = new Point(1, 0),
                            MappingMode = BrushMappingMode.RelativeToBoundingBox,
                            GradientStops = new GradientStopCollection() {
                                new GradientStop(c.YorishiroColor, 1d/4d),
                                new GradientStop(Colors.Transparent, 1d/4d),
                                new GradientStop(Colors.Transparent, 3d/4d),
                                new GradientStop(c.AttributeColor, 3d/4d)
                            }
                        },
                        StrokeThickness = 2,
                        StrokeDashArray = new DoubleCollection() {2, 1},
                        Stroke = c.EnemyRate > 0 && c.EnemyRate < 100 ? Brushes.DarkGray : Brushes.Transparent
                    };

                    //绘制tooltip
                    StringBuilder sb = new StringBuilder();
                    if (c.EnemyNo > 0) {
                        sb.AppendLine("#:" + c.EnemyNo);
                    }
                    if (c.HasDropInfo) {
                        sb.AppendLine($"evo_pt:{c.add_attribute_exp}|exp:{c.unit_exp}");
                        sb.AppendLine($"atk+{c.unit_attack}|hp+{c.unit_life}");
                        if (c.drop_unit != null) {
                            sb.AppendLine(string.Format("drop:[{0}]{1}", c.drop_unit.g_id, c.drop_unit.name));
                        }
                    }
                    if (c.drop_id != 0) {
                        sb.AppendLine("drop_id:" + c.drop_id);
                        sb.AppendLine("gold:" + c.gold_pt);
                    }
                    if (string.IsNullOrWhiteSpace(sb.ToString().Trim()) == false) {
                        rec.ToolTip = new Run(sb.ToString().Trim());
                    }

                    Border b = new Border() {
                        Background = c.Background,
                        Child = tb
                    };

                    MapGrid.Children.Add(b);
                    b.SetValue(Grid.RowProperty, row);
                    b.SetValue(Grid.ColumnProperty, col);

                    if (c.RawCellData != 0) {   //no rectangle overlay when this cell contains nothing
                        MapGrid.Children.Add(rec);
                        rec.SetValue(Grid.RowProperty, row);
                        rec.SetValue(Grid.ColumnProperty, col);
                        rec.SetValue(Grid.ZIndexProperty, 2);
                    }
                }
            }
            //绘制底部标记
            MapGrid.RowDefinitions.Add(new RowDefinition() {
                Height = new GridLength(25)
            });
            for (int j = 0; j < CurrentMapTable.H; j++) {
                int markValue = CurrentMapTable.ZeroMarkPlace - j;
                if (CurrentMapTable.EventCutins?.Any(cutin => cutin.cutin_w == j) == true) {
                    //走到对应列会触发cutin,把mark换成按钮
                    Button button = new Button() {
                        Content = markValue,
                        HorizontalContentAlignment = HorizontalAlignment.Center
                    };
                    int cutinW = j;
                    button.Click += (s, arg) => {
                        LoadEventCutin(cutinW);
                    };
                    MapGrid.Children.Add(button);

                    button.SetValue(Grid.RowProperty, CurrentMapTable.W);
                    button.SetValue(Grid.ColumnProperty, j);
                }
                else {
                    TextBlock tb = new TextBlock() {
                        Text = markValue.ToString() //Now use BossStart as zero mark, farewell 3
                    };
                    Border b = new Border { Child = tb };
                    MapGrid.Children.Add(b);

                    b.SetValue(Grid.RowProperty, CurrentMapTable.W);
                    b.SetValue(Grid.ColumnProperty, j);
                }
            }
            //绘制左侧冻结行标记
            MapMarkGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(25)
            });
            for (int i = 0; i < CurrentMapTable.Rows.Count; i++) {
                MapMarkGrid.RowDefinitions.Add(new RowDefinition() {
                    Height = new GridLength(25)
                });
                TextBlock tb = new TextBlock() {
                    Text = CurrentMapTable.W-i > offsetRemain
                        ? (CurrentMapTable.Y - i - offsetRemain).ToString()
                        : ((CurrentMapTable.Y - i - offsetRemain + CurrentMapTable.W) % CurrentMapTable.W).ToString()
                };
                Border b = new Border {Child = tb};
                MapMarkGrid.Children.Add(b);

                b.SetValue(Grid.RowProperty, i);
                b.SetValue(Grid.ColumnProperty, 0);
            }
            //收起地图工具栏
            MapToolbarToggleButton.IsChecked = false;
        }
Пример #11
0
        private void CreatePuzzle(Stream streamSource)//потік, який має зображення
        {
            zoomSlider.Value = 0.50;
            png = null;

            imageSource = null;
            using (BinaryReader reader = new BinaryReader(streamSource))
            {
                imageSource = new BitmapImage();
                imageSource.BeginInit();
                imageSource.CacheOption  = BitmapCacheOption.OnLoad;
                imageSource.StreamSource = reader.BaseStream;
                imageSource.EndInit();
                imageSource.Freeze();
            }

            //List<Pixel> - ряд пікселів
            //List<List<Pixel>> - ряд рядів пікселів
            chunks = new List <List <List <Pixel> > >();

            //перетворення bitmapImage в bitmap
            Bitmap alg = BitmapImage2Bitmap(imageSource);

            for (int i = 0; i < rows; ++i)
            {
                for (int j = 0; j < columns; ++j)
                {
                    List <List <Pixel> > ch = new List <List <Pixel> >(Height);

                    for (int x = 0; x < Height; ++x)
                    {
                        ch.Add(new List <Pixel>(Width));
                    }

                    for (int x = 0; x < Height; ++x)
                    {
                        for (int y = 0; y < Width; ++y)
                        {
                            //отримання кольору для кожного пікселя
                            System.Drawing.Color clr = alg.GetPixel(j * Width + y, i * Height + x);
                            ch[x].Add(new Pixel(clr.R, clr.G, clr.B));
                        }
                    }

                    chunks.Add(ch);
                }
            }

            rSelection.SetValue(Canvas.ZIndexProperty, 5000);
            cnvPuzzle.Children.Add(rSelection);

            //на даному етапі всі чанки в такому ж порядку, як і шматки
            //їх потрібно перемішати у відповідності до тих, що будуть на панелі вибору

            imgShowImage.Source = imageSource;

            scvImage.Visibility  = Visibility.Hidden;
            cnvPuzzle.Visibility = Visibility.Visible;

            var angles = new int[] { 0, 90, 180, 270 };

            //нарізання пазлу
            int index = 0;

            for (var y = 0; y < rows; ++y)
            {
                for (var x = 0; x < columns; ++x)
                {
                    var piece = new Piece(imageSource, x, y, rows, columns, false, index, scale);
                    piece.SetValue(Canvas.ZIndexProperty, 1000 + x * rows + y);

                    piece.MouseLeftButtonUp  += new MouseButtonEventHandler(piece_MouseLeftButtonUp);
                    piece.MouseRightButtonUp += new MouseButtonEventHandler(piece_MouseRightButtonUp);

                    //відповідна тінь
                    var shadowPiece = new Piece(imageSource, x, y, rows, columns, false, index, scale);
                    shadowPiece.SetValue(Canvas.ZIndexProperty, x * rows + y);

                    pieces.Add(piece);
                    shadowPieces.Add(shadowPiece);
                    index++;
                }
            }

            List <Tuple <List <List <Pixel> >, Piece> > honesty = new List <Tuple <List <List <Pixel> >, Piece> >();

            for (int i = 0; i < pieces.Count; ++i)
            {
                honesty.Add(new Tuple <List <List <Pixel> >, Piece>(chunks[i], pieces[i]));
            }

            var shuffledPieces = pieces.OrderBy(i => Guid.NewGuid()).ToList();
            var shuffled       = honesty.OrderBy(i => Guid.NewGuid()).ToList();
            int it             = 0;

            //заповнення панелі вибору
            foreach (var p in shuffled)
            {
                Random random = new Random();

                p.Item2.ScaleTransform.ScaleX = 1.0;
                p.Item2.ScaleTransform.ScaleY = 1.0;
                p.Item2.X          = -1;
                p.Item2.Y          = -1;
                p.Item2.IsSelected = false;

                pnlPickUp.Children.Insert(it++, p.Item2);//заповнюється wrapPanel
            }

            for (int i = 0; i < pieces.Count; ++i)
            {
                pieces[i] = shuffled[i].Item2;
            }

            for (int i = 0; i < chunks.Count; ++i)
            {
                chunks[i] = shuffled[i].Item1;
            }

            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            ISolver slvr = new Solver(rows, columns, Width, Height);

            permResult           = slvr.GeneratePerm(chunks);
            Mouse.OverrideCursor = null;

            //permResult - така перестановка, яка отримала на вхід пошафлені дані і згенерувала таку перестановку,
            //яку вважає складеним пазлом
        }
Пример #12
0
        public override void SetupCustomUIElements(Controls.dynNodeView nodeUI)
        {
            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);

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            _watchView = new WatchView();
            _watchView.watch_view.DataContext = this;

            RenderOptions.SetEdgeMode(_watchView, EdgeMode.Unspecified);

            Points = new Point3DCollection();
            Lines = new Point3DCollection();

            _points = new PointsVisual3D { Color = Colors.Red, Size = 6 };
            _lines = new LinesVisual3D { Color = Colors.Blue, Thickness = 1 };

            _points.Points = Points;
            _lines.Points = Lines;

            _watchView.watch_view.Children.Add(_lines);
            _watchView.watch_view.Children.Add(_points);

            _watchView.watch_view.Children.Add(new DefaultLights());

            _watchView.Width = 400;
            _watchView.Height = 300;

            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(_watchView);

            nodeUI.grid.Children.Add(backgroundRect);
            nodeUI.grid.Children.Add(_watchView);
            backgroundRect.SetValue(Grid.RowProperty,2);
            backgroundRect.SetValue(Grid.ColumnSpanProperty,3);
            _watchView.SetValue(Grid.RowProperty, 2);
            _watchView.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.Margin = new Thickness(5,0,5,5);
            backgroundRect.Margin = new Thickness(5, 0, 5, 5);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }
Пример #13
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            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);

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            _watchView = new WatchView();
            _watchView.watch_view.DataContext = this;

            RenderOptions.SetEdgeMode(_watchView, EdgeMode.Unspecified);

            Points = new Point3DCollection();
            Lines  = new Point3DCollection();

            _points = new PointsVisual3D {
                Color = Colors.Red, Size = 6
            };
            _lines = new LinesVisual3D {
                Color = Colors.Blue, Thickness = 1
            };

            _points.Points = Points;
            _lines.Points  = Lines;

            _watchView.watch_view.Children.Add(_lines);
            _watchView.watch_view.Children.Add(_points);

            _watchView.watch_view.Children.Add(new DefaultLights());

            _watchView.Width  = 400;
            _watchView.Height = 300;

            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.grid.Children.Add(backgroundRect);
            nodeUI.grid.Children.Add(_watchView);
            backgroundRect.SetValue(Grid.RowProperty, 2);
            backgroundRect.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.SetValue(Grid.RowProperty, 2);
            _watchView.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.Margin            = new Thickness(5, 0, 5, 5);
            backgroundRect.Margin        = new Thickness(5, 0, 5, 5);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }
Пример #14
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            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);

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            //_watchView = new WatchView();
            _watchView = new Watch3DView(GUID.ToString());
            _watchView.DataContext = this;

            _watchView.Width = _watchWidth;
            _watchView.Height = _watchHeight;
            _watchView.View.Camera.Position = _camPosition;
            _watchView.View.Camera.LookDirection = _lookDirection;

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            backgroundRect.IsHitTestVisible = false;
            var bc = new BrushConverter();
            var strokeBrush = (Brush)bc.ConvertFrom("#313131");
            backgroundRect.Stroke = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            var backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 240, 240));
            backgroundRect.Fill = backgroundBrush;

            nodeUI.grid.Children.Add(backgroundRect);
            nodeUI.grid.Children.Add(_watchView);
            backgroundRect.SetValue(Grid.RowProperty, 2);
            backgroundRect.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.SetValue(Grid.RowProperty, 2);
            _watchView.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.Margin = new Thickness(5, 0, 5, 5);
            backgroundRect.Margin = new Thickness(5, 0, 5, 5);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }