// Sets the current bitmap public void SelectBitmap(Bitmap bitmap) { // Does this bitmap contain an alpha channel? if (bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb) { throw new ApplicationException("The bitmap must be 32bpp with alpha-channel."); } // Get device contexts IntPtr screenDc = APIHelp.GetDC(IntPtr.Zero); IntPtr memDc = APIHelp.CreateCompatibleDC(screenDc); IntPtr hBitmap = IntPtr.Zero; IntPtr hOldBitmap = IntPtr.Zero; try { // Get handle to the new bitmap and select it into the current device context hBitmap = bitmap.GetHbitmap(Color.FromArgb(0)); hOldBitmap = APIHelp.SelectObject(memDc, hBitmap); // Set parameters for layered window update APIHelp.Size newSize = new APIHelp.Size(bitmap.Width, bitmap.Height); // Size window to match bitmap APIHelp.Point sourceLocation = new APIHelp.Point(0, 0); APIHelp.Point newLocation = new APIHelp.Point(this.Left, this.Top); // Same as this window APIHelp.BLENDFUNCTION blend = new APIHelp.BLENDFUNCTION(); blend.BlendOp = APIHelp.AC_SRC_OVER; // Only works with a 32bpp bitmap blend.BlendFlags = 0; // Always 0 blend.SourceConstantAlpha = 255; // Set to 255 for per-pixel alpha values blend.AlphaFormat = APIHelp.AC_SRC_ALPHA; // Only works when the bitmap contains an alpha channel // Update the window APIHelp.UpdateLayeredWindow(Handle, screenDc, ref newLocation, ref newSize, memDc, ref sourceLocation, 0, ref blend, APIHelp.ULW_ALPHA); } finally { // Release device context APIHelp.ReleaseDC(IntPtr.Zero, screenDc); if (hBitmap != IntPtr.Zero) { APIHelp.SelectObject(memDc, hOldBitmap); APIHelp.DeleteObject(hBitmap); // Remove bitmap resources } APIHelp.DeleteDC(memDc); } }
/// <summary> /// 添加评论 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="strParamData"></param> /// <param name="strUserName"></param> public void ADDCOMENT(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { string strMsgType = context.Request["MsgType"] ?? ""; string strMsgLYID = context.Request["MsgLYID"] ?? ""; string strPoints = context.Request["Points"] ?? "0"; string strfjID = context.Request["fjID"] ?? ""; string strTLID = context.Request["TLID"] ?? ""; if (!string.IsNullOrEmpty(P1) && APIHelp.TestWB(P1) != "0") { msg.ErrorMsg = "您得发言涉及违规内容,请完善后再发"; return; } JH_Auth_TL Model = new JH_Auth_TL(); Model.CRDate = DateTime.Now; Model.CRUser = UserInfo.User.UserName; Model.CRUserName = UserInfo.User.UserRealName; Model.MSGContent = P1; Model.ComId = UserInfo.User.ComId; Model.MSGTLYID = strMsgLYID; Model.MSGType = strMsgType; Model.MSGisHasFiles = strfjID; Model.Remark1 = P1; if (strTLID != "") { int TLID = Int32.Parse(strTLID); var tl = new JH_Auth_TLB().GetEntity(p => p.ID == TLID); if (tl != null) { Model.TLID = TLID; Model.ReUser = tl.CRUserName; } } int record = 0; int.TryParse(strPoints, out record); Model.Points = record; new JH_Auth_TLB().Insert(Model); if (Model.MSGType == "GZBG" || Model.MSGType == "RWGL" || Model.MSGType == "TSSQ") { int modelId = int.Parse(Model.MSGTLYID); string CRUser = ""; string Content = UserInfo.User.UserRealName + "评论了您的"; if (CRUser != UserInfo.User.UserName) { SZHL_TXSX CSTX = new SZHL_TXSX(); CSTX.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); CSTX.APIName = "XTGL"; CSTX.ComId = UserInfo.User.ComId; CSTX.FunName = "SENDPLMSG"; CSTX.CRUserRealName = UserInfo.User.UserRealName; CSTX.MsgID = modelId.ToString(); CSTX.TXContent = Content; CSTX.ISCS = "N"; CSTX.TXUser = CRUser; CSTX.TXMode = Model.MSGType; CSTX.CRUser = UserInfo.User.UserName; TXSX.TXSXAPI.AddALERT(CSTX); //时间为发送时间 } } msg.Result = Model; if (Model.MSGisHasFiles == "") { Model.MSGisHasFiles = "0"; } msg.Result1 = new FT_FileB().GetEntities(" ID in (" + Model.MSGisHasFiles + ")"); }