示例#1
0
void Configuration::OnBtnDefaultsClick(wxCommandEvent& /*event*/)
{
  if ( cbMessageBox(_("Are you really sure?"),_("Setting defaults"),wxYES|wxNO) != wxID_YES )
    return;

  // Clean up the bindings and start from scratch...
  m_Bindings.m_Groups.clear();
  m_Bindings.SetDefaults();

  ShowGroups();

  m_Dirty = false;
}// OnBtnDefaultsClick
示例#2
0
Configuration::Configuration(wxWindow* parent,wxWindowID id)
{
  //(*Initialize(Configuration)
  wxBoxSizer* sizDefaults;

  Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
  sizMain = new wxBoxSizer(wxHORIZONTAL);
  sizGroups = new wxStaticBoxSizer(wxVERTICAL, this, _("Groups"));
  m_Groups = new wxListBox(this, ID_LST_GROUPS, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_LST_GROUPS"));
  m_Groups->SetToolTip(_("This is a list of all groups of bindings available to the plugin."));
  sizGroups->Add(m_Groups, 1, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizAddDeleteRename = new wxBoxSizer(wxHORIZONTAL);
  m_AddGroup = new wxButton(this, ID_BTN_ADD_GROUP, _("Add"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BTN_ADD_GROUP"));
  m_AddGroup->SetToolTip(_("Add a new group..."));
  sizAddDeleteRename->Add(m_AddGroup, 1, wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
  m_DeleteGroup = new wxButton(this, ID_BTN_DELETE_GROUP, _("Delete"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BTN_DELETE_GROUP"));
  m_DeleteGroup->SetToolTip(_("Delete the selected group..."));
  sizAddDeleteRename->Add(m_DeleteGroup, 1, wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
  m_RenameGroup = new wxButton(this, ID_BTN_RENAME_GROUP, _("Rename"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BTN_RENAME_GROUP"));
  m_RenameGroup->SetToolTip(_("Rename the selected group..."));
  sizAddDeleteRename->Add(m_RenameGroup, 1, wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
  sizGroups->Add(sizAddDeleteRename, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizDefaults = new wxBoxSizer(wxHORIZONTAL);
  m_Defaults = new wxButton(this, ID_BTN_DEFAULTS, _("Defaults"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BTN_DEFAULTS"));
  sizDefaults->Add(m_Defaults, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizGroups->Add(sizDefaults, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizMain->Add(sizGroups, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizBindings = new wxStaticBoxSizer(wxVERTICAL, this, _("Bindings"));
  sizIdentifiersHor = new wxBoxSizer(wxHORIZONTAL);
  sizIdentifiersVert = new wxBoxSizer(wxVERTICAL);
  lblIdentifiers = new wxStaticText(this, ID_LBL_IDENTIFIERS, _("Identifiers:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_LBL_IDENTIFIERS"));
  sizIdentifiersVert->Add(lblIdentifiers, 0, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizIdentifiers = new wxBoxSizer(wxHORIZONTAL);
  m_Identifiers = new wxListBox(this, ID_LST_IDENTIFIERS, wxDefaultPosition, wxSize(188,115), 0, 0, 0, wxDefaultValidator, _T("ID_LST_IDENTIFIERS"));
  m_Identifiers->SetToolTip(_("This is a list of all identifiers (tokens) available within the selected group."));
  sizIdentifiers->Add(m_Identifiers, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizAddDeleteChange = new wxBoxSizer(wxVERTICAL);
  m_AddIdentifier = new wxButton(this, ID_BTN_ADD_IDENTIFIER, _("Add"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BTN_ADD_IDENTIFIER"));
  m_AddIdentifier->SetToolTip(_("Add a new identifier..."));
  sizAddDeleteChange->Add(m_AddIdentifier, 0, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  m_DeleteIdentifier = new wxButton(this, ID_BTN_DELETE_IDENTIFIERS, _("Delete"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BTN_DELETE_IDENTIFIERS"));
  m_DeleteIdentifier->SetToolTip(_("Delete the selected identifier..."));
  sizAddDeleteChange->Add(m_DeleteIdentifier, 0, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  m_ChangeIdentifier = new wxButton(this, ID_BTN_CHANGE_IDENTIFIER, _("Change"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BTN_CHANGE_IDENTIFIER"));
  m_ChangeIdentifier->SetToolTip(_("Change (rename) the selected identifier..."));
  sizAddDeleteChange->Add(m_ChangeIdentifier, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizIdentifiers->Add(sizAddDeleteChange, 0, wxLEFT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizIdentifiersVert->Add(sizIdentifiers, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizIdentifiersHor->Add(sizIdentifiersVert, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizBindings->Add(sizIdentifiersHor, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizHeaders = new wxBoxSizer(wxVERTICAL);
  lblHeaders = new wxStaticText(this, ID_LBL_HEADERS, _("Headers:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_LBL_HEADERS"));
  sizHeaders->Add(lblHeaders, 0, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  m_Headers = new wxTextCtrl(this, ID_TXT_HEADERS, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_MULTILINE, wxDefaultValidator, _T("ID_TXT_HEADERS"));
  m_Headers->SetToolTip(_("This is a list of all header files required for the selected identifier (token) within the selected group."));
  sizHeaders->Add(m_Headers, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizBindings->Add(sizHeaders, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  sizMain->Add(sizBindings, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
  SetSizer(sizMain);
  sizMain->Fit(this);
  sizMain->SetSizeHints(this);

  Connect(ID_LST_GROUPS,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&Configuration::OnGroupsSelect);
  Connect(ID_LST_GROUPS,wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,(wxObjectEventFunction)&Configuration::OnRenameGroup);
  Connect(ID_BTN_ADD_GROUP,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnBtnAddGroupClick);
  Connect(ID_BTN_DELETE_GROUP,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnBtnDeleteGroupClick);
  Connect(ID_BTN_RENAME_GROUP,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnRenameGroup);
  Connect(ID_BTN_DEFAULTS,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnBtnDefaultsClick);
  Connect(ID_LST_IDENTIFIERS,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&Configuration::OnIdentifiersSelect);
  Connect(ID_LST_IDENTIFIERS,wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,(wxObjectEventFunction)&Configuration::OnChangeIdentifier);
  Connect(ID_BTN_ADD_IDENTIFIER,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnBtnAddIdentifierClick);
  Connect(ID_BTN_DELETE_IDENTIFIERS,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnBtnDeleteIdentifierClick);
  Connect(ID_BTN_CHANGE_IDENTIFIER,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Configuration::OnChangeIdentifier);
  Connect(ID_TXT_HEADERS,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&Configuration::OnHeadersText);
  //*)

  m_BlockHeadersText = false;
  m_Dirty            = false;

  ShowGroups();
}// Configuration
示例#3
0
//////////////////////////////////////////////////////////////////
// Apply the specified set of commands to the map.
//
void c_RestFetchImage::ApplyMapViewCommands(MgMap* map, MgPropertyCollection* mapViewCommands)
{
	if(mapViewCommands == NULL)
		return;

	Ptr<MgProperty> val;

	//Set view center X
	val = mapViewCommands->FindItem(m_mapCmdSetViewCenterX);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetViewCenterX);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		Ptr<MgPoint> center = map->GetViewCenter();
		Ptr<MgCoordinate> coord = center? center->GetCoordinate(): NULL;
		double y = coord? coord->GetY(): 0.;
		MgGeometryFactory gf;
		Ptr<MgCoordinate> coordNewCenter = gf.CreateCoordinateXY(MgUtil::StringToDouble(((MgStringProperty*)((MgProperty*)val))->GetValue()), y);
		Ptr<MgPoint> ptNewCenter = gf.CreatePoint(coordNewCenter);
		map->SetViewCenter(ptNewCenter);
	}

	//Set view center Y
	val = mapViewCommands->FindItem(m_mapCmdSetViewCenterY);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetViewCenterY);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		Ptr<MgPoint> center = map->GetViewCenter();
		Ptr<MgCoordinate> coord = center? center->GetCoordinate(): NULL;
		double x = coord? coord->GetX(): 0.;
		MgGeometryFactory gf;
		Ptr<MgCoordinate> coordNewCenter = gf.CreateCoordinateXY(x, MgUtil::StringToDouble(((MgStringProperty*)((MgProperty*)val))->GetValue()));
		Ptr<MgPoint> ptNewCenter = gf.CreatePoint(coordNewCenter);
		map->SetViewCenter(ptNewCenter);
	}

	//Set view scale
	val = mapViewCommands->FindItem(m_mapCmdSetViewScale);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetViewScale);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		STRING sScale = ((MgStringProperty*)((MgProperty*)val))->GetValue();
		double scale = MgUtil::StringToDouble(sScale);
		if(scale <= 0.0)
		{
			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetViewScale);
			arguments.Add(sScale);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
		}

		map->SetViewScale(scale);

		//refresh all layers that are visible
		map->SetLayerRefreshMode(MgMap::refreshAll);
	}

	//Set display dpi
	val = mapViewCommands->FindItem(m_mapCmdSetDisplayDpi);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetDisplayDpi);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		STRING sDpi = ((MgStringProperty*)((MgProperty*)val))->GetValue();
		INT32 dpi = MgUtil::StringToInt32(sDpi);
		if(dpi <= 0)
		{
			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetDisplayDpi);
			arguments.Add(sDpi);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
		}

		map->SetDisplayDpi(dpi);
	}

	//Set display width
	val = mapViewCommands->FindItem(m_mapCmdSetDisplayWidth);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetDisplayWidth);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		STRING sWidth = ((MgStringProperty*)((MgProperty*)val))->GetValue();
		INT32 width = MgUtil::StringToInt32(sWidth);
		if(width <= 0)
		{
			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetDisplayWidth);
			arguments.Add(sWidth);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
		}

		map->SetDisplayWidth(width);
	}

	//Set display height
	val = mapViewCommands->FindItem(m_mapCmdSetDisplayHeight);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetDisplayHeight);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		STRING sHeight = ((MgStringProperty*)((MgProperty*)val))->GetValue();
		INT32 height = MgUtil::StringToInt32(sHeight);
		if(height <= 0)
		{
			MgStringCollection arguments;
			arguments.Add(m_mapCmdSetDisplayHeight);
			arguments.Add(sHeight);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
		}

		map->SetDisplayHeight(height);
	}

	//Show layers
	val = mapViewCommands->FindItem(m_mapCmdShowLayers);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdShowLayers);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		ShowLayers(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), true);
	}

	//Hide layers
	val = mapViewCommands->FindItem(m_mapCmdHideLayers);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdHideLayers);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		ShowLayers(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), false);
	}

	//Show groups
	val = mapViewCommands->FindItem(m_mapCmdShowGroups);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdShowGroups);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		ShowGroups(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), true);
	}

	//Hide groups
	val = mapViewCommands->FindItem(m_mapCmdHideGroups);
	if(val != NULL)
	{
		if(val->GetPropertyType() != MgPropertyType::String)
		{
			STRING buffer;
			MgUtil::Int32ToString((INT32)val->GetPropertyType(), buffer);

			MgStringCollection arguments;
			arguments.Add(m_mapCmdHideGroups);
			arguments.Add(buffer);

			throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
				__LINE__, __WFILE__, &arguments, L"MgInvalidPropertyTypeForCommand", NULL);
		}

		ShowGroups(map, ((MgStringProperty*)((MgProperty*)val))->GetValue(), false);
	}

	//Refresh layers - applies only to DwfController
}//end of c_RestFetchImage::ApplyMapViewCommands