コード例 #1
0
    void tables_getting_started_sample()
    {
        try
        {
            // Initialize storage account
            wa::storage::cloud_storage_account storage_account = wa::storage::cloud_storage_account::parse(storage_connection_string);

            // Create a table
            wa::storage::cloud_table_client table_client = storage_account.create_cloud_table_client();
            wa::storage::cloud_table table = table_client.get_table_reference(U("AzureNativeClientLibrarySampleTable"));
            bool created = table.create_if_not_exists();

            // Insert a table entity
            wa::storage::table_entity entity(U("MyPartitionKey"), U("MyRowKey"));
            entity.properties().reserve(8);
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyA"), wa::storage::entity_property(utility::string_t(U("some string")))));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyB"), wa::storage::entity_property(utility::datetime::utc_now())));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyC"), wa::storage::entity_property(utility::new_uuid())));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyD"), wa::storage::entity_property(1234567890)));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyE"), wa::storage::entity_property(1234567890123456789LL)));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyF"), wa::storage::entity_property(9.1234567890123456789)));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyG"), wa::storage::entity_property(true)));
            entity.properties().insert(wa::storage::table_entity::property_type(U("PropertyH"), wa::storage::entity_property(std::vector<uint8_t>(10, 'X'))));
            wa::storage::table_operation operation1 = wa::storage::table_operation::insert_or_replace_entity(entity);
            wa::storage::table_result insert_result = table.execute(operation1);

            // Retrieve a table entity
            wa::storage::table_operation operation2 = wa::storage::table_operation::retrieve_entity(U("MyPartitionKey"), U("MyRowKey"));
            wa::storage::table_result retrieve_result = table.execute(operation2);

            // Insert table entities in a batch
            wa::storage::table_batch_operation operation3;
            for (int i = 0; i < 10; ++i)
            {
                utility::string_t row_key = U("MyRowKey") + utility::conversions::print_string(i);
                wa::storage::table_entity entity2(U("MyPartitionKey"), row_key);
                entity2.properties().reserve(3);
                entity2.properties().insert(wa::storage::table_entity::property_type(U("PropertyA"), wa::storage::entity_property(utility::string_t(U("another string")))));
                entity2.properties().insert(wa::storage::table_entity::property_type(U("PropertyB"), wa::storage::entity_property(utility::datetime::utc_now())));
                entity2.properties().insert(wa::storage::table_entity::property_type(U("PropertyC"), wa::storage::entity_property(utility::new_uuid())));
                operation3.insert_or_replace_entity(entity2);
            }
            std::vector<wa::storage::table_result> results = table.execute_batch(operation3);

            // Query for some table entities
            wa::storage::table_query query;
            query.set_filter_string(wa::storage::table_query::combine_filter_conditions(
                wa::storage::table_query::generate_filter_condition(U("PartitionKey"), wa::storage::query_comparison_operator::equal, U("MyPartitionKey")), 
                wa::storage::query_logical_operator::and, 
                wa::storage::table_query::generate_filter_condition(U("RowKey"), wa::storage::query_comparison_operator::greater_than_or_equal, U("MyRowKey5"))));
            std::vector<wa::storage::table_entity> entities = table.execute_query(query);
            for (std::vector<wa::storage::table_entity>::const_iterator itr = entities.cbegin(); itr != entities.cend(); ++itr)
            {
                wa::storage::table_entity::properties_type properties = itr->properties();
                ucout << U("PK: ") << itr->partition_key() << U(", RK: ") << itr->row_key() << U(", Prop: ") << utility::uuid_to_string(properties[U("PropertyC")].guid_value()) << std::endl;
            }

            // Delete a table entity
            wa::storage::table_operation operation4 = wa::storage::table_operation::delete_entity(retrieve_result.entity());
            wa::storage::table_result delete_result = table.execute(operation4);

            // Delete the table
            bool deleted = table.delete_table_if_exists();
        }
        catch (wa::storage::storage_exception& e)
        {
            ucout << U("Error: ") << e.what() << std::endl;

            wa::storage::request_result result = e.result();
            wa::storage::storage_extended_error extended_error = result.extended_error();
            if (!extended_error.message().empty())
            {
                ucout << extended_error.message() << std::endl;
            }
        }
        catch (std::exception& e)
        {
            ucout << U("Error: ") << e.what() << std::endl;
        }
    }
