Esempio n. 1
0
        /// <summary>
        /// Initialize the form size. Use the size of the form when last invoked in the current session.
        /// </summary>
        public void InitializeFormSize()
        {
            object   propertyValue;
            CommonDT commonDT   = new CommonDT();
            int      formHeight = this.Height;
            int      formWidth  = this.Width;

            if (commonDT.CheckIfPropertyExists(m_CommandName + ConstantsDT.PROP_DT_EMBEDDED_FORM_HEIGHT, out propertyValue))
            {
                formHeight = Convert.ToInt32(propertyValue);
                if (commonDT.CheckIfPropertyExists(m_CommandName + ConstantsDT.PROP_DT_EMBEDDED_FORM_WIDTH, out propertyValue))
                {
                    formWidth   = Convert.ToInt32(propertyValue);
                    this.Height = formHeight;
                    this.Width  = formWidth;
                }
            }
            else
            {
                // Show form at maximum size
                this.WindowState = FormWindowState.Maximized;
            }

            commonDT = null;
        }
Esempio n. 2
0
        public void Value__Set_to_Empty_String()
        {
            var commonDt = new CommonDT();

            commonDt.Value = string.Empty;
            Assert.AreEqual(string.Empty, commonDt.Value);
        }
Esempio n. 3
0
        private void cmdApply_Click(object sender, EventArgs e)
        {
            // Save settings
            m_OutputToMapWindow   = chkOutputMapWindow.Checked;
            m_ActiveMapWindowOnly = optActiveWindow.Checked;
            m_OverrideStyle       = chkOverrideStyle.Checked;
            m_LineWeight          = cboLineweight.Weight / M_WEIGHT_TO_PT;
            m_TraceColor          = GMTraceColorButton.Color;
            m_FillColor           = GMFillColorButton.Color;
            m_ProblemColor        = GMProblemColorButton.Color;

            m_OverrideMapWindowSettings = chkOverrideMapWindowSettings.Checked;

            if (optViewAtCurrentScale.Checked)
            {
                m_ZoomOption = 1;
            }
            else if (optCenterAtCurrentScale.Checked)
            {
                m_ZoomOption = 2;
            }
            else
            {
                m_ZoomOption = 3;
            }

            if (!(txtZoom.Text.Trim().Length == 0))
            {
                m_ZoomFactor = Convert.ToDouble(txtZoom.Text) / 100;
            }

            m_NotifyChanges = chkNotifyChanges.Checked;

            CommonDT commonDT = new CommonDT();

            // Add Properties so settings will persist in current G/Tech session
            commonDT.AddProperty(M_PROP_OUTPUT_TO_MAP_WINDOW, m_OutputToMapWindow);
            commonDT.AddProperty(M_PROP_ACTIVE_WINDOW_ONLY, m_ActiveMapWindowOnly);
            commonDT.AddProperty(M_PROP_OVERRIDE_STYLE, m_OverrideStyle);
            commonDT.AddProperty(M_PROP_LINE_WEIGHT, m_LineWeight);
            int[] rgb = { m_TraceColor.R, m_TraceColor.G, m_TraceColor.B };
            commonDT.AddProperty(M_PROP_TRACE_COLOR, rgb);
            rgb[0] = m_FillColor.R;
            rgb[1] = m_FillColor.G;
            rgb[2] = m_FillColor.B;
            commonDT.AddProperty(M_PROP_FILL_COLOR, rgb);
            rgb[0] = m_ProblemColor.R;
            rgb[1] = m_ProblemColor.G;
            rgb[2] = m_ProblemColor.B;
            commonDT.AddProperty(M_PROP_PROBLEM_COLOR, rgb);

            commonDT.AddProperty(M_PROP_OVERRIDE_MAP_SETTINGS, m_OverrideMapWindowSettings);
            commonDT.AddProperty(M_PROP_ZOOM_OPTION, m_ZoomOption);
            commonDT.AddProperty(M_PROP_ZOOM_FACTOR, m_ZoomFactor);
            commonDT.AddProperty(M_PROP_NOTIFY_CHANGES, m_NotifyChanges);

            commonDT = null;

            cmdApply.Enabled = false;
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the values to pre-populate on the report.
        /// </summary>
        /// <param name="guyingScenarioNumber">The Guying Scenario Number to use for the report</param>
        /// <returns>Boolean indicating status</returns>
        private bool GetReportData(string guyingScenarioNumber)
        {
            bool returnValue = false;

            try
            {
                string   wrNumber = m_Application.DataContext.ActiveJob;
                CommonDT commonDT = new CommonDT();

                m_EmbeddedDT.WrNumber   = wrNumber;
                m_EmbeddedDT.ReportName = ConstantsDT.COMMAND_NAME_GUYING + " Scenario " + wrNumber + "-" + guyingScenarioNumber + ".pdf";

                commonDT = null;

                List <KeyValuePair <string, string> > reportValues = new List <KeyValuePair <string, string> >();

                // Add report values
                reportValues.Add(new KeyValuePair <string, string>(ConstantsDT.REPORT_PARAMETER_GUY_WR, wrNumber));
                reportValues.Add(new KeyValuePair <string, string>(ConstantsDT.REPORT_PARAMETER_GUY_SCENARIO, guyingScenarioNumber));
                reportValues.Add(new KeyValuePair <string, string>(ConstantsDT.REPORT_PARAMETER_GUY_DATE, DateTime.Now.ToShortDateString()));

                m_EmbeddedDT.ReportValues = reportValues;

                returnValue = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_RETRIEVING_REPORT_DATA + ": " + ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            return(returnValue);
        }
Esempio n. 5
0
        public void Value__Set_to_Null()
        {
            var commonDt = new CommonDT();

            commonDt.Value = null;
            Assert.AreEqual(null, commonDt.Value);
        }
Esempio n. 6
0
        public void SetYearMonthDayPrecision_With_Invalid_Month()
        {
            var commonDt = new CommonDT();

            Assert.Throws <DataTypeException>(
                () => commonDt.SetYearMonthDayPrecision(2001, 13, 3));
        }
Esempio n. 7
0
        public void YearPrecision__Set_to_Invalid_Year()
        {
            var commonDt = new CommonDT();

            Assert.Throws <DataTypeException>(
                () => commonDt.YearPrecision = 20010);
        }
Esempio n. 8
0
        public void Value__Set_to_Empty_Quoted_String()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "\"\"";
            Assert.AreEqual("\"\"", commonDt.Value);
        }
Esempio n. 9
0
        public void setYearMonthDayPrecision_With_Invalid_Day()
        {
            var commonDt = new CommonDT();

            Assert.Throws <DataTypeException>(
                () => commonDt.setYearMonthDayPrecision(2001, 2, 29));
        }
Esempio n. 10
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

                // Get the job information. Used for validating command enabling.
                if (!CommonDT.GetJobInformation())
                {
                    m_CustomCommandHelper.Complete();
                    return;
                }

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();

                // Check if selected feature is a Transformer.
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                if (!(oGTDCKeys[0].FNO == ConstantsDT.FNO_OH_XFMR || oGTDCKeys[0].FNO == ConstantsDT.FNO_UG_XFMR))
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SC_INVALID_FEATURE_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    m_CustomCommandHelper.Complete();
                    return;
                }

                frmStreetLightVoltageDrop.m_CustomCommandHelper = CustomCommandHelper;
                frmStreetLightVoltageDrop.m_TransactionManager  = m_TransactionManager;
                frmStreetLightVoltageDrop.StartPosition         = FormStartPosition.CenterScreen;
                frmStreetLightVoltageDrop.Show(m_Application.ApplicationWindow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }
