'
'  (C) Copyright 2007-2008 by Autodesk, Inc.  All rights reserved.
'
' Permission to use, copy, modify, and distribute this software in
' object code form for any purpose and without fee is hereby granted, 
' provided that the above copyright notice appears in all copies and 
' that both that copyright notice and the limited warranty and
' restricted rights notice below appear in all supporting 
' documentation.
'
' AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
' AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
' DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
' UNINTERRUPTED OR ERROR FREE.
'
' Use, duplication, or disclosure by the U.S. Government is subject to 
' restrictions set forth in FAR 52.227-19 (Commercial Computer
' Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
' (Rights in Technical Data and Computer Software), as applicable.
'

Imports SymBBAuto
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.ApplicationServices

Public Class frmSettings
    Dim taperStd As McadTaperStandard

    Private Sub frmSettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dimType As McadTaperDimensionType
        Dim ratioFormat As McadTaperRatioFormatType
        Dim separator As String = Nothing

        'get dimension type
        taperStd.GetDimensionType(dimType, ratioFormat, separator)
        'set dialog settings
        If (dimType = McadTaperDimensionType.sbRatio) Then
            btnRatio.Checked = True
        Else
            btnPercentage.Checked = True
        End If

        If (ratioFormat = McadTaperRatioFormatType.sbFraction) Then
            cbFormat.SelectedIndex = 0
        ElseIf ratioFormat = McadTaperRatioFormatType.sbNoFraction Then
            cbFormat.SelectedIndex = 1
        Else
            cbFormat.SelectedIndex = 2
        End If

        txtSeparator.Text = separator

    End Sub

    Private Sub m_settingsOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSettingsOk.Click
        'set dimension settings according to dialog changes
        Dim separator As String = txtSeparator.Text
        Dim format As Integer = cbFormat.SelectedIndex
        If (btnRatio.Checked) Then
            taperStd.SetDimensionType(McadTaperDimensionType.sbRatio, CType(format, McadTaperRatioFormatType), separator)
        Else
            taperStd.SetDimensionType(McadTaperDimensionType.sbPercentage, CType(format, McadTaperRatioFormatType), separator)
        End If
        Me.Close()
    End Sub

    Private Sub m_settingsCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSettingsCancel.Click
        Me.Close()
    End Sub

    Public Sub initialize(ByVal std As McadTaperStandard)
        'initialize dimension type
        taperStd = std
    End Sub

    Private Sub btnRatio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRatio.CheckedChanged
        'when Radio is checked, format combo box and separator text box will be enabled.
        If btnRatio.Checked Then
            btnPercentage.Checked = False
            cbFormat.Enabled = True
            txtSeparator.Enabled = True
        End If
    End Sub

    Private Sub btnPercentage_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPercentage.CheckedChanged
        'when Percentage is checked, format combo box and separator text box will be disabled.
        If btnPercentage.Checked Then
            btnRatio.Checked = False
            cbFormat.Enabled = False
            txtSeparator.Enabled = False
        End If
    End Sub
End Class