Esempio n. 1
0
        /// <summary>
        /// Generates the construction prints (plots) for the active job.  Generates a new string List for the prints parameter.
        /// </summary>
        /// <param name="prints">string that will contain the path/file name of the generated plots.</param>
        /// <returns>true if successful; else, false</returns>
        private bool GenerateConstructionPrints(out string prints)
        {
            bool retVal = false;

            prints = string.Empty;

            try
            {
                IGTApplication          app      = GTClassFactory.Create <IGTApplication>();
                CommonMapPrintingHelper mpHelper = new CommonMapPrintingHelper(app);
                string tmpFileName = string.Format("{0}-Close-WorkPrint", app.DataContext.ActiveJob);
                string tmpFilePath = System.IO.Path.GetTempPath();

                #region Code in this region to be removed entirely once Plotting Template(s) are available.

                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Until we get plot templates, then check whether the "Construction Print" named plot exists.
                // If it doesn't, then create one to serve as a temporary solution for a missing plot sheet.
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                bool needNamedPlot = true;

                foreach (IGTNamedPlot namedPlot in app.NamedPlots)
                {
                    if (namedPlot.Name == "Construction Print")
                    {
                        needNamedPlot = false;
                    }
                }

                // If the Construction Print named plot doesn't exist, then create one.
                if (needNamedPlot)
                {
                    IGTNamedPlot  np = app.NewNamedPlot("Construction Print");
                    IGTPlotWindow pw = app.NewPlotWindow(np);

                    IGTPoint frameTopLeft = GTClassFactory.Create <IGTPoint>();
                    frameTopLeft.X = 0.0;
                    frameTopLeft.Y = 0.0;

                    IGTPoint frameBottomRight = GTClassFactory.Create <IGTPoint>();
                    frameBottomRight.X = 20000.0;
                    frameBottomRight.Y = 30000.0;

                    IGTPaperRange paperRange = GTClassFactory.Create <IGTPaperRange>();
                    paperRange.TopLeft     = frameTopLeft;
                    paperRange.BottomRight = frameBottomRight;

                    IGTPlotMap map = pw.InsertMap(paperRange);
                }
                #endregion

                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // For now, defaulting the legend name to Distribution Design Legend for these prints; however,
                // this may be enhanced to determine which legend to use based on the WR type.
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (mpHelper.GenerateConstructionPlots("Distribution Design Legend", tmpFileName, tmpFilePath))
                {
                    prints = string.Format("{0}\\{1}", tmpFilePath, tmpFileName);
                    retVal = true;
                }
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                MessageBox.Show(exMsg, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(retVal);
        }