private void btnShow_Click(object sender, EventArgs e)
        {
            lblMessage.Text = "";

            DrawingHandler MyDrawingHandler = new DrawingHandler();
            int            nDrawings        = 0;

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                int iCounter = 0;
                while (SelectedDrawings.MoveNext())
                {
                    iCounter++;
                }
                nDrawings = iCounter;
            }

            progressBar1.Minimum = 0;
            progressBar1.Maximum = nDrawings;
            progressBar1.Step    = 1;

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                int iCounter = 1;
                while (SelectedDrawings.MoveNext())
                {
                    progressBar1.PerformStep();

                    Drawing      currentDrawing = SelectedDrawings.Current;
                    ListViewItem currentRow     = new ListViewItem(currentDrawing.Mark);

                    currentRow.SubItems.Add(currentDrawing.Name);
                    string strHeight = currentDrawing.Layout.SheetSize.Height.ToString();
                    string strWidth  = currentDrawing.Layout.SheetSize.Width.ToString();
                    currentRow.SubItems.Add(strWidth + "x" + strHeight);
                    string PrinterInstance = "QP_" + strWidth + "x" + strHeight;

                    //TSM.Operations.Operation.DisplayPrompt("Drawing " + currentDrawing.Name + ": " + iCounter.ToString() + "/" + nDrawings.ToString());
                    lblMessage.Text = "";
                    lblMessage.Text = "Drawing " + currentDrawing.Name + ": " + iCounter.ToString() + "/" + nDrawings.ToString();
                    iCounter++;

                    if (chkPDF.Checked)
                    {
                        WriteCurrentDrawing(currentDrawing, PrinterInstance);
                    }

                    if (chkDWG.Checked)
                    {
                        PrintToFile(currentDrawing);
                    }
                }
            }

            //TSM.Operations.Operation.DisplayPrompt("Write command completed!");
            lblMessage.Text    = "Write command completed!";
            progressBar1.Value = 0;
        }
Exemplo n.º 2
0
        private void btnShow_Click(object sender, EventArgs e)
        {
            lblMessage.Text = "";

            DrawingHandler MyDrawingHandler = new DrawingHandler();
            int nDrawings = 0;
            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                int iCounter = 0;
                while (SelectedDrawings.MoveNext())
                {
                    iCounter++;
                }
                nDrawings = iCounter;
            }

            progressBar1.Minimum = 0;
            progressBar1.Maximum = nDrawings;
            progressBar1.Step = 1;

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                int iCounter = 1;
                while (SelectedDrawings.MoveNext())
                {
                    progressBar1.PerformStep();

                    Drawing currentDrawing = SelectedDrawings.Current;
                    ListViewItem currentRow = new ListViewItem(currentDrawing.Mark);

                    currentRow.SubItems.Add(currentDrawing.Name);
                    string strHeight = currentDrawing.Layout.SheetSize.Height.ToString();
                    string strWidth = currentDrawing.Layout.SheetSize.Width.ToString();
                    currentRow.SubItems.Add(strWidth + "x" + strHeight);
                    string PrinterInstance = "QP_" + strWidth + "x" + strHeight;

                    //TSM.Operations.Operation.DisplayPrompt("Drawing " + currentDrawing.Name + ": " + iCounter.ToString() + "/" + nDrawings.ToString());
                    lblMessage.Text = "";
                    lblMessage.Text = "Drawing " + currentDrawing.Name + ": " + iCounter.ToString() + "/" + nDrawings.ToString();
                    iCounter++;

                    if (chkPDF.Checked)
                        WriteCurrentDrawing(currentDrawing, PrinterInstance);

                    if (chkDWG.Checked)
                        PrintToFile(currentDrawing);
                }
            }

            //TSM.Operations.Operation.DisplayPrompt("Write command completed!");
            lblMessage.Text = "Write command completed!";
            progressBar1.Value = 0;
        }
        public override List <InputDefinition> DefineInput()
        {
            //
            // This is an example for selecting two points; change this to suit your needs.
            //
            List <InputDefinition> inputs         = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase  view   = null;
                PointList points = new PointList();

                StringList prompts = new StringList();
                prompts.Add("Pick first point");
                prompts.Add("Pick second point");

                picker.PickPoints(2, prompts, out points, out view);
                inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, points));
            }

            return(inputs);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            DrawingHandler MyDrawingHandler = new DrawingHandler();

            PrintAttributes printAttributes = new PrintAttributes();

            printAttributes.Scale = 1.0;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies       = 1;
            printAttributes.Orientation          = DotPrintOrientationType.Auto;
            printAttributes.PrintArea            = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance      = "PDF_594x420";

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                while (SelectedDrawings.MoveNext())
                {
                    Drawing currentDrawing = SelectedDrawings.Current;

                    //Get print attributes: we need only PrinterInstance
                    MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes);
                }
            }
        }
