📄 satinfoedit.cpp
字号:
// SatInfoEdit.cpp : implementation file
//
#include "stdafx.h"
#include "AliEditor.h"
#include "SatInfoEdit.h"
#include "MainFrm.h"
#include "AliEditorView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSatInfoEdit dialog
CSatInfoEdit::CSatInfoEdit(CWnd* pParent /*=NULL*/)
: CDialog(CSatInfoEdit::IDD, pParent)
{
//{{AFX_DATA_INIT(CSatInfoEdit)
m_sat_name = _T("");
m_sat_pos = 0;
m_sat_long = 0.0;
//}}AFX_DATA_INIT
m_op_type = AddNode;
m_pSatTp = NULL;
}
void CSatInfoEdit::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSatInfoEdit)
DDX_Control(pDX, IDC_SELECT_FLAG, m_sat_selected);
DDX_Control(pDX, IDC_TUNER_BAND, m_tuner_band);
DDX_Control(pDX, IDC_SAT_LONG, m_long_ctrl);
DDX_Control(pDX, IDC_TONE_BURST, m_tone_burst_ctrl);
DDX_Control(pDX, IDC_0_12V, m_0_12v_ctrl);
DDX_Control(pDX, IDC_22K_SWITCH, m_22k_ctrl);
DDX_Control(pDX, IDC_DISEQC, m_diseqc_ctrl);
DDX_Control(pDX, IDC_EAST_WEST_FLAG, m_east_west_flag);
DDX_Control(pDX, IDC_SECOND_FREQUENCY, m_second_freq_ctrl);
DDX_Control(pDX, IDC_FIRST_FREQUENCY, m_first_freq_ctrl);
DDX_Control(pDX, IDC_LNB_TYPE, m_lnb_type_ctrl);
DDX_Text(pDX, IDC_SAT_NAME_EDIT, m_sat_name);
DDV_MaxChars(pDX, m_sat_name, 17);
DDX_Text(pDX, IDC_SAT_POS, m_sat_pos);
DDX_Text(pDX, IDC_SAT_LONG, m_sat_long);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSatInfoEdit, CDialog)
//{{AFX_MSG_MAP(CSatInfoEdit)
ON_CBN_SELCHANGE(IDC_LNB_TYPE, OnSelchangeLnbType)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_RESET_SAT_INFO, OnResetSatInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSatInfoEdit message handlers
BOOL CSatInfoEdit::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
switch(m_op_type)
{
case AddNode://add
AddSatInfo();
break;
case EditNode://edit
EditSatInfo();
break;
default:
break;
}
UpdateData(FALSE);
CAliEditorView *pEditView = ((CMainFrame *)AfxGetMainWnd())->GetEditorView();
if(!pEditView) return FALSE;
CString str;
str.Format("%-5.1f", m_sat_long);
str = pEditView->m_strlines.FilterBackChar(str, ' ');
m_long_ctrl.SetWindowText(str);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
combox_t lnb_type_combox[] =
{
{0, "Standard" },
{16, "User" },
{32, "Universal" }
};
combox_t std_freq_combox[] =
{
{5150, "5150 MHz" },//0
{5750, "5750 MHz" },
{5950, "5950 MHz" },
{9750, "9750 MHz" },
{10000, "10000 MHz" },
{10050, "10050 MHz" },
{10450, "10450 MHz" },
{10600, "10600 MHz" },
{10700, "10700 MHz" },
{10750, "10750 MHz" },
{11250, "11250 MHz" },
{11300, "11300 MHz" },
};
combox_t user_freq_combox[] =
{
{5150, "5150 MHz" },//0
{5750, "5750 MHz" },//1
{5950, "5950 MHz" },
{9750, "9750 MHz" },
{10000, "10000 MHz" },
{10050, "10050 MHz" },
{10450, "10450 MHz" },
{10600, "10600 MHz" },
{10700, "10700 MHz" },
{10750, "10750 MHz" },
{11250, "11250 MHz" },
{11300, "11300 MHz" },
};
combox_t unival_freq_combox[] =
{
{5150, "5150 MHz" },
{5750, "5750 MHz" },
{5950, "5950 MHz" },
{9750, "9750 MHz" },//3
{10000, "10000 MHz" },
{10050, "10050 MHz" },
{10450, "10450 MHz" },
{10600, "10600 MHz" },//7
{10700, "10700 MHz" },
{10750, "10750 MHz" },
{11250, "11250 MHz" },
{11300, "11300 MHz" },
};
combox_t east_west_combox[] =
{
{0, "East" },
{1<<23, "West" },
};
combox_t disqec_combox[] =
{
{0x00000000, "Disable" },
{0x00010000, "1/2" },
{0x00010001, "2/2" },
{0x00020000, "1/4" },
{0x00020001, "2/4" },
{0x00020002, "3/4" },
{0x00020003, "4/4" },
{0x00030000, "1/8" },
{0x00030001, "2/8" },
{0x00030002, "3/8" },
{0x00030003, "4/8" },
{0x00030004, "5/8" },
{0x00030005, "6/8" },
{0x00030006, "7/8" },
{0x00030007, "8/8" },
{0x00040000, "1/16" },
{0x00040001, "2/16" },
{0x00040002, "3/16" },
{0x00040003, "4/16" },
{0x00040004, "5/16" },
{0x00040005, "6/16" },
{0x00040006, "7/16" },
{0x00040007, "8/16" },
{0x00040008, "9/16" },
{0x00040009, "10/16" },
{0x0004000a, "11/16" },
{0x0004000b, "12/16" },
{0x0004000c, "13/16" },
{0x0004000d, "14/16" },
{0x0004000e, "15/16" },
{0x0004000f, "16/16" },
};
combox_t _22k_combox[] =
{
{0, "OFF" },
{1, "ON" },
};
combox_t _0_12v_combox[] =
{
{0, "0 V" },
{1, "12 V" },
};
combox_t tone_burst_combox[] =
{
{0, "OFF" },
{1, "A" },
{2, "B" },
};
void CSatInfoEdit::InitCombox()
{
int i;
m_lnb_type_ctrl.ResetContent();
for(i = 0; i < sizeof(lnb_type_combox) / sizeof(combox_t); i++)
{
m_lnb_type_ctrl.AddString(lnb_type_combox[i].bufsz);
m_lnb_type_ctrl.SetItemData(i, lnb_type_combox[i].data);
}
m_first_freq_ctrl.ResetContent();
for(i = 0; i < sizeof(std_freq_combox) / sizeof(combox_t); i++)
{
m_first_freq_ctrl.AddString(std_freq_combox[i].bufsz);
m_first_freq_ctrl.SetItemData(i, std_freq_combox[i].data);
}
m_east_west_flag.ResetContent();
for(i = 0; i < sizeof(east_west_combox) / sizeof(combox_t); i++)
{
m_east_west_flag.AddString(east_west_combox[i].bufsz);
m_east_west_flag.SetItemData(i, east_west_combox[i].data);
}
m_diseqc_ctrl.ResetContent();
for(i = 0; i < sizeof(disqec_combox) / sizeof(combox_t); i++)
{
m_diseqc_ctrl.AddString(disqec_combox[i].bufsz);
m_diseqc_ctrl.SetItemData(i, disqec_combox[i].data);
}
m_22k_ctrl.ResetContent();
for(i = 0; i < sizeof(_22k_combox) / sizeof(combox_t); i++)
{
m_22k_ctrl.AddString(_22k_combox[i].bufsz);
m_22k_ctrl.SetItemData(i, _22k_combox[i].data);
}
m_0_12v_ctrl.ResetContent();
for(i = 0; i < sizeof(_0_12v_combox) / sizeof(combox_t); i++)
{
m_0_12v_ctrl.AddString(_0_12v_combox[i].bufsz);
m_0_12v_ctrl.SetItemData(i, _0_12v_combox[i].data);
}
m_tone_burst_ctrl.ResetContent();
for(i = 0; i < sizeof(tone_burst_combox) / sizeof(combox_t); i++)
{
m_tone_burst_ctrl.AddString(tone_burst_combox[i].bufsz);
m_tone_burst_ctrl.SetItemData(i, tone_burst_combox[i].data);
}
}
void CSatInfoEdit::AddSatInfo()
{
if(!m_pSatTp) return;
CAliEditorView *pEditView = ((CMainFrame *)AfxGetMainWnd())->GetEditorView();
if(!pEditView) return;
InitCombox();
m_sat_name = "New Satellite";
m_pSatTp->pNameStr = new CString(m_sat_name);
m_tuner_band.SetCurSel(0);
m_lnb_type_ctrl.SetCurSel(0);
m_first_freq_ctrl.SetCurSel(0);
m_second_freq_ctrl.EnableWindow(FALSE);
m_sat_pos = 0;
m_sat_long = 0;
m_east_west_flag.SetCurSel(0);
m_diseqc_ctrl.SetCurSel(0);
m_22k_ctrl.SetCurSel(0);
m_0_12v_ctrl.SetCurSel(0);
m_tone_burst_ctrl.SetCurSel(0);
}
int CSatInfoEdit::GetCurSel(combox_t *pcmt, int count, DWORD data)
{
int sel = -1;
for(int i = 0; i < count; i++)
{
if(pcmt[i].data == data)
{
sel = i;
break;
}
}
return sel;
}
int CSatInfoEdit::GetSatNodeIndex(const char *keysz)
{
if(!keysz) return -1;
CAliEditorView *pEditView = ((CMainFrame *)AfxGetMainWnd())->GetEditorView();
if(!pEditView) return -1;
NodeField **pSatNode = pEditView->m_strlines.GetNodeFieldInfo(SAT_NODE);
if(!pSatNode) return -1;
return ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetIndexOfNodeInfo(pSatNode, keysz);
}
void CSatInfoEdit::EditSatInfo()
{
int i, index;
char bufsz[64];
if(!m_pSatTp) return;
CAliEditorView *pEditView = ((CMainFrame *)AfxGetMainWnd())->GetEditorView();
if(!pEditView) return;
if(!m_pSatTp->pNameStr) return;
InitCombox();
m_sat_name = *m_pSatTp->pNameStr;//satellite name
BOOL bSatSelected = FALSE;
BOOL bTuner1Banded = FALSE;
BOOL bTuner2Banded = FALSE;
int nCombBandedSel = 0;
index = GetSatNodeIndex(SKEYZ_SELECTED_FLAG);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
bSatSelected = pEditView->GetDataValue(bufsz);
m_sat_selected.SetCheck(bSatSelected);
}
index = GetSatNodeIndex(PKEY2_TUNER1_VALID);
if( index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
bTuner1Banded = pEditView->GetDataValue(bufsz);
}
index = GetSatNodeIndex(PKEY2_TUNER2_VALID);
if( index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
bTuner2Banded = pEditView->GetDataValue(bufsz);
}
if( bTuner1Banded)
{
if( bTuner2Banded )
nCombBandedSel = 3;
else
nCombBandedSel = 1;
}
else
{
if( bTuner2Banded)
nCombBandedSel = 2;
else
nCombBandedSel = 0;
}
m_tuner_band.SetCurSel(nCombBandedSel);
int lnb_type = 0;
int lnb_sel = 0;
index = GetSatNodeIndex(SKEYZ_LNB_TYPE);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
if(bRet)
{
lnb_type = pEditView->GetDataValue(bufsz);
lnb_sel = GetCurSel(lnb_type_combox, sizeof(lnb_type_combox) / sizeof(combox_t), lnb_type);
if(lnb_sel != -1) m_lnb_type_ctrl.SetCurSel(lnb_sel);
}
}
if(lnb_sel == 0)
{
m_first_freq_ctrl.ResetContent();
for(i = 0; i < sizeof(std_freq_combox) / sizeof(combox_t); i++)
{
m_first_freq_ctrl.AddString(std_freq_combox[i].bufsz);
m_first_freq_ctrl.SetItemData(i, std_freq_combox[i].data);
}
int std_freq_sel = 0;
index = GetSatNodeIndex(SKEYZ_LNB_LOW);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
if(bRet)
{
int lnb_low = pEditView->GetDataValue(bufsz);
std_freq_sel = GetCurSel(std_freq_combox, sizeof(std_freq_combox) / sizeof(combox_t), lnb_low);
if(std_freq_sel != -1) m_first_freq_ctrl.SetCurSel(std_freq_sel);
}
}
m_second_freq_ctrl.ResetContent();
m_second_freq_ctrl.EnableWindow(FALSE);
}
else if(lnb_sel == 1)//user
{
m_first_freq_ctrl.ResetContent();
for(i = 0; i < sizeof(user_freq_combox) / sizeof(combox_t); i++)
{
m_first_freq_ctrl.AddString(user_freq_combox[i].bufsz);
m_first_freq_ctrl.SetItemData(i, user_freq_combox[i].data);
}
int user_freq_sel = 0;
index = GetSatNodeIndex(SKEYZ_LNB_LOW);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
if(bRet)
{
int lnb_low = pEditView->GetDataValue(bufsz);
user_freq_sel = GetCurSel(user_freq_combox, sizeof(user_freq_combox) / sizeof(combox_t), lnb_low);
if(user_freq_sel != -1) m_first_freq_ctrl.SetCurSel(user_freq_sel);
}
}
m_second_freq_ctrl.ResetContent();
for(i = 0; i < sizeof(user_freq_combox) / sizeof(combox_t); i++)
{
m_second_freq_ctrl.AddString(user_freq_combox[i].bufsz);
m_second_freq_ctrl.SetItemData(i, user_freq_combox[i].data);
}
index = GetSatNodeIndex(SKEYZ_LNB_HIGH);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
if(bRet)
{
int lnb_high = pEditView->GetDataValue(bufsz);
user_freq_sel = GetCurSel(user_freq_combox, sizeof(user_freq_combox) / sizeof(combox_t), lnb_high);
if(user_freq_sel != -1) m_second_freq_ctrl.SetCurSel(user_freq_sel);
}
}
}
else if(lnb_sel == 2)//unival
{
m_first_freq_ctrl.ResetContent();
for(i = 0; i < sizeof(unival_freq_combox) / sizeof(combox_t); i++)
{
m_first_freq_ctrl.AddString(unival_freq_combox[i].bufsz);
m_first_freq_ctrl.SetItemData(i, unival_freq_combox[i].data);
}
int unival_freq_sel = 0;
index = GetSatNodeIndex(SKEYZ_LNB_LOW);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
if(bRet)
{
int lnb_low = pEditView->GetDataValue(bufsz);
unival_freq_sel = GetCurSel(unival_freq_combox, sizeof(unival_freq_combox) / sizeof(combox_t), lnb_low);
if(unival_freq_sel != -1) m_first_freq_ctrl.SetCurSel(unival_freq_sel);
}
}
m_second_freq_ctrl.ResetContent();
for(i = 0; i < sizeof(unival_freq_combox) / sizeof(combox_t); i++)
{
m_second_freq_ctrl.AddString(unival_freq_combox[i].bufsz);
m_second_freq_ctrl.SetItemData(i, unival_freq_combox[i].data);
}
index = GetSatNodeIndex(SKEYZ_LNB_HIGH);
if(index != -1)
{
BOOL bRet = ((CMainFrame*)AfxGetMainWnd())->m_dbParser.GetNodeData(SAT_NODE, m_pSatTp->offset, index, bufsz);
if(bRet)
{
int lnb_high = pEditView->GetDataValue(bufsz);
unival_freq_sel = GetCurSel(unival_freq_combox, sizeof(unival_freq_combox) / sizeof(combox_t), lnb_high);
if(unival_freq_sel != -1) m_second_freq_ctrl.SetCurSel(unival_freq_sel);
}
}
}
index = GetSatNodeIndex(SKEYZ_POSITION);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -