BaoKai_202508-Wms-Jingwang..../WMS.Frm.Base/FrmGoods.cs
2025-08-24 09:35:55 +08:00

117 lines
3.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using WMS.Base.WebService;
using WMS.Model.Base;
using System.IO;
namespace WMS.Frm.Base
{
public partial class FrmGoods : Form
{
private static FrmGoods goods;
private string oldGoodsID;
/// <summary>
/// 实例化Goods的一个对象
/// </summary>
/// <returns>Goods对象</returns>
public static FrmGoods GetInstance()
{
if (goods == null || goods.IsDisposed)
{
goods = new FrmGoods();
}
return goods;
}
public FrmGoods()
{
InitializeComponent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Opacity = 0.6;
}
public bool Set(string goodsID,Point point)
{
if (oldGoodsID != goodsID) {
//获取商品信息
string strGoodsList = WebLockConfig.Instance.Goods.GetGoodsList(goodsID, "", "", "");
List<GoodsInfoModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GoodsInfoModel>>(strGoodsList);
if (list.Count == 0)
{
return false;
}
GoodsInfoModel goods = list[0];
//显示图片
if (goods.IMG != null)
{
MemoryStream ms = new System.IO.MemoryStream(goods.IMG);
pictureEdit.Image = System.Drawing.Image.FromStream(ms);
this.pictureEdit.Size = pictureEdit.Image.Size;
this.ClientSize = this.pictureEdit.Size;
}
oldGoodsID = goodsID;
}
if (pictureEdit.Image == null) {
return false;
}
//根据图片调整位置
int screenHeight = Screen.GetWorkingArea(this).Height;
if (point.Y + pictureEdit.Image.Height > screenHeight)
{
point = new Point(point.X, point.Y - pictureEdit.Image.Height - 20);
}
this.Location = point;
return true;
}
///// <summary>
///// 修改窗体的Paint事件美化界面这里做一个渐变背景需要引入System.Drawing.Drawing2D;
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void Goods_Paint(object sender, PaintEventArgs e)
//{
// Graphics g = e.Graphics;
// Color FColor = Color.Red;
// Color TColor = Color.Yellow;
// Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.ForwardDiagonal);
// g.FillRectangle(b, this.ClientRectangle);
//}
////实现鼠标拖动悬浮窗体
//const int WM_NCHITTEST = 0x0084;
//const int HTCLIENT = 0x0001;
//const int HTCAPTION = 0x0002;
//protected override void WndProc(ref System.Windows.Forms.Message m)
//{
// switch (m.Msg)
// {
// case WM_NCHITTEST:
// base.WndProc(ref m);
// if (m.Result == (IntPtr)HTCLIENT)
// m.Result = (IntPtr)HTCAPTION;
// break;
// default:
// base.WndProc(ref m);
// break;
// }
//}
}
}