Exemplo n.º 5
0
        private void SelectedDrawing_Click(object sender, EventArgs e)
        {
            this.progressBar1.Value = 0;
            DrawingHandler drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator selected = drawingHandler.GetDrawingSelector().GetSelected();
                this.RenameDrawingTitle(selected);
            }
        }
Exemplo n.º 6
0
        static void Main()
        {
            try
            {
                DrawingHandler drawingHandler = new DrawingHandler();

                if (drawingHandler.GetConnectionStatus())
                {
                    Drawing CurrentDrawing = drawingHandler.GetActiveDrawing();
                    if (CurrentDrawing != null)
                    {
                        DrawingObjectEnumerator drawingObjectEnumerator = CurrentDrawing.GetSheet().GetAllObjects(typeof(Part));

                        foreach (Part myPart in drawingObjectEnumerator)
                        {
                            View view = myPart.GetView() as View;
                            TransformationPlane SavePlane = new Model().GetWorkPlaneHandler().GetCurrentTransformationPlane();
                            new Model().GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(view.DisplayCoordinateSystem));

                            Identifier  Identifier  = myPart.ModelIdentifier;
                            ModelObject modelObject = new Model().SelectModelObject(Identifier);

                            PointList PointList = new PointList();
                            Beam      myBeam    = new Beam();
                            if (modelObject.GetType().Equals(typeof(Beam)))
                            {
                                myBeam.Identifier = Identifier;
                                myBeam.Select();

                                PointList.Add(myBeam.StartPoint);
                                PointList.Add(myBeam.EndPoint);
                            }

                            ViewBase viewBase = myPart.GetView();
                            StraightDimensionSet.StraightDimensionSetAttributes attr = new StraightDimensionSet.StraightDimensionSetAttributes(myPart);

                            if (myBeam.StartPoint.X != myBeam.EndPoint.X)
                            {
                                StraightDimensionSet XDimensions = new StraightDimensionSetHandler().CreateDimensionSet(viewBase, PointList, new Vector(0, 100, 0), 100, attr);
                                XDimensions.Insert();
                            }

                            new Model().GetWorkPlaneHandler().SetCurrentTransformationPlane(SavePlane);
                        }
                    }
                }
            }
            catch (Exception EX)
            {
                Console.WriteLine("Exception : " + EX.ToString());
            }
        }
        /// <summary>
        /// Edit opened drawing, take string from dialog and write it under every view in the drawing.
        /// Draws also rectangle around the text string.
        /// </summary>
        private void EditOpenedDrawing()
        {
            if (MyDrawingHandler.GetConnectionStatus())
            {
                Drawing MyDrawing = MyDrawingHandler.GetActiveDrawing();

                ContainerView           Sheet            = MyDrawing.GetSheet();
                DrawingObjectEnumerator MyViewEnumerator = Sheet.GetViews();

                //Looping through views in the drawing
                while (MyViewEnumerator.MoveNext())
                {
                    View CurrentView = MyViewEnumerator.Current as View; //If ViewBase used instead of View, then multidrawing's container views would work here also

                    if (CurrentView != null)
                    {
                        //Getting bounding box for the view frame and calculating then the CenterPoint under it
                        RectangleBoundingBox ViewAABB = CurrentView.GetAxisAlignedBoundingBox();
                        Point CenterPoint             = new Point();
                        CenterPoint.X = ViewAABB.LowerLeft.X + (ViewAABB.LowerRight.X - ViewAABB.LowerLeft.X) / 2.0;
                        CenterPoint.Y = ViewAABB.LowerLeft.Y - 5.0;  //5.0 mm below the view's bounding box

                        Text MyViewTitle = new Text(Sheet, CenterPoint, ViewTitle.Text, new Text.TextAttributes());
                        if (!MyViewTitle.Insert())
                        {
                            Console.WriteLine("Insert failed.");
                        }
                        else
                        {
                            RectangleBoundingBox TitleAABB = MyViewTitle.GetAxisAlignedBoundingBox();
                            Rectangle            myBox     = new Rectangle(Sheet, TitleAABB.LowerLeft, TitleAABB.UpperRight);
                            myBox.Insert();
                        }
                    }
                }
                MyDrawing.CommitChanges();
            }
        }
