public void GetFabricAdjustmentSettings()
        {
            try
              {
              Utilities FabUtils= new Utilities();
              string sLSABearingTolerance=
              FabUtils.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\Desktop10.1\\ArcMap\\Cadastral", "LSABearingTolerance",false);

              string sLSAListingDetailLevel=
              FabUtils.ReadFromRegistry(RegistryHive.CurrentUser,
              "Software\\ESRI\\Desktop10.1\\ArcMap\\Cadastral", "LSAListingDetailLevel", false);

              dlgAdjustmentSettings pAdjustmentSettingsDialog = new dlgAdjustmentSettings();

              //Display the dialog
              DialogResult pDialogResult = pAdjustmentSettingsDialog.ShowDialog();

              if (pDialogResult != DialogResult.OK)
            return;

              }
              catch(Exception ex)
              {
            MessageBox.Show(ex.Message);
              }
        }
    public AdjustmentDockWindow(object hook)
    {
      InitializeComponent();
      this.Hook = hook;
      s_TxtToler = txtMainDistResReport;
      s_BtnRun = btnRun;
      s_BtnSettings=btnSettings;
      s_ChkUseLinePoints = chkUseLinePoints;
      s_LblDistUnits=lblUnits1;
      //read from registry
      Utilities FabUTILS = new Utilities();
      string sVersion = FabUTILS.GetDesktopVersionFromRegistry();
      string sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
     "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
     "LSADistanceToleranceReport", true);
      if (sVal.Trim() != "")
        this.txtMainDistResReport.Text = sVal;
      
      SetEnabled(false);

      s_LblDistUnits.Text="";
      FabUTILS=null;
    }
    internal static void SetEnabled(bool enabled)
    {
      s_enabled = enabled;
        Utilities FabUTILS = new Utilities();
        string sVersion = FabUTILS.GetDesktopVersionFromRegistry();
      // if the dockable window was never displayed, text box could be null
      if (s_TxtToler == null)
        return;
      s_TxtToler.Enabled= enabled;

      if(!enabled)
        s_TxtToler.Text="";
      else
      {
        string sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSADistanceToleranceReport", true);
        if (sVal.Trim() != "")
          s_TxtToler.Text= sVal;
      }

      if (s_BtnRun == null)
        return;
      s_BtnRun.Enabled = enabled;

      s_BtnSettings.Enabled = enabled;

      s_ChkUseLinePoints.Enabled=enabled;

      s_LblDistUnits.Visible=enabled;

      IActiveView pActView = ArcMap.Document.ActiveView;
      if (pActView!=null)
        s_LblDistUnits.Text = FabUTILS.UnitNameFromSpatialReference(pActView.FocusMap.SpatialReference);
      FabUTILS = null;

    }
    private void LoadValuesFromRegistry()
    {
      Utilities FabUTILS = new Utilities();
      try
      {
        string sVal ="";
        string sVersion = FabUTILS.GetDesktopVersionFromRegistry();
        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSADistanceToleranceReport", false);
        if (sVal.Trim() != "")
          m_dDistToleranceReport = Convert.ToDouble(sVal);
        

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSABearingToleranceReport", false);
        if (sVal.Trim() != "")
          m_dBearingToleranceReport = Convert.ToDouble(sVal); 

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSALinePointsOffsetToleranceReport", false);
        if (sVal.Trim() != "")
          m_dLinePtsOffsetToleranceReport = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSAClosePointsToleranceReport", false);
        if (sVal.Trim() != "")
          m_dClosePointsToleranceReport = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSANumberRepeatCountIteration", false);
        if (sVal.Trim() != "")
          m_iRepeatCount = Convert.ToInt32(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSAConvergenceValue", false);
        if (sVal.Trim() != "")
          m_dConvergenceValue = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
        "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
        "LSADivergenceValue", false);
        if (sVal.Trim() != "")
          m_dDivergenceValue = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAReportType", false);
        if (sVal.Trim() != "")
          m_iReportType = Convert.ToInt32(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSABrowseFilePath", false);
        if (sVal.Trim() != "")
          m_sBrowseFilePath = sVal;

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAChkBendLinesOn", false);
        if (sVal.Trim() != "")
          m_bBendLines = ((sVal.ToUpper().Trim()) == "TRUE");

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSABendLinesTolerance", false);
        if (sVal.Trim() != "")
          m_dBendLinesTolerance = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAChkIncludeDependentLines", false);
        if (sVal.Trim() != "")
          m_bIncludeDependentLines = ((sVal.ToUpper().Trim()) == "TRUE");

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAChkSnapLinePointsToLines", false);
        if (sVal.Trim() != "")
          m_bSnapLinePointsToLines = ((sVal.ToUpper().Trim()) == "TRUE");

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSASnapLinePtsToLinesTolerance", false);
        if (sVal.Trim() != "")
          m_dSnapLinePointTolerance = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAChkStraightenRoadFrontages", false);
        if (sVal.Trim() != "")
          m_bStraightenRoadFrontages = ((sVal.ToUpper().Trim()) == "TRUE");

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAStraightenRoadFrontagesOffset", false);
        if (sVal.Trim() != "")
          m_dStraightRoadOffsetTolerance = Convert.ToDouble(sVal);

        sVal = FabUTILS.ReadFromRegistry(RegistryHive.CurrentUser,
       "Software\\ESRI\\Desktop" + sVersion + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
       "LSAStraightenRoadFrontagesAngle", false);
        if (sVal.Trim() != "")
          m_dStraightRoadAngleTolerance = Convert.ToDouble(sVal);
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message, "Fabric Adjustment Settings");
      }
      finally
      {
        FabUTILS = null;
      }
    }
        protected override void OnStartup()
        {
            //AdjustmentDockWindow pDock=

              Utilities UTIL = new Utilities();
              s_extension = this;

              try
              {
            string sDesktopVers = UTIL.GetDesktopVersionFromRegistry();
            if (sDesktopVers.Trim() == "")
              sDesktopVers = "Desktop10.0";
            else
              sDesktopVers = "Desktop" + sDesktopVers;

            string sValues = UTIL.ReadFromRegistry(RegistryHive.CurrentUser,
            "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral\\AddIn.ParcelEditHelper",
              "Options", false);

            string[] Values = sValues.Split(',');
            string sVal = Values[0];
            string sFieldName = Values[1];
            bool bUseFieldRecord = false;

            if (sVal.Trim() != "")
              bUseFieldRecord = ((sVal.ToUpper().Trim()) == "1");

            s_extension.FieldName = sFieldName;
            s_extension.RecordToField = bUseFieldRecord;

              }
              catch
              {}

              m_editEvents = ArcMap.Editor as IEditEvents_Event;
              m_editEvents.OnStartEditing += new IEditEvents_OnStartEditingEventHandler(m_editEvents_OnStartEditing);
              m_editEvents.OnStopEditing += new IEditEvents_OnStopEditingEventHandler(m_editEvents_OnStopEditing);
        }