117 lines
3.7 KiB
C#
117 lines
3.7 KiB
C#
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;
|
||
// }
|
||
//}
|
||
}
|
||
}
|