Exemplo n.º 8
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            DrawingHandler drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                CircleOpening program = new CircleOpening(drawingHandler);
                program.main();
            }
            else
            {
                MessageBox.Show("Ei leia joonist");
            }
        }
        public bool CheckConnect()
        {
            model = new Model();
            CourretDrawingHandler = new DrawingHandler();

            if (model.GetConnectionStatus() && CourretDrawingHandler.GetConnectionStatus())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 10
0
        public Form1()
        {
            _drawingHandler = new DrawingHandler();
            _model          = new Model();

            if (_model.GetConnectionStatus() &&
                _drawingHandler.GetConnectionStatus())
            {
                InitializeComponent();
            }
            else
            {
                MessageBox.Show("Tekla Structures must be opened!");
            }
        }
Exemplo n.º 11
0
        public Form1()
        {
            drawingHandler = new DrawingHandler();
            model          = new Model();
            if (model.GetConnectionStatus() && drawingHandler.GetConnectionStatus())
            {
                InitializeComponent();
            }
            else
            {
                MessageBox.Show("Tekla Structures must be opend!");
            }

            PickObjectInDrawing.Click += PickObjectInDrawing_Click;
            Quit.Click += Quit_Click;
        }
Exemplo n.º 12
0
        public Form1()
        {
            var model = new Model();                          //получаем доступ к модели
            var CurrentDrawingHandler = new DrawingHandler(); //получаем доступ к чертежам

            //если подключение прошло успешно
            if (model.GetConnectionStatus() &&
                CurrentDrawingHandler.GetConnectionStatus())
            {
                InitializeComponent();
            }
            else
            {
                MessageBox.Show("Tekla Structures must be opened!");
            }
        }
Exemplo n.º 13
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> input          = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase      view       = null;
                DrawingObject pickedPart = null;

                picker.PickObject("Pick part", out pickedPart, out view);

                input.Add(InputDefinitionFactory.CreateInputDefinition(view, pickedPart));
            }

            return(input);
        }
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            DrawingHandler myDrawingHandler = new DrawingHandler();
            if (myDrawingHandler.GetConnectionStatus())
            {
                DrawingObjectEnumerator selectedObjects = myDrawingHandler.GetDrawingObjectSelector().GetSelected();
                while (selectedObjects.MoveNext())
                {
                    if (selectedObjects.Current is StraightDimensionSet)
                    {
                        StraightDimensionSet curDimSet = selectedObjects.Current as TSD.StraightDimensionSet;
                        TSD.ContainerElement LUT = curDimSet.Attributes.LeftUpperTag as TSD.ContainerElement;
                        TSD.ContainerElement RUT = curDimSet.Attributes.RightUpperTag as TSD.ContainerElement;

                        curDimSet.Attributes.LeftUpperTag = RUT;
                        curDimSet.Attributes.RightUpperTag = LUT;
                        curDimSet.Modify();
                    }
                }
            }
        }
