Exemple #1
0
 /*Draw Underlay*/
 public static void DrawUnderlay(Underlay xUnderlay, Canvas mainCanvas)
 {
     /*DrawUtils.DrawPoint(xUnderlay.Position, mainCanvas, Colors.Red, 10, 0.5);*/
     DrawUtils.DrawText(xUnderlay.Definition.Name, 10, TypeConverter.ToMediaColor(xUnderlay.Color.ToColor()), xUnderlay.Position.X, xUnderlay.Position.Y + 20, mainCanvas);
 }
        public Grid mainGrid     = new Grid();   //面板 grid

        public Grid GetMainGrid(netDxf.DxfDocument dxfFile, bool avecGrille, bool avecOrigine, Color bgColor)
        {
            try
            {
                mainCanvas.Children.Clear();
                DrawEntities.RazMaxDim();
                DrawEntities.AddNewMaxDim();

                ;
                //  mainGrid = new Grid();
                mainGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
                mainGrid.VerticalAlignment   = VerticalAlignment.Stretch;


                Color m_Color = Color.FromArgb(255, (byte)128, (byte)128, (byte)128);
                mainGrid.Background = new SolidColorBrush(m_Color);


                border.Height = GridHeight;
                border.Width  = GridWidth;
                //

                border.Background          = new SolidColorBrush(m_Color); //UNdone::取消背景颜色
                border.HorizontalAlignment = HorizontalAlignment.Stretch;
                border.VerticalAlignment   = VerticalAlignment.Stretch;
                border.Scale = Scale;//增加比例


                mainCanvas.Name = "mainCanvas";
                if (DxfDoc.DrawingVariables.AcadVer < netDxf.Header.DxfVersion.AutoCad2000)
                {
                    DrawUtils.DrawText("Le format du fichier doit être dxf2000 ou supérieur.", 10, Colors.Red, 20, 50, mainCanvas);
                }
                GetCanvas(DxfDoc, mainCanvas);

                if (avecOrigine == true)
                {
                    DrawEntities.AddNewMaxDim();
                    DrawUtils.DrawOrigin(mainCanvas);
                    DrawEntities.DeleteLastMaxDim();
                }

                if (avecGrille == true)
                {
                    Canvas bgCanvas = new Canvas();
                    if (border.Child == null)
                    {
                        bgCanvas = CreateBgCanvas();
                        bgCanvas.Children.Add(mainCanvas);

                        border.Child = bgCanvas;
                    }
                }
                else
                {
                    border.Child = mainCanvas;
                }

                Canvas.SetTop(mainCanvas, GridHeight / 2);
                Canvas.SetLeft(mainCanvas, GridWidth / 2);

                //  Canvas.SetTop(mainCanvas, 0);
                //  Canvas.SetLeft(mainCanvas, 0);

                //border.Reset(GridHeight,GridWidth,true,ViewHeight,ViewWidth,WinHeight,WinWidth);



                if (mainGrid.Children.Count == 0)
                {
                    //bool res = mainGrid.Children.Contains(border);
                    // if(res==false)
                    mainGrid.Children.Add(border);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            return(mainGrid);
        }