Exemplo n.º 1
0
// Main dialog procedure
UINT EmMainDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param)
{
	NMHDR *n;
	RPC *r = (RPC *)param;
	UINT i;
	char *name;
	// Validate arguments
	if (hWnd == NULL)
	{
		return 0;
	}

	switch (msg)
	{
	case WM_INITDIALOG:
		EmMainInit(hWnd, r);
		break;

	case WM_COMMAND:
		switch (wParam)
		{
		case IDOK:
			// Edit
			i = LvGetSelected(hWnd, L_LIST);
			if (i != INFINITE)
			{
				wchar_t *tmp;
				tmp = LvGetStr(hWnd, L_LIST, i, 0);
				if (tmp != NULL)
				{
					name = CopyUniToStr(tmp);
					EmAdd(hWnd, r, name);
					Free(tmp);
					Free(name);
				}
			}
			break;

		case B_PASSWORD:
			// Admin password
			Dialog(hWnd, D_EM_PASSWORD, EmPasswordDlg, r);
			break;

		case B_LICENSE:
			// Admin password
			Dialog(hWnd, D_EM_LICENSE, EmLicenseDlg, r);
			break;

		case B_ADD:
			// Add
			EmAdd(hWnd, r, NULL);
			EmMainRefresh(hWnd, r);
			break;

		case B_DELETE:
			// Delete
			i = LvGetSelected(hWnd, L_LIST);
			if (i != INFINITE)
			{
				wchar_t *tmp;
				tmp = LvGetStr(hWnd, L_LIST, i, 0);
				if (tmp != NULL)
				{
					RPC_DELETE_DEVICE t;
					wchar_t msg[MAX_SIZE];
					name = CopyUniToStr(tmp);
					UniFormat(msg, sizeof(msg), _UU("EM_DELETE_CONFIRM"), name);
					if (MsgBox(hWnd, MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2, msg) == IDYES)
					{
						Zero(&t, sizeof(t));
						StrCpy(t.DeviceName, sizeof(t.DeviceName), name);
						if (CALL(hWnd, EcDelDevice(r, &t)))
						{
							EmMainRefresh(hWnd, r);
						}
					}
					Free(tmp);
					Free(name);
				}
			}
			break;

		case IDCANCEL:
			Close(hWnd);
			break;
		}
		break;

	case WM_TIMER:
		switch (wParam)
		{
		case 1:
			KillTimer(hWnd, 1);
			EmMainRefresh(hWnd, r);
			SetTimer(hWnd, 1, 1000, NULL);
			break;
		}
		break;

	case WM_NOTIFY:
		n = (NMHDR *)lParam;
		switch (n->code)
		{
		case NM_DBLCLK:
			switch (n->idFrom)
			{
			case L_LIST:
				if (IsEnable(hWnd, IDOK))
				{
					Command(hWnd, IDOK);
				}
				break;
			}
			break;
		case LVN_ITEMCHANGED:
			switch (n->idFrom)
			{
			case L_LIST:
				EmMainUpdate(hWnd, r);
				break;
			}
			break;
		}
		break;

	case WM_CLOSE:
		EndDialog(hWnd, 0);
		break;
	}

	return 0;
}
Prog::Prog(const Theme & theme, ALLEGRO_DISPLAY *display) :
   d(Dialog(theme, display, 20, 40)),
   memory_label(Label("Memory")),
   texture_label(Label("Texture")),
   source_label(Label("Source", false)),
   destination_label(Label("Destination", false)),
   source_image(List(0)),
   destination_image(List(1)),
   draw_mode(List(0))
{
   d.add(memory_label, 9, 0, 10, 2);
   d.add(texture_label, 0, 0, 10, 2);
   d.add(source_label, 1, 15, 6, 2);
   d.add(destination_label, 7, 15, 6, 2);

   List *images[] = {&source_image, &destination_image, &draw_mode};
   for (int i = 0; i < 3; i++) {
      List & image = *images[i];
      if (i < 2) {
         image.append_item("Mysha");
         image.append_item("Allegro");
         image.append_item("Mysha (tinted)");
         image.append_item("Allegro (tinted)");
         image.append_item("Color");
      }
      else {
         image.append_item("original");
         image.append_item("scaled");
         image.append_item("rotated");
      }
      d.add(image, 1 + i * 6, 17, 4, 6);
   }

   for (int i = 0; i < 4; i++) {
      operation_label[i] = Label(i % 2 == 0 ? "Color" : "Alpha", false);
      d.add(operation_label[i], 1 + i * 3, 24, 3, 2);
      List &l = operations[i];
      l.append_item("ONE");
      l.append_item("ZERO");
      l.append_item("ALPHA");
      l.append_item("INVERSE");
      d.add(l, 1 + i * 3, 25, 3, 6);
   }

   for (int i = 4; i < 6; i++) {
      operation_label[i] = Label(i == 4 ? "Blend op" : "Alpha op", false);
      d.add(operation_label[i], 1 + i * 3, 24, 3, 2);
      List &l = operations[i];
      l.append_item("ADD");
      l.append_item("SRC_MINUS_DEST");
      l.append_item("DEST_MINUS_SRC");
      d.add(l, 1 + i * 3, 25, 3, 6);
   }

   rgba_label[0] = Label("RGBA");
   rgba_label[1] = Label("RGBA");
   d.add(rgba_label[0], 1, 32, 4, 1);
   d.add(rgba_label[1], 7, 32, 4, 1);

   for (int i = 0; i < 2; i++) {
      r[i] = VSlider(255, 255);
      g[i] = VSlider(255, 255);
      b[i] = VSlider(255, 255);
      a[i] = VSlider(255, 255);
      d.add(r[i], 1 + i * 6, 33, 1, 6);
      d.add(g[i], 2 + i * 6, 33, 1, 6);
      d.add(b[i], 3 + i * 6, 33, 1, 6);
      d.add(a[i], 4 + i * 6, 33, 1, 6);
   }
}
Exemplo n.º 3
0
// Connecting dialog
UINT NmConnectDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param)
{
	NM_CONNECT *t = (NM_CONNECT *)param;
	RPC *rpc;
	NM_LOGIN login;
	UINT err;
	// Validate arguments
	if (hWnd == NULL)
	{
		return 0;
	}

	switch (msg)
	{
	case WM_INITDIALOG:
		FormatText(hWnd, S_TITLE, t->Hostname);
		SetTimer(hWnd, 1, 50, NULL);
		break;

	case WM_TIMER:
		switch (wParam)
		{
		case 1:
			KillTimer(hWnd, 1);

			while (true)
			{
				bool flag = false;
RETRY_PASSWORD:
				// Password input dialog
				Zero(&login, sizeof(login));
				login.Hostname = t->Hostname;
				login.Port = t->Port;
				Sha0(login.hashed_password, "", 0);

				if (flag)
				{
					if (Dialog(hWnd, D_NM_LOGIN, NmLogin, &login) == false)
					{
						EndDialog(hWnd, false);
						break;
					}
				}

RETRY_CONNECT:
				Refresh(DlgItem(hWnd, S_TITLE));
				Refresh(hWnd);
				// Connection
				rpc = NatAdminConnect(nm->Cedar, t->Hostname, t->Port, login.hashed_password, &err);
				if (rpc != NULL)
				{
					t->Rpc = rpc;
					EndDialog(hWnd, true);
					break;
				}

				// Error
				if (err == ERR_ACCESS_DENIED || err == ERR_AUTH_FAILED)
				{
					if (flag)
					{
						if (MsgBox(hWnd, MB_ICONEXCLAMATION | MB_RETRYCANCEL,
							_E(err)) == IDCANCEL)
						{
							EndDialog(hWnd, false);
							break;
						}
					}
					flag = true;
					goto RETRY_PASSWORD;
				}
				else
				{
					if (MsgBox(hWnd, MB_ICONEXCLAMATION | MB_RETRYCANCEL,
						_E(err)) == IDCANCEL)
					{
						EndDialog(hWnd, false);
						break;
					}
					goto RETRY_CONNECT;
				}
			}
			break;
		}
		break;
	}

	return 0;
}
Exemplo n.º 4
0
void CProfile::Show()
{
	CProfileShowDialog Dialog(this);
	Dialog.DoModal();
}
Exemplo n.º 5
0
void CCardView::OnCardServer()
{
	// Some configurations do not support online greetings ("card server").
	if (!GetConfiguration()->SupportsCardServer())
	{
		return;
	}

	// Get our document.
	CPmwDoc* pDoc = GetDocument();

	if(GetGlobalContentManager()->CheckAccountStatus())
	{
		CString strID = GetGlobalContentManager()->GetAccountID();
		if(strID != "")
		{
			// Put up the card server dialog.

			CCardServerDialog Dialog(this);

			Dialog.m_ctTime = CTime::GetCurrentTime();
			if (Dialog.DoModal() == IDOK)
			{
				// Put up the disclaimer dialog.
				CCardServerDisclaimer Disclaimer(this);

				if (Disclaimer.DoModal() == IDOK)
				{
					// Create the directory we want to use as our FTP source.
					CString csDir = pDoc->GetPathManager()->ExpandPath("[[U]]\\NETCARD");

					if (!Util::MakeDirectory(csDir))
					{
						// Not able to make the directory.
						// LPCSTR pFormat = "Can't create the directory\n%s";
						LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateDirectory);
						CString csMessage;
						csMessage.Format(pFormat, (LPCSTR)csDir);
						AfxMessageBox(csMessage);
						return;
					}

					// Construct the text file.
					CString csTextFile;
					Util::ConstructPath(csTextFile, csDir, "INFO.INI");

					CFile cfText;
					CString csVersion;
					CString csPPN;
					TRY
					{
						CFileException e;
						//if (!cfText.Open(csTextFile,
						//					  CFile::modeCreate
						//							| CFile::modeWrite,
						//					  &e))
						//{
						//	AfxThrowFileException(e.m_cause, e.m_lOsError);
						//}

						//do the time stuff 
						
						//time zone difference from PST
						struct _timeb tstruct;
						_ftime( &tstruct );
						int timecorrection = PacificTimeCorrection(tstruct.timezone);
						
						//get date of delivery - include current time
						struct tm when;   
						CString strDate;
						CTime testtime = CTime::GetCurrentTime();
						when = *testtime.GetLocalTm(NULL);

						SYSTEMTIME sysTime = *Dialog.GetTime();
						
						if((when.tm_mday != sysTime.wDay) || (when.tm_mon != (sysTime.wMonth - 1)))
						{
							when.tm_mday = sysTime.wDay;
							when.tm_mon = sysTime.wMonth - 1;

							ConvertToPST(&when, timecorrection);

							CString str_ampm = "AM";
						  
							if( when.tm_hour > 12 )        /* Set up extension. */
									 str_ampm = "PM";
							if( when.tm_hour > 12 )        /* Convert from 24-hour */
									 when.tm_hour -= 12;    /*   to 12-hour clock.  */
							if( when.tm_hour == 0 )        /*Set hour to 12 if midnight. */
									 when.tm_hour = 12;
							
							strDate.Format("%d/%d/%d %d:%d:%d%s", 
													(int)((int)when.tm_mon + 1),when.tm_mday,when.tm_year,when.tm_hour,when.tm_min,when.tm_sec,str_ampm);   
						}
						else
						{
							strDate = "";
						}
						
						CString strPSTCorrection;
						strPSTCorrection.Format("%d", timecorrection);   

						// Construct the version string.
						CString csEol = "\r\n";
						csVersion = GetConfiguration()->ReplacementText('T');
						csVersion += ' ';
						csVersion += GET_PMWAPP()->GetVersion();

						csPPN = GET_PMWAPP()->GetParentPartNumber();

						WritePrivateProfileString( "UserData", "UserId",
													GetGlobalContentManager()->GetAccountID(), csTextFile);
						
						WritePrivateProfileString( "UserData", "Description",
													csVersion, csTextFile);

						WritePrivateProfileString( "UserData", "SenderEmail",
													Dialog.m_csFrom, csTextFile);

						WritePrivateProfileString( "UserData", "RecipientEmail",
													Dialog.m_csTo, csTextFile);

						WritePrivateProfileString( "UserData", "sku",
													csPPN, csTextFile);


						WritePrivateProfileString( "CardData", "Title",
													Dialog.m_csTitle, csTextFile);

						WritePrivateProfileString( "CardData", "Date",
													strDate, csTextFile);

						WritePrivateProfileString( "CardData", "Offset",
													strPSTCorrection, csTextFile);


		#if 0 
						// Write version
						cfText.Write(csVersion, csVersion.GetLength());
						cfText.Write(csEol, csEol.GetLength());
						// Write "from" email address
						cfText.Write(Dialog.m_csFrom, Dialog.m_csFrom.GetLength());
						cfText.Write(csEol, csEol.GetLength());
						// Write "to" email address
						cfText.Write(Dialog.m_csTo, Dialog.m_csTo.GetLength());
						cfText.Write(csEol, csEol.GetLength());
						// Write Parent Part Number
						cfText.Write(csPPN, csPPN.GetLength());
						cfText.Write(csEol, csEol.GetLength());
		#endif

						//cfText.Close();
					}
					CATCH_ALL(e)
					{
						// Could not write the text file. Complain.
						// LPCSTR pFormat = "Can't create the file\n%s";
						LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateFile);
						CString csMessage;
						csMessage.Format(pFormat, (LPCSTR)csTextFile);
						AfxMessageBox(csMessage);
						return;
					}
					END_CATCH_ALL

					// Figure out how big we want the panels to be.
					CPoint cpFrontDims;
					CPoint cpInsideDims;

					PBOX World;
					pDoc->get_panel_world(&World, CARD_PANEL_Front);

					// Fit the front panel into a 425x425 square.
					PPNT FrontDims;
					FrontDims.x = World.x1 - World.x0;
					FrontDims.y = World.y1 - World.y0;

					double dScale = 425.0/(double)FrontDims.x;
					double dYScale = 425.0/(double)FrontDims.y;
					if (dScale > dYScale) dScale = dYScale;

					cpFrontDims.x = (int)((double)FrontDims.x*dScale);
					cpFrontDims.y = (int)((double)FrontDims.y*dScale);

					pDoc->get_panel_world(&World, CARD_PANEL_Inside);

					cpInsideDims.x = (int)((double)(World.x1-World.x0)*dScale);
					cpInsideDims.y = (int)((double)(World.y1-World.y0)*dScale);

					TRACE("Front: %d, %d; Inside: %d, %d\n",
							cpFrontDims.x, cpFrontDims.y,
							cpInsideDims.x, cpInsideDims.y);

					BOOL fSuccess = FALSE;

					CCardServerProgressDialog ProgressDialog(AfxGetMainWnd());

					CString csName;
					Util::ConstructPath(csName, csDir, "front.gif");
					ProgressDialog.SetStatus(IDS_BuildingFront);
					if (DumpPanel(CARD_PANEL_Front, csName, cpFrontDims))
					{
						ProgressDialog.SetStatus(IDS_BuildingInside);
						Util::ConstructPath(csName, csDir, "inside.gif");
						if(DumpPanel(CARD_PANEL_Inside, csName, cpInsideDims))
   						fSuccess = TRUE;
					}

					if (!fSuccess)
					{
						// "Can't create card pictures."
						AfxMessageBox(GET_PMWAPP()->GetResourceStringPointer(IDS_ErrWriteCardPictures));
						return;
					}

					// Now, invoke the DLL to write the data.
					CCardServerDLL DLL;
		#ifdef WIN32
					CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP32.DLL");
		#else
					CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP16.DLL");
		#endif
					// Startup the dialog.
					if (DLL.Startup(csDLLName))
					{
						if(CheckForValidConnection()){
							
							// Put up our progress dialog.
							// Send the files.
							int nResult = DLL.SendFiles(csDir, ProgressDialog);

							// Take down the progress dialog now.
							ProgressDialog.DestroyWindow();

							// Shut down the DLL.
							DLL.Shutdown();

							CPmwDialog Dialog(nResult == 0 ? IDD_CARD_SERVER_SUCCESS : IDD_CARD_SERVER_FAILURE);
							Dialog.DoModal();
						}
					}
					else
					{
						// Not able to load the DLL. Complain.
						// LPCSTR pFormat = "The file\n%s\nis missing or bad.";
						LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrMissingDLL);
						CString csMessage;
						csMessage.Format(pFormat, (LPCSTR)csDLLName);
						AfxMessageBox(csMessage);
					}
				}
Exemplo n.º 6
0
void UtSpeedMeterEx(void *hWnd)
{
	Dialog((HWND)hWnd, D_SPEEDMETER, UtSpeedMeterDlgProc, NULL);
}