Exemplo n.º 15
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> inputs         = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase  view   = null;
                PointList points = new PointList();

                StringList prompts = new StringList();
                prompts.Add("Pick first point");
                prompts.Add("Pick second point");

                picker.PickPoints(2, prompts, out points, out view);
                inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, points));
            }

            return(inputs);
        }
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            DrawingHandler myDrawingHandler = new DrawingHandler();

            if (myDrawingHandler.GetConnectionStatus())
            {
                DrawingObjectEnumerator selectedObjects = myDrawingHandler.GetDrawingObjectSelector().GetSelected();
                while (selectedObjects.MoveNext())
                {
                    if (selectedObjects.Current is StraightDimensionSet)
                    {
                        StraightDimensionSet curDimSet = selectedObjects.Current as TSD.StraightDimensionSet;
                        TSD.ContainerElement LUT       = curDimSet.Attributes.LeftUpperTag as TSD.ContainerElement;
                        TSD.ContainerElement RUT       = curDimSet.Attributes.RightUpperTag as TSD.ContainerElement;

                        curDimSet.Attributes.LeftUpperTag  = RUT;
                        curDimSet.Attributes.RightUpperTag = LUT;
                        curDimSet.Modify();
                    }
                }
            }
        }
Exemplo n.º 17
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> inputs         = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase  view;
                PointList pointList;

                StringList promts = new StringList();
                promts.Add("able_Pick_center_point");
                promts.Add("able_Pick_major_point");

                picker.PickPoints(2, promts, out pointList, out view);
                inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, pointList));
            }

            return(inputs);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 初始化主梁对象;
        /// </summary>
        /// <returns></returns>
        private void InitMainPart()
        {
            DrawingHandler drawingHandler = new DrawingHandler();

            if (mModel.GetConnectionStatus() && drawingHandler.GetConnectionStatus())
            {
                DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT);
                AssemblyDrawing assemblyDrawing = drawingHandler.GetActiveDrawing() as AssemblyDrawing;
                if (assemblyDrawing != null)
                {
                    Assembly assembly = new Assembly
                    {
                        Identifier = assemblyDrawing.AssemblyIdentifier
                    };

                    assembly.Select();
                    TSM.Part mainPart = assembly.GetMainPart() as TSM.Part;

                    //创建自定义的主梁对象;
                    CMrMainBeam mainBeam = new CMrMainBeam(mainPart, null);
                    CMrMainBeam.SetInstance(mainBeam);

                    double dblFlangeThickness = 0.0;
                    double dblWebThickness    = 0.0;

                    //assembly.GetMainPart().GetReportProperty(CDogTools.GetInstance().GetFLANGEStr(), ref dblFlangeThickness);//YB 01 101 6 PROFILE.FLANGE_THICKNESS
                    //assembly.GetMainPart().GetReportProperty(CDogTools.GetInstance().GetWEBStr(), ref dblWebThickness);      //111 6  PROFILE.WEB_THICKNESS

                    assembly.GetMainPart().GetReportProperty("PROFILE.FLANGE_THICKNESS", ref dblFlangeThickness);
                    assembly.GetMainPart().GetReportProperty("PROFILE.WEB_THICKNESS", ref dblWebThickness);

                    mainBeam.mFlangeThickness = dblFlangeThickness;
                    mainBeam.mWebThickness    = dblWebThickness;
                }
            }
        }
 public static void Run(Tekla.Technology.Akit.IScript akit)
 {
     DrawingHandler drawingHandler = new DrawingHandler();
     if (drawingHandler.GetConnectionStatus())
     {
         CircleOpening program = new CircleOpening(drawingHandler);
         program.main();
     }
     else
     {
         MessageBox.Show("Ei leia joonist");
     }
 }