Esempio n. 11
0
        public void Value__Set_to_Invalid_Month()
        {
            var commonDt = new CommonDT();

            Assert.Throws <DataTypeException>(
                () => commonDt.Value = "20010a");
        }
Esempio n. 12
0
        public void Value__Set_to_Empty_String()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "";
            Assert.Equal("", commonDt.Value);
        }
Esempio n. 13
0
        public void Value__Set_to_Null()
        {
            var commonDt = new CommonDT();

            commonDt.Value = null;
            Assert.Null(commonDt.Value);
        }
Esempio n. 14
0
        public void Value__Set_to_Valid_Year()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "2001";
            Assert.AreEqual("2001", commonDt.Value);
            Assert.AreEqual(2001, commonDt.Year);
        }
Esempio n. 15
0
        public void Value__Set_to_Valid_Year_and_Month()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "200102";
            Assert.AreEqual("200102", commonDt.Value);
            Assert.AreEqual(2001, commonDt.Year);
            Assert.AreEqual(2, commonDt.Month);
        }
Esempio n. 16
0
        public void setYearMonthPrecision_With_Valid_Year_and_Month()
        {
            var commonDt = new CommonDT();

            commonDt.setYearMonthPrecision(2001, 02);
            Assert.AreEqual("200102", commonDt.Value);
            Assert.AreEqual(2001, commonDt.Year);
            Assert.AreEqual(2, commonDt.Month);
        }
