Commit 978cd024 LN

1

1 个父辈 2c0bdca5
...@@ -784,16 +784,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -784,16 +784,20 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
string shelfRfid = ReadyShelf(); string shelfRfid = ReadyShelf();
if (String.IsNullOrEmpty(shelfRfid))
{
//无可用料架
WarnMsg = $"{LineConnect.DoorPosInfo.ToStr()}暂无可用料架";
return;
}
ClearWarnMsg("暂无可用料架");
//获取库位号 //获取库位号
string outMsg = ""; string outMsg = "";
CurrTray = HttpServer.GetDiskInfo(1, shelfRfid, out outMsg); CurrTray = HttpServer.GetLocation(1, shelfRfid, out outMsg);
//需要取放料,且料架已准备好 //需要取放料,且料架已准备好
if (String.IsNullOrEmpty(CurrTray.getP).Equals(false) && outMsg.Equals("")) if (String.IsNullOrEmpty(CurrTray.getP).Equals(false) && outMsg.Equals(""))
{ {
if (WarnMsg.Contains("getLocation")) ClearWarnMsg("getLocation");
{
WarnMsg = "";
}
string targetP = GetShelfPosId(); string targetP = GetShelfPosId();
if (!String.IsNullOrEmpty(targetP)) if (!String.IsNullOrEmpty(targetP))
{ {
...@@ -816,6 +820,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -816,6 +820,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + "InShelfProcess:" + ex.ToString()); LogUtil.error(Name + "InShelfProcess:" + ex.ToString());
} }
} }
private void ClearWarnMsg(string str)
{
if (WarnMsg.Contains(str))
{
WarnMsg = "";
}
}
internal string GetShelfPosId() internal string GetShelfPosId()
{ {
string str = ""; string str = "";
...@@ -939,8 +950,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -939,8 +950,9 @@ namespace OnlineStore.DeviceLibrary
{ {
if (isInSuddenDown || isNoAirCheck || if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing)) (!storeRunStatus.Equals(StoreRunStatus.Runing))
|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.OutStoreExecute) //|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.InStoreEnd)
|| storeStatus.Equals(StoreStatus.InStoreEnd) || storeStatus.Equals(StoreStatus.OutStoreBoxEnd)) || storeStatus.Equals(StoreStatus.OutStoreExecute)
|| storeStatus.Equals(StoreStatus.OutStoreBoxEnd))
{ {
return false; return false;
} }
...@@ -958,10 +970,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -958,10 +970,7 @@ namespace OnlineStore.DeviceLibrary
} }
return msg; return msg;
} }
#region 出料命令处理
public void CylinderMove(string IoLowType, string IoHighType, StoreMoveInfo moveInfo = null) public void CylinderMove(string IoLowType, string IoHighType, StoreMoveInfo moveInfo = null)
{ {
try try
...@@ -978,10 +987,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -978,10 +987,9 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error(Name + "CylinderMove [" + IoLowType + "] [" + IoHighType + "] 出错:" + ex.ToString()); LogUtil.error(Name + "CylinderMove [" + IoLowType + "] [" + IoHighType + "] 出错:" + ex.ToString());
} }
} }
#endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作 #region 通信定时器
private bool isInProcess = false; private bool isInProcess = false;
private DateTime lastConTime = DateTime.Now; private DateTime lastConTime = DateTime.Now;
...@@ -1053,7 +1061,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1053,7 +1061,7 @@ namespace OnlineStore.DeviceLibrary
isNeedAlarmLed = true; isNeedAlarmLed = true;
} }
if (MoveInfo.MoveType.Equals(StoreMoveType.InStore)) if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{ {
isInOut = true; isInOut = true;
} }
......
...@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
/// <param name="robot">ABB机器人索引号</param> /// <param name="robot">ABB机器人索引号</param>
/// <param name="currRFID">当前工位的RFID</param> /// <param name="currRFID">当前工位的RFID</param>
public static TrayInfo GetDiskInfo(int robot, string currRFID, out string msg) public static TrayInfo GetLocation(int robot, string currRFID, out string msg)
{ {
TrayInfo tray = new TrayInfo(); TrayInfo tray = new TrayInfo();
string api = "getLocation"; string api = "getLocation";
......
...@@ -104,8 +104,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -104,8 +104,10 @@ namespace OnlineStore.DeviceLibrary
internal static bool IsRealRfid(string shelfRfid) internal static bool IsRealRfid(string shelfRfid)
{ {
//判断料架号是否是真实的料架号 //判断料架号是否是真实的料架号
if (shelfRfid.StartsWith("C") || shelfRfid.StartsWith("D")) //混合料架用F
{ if (shelfRfid.StartsWith("F"))
//if (shelfRfid.StartsWith("C") || shelfRfid.StartsWith("D"))
{
int num = -1; int num = -1;
try try
{ {
......
...@@ -71,7 +71,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -71,7 +71,7 @@ namespace OnlineStore.DeviceLibrary
{ {
switch (MoveInfo.MoveType) switch (MoveInfo.MoveType)
{ {
case StoreMoveType.InStore: case StoreMoveType.OutStore:
OutProcess(); OutProcess();
isInPro = false; isInPro = false;
break; break;
...@@ -98,11 +98,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -98,11 +98,11 @@ namespace OnlineStore.DeviceLibrary
{ {
alarmMsg = alarmMsg.Replace(Name, ""); alarmMsg = alarmMsg.Replace(Name, "");
int inoutStatus = 0; int inoutStatus = 0;
if (storeMoveType.Equals(StoreMoveType.InStore)) if (storeMoveType.Equals(StoreMoveType.OutStore))
{ {
inoutStatus = 1; inoutStatus = 1;
} }
else if (storeMoveType.Equals(StoreMoveType.InStore)) else if (storeMoveType.Equals(StoreMoveType.OutStore))
{ {
inoutStatus = 2; inoutStatus = 2;
} }
...@@ -306,12 +306,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -306,12 +306,12 @@ namespace OnlineStore.DeviceLibrary
case StoreStatus.Debugging: case StoreStatus.Debugging:
aa = "设备调试中"; aa = "设备调试中";
break; break;
case StoreStatus.InStoreEnd: //case StoreStatus.InStoreEnd:
aa = "料盘入仓位完成"; // aa = "料盘入仓位完成";
break; // break;
case StoreStatus.InStoreExecute: //case StoreStatus.InStoreExecute:
aa = "出料执行中"; // aa = "出料执行中";
break; // break;
case StoreStatus.InTrouble: case StoreStatus.InTrouble:
aa = "故障中"; aa = "故障中";
break; break;
...@@ -327,15 +327,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -327,15 +327,15 @@ namespace OnlineStore.DeviceLibrary
case StoreStatus.SuddenStop: case StoreStatus.SuddenStop:
aa = "急停中"; aa = "急停中";
break; break;
case StoreStatus.OutMoveExecute: //case StoreStatus.OutMoveExecute:
aa = "出库完成"; // aa = "出库完成";
break; // break;
case StoreStatus.InStoreFaild: //case StoreStatus.InStoreFaild:
aa = "出料失败(" + WarnMsg + ")"; // aa = "出料失败(" + WarnMsg + ")";
break; // break;
case StoreStatus.OutStoreFaild: //case StoreStatus.OutStoreFaild:
aa = "出库失败(" + WarnMsg + ")"; // aa = "出库失败(" + WarnMsg + ")";
break; // break;
case StoreStatus.Check_PosMove: case StoreStatus.Check_PosMove:
aa = "盘点中"; aa = "盘点中";
break; break;
...@@ -344,7 +344,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -344,7 +344,7 @@ namespace OnlineStore.DeviceLibrary
{ {
string inout = ""; string inout = "";
if (MoveInfo.MoveType.Equals(StoreMoveType.InStore)&& MoveInfo.MoveParam!=null&& MoveInfo.MoveParam.PosInfo!=null) if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore)&& MoveInfo.MoveParam!=null&& MoveInfo.MoveParam.PosInfo!=null)
{ {
inout = "_出料:"+MoveInfo.MoveParam.PosInfo.ToStr(); inout = "_出料:"+MoveInfo.MoveParam.PosInfo.ToStr();
} }
......
...@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 出料 /// 出料
/// </summary> /// </summary>
InStore = 1, OutStore = 1,
/// <summary> /// <summary>
/// 原点返回 /// 原点返回
......
...@@ -74,18 +74,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,18 +74,18 @@ namespace OnlineStore.DeviceLibrary
/// 5=设备调试中 /// 5=设备调试中
/// </summary> /// </summary>
Debugging = 5, Debugging = 5,
/// <summary> ///// <summary>
/// 6=出料执行中 ///// 6=出料执行中
/// </summary> ///// </summary>
InStoreExecute = 6, //InStoreExecute = 6,
/// <summary> ///// <summary>
/// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态) ///// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
/// </summary> ///// </summary>
InStoreEnd = 7, //InStoreEnd = 7,
/// <summary> ///// <summary>
/// 8=出料失败 ///// 8=出料失败
/// </summary> ///// </summary>
InStoreFaild = 8, //InStoreFaild = 8,
/// <summary> /// <summary>
/// 9=出库执行中", /// 9=出库执行中",
/// </summary> /// </summary>
...@@ -94,18 +94,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -94,18 +94,18 @@ namespace OnlineStore.DeviceLibrary
///10= 出仓位完成( 料盘已经放到Box门口) ///10= 出仓位完成( 料盘已经放到Box门口)
/// </summary> /// </summary>
OutStoreBoxEnd = 10, OutStoreBoxEnd = 10,
/// <summary> ///// <summary>
/// 12=移栽出库移栽过程中(移栽完成后变成OnLine) ///// 12=移栽出库移栽过程中(移栽完成后变成OnLine)
/// </summary> ///// </summary>
OutMoveExecute = 12, //OutMoveExecute = 12,
/// <summary> ///// <summary>
///11=出库失败 /////11=出库失败
/// </summary> ///// </summary>
OutStoreFaild = 11, //OutStoreFaild = 11,
/// <summary> /// <summary>
/// 重置中(原点返回和重置都发此状态) /// 重置中(原点返回和重置都发此状态)
/// </summary> /// </summary>
ResetMove=13, ResetMove =13,
/// <summary> /// <summary>
/// 库位盘点中 /// 库位盘点中
/// </summary> /// </summary>
...@@ -161,105 +161,89 @@ namespace OnlineStore.DeviceLibrary ...@@ -161,105 +161,89 @@ namespace OnlineStore.DeviceLibrary
#region 出料 #region 出料
///// <summary>
///// 出料:等待入口检测有料
///// </summary>
//SI_01_TrayCheck = 201,
///// <summary>
/////出料:获取料架库位号
///// </summary>
//SI_02_GetPosition,
///// <summary>
/////出料:等待料架准备完成
///// </summary>
//SI_03_WaitShelf,
///// <summary>
/////出料:顶升气缸上升
///// </summary>
//SI_04_LocationUp,
/// <summary> /// <summary>
/// 出料:进出轴(叉子)先返回P1 /// 出料:进出轴(叉子)先返回P1
/// </summary> /// </summary>
SI_11_InOutToP1 = 211, SO_11_InOutToP1 = 211,
/// <summary> /// <summary>
/// 出料:所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3 /// 出料:所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3
/// </summary> /// </summary>
SI_12_AxisToP1, SO_12_AxisToP1,
/// <summary> /// <summary>
/// 出料:压紧物品 压紧轴到P3(压紧前点) /// 出料:压紧物品 压紧轴到P3(压紧前点)
/// </summary> /// </summary>
SI_13_ComToP3, SO_13_ComToP3,
/// <summary> /// <summary>
/// 出料:叉子进入出料口,进出轴到P2 /// 出料:叉子进入出料口,进出轴到P2
/// </summary> /// </summary>
SI_14_InoutToP2, SO_14_InoutToP2,
/// <summary> /// <summary>
/// 出料:把物品放入叉子上,升降轴到P2,压紧物品,压紧轴到P2(压紧点) /// 出料:把物品放入叉子上,升降轴到P2,压紧物品,压紧轴到P2(压紧点)
/// </summary> /// </summary>
SI_15_GetReel, SO_15_GetReel,
/// <summary> /// <summary>
/// 出料: 进出轴到P1( 待机点) /// 出料: 进出轴到P1( 待机点)
/// </summary> /// </summary>
SI_16_InoutBack, SO_16_InoutBack,
/// <summary> /// <summary>
/// 出料:等待检测到料盘 /// 出料:等待检测到料盘
/// </summary> /// </summary>
SI_17_TrayCheck, SO_17_TrayCheck,
/// <summary> /// <summary>
/// 出料到料架:移动到库位点,旋转轴到P2( 库位点)升降轴到P3 /// 出料到料架:移动到库位点,旋转轴到P2( 库位点)升降轴到P3
/// </summary> /// </summary>
SI_21_MoveToBag=221, SO_21_MoveToBag=221,
/// <summary> /// <summary>
/// 出料到料架:叉子进出料位中,进出轴到P3 /// 出料到料架:叉子进出料位中,进出轴到P3
/// </summary> /// </summary>
SI_22_InoutToP3, SO_22_InoutToP3,
/// <summary> /// <summary>
/// 出料到料架:放下物品,升降轴到P4 ,压紧轴到P3( 压紧前点) /// 出料到料架:放下物品,升降轴到P4 ,压紧轴到P3( 压紧前点)
/// </summary> /// </summary>
SI_23_PutReel, SO_23_PutReel,
/// <summary> /// <summary>
/// 出料到料架:叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点) /// 出料到料架:叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点)
/// </summary> /// </summary>
SI_24_InoutBack, SO_24_InoutBack,
/// <summary> /// <summary>
/// 出料到料架:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始 /// 出料到料架:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary> /// </summary>
SI_25_GoBack, SO_25_GoBack,
/// <summary> /// <summary>
///出料到料架:等待叉子无信号 ///出料到料架:等待叉子无信号
/// </summary> /// </summary>
SI_26_WaitNoReel, SO_26_WaitNoReel,
/// <summary> /// <summary>
/// NG料:移动到NG位,旋转轴到P3 升降轴到P5 /// NG料:移动到NG位,旋转轴到P3 升降轴到P5
/// </summary> /// </summary>
SI_31_MoveToNG = 231, SO_31_MoveToNG = 231,
/// <summary> /// <summary>
/// </summary> /// </summary>
/// NG料:进出轴到P4 /// NG料:进出轴到P4
SI_32_InoutToP4, SO_32_InoutToP4,
/// <summary> /// <summary>
/// NG料: 升降轴到P6, 压紧轴到P3( 压紧前点) /// NG料: 升降轴到P6, 压紧轴到P3( 压紧前点)
/// </summary> /// </summary>
SI_33_PutReel, SO_33_PutReel,
/// <summary> /// <summary>
/// NG料:进出轴返回P1 /// NG料:进出轴返回P1
/// </summary> /// </summary>
SI_34_InoutToP1, SO_34_InoutToP1,
/// <summary> /// <summary>
/// NG料:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始 /// NG料:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary> /// </summary>
SI_35_GoBack, SO_35_GoBack,
/// <summary> /// <summary>
///NG料:等待叉子无信号 ///NG料:等待叉子无信号
/// </summary> /// </summary>
SI_36_WaitNoReel, SO_36_WaitNoReel,
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.HCSingleStore
{
class Class1
{
// <Query Kind = "Program" >
// < Reference > &lt; RuntimeDirectory&gt;\System.Net.Http.dll</Reference>
// <Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
// <NuGetReference>Newtonsoft.Json</NuGetReference>
// <NuGetReference>SharpDX</NuGetReference>
// <NuGetReference>SharpDX.Direct2D1</NuGetReference>
// <NuGetReference>SharpDX.Mathematics</NuGetReference>
// <Namespace>D2D = SharpDX.Direct2D1</Namespace>
// <Namespace>DWrite = SharpDX.DirectWrite</Namespace>
// <Namespace>Newtonsoft.Json.Linq</Namespace>
// <Namespace>SharpDX.Direct2D1</Namespace>
// <Namespace>SharpDX.IO</Namespace>
// <Namespace>SharpDX.Mathematics.Interop</Namespace>
// <Namespace>System.Net.Http</Namespace>
// <Namespace>System.Threading.Tasks</Namespace>
// <Namespace>WIC = SharpDX.WIC</Namespace>
// <Namespace>SharpDX</Namespace>
// <Namespace>System.Runtime.InteropServices</Namespace>
// <Namespace>Microsoft.Win32</Namespace>
// <Namespace>System.Windows.Forms</Namespace>
//</Query>
HttpClient http = new HttpClient();
async Task Main()
{
$"Get bing url...".Dump();
string url = await GetBingPicture();
$"Get quote...".Dump();
string english = await GetQuote();
$"Download {url}...".Dump();
string file = await DownloadUrlAsFileName(url);
$"Generating...".Dump();
string wallpaperFileName = GenerateWallpaper(file, english);
Wallpaper.Set(wallpaperFileName, UserQuery.Wallpaper.Style.Centered);
Util.Image(wallpaperFileName.Dump()).Dump();
}
string GenerateWallpaper(string pictureFileName, string english)
{
var wic = new WIC.ImagingFactory2();
var d2d = new D2D.Factory();
float dpi = d2d.DesktopDpi.Width;
Size2 size = new Size2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
WIC.FormatConverter image = CreateWicImage(wic, pictureFileName);
using (var wicBitmap = new WIC.Bitmap(wic, size.Width, size.Height, WIC.PixelFormat.Format32bppPBGRA, WIC.BitmapCreateCacheOption.CacheOnDemand))
using (var target = new D2D.WicRenderTarget(d2d, wicBitmap, new D2D.RenderTargetProperties()))
using (var dc = target.QueryInterface<D2D.DeviceContext>())
using (var bmpPicture = D2D.Bitmap.FromWicBitmap(target, image))
using (var dwriteFactory = new SharpDX.DirectWrite.Factory())
using (var brush = new SolidColorBrush(target, SharpDX.Color.Yellow))
using (var bmpLayer = new D2D.Bitmap1(dc, target.PixelSize,
new D2D.BitmapProperties1(new D2D.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Premultiplied), dpi, dpi, D2D.BitmapOptions.Target)))
{
var oldTarget = dc.Target;
dc.Target = bmpLayer;
target.BeginDraw();
{
var textFormat = new DWrite.TextFormat(dwriteFactory, "Tahoma", size.Height / 27);
// draw English
{
var textLayout = new DWrite.TextLayout(dwriteFactory, english, textFormat, target.Size.Width * 0.75f, float.MaxValue);
var center = new Vector2((target.Size.Width - textLayout.Metrics.Width) / 2, (target.Size.Height - textLayout.Metrics.Height) / 2);
target.DrawTextLayout(new Vector2(center.X, center.Y), textLayout, brush);
}
}
target.EndDraw();
// shadow
var shadow = new D2D.Effects.Shadow(dc);
shadow.SetInput(0, bmpLayer, new RawBool(false));
dc.Target = oldTarget;
target.BeginDraw();
{
target.DrawBitmap(bmpPicture, new RectangleF(0, 0, target.Size.Width, target.Size.Height), 1.0f, BitmapInterpolationMode.Linear);
dc.DrawImage(shadow, new Vector2(size.Height / 150.0f, size.Height / 150.0f));
dc.UnitMode = UnitMode.Pixels;
target.DrawBitmap(bmpLayer, 1.0f, BitmapInterpolationMode.Linear);
}
target.EndDraw();
string wallpaperFileName = Path.GetTempPath() + "wallpaper.png";
using (var wallpaperStream = File.OpenWrite(wallpaperFileName))
{
SaveD2DBitmap(wic, wicBitmap, wallpaperStream);
wallpaperStream.Close();
return wallpaperFileName;
}
}
}
async Task<string> GetQuote()
{
var url = @"https://favqs.com/api/qotd";
var content = await http.GetStringAsync(url);
var json = JToken.Parse(content);
return json["quote"]["body"] + "\r\n\t\t\t\t——" + json["quote"]["author"];
}
async Task<string> GetBingPicture()
{
var url = @"https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=5&mkt=zh-cn";
var content = await http.GetStringAsync(url);
var json = JToken.Parse(content);
var images = json["images"]
.Select(x => x["url"].ToString())
.Select(x => "https://cn.bing.com" + x);
return images.First();
}
async Task<string> DownloadUrlAsFileName(string url)
{
var fileName = Path.GetTempFileName();
File.WriteAllBytes(fileName, await http.GetByteArrayAsync(url));
return fileName;
}
WIC.FormatConverter CreateWicImage(WIC.ImagingFactory wicFactory, string filename)
{
using (var decoder = new WIC.JpegBitmapDecoder(wicFactory))
using (var decodeStream = new WIC.WICStream(wicFactory, filename, NativeFileAccess.Read))
{
decoder.Initialize(decodeStream, WIC.DecodeOptions.CacheOnLoad);
using (var decodeFrame = decoder.GetFrame(0))
{
var converter = new WIC.FormatConverter(wicFactory);
converter.Initialize(decodeFrame, WIC.PixelFormat.Format32bppPBGRA);
return converter;
}
}
}
void SaveD2DBitmap(WIC.ImagingFactory wicFactory, WIC.Bitmap wicBitmap, Stream outputStream)
{
using (var encoder = new WIC.BitmapEncoder(wicFactory, WIC.ContainerFormatGuids.Png))
{
encoder.Initialize(outputStream);
using (var frame = new WIC.BitmapFrameEncode(encoder))
{
frame.Initialize();
frame.SetSize(wicBitmap.Size.Width, wicBitmap.Size.Height);
var pixelFormat = wicBitmap.PixelFormat;
frame.SetPixelFormat(ref pixelFormat);
frame.WriteSource(wicBitmap);
frame.Commit();
encoder.Commit();
}
}
}
public sealed class Wallpaper
{
const int SPI_SETDESKWALLPAPER = 20;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
public enum Style : int
{
Tiled,
Centered,
Stretched
}
public static void Set(string pictureFileName, Style style)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
if (style == Style.Stretched)
{
key.SetValue(@"WallpaperStyle", 2.ToString());
key.SetValue(@"TileWallpaper", 0.ToString());
}
if (style == Style.Centered)
{
key.SetValue(@"WallpaperStyle", 1.ToString());
key.SetValue(@"TileWallpaper", 0.ToString());
}
if (style == Style.Tiled)
{
key.SetValue(@"WallpaperStyle", 1.ToString());
key.SetValue(@"TileWallpaper", 1.ToString());
}
SystemParametersInfo(SPI_SETDESKWALLPAPER,
0,
pictureFileName,
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}
}
}
}
...@@ -29,5 +29,6 @@ namespace OnlineStore.ACSingleStore ...@@ -29,5 +29,6 @@ namespace OnlineStore.ACSingleStore
MessageBox.Show(ex.ToString()); MessageBox.Show(ex.ToString());
} }
} }
} }
} }
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="FrmAxisDebug.cs"> <Compile Include="FrmAxisDebug.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!