Exemplo n.º 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            DrawingHandler MyDrawingHandler = new DrawingHandler();

            PrintAttributes printAttributes = new PrintAttributes();
            printAttributes.Scale = 1.0;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies = 1;
            printAttributes.Orientation = DotPrintOrientationType.Auto;
            printAttributes.PrintArea = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance = "PDF_594x420";

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                while (SelectedDrawings.MoveNext())
                {
                    Drawing currentDrawing = SelectedDrawings.Current;

                    //Get print attributes: we need only PrinterInstance
                    MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes);
                }
            }
        }
Exemplo n.º 21
0
        private void PaintBlueRectangle()
        {
            ArrayList ItemList = new ArrayList();
            Drawing ActivatedDrawing;
            bool DrawingFound = false;

            DrawingHandler MyDrawingHandler = new DrawingHandler();

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();

                while (SelectedDrawings.MoveNext() && !DrawingFound)
                {
                    ActivatedDrawing = SelectedDrawings.Current;
                    double sheetHeight = ActivatedDrawing.Layout.SheetSize.Height;
                    double sheetWidth = ActivatedDrawing.Layout.SheetSize.Width;

                    double minX = 0.0;
                    double minY = 0.0;
                    double maxX = sheetWidth;
                    double maxY = sheetHeight;

                    TSD.ContainerView currentSheet = ActivatedDrawing.GetSheet();
                    TSD.DrawingObjectEnumerator viewEnum = currentSheet.GetViews();
                    while (viewEnum.MoveNext())
                    {
                        TSD.View currentView = viewEnum.Current as TSD.View;
                        RectangleBoundingBox ViewAABB = currentView.GetAxisAlignedBoundingBox();
                        double rbbx = ViewAABB.UpperLeft.X;
                        double rbby = ViewAABB.UpperLeft.Y;
                        double rbbW = ViewAABB.Width;
                        double rbbH = ViewAABB.Height;
                        double viewScale = currentView.Attributes.Scale;
                        //MessageBox.Show("rbbx=" + Convert.ToString(rbbx) + ", rbby=" + Convert.ToString(rbby) + ", rbbW=" + Convert.ToString(rbbW) + ", rbbH=" + Convert.ToString(rbbH));
                        ItemList.Add(rbbx);
                        ItemList.Add(rbby);
                        ItemList.Add(rbbW);
                        ItemList.Add(rbbH);
                        ItemList.Add(viewScale);

                        if (ViewAABB.UpperLeft.X < minX)
                        {
                            minX = ViewAABB.UpperLeft.X;
                        }
                        if (ViewAABB.LowerLeft.Y < minY)
                        {
                            minY = ViewAABB.LowerLeft.Y;
                        }
                        if (ViewAABB.UpperRight.X > maxX)
                        {
                            maxX = ViewAABB.UpperRight.X;
                        }
                        if (ViewAABB.UpperLeft.Y > maxY)
                        {
                            maxY = ViewAABB.UpperLeft.Y;
                        }
                    }

                    double bufferWidth = Math.Abs(minX) + maxX;
                    double bufferHeight = Math.Abs(minY) + maxY;

                    //panel1.Width = (int)Convert.ToInt32(bufferWidth);
                    //panel1.Height = (int)Convert.ToInt32(bufferHeight);
                    //btnPreview2.Location = new Point(panel1.Width - btnPreview2.Size.Width - 15, panel1.Height + btnPreview2.Size.Height);
                    //checkBox1.Location = new Point((int)Convert.ToInt32(0.2 * panel1.Width), panel1.Height + checkBox1.Size.Height + 20);
                    this.Size = new System.Drawing.Size(panel1.Width + 20, panel1.Height + btnPreview2.Size.Height + 20);
                    buffer = new Bitmap((int)Convert.ToInt32(bufferWidth), (int)Convert.ToInt32(bufferHeight));

            ////////////////////////////////////////////////////////////////////////////////////////
                    /*
                                   double scaleFactorX = 297 / bufferWidth;
                                   double scaleFactorY = 210 / bufferHeight;
                                   double scaleFactor = 0;
                                   if (scaleFactorX <= scaleFactorY)
                                   {
                                       scaleFactor = scaleFactorX;
                                   }else{
                                       scaleFactor=scaleFactorY;
                                   }

                                                       panel1.Width = (int)Convert.ToInt32(bufferWidth * scaleFactor);
                                                       panel1.Height = (int)Convert.ToInt32(bufferHeight * scaleFactor);
                                                       btnPreview2.Location = new Point(panel1.Width - btnPreview2.Size.Width - 15, panel1.Height + btnPreview2.Size.Height);
                                                       checkBox1.Location = new Point((int)Convert.ToInt32(0.2*panel1.Width), panel1.Height + checkBox1.Size.Height + 20);
                                                       this.Size = new System.Drawing.Size(panel1.Width + 20, panel1.Height + btnPreview2.Size.Height + 20);
                                                       buffer = new Bitmap((int)Convert.ToInt32(bufferWidth * scaleFactor), (int)Convert.ToInt32(bufferHeight * scaleFactor));
                                      */
             //////////////////////////////////////////////////////////////////////////////////////

                    // Draw blue rectangle into the buffer
                    using (Graphics bufferGrph = Graphics.FromImage(buffer))
                    {
                        Pen drwPen = new Pen(Color.DarkBlue, 4);
                        bufferGrph.Clear(Color.White);
                        System.Drawing.Rectangle myRectangle = new System.Drawing.Rectangle((int)Convert.ToInt32(Math.Abs(minX)), (int)Convert.ToInt32(Math.Abs(maxY)-sheetHeight), (int)Convert.ToInt32(sheetWidth), (int)Convert.ToInt32(sheetHeight));

                        bufferGrph.DrawRectangle(drwPen, myRectangle);

                        for (int i = 0; i <= ItemList.Count / 5 - 1; i++)
                        {
                            int w = (int)Convert.ToInt32(ItemList[5 * i + 2]);
                            int h = (int)Convert.ToInt32(ItemList[5 * i + 3]) ;
                            int x = (int)Convert.ToInt32(ItemList[5 * i]) + (int)Convert.ToInt32(Math.Abs(minX));
                            int y = (int)Convert.ToInt32(Math.Abs(maxY) - Convert.ToDouble(ItemList[5 * i + 1]));
                            bufferGrph.DrawRectangle(new Pen(Color.Blue, 2), x, y, w, h);

                            if (checkBox1.Checked)
                            {
                                int sx, sy;
                                // Create string to draw.
                                String drawString = "Scale:" + Convert.ToString(ItemList[5 * i + 4]);
                                // Create font and brush.
                                Font drawFont = new Font("Arial", 8);
                                SolidBrush drawBrush = new SolidBrush(Color.Black);
                                // Set format of string.
                                StringFormat drawFormat = new StringFormat();
                                if (h > w)
                                {
                                    // Create point for upper-left corner of drawing.
                                    sx = x + (int)(0.5 * w); sy = y + (int)(0.25 * h);
                                    drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                                }
                                else
                                {
                                    // Create point for upper-left corner of drawing.
                                    sx = x + (int)(0.25 * w); sy = y + (int)(0.5 * h);
                                    drawFormat.FormatFlags = StringFormatFlags.DisplayFormatControl;
                                }
                                // Draw string to screen.
                                bufferGrph.DrawString(drawString, drawFont, drawBrush, sx, sy, drawFormat);
                            }
                        }
                        //Be sure the dispose of the pench
                        drwPen.Dispose();
                    }
                    // Invalidate the panel. This will lead to a call of 'panel1_Paint'
                    panel1.Invalidate();
                    //only one loop
                    DrawingFound = true;
                }
            }
        }