Esempio n. 17
0
        public void Value__Set_to_Valid_Year_and_Month_and_Day()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "20010203";
            Assert.Equal("20010203", commonDt.Value);
            Assert.Equal(2001, commonDt.Year);
            Assert.Equal(2, commonDt.Month);
            Assert.Equal(3, commonDt.Day);
        }
Esempio n. 18
0
        public void setYearMonthDayPrecision_With_Valid_Year_and_Month_and_Day()
        {
            var commonDt = new CommonDT();

            commonDt.setYearMonthDayPrecision(2001, 2, 3);
            Assert.AreEqual("20010203", commonDt.Value);
            Assert.AreEqual(2001, commonDt.Year);
            Assert.AreEqual(2, commonDt.Month);
            Assert.AreEqual(3, commonDt.Day);
        }
Esempio n. 19
0
        public void YearPrecision__Set_to_Valid_Year()
        {
            var commonDt = new CommonDT();

            commonDt.YearPrecision = 2001;
            Assert.AreEqual("2001", commonDt.Value);
            Assert.AreEqual(2001, commonDt.Year);
            Assert.AreEqual(0, commonDt.Month);
            Assert.AreEqual(0, commonDt.Day);
        }
Esempio n. 20
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

                // Get the job information. Used for validating command enabling.
                if (!CommonDT.GetJobInformation())
                {
                    m_CustomCommandHelper.Complete();
                    return;
                }

                if (m_Application.SelectedObjects.FeatureCount > 1)
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_MULTIPLE_FEATURES_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    m_CustomCommandHelper.Complete();
                    return;
                }
                else if (m_Application.SelectedObjects.FeatureCount == 1)
                {
                    // Only one feature in select set. Check if selected feature is a Duct Bank.
                    IGTDDCKeyObjects oGTDCKeys    = m_Application.SelectedObjects.GetObjects();
                    IGTDDCKeyObject  objKeyObject = GTClassFactory.Create <IGTDDCKeyObject>();
                    if (oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_SECCOND && oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_COND)
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_FEATURE_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        m_CustomCommandHelper.Complete();
                        return;
                    }
                }

                frmCablePullTension.m_CustomCommandHelper = CustomCommandHelper;
                frmCablePullTension.StartPosition         = FormStartPosition.CenterScreen;
                frmCablePullTension.Show(m_Application.ApplicationWindow);

                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, "IGTCustomCommandModeless_Activate:" + Environment.NewLine + "Error (" + ex.Source + ") - " + ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }
