Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

将下面两个函数改用C#编写 Gdiplus::Image * MeowSkinDelegate::GetImageByKey(UINT32 key) {…

  1. User

    将下面两个函数改用C#编写

    Gdiplus::Image * MeowSkinDelegate::GetImageByKey(UINT32 key) { std::map<MEOW_SKIN_IMAGEKEY, Gdiplus::Image *>::iterator it = images.find((MEOW_SKIN_IMAGEKEY)key); if (it != images.end()) { return it->second; } else { WCHAR buff[MAX_PATH]; switch (key) { case MS_IK_LANGUAGE: GetImagePathByName(L"language.png", buff, MAX_PATH); break; case MS_IK_PUNCTUATION: GetImagePathByName(L"punctuation.png", buff, MAX_PATH); break; case MS_IK_CONFIGURE: GetImagePathByName(L"configure.png", buff, MAX_PATH); break; default: case MS_IK_PINYIN: GetImagePathByName(L"pinyin.png", buff, MAX_PATH); break; }

    	Gdiplus::Image *image = new Gdiplus::Image(buff);
    	images.insert(std::map<MEOW_SKIN_IMAGEKEY, Gdiplus::Image *>::value_type((MEOW_SKIN_IMAGEKEY)key, image));
    	return image;
    }
    

    } BOOL MeowSkinDelegate::GetImagePathByName(WCHAR * name, WCHAR * buff, UINT32 length) { CString xx = (name); xx = root + xx; wcscpy_s(buff, length, (LPCWSTR)xx); return TRUE; }

  2. Assistant

    using System.Drawing; public Image GetImageByKey(UInt32 key) { if (images.ContainsKey((MEOW_SKIN_IMAGEKEY)key)) { return images[(MEOW_SKIN_IMAGEKEY)key]; } else { string imageName; switch (key) { case MS_IK_LANGUAGE: imageName = "language.png"; break; case MS_IK_PUNCTUATION: imageName = "punctuation.png"; break; case MS_IK_CONFIGURE: imageName = "configure.png"; break; default: case MS_IK_PINYIN: imageName = "pinyin.png"; break; }

        string imagePath = root + imageName;
        Image image = Image.FromFile(imagePath);
        images.Add((MEOW_SKIN_IMAGEKEY)key, image);
        return image;
    }
    

    } bool GetImagePathByName(string name, out string imagePath) { imagePath = root + name; return true; }