void CFormatTabDlg::DoDataExchange(CDataExchange* pDX) { CCSDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFormatTabDlg) DDX_Control(pDX, IDC_BUTTON_CLEARALL, m_buttonClearAll); DDX_Control(pDX, IDC_BUTTON_SET, m_buttonSet); DDX_Control(pDX, IDC_BUTTON_CLEAR, m_buttonClear); DDX_Control(pDX, IDC_COMBO1, m_comboBox); //}}AFX_DATA_MAP if (!pDX->m_bSaveAndValidate) UpdateListBox(); }
void CHveditDlg::OnLoad() { MXML_NODE *tree, *root, *channel, *demand, *node; char str[256], error[256]; int i, j; /* find out if we have write access */ m_pDemandKey->UpdateKey(); if (!(m_pDemandKey->GetAccessMode() & MODE_WRITE)) { MessageBox("Change of demand values currently not allowed"); return; } CFileDialog dlg(TRUE, "hv", "*.hv", OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, "High Voltage Files (*.hv)|*.hv|All Files (*.*)|*.*||"); if (dlg.DoModal() == IDOK) { m_LastFileName = dlg.GetPathName(); //m_pDemandKey->Load(m_LastFileName); tree = mxml_parse_file(m_LastFileName, str, sizeof(str)); if (tree == NULL) { sprintf(error, "Error in XML file: %s", str); MessageBox(error); } else { root = mxml_find_node(tree, "HV"); if (root == NULL) { MessageBox("Cannot find element \"HV\" in XML file"); } else { for (i = 0; i < mxml_get_number_of_children(root); i++) { channel = mxml_subnode(root, i); node = mxml_find_node(channel, "name"); if (!node) continue; // skip units /* search for channel name */ for (j = 0; j < m_nChannels; j++) if (strcmp(mxml_get_value(node), m_Name + j * m_nNameLength) == NULL) { demand = mxml_find_node(channel, "demand"); if (demand) { m_Demand[j] = (float) atof(mxml_get_value(demand)); m_pDemandKey->SetDataIndex(m_Demand + j, j, TID_FLOAT); } } } } mxml_free_tree(tree); } UpdateListBox(-1); } }
void CHveditDlg::OnRestore() { int n, i; // Get current selection n = m_ctlChannels.GetSelItems(m_nChannels, m_Selection); // Retrieve voltages from Restore buffer for (i = 0; i < n; i++) m_Demand[ChannelIndex(m_Selection[i])] = m_Restore[ChannelIndex(m_Selection[i])]; UpdateODB(n == 1 ? ChannelIndex(m_Selection[0]) : -1); UpdateListBox(n == 1 ? m_Selection[0] : -1); }
void CFormatTabDlg::OnClickedClear() { int nTab; int nSel = m_comboBox.GetCurSel(); if (nSel == CB_ERR) { CDataExchange dx(this, TRUE); DDX_Twips(&dx, IDC_COMBO1, nTab); DDV_MinMaxTwips(&dx, nTab, 0, 31680); if (nTab != DDXM_BLANK) { if (RemoveTabFromArray(nTab)) UpdateListBox(); } } else { ASSERT(nSel < m_nCount); RemoveTabFromArrayByIndex(nSel); UpdateListBox(); } UpdateButtons(); SetEditFocus(); }
void CHveditDlg::OnAllOff() { int i; if (MessageBox("Are you sure to set all channels in all groups to zero?", "HV Edit", MB_YESNO) == IDYES) { for (i = 0; i < m_nChannels; i++) { if (m_Demand[i] > 0) m_Restore[i] = m_Demand[i]; m_Demand[i] = 0.f; } UpdateODB(-1); UpdateListBox(-1); } }
void CHveditDlg::OnZero() { int n, i, j; // Get current selection n = m_ctlChannels.GetSelItems(m_nChannels, m_Selection); // Save voltages in Restore buffer, then zero them for (i = 0; i < n; i++) { j = ChannelIndex(m_Selection[i]); if (m_Demand[j] > 0) m_Restore[j] = m_Demand[j]; m_Demand[j] = 0.f; } UpdateODB(n == 1 ? ChannelIndex(m_Selection[0]) : -1); UpdateListBox(n == 1 ? m_Selection[0] : -1); }
void CHveditDlg::OnSet() { int n, i; // Update m_Voltage if (!GetInput()) return; // Get current selection n = m_ctlChannels.GetSelItems(m_nChannels, m_Selection); // Set voltage to selected channels for (i = 0; i < n; i++) m_Demand[ChannelIndex(m_Selection[i])] = m_Voltage; UpdateODB(n == 1 ? ChannelIndex(m_Selection[0]) : -1); UpdateListBox(n == 1 ? m_Selection[0] : -1); }
void CDlgPlayfairAnalysis::OnUpdate() // sobald ein neues Zeichen im Passwort eingegeben wurde { int sels, sele, i, k; char c; CString res; UpdateData(TRUE); //erstmal wieder die Daten aus dem Formular holen m_pwfeld.GetSel(sels, sele); res.Empty(); m_password.MakeUpper(); //abprüfen, ob ein ungültiges Zeichen in der Paßwortzeile eingegeben wurde for(k=i=0;i<m_password.GetLength();i++) { c = m_password[i]; if(!m_Alg->myisalpha2(c)) // TG, Umlaute oder französische Zeichen zu etwas ähnlichem ersetzen. c = m_Alg->getAlphabet()->replaceInvalidLetter(true, c); if(m_Alg->myisalpha2(c)) { // valid character res += c; k++; } else { // invalid character MessageBeep(MB_OK); if(k<sels) sels--; if(k<sele) sele--; } } m_password = res; m_Alg->SetPass(m_password.GetBuffer(36)); // GetBuffer(25) auf GetBuffer(36) ??? for (i=0;i<m_Alg->getSize();i++) { for (k=0;k<m_Alg->getSize();k++) { m_mat[i][k]=m_Alg->getCharOfMatrix(i,k); } } UpdateData(FALSE); UpdateListBox(); m_pwfeld.SetSel(sels,sele); }
void CHveditDlg::Increment(const float incr) { int n, i; // Get current selection n = m_ctlChannels.GetSelItems(m_nChannels, m_Selection); // Set voltage to selected channels for (i = 0; i < n; i++) m_Demand[ChannelIndex(m_Selection[i])] = max(0, m_Demand[ChannelIndex(m_Selection[i])] + incr); if (n > 0) m_Voltage = m_Demand[ChannelIndex(m_Selection[0])]; SetInput(); UpdateODB(n == 1 ? ChannelIndex(m_Selection[0]) : -1); UpdateListBox(n == 1 ? m_Selection[0] : -1); }
BOOL CFormatTabDlg::Set() { int nTab; CDataExchange dx(this, TRUE); DDX_Twips(&dx, IDC_COMBO1, nTab); DDV_MinMaxTwips(&dx, nTab, 0, 31680); if (nTab != DDXM_BLANK) { if (m_nCount == MAX_TAB_STOPS) { AfxMessageBox(IDS_NOMORETABS); m_comboBox.Clear(); return FALSE; } if (AddTabToArray(nTab)) UpdateListBox(); return TRUE; } return FALSE; }
void UpdateSpellList(uint32 typeMask, SPELL_SET_MODES setMode) { if (!m_pOwner) return; iSortArray<uint16> spells; if (setMode == SSM_FAVORITES) { for (uint32 xx=0; xx<m_pOwner->SpellBook().FavoritesCount(); ++xx) { if (typeMask & (1<<m_pOwner->SpellBook().FavoriteByIdx(xx)->Type())) { spells.Insert(m_pOwner->SpellBook().Favorite(xx), SPELL_DESCRIPTORS[m_pOwner->SpellBook().Favorite(xx)].level); } } } else { uint32 spmask = SPELL_SET_MASKS[setMode]; for (uint32 xx=0; xx<m_pOwner->SpellBook().SpellsCount(); ++xx) { if ( (typeMask & (1<<m_pOwner->SpellBook().SpellByIdx(xx)->Type())) && (spmask & (1<<m_pOwner->SpellBook().SpellByIdx(xx)->School()))) { spells.Insert(m_pOwner->SpellBook().Spell(xx), SPELL_DESCRIPTORS[m_pOwner->SpellBook().Spell(xx)].level); } } } m_spells.RemoveAll(); for (uint32 xx=0; xx<spells.Size(); ++xx) m_spells.Add(spells.Value(xx)); UpdateListBox(); }
void CDlgPlayfairAnalysis::OnAnalyse() // Schalter "erzeuge Matrix", war "Häufigkeitsanalyse" { int i, k; char buf[MAXSHOWLETTER+2], line[256]; int maxchars=MAXSHOWLETTER; BOOL flagSuccess; UpdateData(TRUE); CString m_plaintext; m_txtfeld.GetWindowText(m_plaintext); i=0; while ((i<maxchars)&&(i<m_plaintext.GetLength())) { buf[i] = m_plaintext[i]; i++; } buf[i]='\0'; if (!(flagSuccess = m_Alg->CreateMatrixStandalone(buf, i))) { // Analyse Peer Wichmann // keine gültige Matrix gefunden LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_NOMATRIX,pc_str,STR_LAENGE_STRING_TABLE); sprintf(line,pc_str); AfxMessageBox (line); } m_password = m_Alg->CreatePassfromMatrix(); // Matrix neu schreiben for (i=0;i<m_Alg->getSize();i++) { for (k=0;k<m_Alg->getSize();k++) { m_mat[i][k]=m_Alg->getCharOfMatrix(i,k); } } UpdateData(FALSE); UpdateListBox(); if ( m_ActualiseExpectedPlaintext && flagSuccess ) { char obuf[MAXSHOWLETTER+2]; int i,j,k; i=j=k=0; while(i<MAXSHOWLETTER&&j<m_Alg->inbuflen) { char c=m_Alg->inbuf[j++]; if(!m_Alg->myisalpha2(c) && !isinvalidoccured) c = m_Alg->getAlphabet()->replaceInvalidLetter(true, c); if(m_Alg->myisalpha2(c)) { obuf[i] = m_Alg->outbuf[k]; k++; } else { obuf[i] = '.'; } i++; } obuf[i] = '\0'; CString tmp = obuf; int ps, pe; m_txtfeld.GetSel(ps, pe); m_txtfeld.SetSel(0,-1); m_txtfeld.ReplaceSel(tmp, TRUE); m_txtfeld.SetSel(ps,ps); } m_txtfeld.SetFocus(); }
void CDlgPlayfairAnalysis::OnManAnalyse() { char buf[MAXSHOWLETTER+2], line[256]; int i,j, n, k; int maxchars=MAXSHOWLETTER; playfair_digrammlist* diglist; UpdateData(); i=0; j=0; CString m_plaintext; m_txtfeld.GetWindowText(m_plaintext); while ((i<maxchars)&&(j<m_plaintext.GetLength())) { char nChar = m_plaintext[j]; if (m_Alg->myisalpha2(nChar)) buf[i] = nChar; else { if ((nChar=='j')||(nChar=='J')||(('0'<=nChar)&&(nChar<='9'))) { Message(IDS_STRING_PLAYFAIR_WARNMSG003, MB_ICONEXCLAMATION); } buf[i] = NULLELEMENT; } i++; j++; } buf[i]='\0'; digbuf[0]='\0'; m_Alg->initDigrams(); diglist = new playfair_digrammlist(m_Alg->getAlphabet(), m_Alg->getDigrams(), buf, m_Alg->inbuf, min (maxchars, m_Alg->inbuflen)); // in der Initialisierung läuft die eigentliche Arbeit ab: // für jedes Pärchen des Klartextes, wird das passende Digramm gesucht, das durch das Chiffrat festgelegt ist. n = 2*diglist->getLen(); m_txtfeld.SetLimitText (n); // limitiere Ausgabe diglist->getPlainString(digbuf, n); // lege Ausgabe des Klartextes fest (2.Zeile) try { if (true || (i%2==0)) { m_Alg->DeleteLetterGraph(); m_Alg->AnalyseDigramme(diglist); //untersuchen der Digramme und erstellen des Lettergraphen } } catch (playfair_error e) { switch (e.getCode()) { case 1: LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_ERRMSG001,pc_str,STR_LAENGE_STRING_TABLE); break; case 101: case 102: case 103: case 104: case 105: case 106: case 107: LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_ERRMSG100,pc_str,STR_LAENGE_STRING_TABLE); break; case 113: case 114: LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_ERRMSG110,pc_str,STR_LAENGE_STRING_TABLE); break; case 201: case 202: case 203: case 204: LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_ERRMSG200,pc_str,STR_LAENGE_STRING_TABLE); break; default: LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_ERRMSGALLG,pc_str,STR_LAENGE_STRING_TABLE); break; } sprintf(line,pc_str,e.getPosition()+1,(e.getLetter())?e.getLetter()->getValue():m_Alg->getAlphabet()->getNullElement()->getValue()); AfxMessageBox (line); } if ((false) && (i%2==0) && (i>0)) { //automatische Generierung der Matrix aktiv if (!m_Alg->CreateMatrixStandalone (buf, i)) { // Analyse Peer Wichmann // keine gültige Matrix gefunden LoadString(AfxGetInstanceHandle(),IDS_STRING_PLAYFAIR_NOMATRIX,pc_str,STR_LAENGE_STRING_TABLE); sprintf(line,pc_str); AfxMessageBox (line); } m_password = m_Alg->CreatePassfromMatrix(); } delete (diglist); // Matrix neu schreiben for (i=0;i<m_Alg->getSize();i++) { for (k=0;k<m_Alg->getSize();k++) { m_mat[i][k]=m_Alg->getCharOfMatrix(i,k); } } UpdateData(FALSE); UpdateListBox(); }
/***************************************************************************** * BOOL RunPip() *****************************************************************************/ BOOL RunPip( void ) { static BOOL ShowCursor; switch ( g_PipAction ) { case PIP_START: ShowCursor = FALSE; CreateListBox(); if ( g_AutoMode ) g_PipAction = PIP_MOVE; else g_PipAction = PIP_SELECT; return TRUE; case PIP_SELECT: if(btnS3 == HW_BUTTON_PRESS) { while(btnS3 == HW_BUTTON_PRESS); UpdateListBox( TRUE, FALSE ); } if(btnS1 == HW_BUTTON_PRESS) { while(btnS1 == HW_BUTTON_PRESS); UpdateListBox( FALSE, TRUE ); } if(btnS2 == HW_BUTTON_PRESS) { while(btnS2 == HW_BUTTON_PRESS); g_PipAction = ListBoxSelected(); } return TRUE; case PIP_SHOW_CURSOR: ShowCursor = ! ShowCursor; if ( ShowCursor ) GFX_DRIVER_ShowLayer( GFX_CURSOR_LAYER ); else GFX_DRIVER_HideLayer( GFX_CURSOR_LAYER ); g_PipAction = PIP_SELECT; return TRUE; case PIP_MOVE_CURSOR: if ( ! MoveCursor() ) g_PipAction = PIP_SELECT; return TRUE; case PIP_MOVE: if ( ! MovePip() ) { if ( g_AutoMode ) g_PipAction = PIP_EXIT; else g_PipAction = PIP_SELECT; } return TRUE; default: case PIP_EXIT: DeleteListBox(); g_PipAction = PIP_START; return FALSE; } //return TRUE; }
void CHveditDlg::OnSelchangeListGroup() { m_iGroup = m_ctlGroups.GetCurSel(); UpdateListBox(-1); }
BOOL CHveditDlg::OnInitDialog() { INT tabs[5]; CString str; int x, y; CDialog::OnInitDialog(); // Check if connected to MIDAS if (!m_pExperiment->IsConnected() || !OpenKeys()) { EndDialog(1); return TRUE; } // Set caption text if (m_HostName.IsEmpty()) str = m_EquipmentName + " - [local]"; else { str = m_EquipmentName + " - \\\\" + m_HostName; if (!m_ExperimentName.IsEmpty()) { str += "\\"; str += m_ExperimentName; } } SetWindowText(str); // Set tabs in listbox tabs[0] = 37; tabs[1] = 71; tabs[2] = 105; m_ctlChannels.SetTabStops(3, tabs); if (!UpdateChannelDefinition()) return FALSE; UpdateListBox(-1); // Set initial state of radio buttons m_ctlInput.SetWindowText("0"); m_ctlChannels.SetSel(0, TRUE); // Move window to previous position x = AfxGetApp()->GetProfileInt("Window Position", "Left", 100); y = AfxGetApp()->GetProfileInt("Window Position", "Top", 100); /* SetWindowPos(NULL, x, y, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); */ // Add "About..." menu item to system menu. CMenu *pSysMenu = GetSystemMenu(FALSE); CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // Start timer for checking FE status if (!SetTimer(1176, 10000, NULL)) MessageBox("Cannot set timer"); return TRUE; // return TRUE unless you set the focus to a control }