Esempio n. 21
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

                // Get the job information. Used for validating command enabling.
                if (!CommonDT.GetJobInformation())
                {
                    m_CustomCommandHelper.Complete();
                    return;
                }

                // Get the metadata for the command
                if (!m_frmSecondaryCalculator.GetMetadata())
                {
                    m_CustomCommandHelper.Complete();
                    return;
                }

                // Check if selected feature is a Transformer.
                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                if (oGTDCKeys[0].FNO != ConstantsDT.FNO_OH_XFMR && oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_XFMR)
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SC_INVALID_FEATURE_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    m_CustomCommandHelper.Complete();
                    return;
                }

                // If the selected Transformer is a 3 Phase then check for valid voltage.
                short xfmrFNO     = oGTDCKeys[0].FNO;
                int   xfmrFID     = oGTDCKeys[0].FID;
                short xfmrUnitCNO = 0;

                if (xfmrFNO == ConstantsDT.FNO_OH_XFMR)
                {
                    xfmrUnitCNO = ConstantsDT.CNO_OH_XFMR_UNIT;
                }
                else
                {
                    xfmrUnitCNO = ConstantsDT.CNO_UG_XFMR_UNIT;
                }

                IGTKeyObject  oGTKey        = m_Application.DataContext.OpenFeature(xfmrFNO, xfmrFID);
                IGTComponents oGTComponents = oGTKey.Components;
                Recordset     componentRS   = oGTComponents.GetComponent(xfmrUnitCNO).Recordset;
                Recordset     xfmrConfigChecker;
                if (xfmrFNO == ConstantsDT.FNO_OH_XFMR)
                {
                    xfmrConfigChecker = oGTComponents.GetComponent(ConstantsDT.CNO_OH_XFMR_BANK).Recordset;
                }
                else
                {
                    xfmrConfigChecker = oGTComponents.GetComponent(ConstantsDT.CNO_UG_XFMR_UNIT).Recordset;
                }
                short  phaseCount       = 0;
                string secondaryVoltage = string.Empty;

                if (componentRS.RecordCount > 0)
                {
                    secondaryVoltage = componentRS.Fields[ConstantsDT.FIELD_XFMRUNIT_VOLTAGE_SEC].Value.ToString();
                    if (!Convert.IsDBNull(componentRS.Fields[ConstantsDT.FIELD_XFMRUNIT_PHASE_QUANTITY].Value))
                    {
                        phaseCount = Convert.ToInt16(componentRS.Fields[ConstantsDT.FIELD_XFMRUNIT_PHASE_QUANTITY].Value);
                    }
                    if ((!Convert.IsDBNull(xfmrConfigChecker.Fields["CONFIG_PRI_C"].Value) && xfmrConfigChecker.Fields["CONFIG_PRI_C"].Value.ToString().Contains("OPEN")))
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SC_INVALID_CONFIGURATION, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        m_CustomCommandHelper.Complete();
                        return;
                    }
                }

                if (phaseCount == 3 && !m_frmSecondaryCalculator.m_ValidThreePhaseVoltages.Contains(secondaryVoltage))
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SC_INVALID_3PH_VOLTAGE, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    m_CustomCommandHelper.Complete();
                    return;
                }

                // Check if Transformer is a Tie Transformer
                string sql = "select g3e_fid from " + ConstantsDT.TABLE_XFMR_OH_BANK + " where ((" + ConstantsDT.FIELD_XFMR_TIE_XFMR_ID + " = ?) or " +
                             "(g3e_fid = ? and " + ConstantsDT.FIELD_XFMR_TIE_XFMR_ID + " is not null)) and " + ConstantsDT.FIELD_XFMR_TIE_XFMR_ID + " <> g3e_fid " +
                             "union " +
                             "select g3e_fid from " + ConstantsDT.TABLE_XFMR_UG_UNIT + " where ((" + ConstantsDT.FIELD_XFMR_TIE_XFMR_ID + " = ?) or " +
                             "(g3e_fid = ? and " + ConstantsDT.FIELD_XFMR_TIE_XFMR_ID + " is not null)) and " + ConstantsDT.FIELD_XFMR_TIE_XFMR_ID + " <> g3e_fid";

                int recordsAffected = 0;

                ADODB.Recordset rs = m_Application.DataContext.Execute(sql, out recordsAffected, (int)CommandTypeEnum.adCmdText, xfmrFID, xfmrFID, xfmrFID, xfmrFID);

                if (rs.RecordCount > 0)
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SC_TIE_XFMR_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    m_CustomCommandHelper.Complete();
                    return;
                }

                m_frmSecondaryCalculator.m_CustomCommandHelper = CustomCommandHelper;
                m_frmSecondaryCalculator.StartPosition         = FormStartPosition.CenterScreen;
                m_frmSecondaryCalculator.Show(m_Application.ApplicationWindow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }
