private void btn_EditTestParameter_Click(object sender, RoutedEventArgs e)
        {
            TestParameterViewModel pCurrentSelection = lst_TestParameters.SelectedItem as TestParameterViewModel;

            if (pCurrentSelection == null)
            {
                MessageBox.Show("Please select a TestParameter from the list for editing", "No selection", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                AddEditTestParamDialog pDialog = new AddEditTestParamDialog();
                pDialog.SetData(pCurrentSelection);

                bool?bResult = pDialog.ShowDialog();

                if (bResult.HasValue && bResult.Value)
                {
                    if (EditTestParameter != null)
                    {
                        EditTestParameter(this, new TestParameterArgs {
                            TestParams = pDialog.Data
                        });
                    }
                }
            }
        }
 private void lst_TestParameters_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         TestParameterViewModel pParam = e.AddedItems[0] as TestParameterViewModel;
         tpc_TestParam.SetData(pParam);
     }
 }
        public TestParameterViewModel GetData()
        {
            long nID = 0;

            Int64.TryParse(tbk_ParamID.Text, out nID);

            TestParameterViewModel pResult = new TestParameterViewModel(nID, txb_ParamName.Text, iud_PreTest.Value.GetValueOrDefault(), iud_Test.Value.GetValueOrDefault(), (double)dud_Highlimit.Value.GetValueOrDefault(), (double)dud_Lowlimit.Value.GetValueOrDefault());

            return(pResult);
        }
        public void SetData(TestParameterViewModel pParamModel)
        {
            if (pParamModel == null)
            {
                btn_Accept.Content = "Add";
                Title = "Add new Test Parameter";
            }
            else
            {
                btn_Accept.Content = "Save";
                Title = "Edit Test Parameter";
            }

            tpc_AddOrEditTestParam.SetData(pParamModel);
        }
        private void btn_Accept_Click(object sender, RoutedEventArgs e)
        {
            string sMessage = string.Empty;

            if (tpc_AddOrEditTestParam.ValidateInput(out sMessage))
            {
                TestParameterViewModel pData = tpc_AddOrEditTestParam.GetData();
                Data         = pData;
                DialogResult = true;
            }
            else
            {
                sti_Status.Content = sMessage;
                Data = null;
            }
        }
 public void SetData(TestParameterViewModel pTestModel)
 {
     if (pTestModel != null)
     {
         tbk_ParamID.Text    = pTestModel.ID.ToString();
         txb_ParamName.Text  = pTestModel.Name;
         iud_PreTest.Value   = Math.Max(0, pTestModel.PreTestMS);
         iud_Test.Value      = Math.Max(0, pTestModel.TestTimeMS);
         dud_Highlimit.Value = (decimal)pTestModel.HighLimitmV;
         dud_Lowlimit.Value  = (decimal)pTestModel.LowLimitmV;
     }
     else
     {
         tbk_ParamID.Text    = "---";
         txb_ParamName.Text  = string.Empty;
         iud_PreTest.Value   = 0;
         iud_Test.Value      = 0;
         dud_Highlimit.Value = 0;
         dud_Lowlimit.Value  = 0;
     }
 }
        public void SetData(FullSensorViewModel pSensorModel, List <TestParameterViewModel> pTestParams)
        {
            if (pSensorModel == null)
            {
                btn_Accept.Content = "Add";
                Title = "Add new Sensor";
                ssc_NewSensor.ReadOnly = false;
            }
            else
            {
                btn_Accept.Content = "Save";
                Title = "Edit Sensor";
                ssc_NewSensor.ReadOnly = true;
            }

            ssc_NewSensor.SetData(pSensorModel);

            TestParams = pTestParams;

            if (pSensorModel != null && pSensorModel.TestParam != null)
            {
                TestParameterViewModel pFittingParam = TestParams.FirstOrDefault(p => p.ID == pSensorModel.TestParam.ID);

                if (pFittingParam != null)
                {
                    ckb_AddTestParameter.IsChecked = true;
                    lst_TestParams.SelectedItem    = pFittingParam;
                }
                else
                {
                    tpc_TestParam.SetData(new TestParameterViewModel(pSensorModel.TestParam));
                    ckb_AddTestParameter.IsChecked = false;
                }
            }
            else
            {
                tpc_TestParam.SetData(null);
            }
        }
        private void __pView_AddNewTestParameters(object sender, EventArgs e)
        {
            AddEditTestParamDialog pDialog = new AddEditTestParamDialog();

            bool?bResult = pDialog.ShowDialog();

            if (bResult.HasValue && bResult.Value)
            {
                try {
                    TestParameterViewModel pData = pDialog.Data;

                    long nNewID = __pServiceProxy.AddTestParameter(pData);

                    if (nNewID > 0)
                    {
                        pData.ID = nNewID;
                        __pParamModels.Add(pData);
                    }
                }
                catch (Exception ex) {
                    //todo: Add logging
                }
            }
        }
        private void lst_TestParams_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            TestParameterViewModel pParam = lst_TestParams.SelectedItem as TestParameterViewModel;

            tpc_TestParam.SetData(pParam);
        }