private void Btn_RFT_Click(object sender, RoutedEventArgs e)
        {
            #region RFT Visualization
            GeometryEngineRFT.Remove("RFT");

            /*----------RFT Visualization---------*/
            RFTCanvas.CalcSpanVals();
            RFTCanvas.CalcComSpanVals(GeometryEditorVM.GeometryEditor.NumberOfSpans);
            RFTCanvas.CalcThickness();

            //Points  /*--------the Order is Important-----------*/
            RFTCanvas.ConstructTopStartPoints(20);
            RFTCanvas.ConstructTopEndPoints(20);

            RFTCanvas.ConstructBotStartPoints(20);
            RFTCanvas.ConstructBotEndPoints(20);



            //Lines
            RFTCanvas.ConstructTopLines(GeometryEngineRFT.GCanvas, GeometryEngineRFT);
            RFTCanvas.ConstructBotLines(GeometryEngineRFT.GCanvas, GeometryEngineRFT);
            RFTCanvas.ConstructColLines(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            //RFT Lines
            RFTCanvas.BotRFT(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);
            RFTCanvas.TopRFT(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            //Stirrups
            RFTCanvas.LeftSecStirrups(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);
            RFTCanvas.RightSecStirrups(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            #region Text Trial
            //TxtRFTCanvas.CalcSpanVals();
            //TxtRFTCanvas.CalcComSpanVals();
            ////TxtRFTCanvas.CreateBottomRFTTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);
            //TxtRFTCanvas.CreateTopRFTTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            #endregion

            GeometryEngineRFT.RenderAll();
            #endregion
        }
        private void Btn_Design_Click(object sender, RoutedEventArgs e)
        {//----------------Consider Revision
            int[] secIndex = new int[GeometryEditorVM.GeometryEditor.GridData.Count];
            for (int i = 0; i < GeometryEditorVM.GeometryEditor.GridData.Count; i++)
            {
                for (int j = 0; j < AnalysisMapping.SapSectionsArr.Length; j++)
                {
                    if (GeometryEditorVM.GeometryEditor.GridData[i].SelectedSection.Width == AnalysisMapping.SapSectionsArr[j].B &&
                        GeometryEditorVM.GeometryEditor.GridData[i].SelectedSection.Depth == AnalysisMapping.SapSectionsArr[j].T)
                    {
                        secIndex[i] = j;
                    }
                }
            }
            int bindex = 0;

            foreach (var item in AnalysisMapping.xbeams)
            {
                //clear all case and combo output selections:
                int ret1 = AnalysisMapping.mySapModel.MySapObjectModel.Results.Setup.DeselectAllCasesAndCombosForOutput();

                //set case and combo output selections
                int ret2 = AnalysisMapping.mySapModel.MySapObjectModel.Results.Setup.SetComboSelectedForOutput(DesignCombinationComboBox.SelectedItem as string);



                AnalysisMapping.xbeams[bindex].FrameResults.Add(new SapFrameResult(AnalysisMapping.mySapModel.MySapObjectModel, item.Label));

                //add sections created:
                AnalysisMapping.xbeams[bindex].Sec.Add(AnalysisMapping.SapSectionsArr[secIndex[bindex]]);
                bindex++;
            }
            /*----------------------------------------------------------*/
            //Design:
            double fcu       = Convert.ToDouble(MaterialEditorVM.Material.Fcu);
            double fy        = Convert.ToDouble(MaterialEditorVM.Material.Fy);
            double fystr     = Convert.ToDouble(MaterialEditorVM.Material.FyStirrups);
            int    nBranches = Convert.ToInt32(MaterialEditorVM.Material.NoOfBranches);

            BeamDesign design = new BeamDesign(AnalysisMapping.xbeams, fy, fystr, fcu, nBranches);

            /* --------------------- ADD RFT --------------------- */

            #region RFT Visualization
            GeometryEngineRFT.Remove("RFT");

            /*----------RFT Visualization---------*/
            RFTCanvas.CalcSpanVals();
            RFTCanvas.CalcComSpanVals(GeometryEditorVM.GeometryEditor.NumberOfSpans);
            RFTCanvas.CalcThickness();

            //Points  /*--------the Order is Important-----------*/
            RFTCanvas.ConstructTopStartPoints(20);
            RFTCanvas.ConstructTopEndPoints(20);

            RFTCanvas.ConstructBotStartPoints(20);
            RFTCanvas.ConstructBotEndPoints(20);



            //Lines
            RFTCanvas.ConstructTopLines(GeometryEngineRFT.GCanvas, GeometryEngineRFT);
            RFTCanvas.ConstructBotLines(GeometryEngineRFT.GCanvas, GeometryEngineRFT);
            RFTCanvas.ConstructColLines(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            //RFT Lines
            RFTCanvas.BotRFT(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);
            RFTCanvas.TopRFT(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            //Stirrups
            RFTCanvas.LeftSecStirrups(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);
            RFTCanvas.RightSecStirrups(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            #region Text Trial
            //TxtRFTCanvas.CalcSpanVals();
            //TxtRFTCanvas.CalcComSpanVals();
            ////TxtRFTCanvas.CreateBottomRFTTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);
            //TxtRFTCanvas.CreateTopRFTTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            #endregion

            GeometryEngineRFT.Render("RFT");
            #endregion

            /* --------------------- ADD TEXT --------------------- */
            #region Text RFTCanvas
            GeometryEngineRFT.Remove("Text");


            TxtRFTCanvas.CalcSpanVals();
            TxtRFTCanvas.CalcComSpanVals();

            //Bottom RFT
            TxtRFTCanvas.GetnRebarBotArr(AnalysisMapping.xbeams);
            TxtRFTCanvas.GetChosenDiameterArr(AnalysisMapping.xbeams);
            TxtRFTCanvas.CreateBottomRFTTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            //Top RFT
            TxtRFTCanvas.GetnRebarTopSupportArr(AnalysisMapping.xbeams);
            TxtRFTCanvas.GetChosenDiameterTopSupportArr(AnalysisMapping.xbeams);
            TxtRFTCanvas.CreateTopRFTTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            //Stirrups Left
            TxtRFTCanvas.GetSpacingLeftArr(AnalysisMapping.xbeams);
            TxtRFTCanvas.GetSpacingLeftArrIndexes(AnalysisMapping.xbeams);
            TxtRFTCanvas.StirrupLeftTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);


            //Stirrups Right
            TxtRFTCanvas.GetSpacingRightArr(AnalysisMapping.xbeams);
            TxtRFTCanvas.GetSpacingRightArrIndexes(AnalysisMapping.xbeams);
            TxtRFTCanvas.StirrupRightTxt(GeometryEngineRFT.GCanvas, GeometryEngineRFT, 20);

            GeometryEngineRFT.Render("Text");
            #endregion
        }