Esempio n. 22
0
        private bool InitializeForm()
        {
            object   propertyValue;
            bool     returnValue = false;
            CommonDT commonDT    = new CommonDT();

            try
            {
                if (commonDT.CheckIfPropertyExists(M_PROP_OUTPUT_TO_MAP_WINDOW, out propertyValue))
                {
                    chkOutputMapWindow.Checked = Convert.ToBoolean(propertyValue);
                    m_OutputToMapWindow        = chkOutputMapWindow.Checked;
                }
                else
                {
                    m_OutputToMapWindow = chkOutputMapWindow.Checked;
                    commonDT.AddProperty(M_PROP_OUTPUT_TO_MAP_WINDOW, m_OutputToMapWindow);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_ACTIVE_WINDOW_ONLY, out propertyValue))
                {
                    optActiveWindow.Checked = Convert.ToBoolean(propertyValue);
                    optAllWindows.Checked   = !Convert.ToBoolean(propertyValue);
                    m_ActiveMapWindowOnly   = optActiveWindow.Checked;
                }
                else
                {
                    m_ActiveMapWindowOnly = optActiveWindow.Checked;
                    commonDT.AddProperty(M_PROP_ACTIVE_WINDOW_ONLY, m_ActiveMapWindowOnly);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_OVERRIDE_STYLE, out propertyValue))
                {
                    chkOverrideStyle.Checked = Convert.ToBoolean(propertyValue);
                    m_OverrideStyle          = chkOverrideStyle.Checked;
                }
                else
                {
                    m_OverrideStyle = chkOverrideStyle.Checked;
                    commonDT.AddProperty(M_PROP_OVERRIDE_STYLE, m_OverrideStyle);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_LINE_WEIGHT, out propertyValue))
                {
                    cboLineweight.Weight = Convert.ToDouble(propertyValue) * M_WEIGHT_TO_PT;
                    m_LineWeight         = cboLineweight.Weight / M_WEIGHT_TO_PT;
                }
                else
                {
                    cboLineweight.Weight = M_WEIGHT_TO_PT;
                    m_LineWeight         = cboLineweight.Weight / M_WEIGHT_TO_PT;
                    commonDT.AddProperty(M_PROP_LINE_WEIGHT, m_LineWeight);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_TRACE_COLOR, out propertyValue))
                {
                    int [] rgb = (int[])propertyValue;
                    GMTraceColorButton.Color = Color.FromArgb(rgb[0], rgb[1], rgb[2]);
                    m_TraceColor             = GMTraceColorButton.Color;
                }
                else
                {
                    m_TraceColor = GMTraceColorButton.Color;
                    int[] rgb = { m_TraceColor.R, m_TraceColor.G, m_TraceColor.B };
                    commonDT.AddProperty(M_PROP_TRACE_COLOR, rgb);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_FILL_COLOR, out propertyValue))
                {
                    int[] rgb = (int[])propertyValue;
                    GMFillColorButton.Color = Color.FromArgb(rgb[0], rgb[1], rgb[2]);
                    m_FillColor             = GMFillColorButton.Color;
                }
                else
                {
                    m_FillColor = GMFillColorButton.Color;
                    int[] rgb = { m_FillColor.R, m_FillColor.G, m_FillColor.B };
                    commonDT.AddProperty(M_PROP_FILL_COLOR, rgb);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_PROBLEM_COLOR, out propertyValue))
                {
                    int[] rgb = (int[])propertyValue;
                    GMProblemColorButton.Color = Color.FromArgb(rgb[0], rgb[1], rgb[2]);
                    m_ProblemColor             = GMProblemColorButton.Color;
                }
                else
                {
                    m_ProblemColor = GMProblemColorButton.Color;
                    int[] rgb = { m_ProblemColor.R, m_ProblemColor.G, m_ProblemColor.B };
                    commonDT.AddProperty(M_PROP_PROBLEM_COLOR, rgb);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_OVERRIDE_MAP_SETTINGS, out propertyValue))
                {
                    chkOverrideMapWindowSettings.Checked = Convert.ToBoolean(propertyValue);
                    m_OverrideMapWindowSettings          = chkOverrideMapWindowSettings.Checked;
                }
                else
                {
                    m_OverrideMapWindowSettings = chkOverrideMapWindowSettings.Checked;
                    commonDT.AddProperty(M_PROP_OVERRIDE_MAP_SETTINGS, m_OverrideMapWindowSettings);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_ZOOM_OPTION, out propertyValue))
                {
                    if (Convert.ToInt16(propertyValue) == 1)
                    {
                        optViewAtCurrentScale.Checked = true;
                        m_ZoomOption = 1;
                    }
                    else if (Convert.ToInt16(propertyValue) == 2)
                    {
                        optCenterAtCurrentScale.Checked = true;
                        m_ZoomOption = 2;
                    }
                    else
                    {
                        optFitAndZoomOut.Checked = true;
                        m_ZoomOption             = 3;
                    }
                }
                else
                {
                    if (optViewAtCurrentScale.Checked)
                    {
                        m_ZoomOption = 1;
                    }
                    else if (optCenterAtCurrentScale.Checked)
                    {
                        m_ZoomOption = 2;
                    }
                    else
                    {
                        m_ZoomOption = 3;
                    }

                    commonDT.AddProperty(M_PROP_ZOOM_OPTION, m_ZoomOption);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_ZOOM_FACTOR, out propertyValue))
                {
                    txtZoom.Text = Convert.ToString(Convert.ToDouble(propertyValue) * 100);
                    m_ZoomFactor = Convert.ToDouble(txtZoom.Text);
                }
                else
                {
                    m_ZoomFactor = Convert.ToDouble(txtZoom.Text) / 100;
                    commonDT.AddProperty(M_PROP_ZOOM_FACTOR, m_ZoomFactor);
                }

                if (commonDT.CheckIfPropertyExists(M_PROP_NOTIFY_CHANGES, out propertyValue))
                {
                    chkNotifyChanges.Checked = Convert.ToBoolean(propertyValue);
                    m_NotifyChanges          = chkNotifyChanges.Checked;
                }
                else
                {
                    m_NotifyChanges = chkNotifyChanges.Checked;
                    commonDT.AddProperty(M_PROP_NOTIFY_CHANGES, m_NotifyChanges);
                }

                cmdApply.Enabled = false;
            }
            catch
            {
                // Ignore error
            }
            finally
            {
                commonDT = null;
            }

            return(returnValue);
        }