Exemplo n.º 22
0
        private void AddDrawingsToDataGridView()
        {
            if (_drawingHandler.GetConnectionStatus())
            {
                var revisions = new List <dynamic>(0);

                var drawingItems = _drawings.AsParallel().Select(d =>
                {
                    var part     = GetPart(d);
                    var assy_pos = string.Empty;
                    var part_pos = string.Empty;
                    part?.GetReportProperty("ASSEMBLY_POS", ref assy_pos);
                    part?.GetReportProperty("PART_POS", ref part_pos);

                    var revisionMark = string.Empty;
                    part?.GetReportProperty("DRAWING.REVISION.MARK", ref revisionMark);
                    var revisionDescription = string.Empty;
                    part?.GetReportProperty("DRAWING.REVISION.DESCRIPTION", ref revisionDescription);

                    var revisionlastMark = string.Empty;
                    part?.GetReportProperty("DRAWING.REVISION.LAST_MARK", ref revisionlastMark);

                    var revisionItem = new
                    {
                        Mark        = revisionMark,
                        Description = revisionDescription,
                    };

                    revisions.Add(revisionItem);

                    var size = Math.Round(d.Layout.SheetSize.Width / 25.4, 1)
                               + "x" + Math.Round(d.Layout.SheetSize.Height / 25.4, 1);

                    var drawingItem = new
                    {
                        Size             = size,
                        Status           = d.UpToDateStatus.ToString(),
                        Type             = GetDrawingTypeCharacter(d),
                        DrawingMark      = d.Mark,
                        AssyMark         = assy_pos,
                        PartMark         = part_pos,
                        Name             = d.Name,
                        Rev              = revisionMark,
                        RevDescription   = revisionDescription,
                        CreationDate     = d.CreationDate,
                        ModificationDate = d.ModificationDate,
                        Title1           = d.Title1,
                        Title2           = d.Title2,
                        Title3           = d.Title3,
                        Id = part?.Identifier.ID,
                    };
                    return(drawingItem);
                }).ToList();

                dataGridView1.DataSource =
                    drawingItems
                    .OrderBy(d => d.Type)
                    .ThenBy(d => d.DrawingMark)
                    .ThenBy(d => d.PartMark)
                    .ThenBy(d => d.AssyMark)
                    .ToList();

                var rows = dataGridView1.Rows.OfType <DataGridViewRow>().ToList();
                rows.ForEach(r =>
                {
                    dynamic item = r.DataBoundItem;
                    var status   = item.Status;
                    if (status == "DrawingIsUpToDate")
                    {
                        r.DefaultCellStyle.BackColor = Color.LightGreen;
                        r.DefaultCellStyle.ForeColor = Color.Black;
                    }
                    else if (status == "PartsWereModified")
                    {
                        r.DefaultCellStyle.BackColor = Color.LightGoldenrodYellow;
                        r.DefaultCellStyle.ForeColor = Color.Crimson;
                    }
                    else if (status == "DrawingWasCloned")
                    {
                        r.DefaultCellStyle.BackColor = Color.LightSkyBlue;
                    }
                    else if (status == "DrawingIsUpToDateButMayNeedChecking")
                    {
                        r.DefaultCellStyle.BackColor = Color.Coral;
                    }
                    else if (status == "NumberOfPartsInNumberingSeriesIncreased")
                    {
                        r.DefaultCellStyle.BackColor = Color.DarkGoldenrod;
                    }
                    else if (status == "AllPartsDeleted")
                    {
                        r.DefaultCellStyle.BackColor = Color.DarkGray;
                    }
                    else if (status == "OriginalPartDeleted")
                    {
                        r.DefaultCellStyle.BackColor = Color.CadetBlue;
                    }
                });
            }
        }