コード例 #2
0
ファイル: main.cpp プロジェクト: jjimenezg93/InputManager
int main() {
	Screen::Instance().Open(800, 600, false);

	//Entity
	Image * alienImg = ResourceManager::Instance().LoadImage("data/alien.png");
	alienImg->SetMidHandle();
	CEntity entity(alienImg);
	entity.GetSprite()->SetPosition(350, 340);

	CEntity entity2(alienImg);
	entity2.GetSprite()->SetPosition(700, 300);

	//Windows
	Image * backgroundImg = ResourceManager::Instance().LoadImage("data/background.jpg");
	Image * windowImg = ResourceManager::Instance().LoadImage("data/window4.png");

	//button Imgs
	Image * buttonImgDefault = ResourceManager::Instance().LoadImage("data/button_default.png");
	buttonImgDefault->SetMidHandle();
	Image * buttonImgOnClick = ResourceManager::Instance().LoadImage("data/button_onclick.png");
	buttonImgOnClick->SetMidHandle();
	Image * buttonImgInactive = ResourceManager::Instance().LoadImage("data/button_inactive.png");
	buttonImgInactive->SetMidHandle();

	//checkbox Imgs
	Image * checkboxImgDefault = ResourceManager::Instance().LoadImage(
	"data/checkbox_disabled.png");
	checkboxImgDefault->SetMidHandle();
	Image * checkboxImgOnClick = ResourceManager::Instance().LoadImage(
	"data/checkbox_enabled.png");
	checkboxImgOnClick->SetMidHandle();

	//slider Imgs
	Image * sliderBallImg = ResourceManager::Instance().LoadImage("data/slider_ball.png");	
	sliderBallImg->SetHandle(
		static_cast<float>(sliderBallImg->GetWidth() * sliderBallImg->GetHFrames() / 2),
		static_cast<float>(sliderBallImg->GetHeight() * sliderBallImg->GetVFrames()));
	
	Image * sliderBarImg = ResourceManager::Instance().LoadImage("data/slider_bar.png");
	sliderBarImg->SetHandle(0,
		static_cast<float>(sliderBarImg->GetHeight() * sliderBarImg->GetVFrames()));
	
	Image * sliderLeftDefaultImg = ResourceManager::Instance().LoadImage(
		"data/slider_left_default.png");
	sliderLeftDefaultImg->SetMidHandle();
	
	Image * sliderRightDefaultImg = ResourceManager::Instance().LoadImage(
		"data/slider_right_default.png");
	sliderRightDefaultImg->SetMidHandle();
	
	Image * sliderLeftOnClickImg = ResourceManager::Instance().LoadImage(
		"data/slider_left_onclick.png");
	sliderLeftOnClickImg->SetMidHandle();
	
	Image * sliderRightOnClickImg = ResourceManager::Instance().LoadImage(
		"data/slider_right_onclick.png");
	sliderRightOnClickImg->SetMidHandle();

	//Input & Control managers
	CInputManager * inputManager = &CInputManager::Instance();

	assert(inputManager != nullptr);

	CControlManagerUI controlManager;

	controlManager.Init();

	String str;
	//Controls
	CWindowUI background;
	background.Init(0, 0, backgroundImg);
	background.SetId(0);
	controlManager.AddControl(&background);

	CWindowUI windowSlider;
	windowSlider.Init(100, 0, windowImg);
	windowSlider.SetId(1);
	controlManager.AddControl(&windowSlider);

	CButtonUI button;
	button.Init(350, 80, buttonImgDefault, buttonImgOnClick, buttonImgInactive);
	button.SetId(0);
	str = "Inactive";
	button.SetText(str);
	controlManager.AddControl(&button);
	button.SetCurrentState(EGUICS_INACTIVE);

	CButtonUI button2;
	button2.Init(350, 140, buttonImgDefault, buttonImgOnClick, buttonImgInactive);
	button2.SetId(1);
	str = "Click";
	button2.SetText(str);
	controlManager.AddControl(&button2);

	CSliderUI slider;
	slider.Init(200, 400, 0, 10, sliderBarImg, sliderBallImg, sliderLeftDefaultImg,
		sliderLeftOnClickImg, sliderRightDefaultImg, sliderRightOnClickImg);
	slider.SetId(0);
	controlManager.AddControl(&slider);

	CCheckBoxUI checkbox;
	checkbox.Init(300, 220, checkboxImgDefault, checkboxImgOnClick);
	checkbox.SetId(0);

	CCheckBoxUI checkbox2;
	checkbox2.Init(340, 220, checkboxImgDefault, checkboxImgOnClick);
	checkbox2.SetId(1);

	CCheckBoxUI checkbox3;
	checkbox3.Init(380, 220, checkboxImgDefault, checkboxImgOnClick);
	checkbox3.SetId(2);

	CCheckBoxGroup cbGroup;
	cbGroup.Init();
	cbGroup.AddControl(&checkbox);
	cbGroup.AddControl(&checkbox2);
	cbGroup.AddControl(&checkbox3);
	controlManager.AddControl(&cbGroup);
	cbGroup.AddEventListener(&entity);

	checkbox.SetCurrentState(EGUICS_ONCLICK);

	button2.AddEventListener(&entity);
	slider.AddEventListener(&entity);
	entity.GetSprite()->SetColor(entity.GetSprite()->GetRed(), entity.GetSprite()->GetGreen(),
		entity.GetSprite()->GetBlue(), 0);
	/*entity.Register(EEC_MOUSE, EME_LMB_PRESS);
	entity.Register(EEC_MOUSE, EME_LMB_RELEASE);
	entity.Register(EEC_MOUSE, EME_LMB_CLICK);
	entity.Register(EEC_MOUSE, EME_RMB_PRESS);
	entity.Register(EEC_KEYBOARD, EKE_SPACE);*/
	entity2.Register(EEC_MOUSE, EME_LMB_DRAG);

	Renderer::Instance().SetBlendMode(Renderer::BlendMode::ALPHA);

	while (Screen::Instance().IsOpened() && !Screen::Instance().KeyPressed(GLFW_KEY_ESC)) {
		Renderer::Instance().Clear();

		inputManager->Update();

		controlManager.Update();
		controlManager.Render();

		entity.GetSprite()->Update(Screen::Instance().ElapsedTime());
		entity.GetSprite()->Render();

		entity2.GetSprite()->Update(Screen::Instance().ElapsedTime());
		entity2.GetSprite()->Render();

		Screen::Instance().Refresh();
	}

	ResourceManager::Instance().FreeResources();
}