Esempio n. 23
0
        //public string node1Structure

        public bool ProcessSelectSet()
        {
            bool bReturnValue = false;

            try
            {
                m_aSortedPoints = new CablePullPoint[1];
                m_aSegments     = new CablePullSegment[1];

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                relationshipService.DataContext = m_Application.DataContext;
                int index = 0;
                m_SelectedFID = oGTDCKeys[index].FID;
                m_SelectedFNO = oGTDCKeys[index].FNO;
                relationshipService.ActiveFeature = m_Application.DataContext.OpenFeature(m_SelectedFNO, m_SelectedFID);

                if (relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value != null)
                {
                    m_featureState = relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value.ToString();
                }

                if (relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.RecordCount > 0)
                {
                    relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.MoveFirst();
                    m_CU = relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.Fields["CU_C"].Value.ToString();
                }

                if (CommonDT.AllowCUEdit(relationshipService.ActiveFeature))
                {
                    m_AllowCUEdit = true;
                }
                else
                {
                    m_AllowCUEdit = false;
                }

                int ductBankFID = 0;

                try
                {
                    IGTKeyObjects relatedDuctKOs = relationshipService.GetRelatedFeatures(6);

                    if (relatedDuctKOs.Count > 0)
                    {
                        relationshipService.ActiveFeature = relatedDuctKOs[0];
                        IGTKeyObjects relatedFormationKOs = relationshipService.GetRelatedFeatures(6);
                        if (relatedFormationKOs.Count > 0)
                        {
                            relationshipService.ActiveFeature = relatedFormationKOs[0];
                            IGTKeyObjects relatedDuctBankKOs = relationshipService.GetRelatedFeatures(3);
                            if (relatedDuctBankKOs.Count > 0)
                            {
                                ductBankFID = relatedDuctBankKOs[0].FID;
                                relationshipService.ActiveFeature = relatedDuctBankKOs[0];
                                IGTKeyObjects structure1 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                IGTKeyObjects structure2 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                                if (structure1.Count > 0)
                                {
                                    IGTKeyObject thing = structure1[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node1Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                                if (structure2.Count > 0)
                                {
                                    IGTKeyObject thing = structure2[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node2Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_NO_RELATED_DUCTBANK, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
                catch
                {
                }


                // Get the primary geographic and primary detail componentviews from metadata
                // Get the selected object matching the primary geographic or primary detail componentviews in that order
                Recordset metadataRS           = m_Application.DataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "g3e_fno = " + ConstantsDT.FNO_DUCTBANK);
                short     primaryGeographicCNO = 0;
                short     primaryDetailCNO     = 0;
                if (metadataRS.RecordCount > 0)
                {
                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value))
                    {
                        primaryGeographicCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value);
                    }

                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value))
                    {
                        primaryDetailCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value);
                    }
                }

                IGTDDCKeyObjects oDuctBankGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oDuctBankGTDCKeys = m_Application.DataContext.GetDDCKeyObjects(ConstantsDT.FNO_DUCTBANK, ductBankFID, GTComponentGeometryConstants.gtddcgAllPrimary);

                metadataRS = m_Application.DataContext.MetadataRecordset("G3E_COMPONENTVIEWS_OPTABLE");
                string filter = "(g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryGeographicCNO + ") or (g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryDetailCNO + ")";
                metadataRS.Filter = filter;
                if (metadataRS.RecordCount > 0)
                {
                    metadataRS.Sort = "g3e_detail";

                    while (!metadataRS.EOF)
                    {
                        if (metadataRS.Fields["G3E_VIEW"].Value.ToString() == oDuctBankGTDCKeys[index].ComponentViewName)
                        {
                            //m_SelectedFID = oGTDCKeys[index].FID;
                            //m_SelectedFNO = oGTDCKeys[index].FNO;
                            break;
                        }
                        metadataRS.MoveNext();
                        index++;
                    }


                    IGTGeometry         oGeometry     = oDuctBankGTDCKeys[index].Geometry;
                    IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();

                    if (oGeometry.Type == GTGeometryTypeConstants.gtgtPolylineGeometry || oGeometry.Type == GTGeometryTypeConstants.gtgtLineGeometry)
                    {
                        // Geometry is okay to use as it is.
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry;
                        bReturnValue  = true;
                    }
                    else if (oGeometry.Type == GTGeometryTypeConstants.gtgtCompositePolylineGeometry)
                    {
                        // Any arcs must be stroked to line segments
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry.Stroke();
                        bReturnValue  = true;
                    }
                    else
                    {
                        // Invalid geometry type.
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_GEOMETRY, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        bReturnValue = false;
                    }

                    if (bReturnValue)
                    {
                        // Store each point of the line in the feature's geometry
                        StoreLinePoints(oPolyLineGeom, m_SelectedFNO, m_SelectedFID);

                        //Compute the included angles for each set of three points in the sorted array
                        ComputeIncludedAngles();

                        //Build the arrays for the segments and bends that will comprise the pull
                        if (!BuildSegmentsAndBends())
                        {
                            bReturnValue = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_COMPONENT_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    bReturnValue = false;
                }
            }
            catch (Exception e)
            {
                m_aSegments     = new CablePullSegment[1];
                m_aBends        = new double[1];
                m_aSortedPoints = new CablePullPoint[1];
            }

            return(bReturnValue);
        }
Esempio n. 24
0
        public void Constructor_Sets_Value()
        {
            var commonDt = new CommonDT("20010203");

            Assert.AreEqual("20010203", commonDt.Value);
        }
Esempio n. 25
0
        public void YearPrecision__Set_to_Invalid_Year()
        {
            var commonDt = new CommonDT();

            commonDt.YearPrecision = 20010;
        }
Esempio n. 26
0
        public void setYearMonthPrecision_With_Invalid_Month()
        {
            var commonDt = new CommonDT();

            commonDt.setYearMonthPrecision(2001, 13);
        }
Esempio n. 27
0
        public void setYearMonthDayPrecision_With_Invalid_Day()
        {
            var commonDt = new CommonDT();

            commonDt.setYearMonthDayPrecision(2001, 2, 29);
        }
Esempio n. 28
0
        public void Value__Set_to_Invalid_Year()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "200a";
        }
Esempio n. 29
0
        public void Value__Set_to_Invalid_Month()
        {
            var commonDt = new CommonDT();

            commonDt.Value = "20010a";
        }
Esempio n. 30
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

                // Get the job information. Used for validating command enabling.
                if (!CommonDT.GetJobInformation())
                {
                    m_CustomCommandHelper.Complete();
                    return;
                }

                short fno = 0;
                int   fid = 0;

                m_EmbeddedDT.cmdSaveReport.Enabled = false;

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                if (oGTDCKeys.Count > 0)
                {
                    // Check if selected feature is a Conductor.
                    if (oGTDCKeys[0].FNO == ConstantsDT.FNO_OH_COND || oGTDCKeys[0].FNO == ConstantsDT.FNO_UG_COND ||
                        oGTDCKeys[0].FNO == ConstantsDT.FNO_OH_SECCOND || oGTDCKeys[0].FNO == ConstantsDT.FNO_UG_SECCOND)
                    {
                        fid = oGTDCKeys[0].FID;
                        fno = oGTDCKeys[0].FNO;
                        m_EmbeddedDT.cmdSaveReport.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SAG_INVALID_FEATURE_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        m_CustomCommandHelper.Complete();
                        return;
                    }
                }

                // Get the report data
                if (!GetReportData(fno, fid))
                {
                    CustomCommandHelper.Complete();
                    return;
                }

                // Get the form Close events so we can call the Complete method for the command
                // when the form closes.
                m_EmbeddedDT.cmdClose.Click += cmdClose_Click;
                m_EmbeddedDT.FormClosing    += cmdClose_Click;

                m_EmbeddedDT.Application = m_Application;
                m_EmbeddedDT.Text        = ConstantsDT.COMMAND_NAME_SAG_CLEARANCE;
                m_EmbeddedDT.CommandName = ConstantsDT.COMMAND_NAME_SAG_CLEARANCE;
                m_EmbeddedDT.SelectedFID = fid;
                m_EmbeddedDT.SelectedFNO = fno;

                m_EmbeddedDT.InitializeFormSize();

                m_EmbeddedDT.StartPosition = FormStartPosition.CenterScreen;
                m_EmbeddedDT.Show(m_Application.ApplicationWindow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }