Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Fixed #4 截图多张以后点击其它的程序窗口,某几张图就会被盖住
Browse files Browse the repository at this point in the history
Fixed #4 截图多张以后点击其它的程序窗口,某几张图就会被盖住

Fixed #5 无法调整程序的大小

Fixed 从回收站拿出来的图片会报NULL引用

Fixed 重启后,之前的截图双击位置不对

Fixed 4k屏移动截图时会有卡顿现象

Update Version
  • Loading branch information
tylearymf committed Aug 17, 2019
1 parent 6854841 commit 1b6ca39
Show file tree
Hide file tree
Showing 18 changed files with 1,046 additions and 658 deletions.
2 changes: 1 addition & 1 deletion AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: System.Runtime.InteropServices.Guid("4483e561-8b3e-427d-98a4-e0e821b7bf2f")]
[assembly: System.Reflection.AssemblyConfiguration("")]
[assembly: System.Reflection.AssemblyFileVersion("2.5.1")]
[assembly: System.Reflection.AssemblyFileVersion("2.5.2")]
[assembly: System.Runtime.CompilerServices.CompilationRelaxations(8)]
[assembly: System.Runtime.CompilerServices.RuntimeCompatibility(WrapNonExceptionThrows = true)]

2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Mainform implement = new Mainform();
Mainform implement = Mainform.instance;
instance.AddSingletonFormListener(implement);
implement.CommandRun(args);
Application.Run(implement);
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
>>>> - Win10周年更新以上
>>>> - .Net Framework 4.7以上
- 支持电脑重启后继续显示之前未关闭的截图(保留截图信息:位置和是否缩放)
- 支持开机启动
- 支持配置开机启动、支持配置截图始终置顶
>> 配置方法:选项->常规->其他
---

## 目前已知问题
- 4k屏移动截图时会有卡顿现象
- 重启后,之前的截图双击位置不对
- 从回收站拿出来的图片会报NULL引用

- 暂无
---

## 后续要加的功能
Expand Down
2 changes: 2 additions & 0 deletions SETUNA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@
</Compile>
<Compile Include="SETUNA\Main\Other\AutoStartup.cs" />
<Compile Include="SETUNA\Main\Other\DPIUtils.cs" />
<Compile Include="SETUNA\Main\Other\LayerManager.cs" />
<Compile Include="SETUNA\Main\Other\MyConsole.cs" />
<Compile Include="SETUNA\Main\Other\WindowsAPI.cs" />
<Compile Include="SETUNA\Main\RGBColor.cs" />
<Compile Include="SETUNA\Main\ScrapBase.cs">
<SubType>Form</SubType>
Expand Down
133 changes: 94 additions & 39 deletions SETUNA/Main/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,41 @@ namespace SETUNA.Main
public class ScrapBaseInfo
{
[NonSerialized]
Image mImage;
Image mSerialImage;
ScrapWeightInfo mWeightInfo;

public ScrapWeightInfo weightInfo { get => mWeightInfo; private set => mWeightInfo = value; }

public string name { set; get; }
public Image image
{
private set
{
mImage = value;
mSerialImage = new Bitmap(value);
}
get
{
return mImage;
}
get => weightInfo.image;
}

public string name { set; get; }
public int posX { set; get; }
public int posY { set; get; }
public int imageWidth { private set; get; }
public int imageHeight { private set; get; }
public string guid { private set; get; }
public int imageWidth { set; get; }
public int imageHeight { set; get; }
public string guid { set; get; }
public int styleID { set; get; }
public Point stylePoint { set; get; }

protected ScrapBaseInfo() { }

public ScrapBaseInfo(Image pImage, int pPosX, int pPosY, int pImageWidth, int pImageHeight, string pGuid)
{
weightInfo = new ScrapWeightInfo(pImage);

name = string.Empty;
image = pImage;
posX = pPosX;
posY = pPosY;
imageWidth = pImageWidth;
imageHeight = pImageHeight;
guid = pGuid;
}

public void Init()
public void InitWeightInfo(ScrapWeightInfo pInfo)
{
if (mSerialImage == null || mImage != null) return;

mImage = new Bitmap(mSerialImage);
weightInfo = pInfo;
}

public override string ToString()
Expand All @@ -66,18 +59,58 @@ public override string ToString()

public string GetFileName()
{
return guid + CacheManager.cExtension;
return CacheManager.cInfoName1 + CacheManager.cExtension;
}

public string GetFolderName()
{
return Path.Combine(CacheManager.path, guid);
}
}

[Serializable]
public class ScrapWeightInfo
{
[NonSerialized]
Image mImage;
Image mSerialImage;

public ScrapWeightInfo(Image pImage)
{
image = pImage;
}

public Image image
{
private set
{
mImage = value;
mSerialImage = new Bitmap(value);
}
get
{
return mImage;
}
}

public string GetFullName()
public void Init()
{
return Path.Combine(CacheManager.path, GetFileName());
if (mSerialImage == null || mImage != null) return;

mImage = new Bitmap(mSerialImage);
}

public string GetFileName()
{
return CacheManager.cInfoName2 + CacheManager.cExtension;
}
}

public class CacheManager
{
public const string cExtension = ".dat";
public const string cInfoName1 = "info1";
public const string cInfoName2 = "info2";

static string mPath;
static public string path
Expand All @@ -100,21 +133,30 @@ static public void Init(Action<ScrapBaseInfo> pCallBack)
}

var tInfo = new DirectoryInfo(path);
var tFiles = tInfo.GetFiles("*" + cExtension);
foreach (var tFileInfo in tFiles)
var tDirectories = tInfo.GetDirectories("*", SearchOption.TopDirectoryOnly);
foreach (var tDirectoryInfo in tDirectories)
{
try
{
var tCacheInfo = Deserialize<ScrapBaseInfo>(tFileInfo.FullName);
if (tCacheInfo == null) continue;
tCacheInfo.Init();
MyConsole.WriteLine(tCacheInfo.ToString());
var tFolderName = tDirectoryInfo.FullName;
var tInfoPath1 = Path.Combine(tFolderName, cInfoName1 + cExtension);
var tInfoPath2 = Path.Combine(tFolderName, cInfoName2 + cExtension);

pCallBack(tCacheInfo);
}
catch (Exception ex)
if (File.Exists(tInfoPath1) && File.Exists(tInfoPath2))
{
MyConsole.WriteLine("加载图片失败:" + ex.ToString());
try
{
var tInfo1 = Deserialize<ScrapBaseInfo>(tInfoPath1);
var tInfo2 = Deserialize<ScrapWeightInfo>(tInfoPath2);

tInfo2.Init();
tInfo1.InitWeightInfo(tInfo2);
MyConsole.WriteLine(tInfo1.ToString());

pCallBack(tInfo1);
}
catch (Exception ex)
{
MyConsole.WriteLine("加载图片失败:" + ex.ToString());
}
}
}
}
Expand All @@ -125,7 +167,20 @@ static public void SaveCacheInfo(ScrapBaseInfo pInfo)

try
{
Serialize(pInfo, pInfo.GetFullName());
var tFolderName = pInfo.GetFolderName();
if (!Directory.Exists(tFolderName))
{
Directory.CreateDirectory(tFolderName);
}

var tPath = Path.Combine(tFolderName, pInfo.GetFileName());
Serialize(pInfo, tPath);

tPath = Path.Combine(tFolderName, pInfo.weightInfo.GetFileName());
if (!File.Exists(tPath))
{
Serialize(pInfo.weightInfo, tPath);
}

MyConsole.WriteLine("缓存图片成功. {0}", pInfo.ToString());
}
Expand All @@ -139,10 +194,10 @@ static public void DeleteCacheInfo(ScrapBaseInfo pInfo)
{
try
{
var tPath = pInfo.GetFullName();
if (File.Exists(tPath))
var tPath = pInfo.GetFolderName();
if (Directory.Exists(tPath))
{
File.Delete(tPath);
Directory.Delete(tPath, true);
}
MyConsole.WriteLine("删除图片成功. {0}", pInfo.ToString());
}
Expand Down
10 changes: 10 additions & 0 deletions SETUNA/Main/CaptureForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,17 @@ private void InitializeComponent()
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.CaptureForm_MouseMove);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.CaptureForm_MouseUp);
this.ResumeLayout(false);
}

LayerInfo mLayerInfo;
protected override void OnLoad(EventArgs e)
{
mLayerInfo = new LayerInfo(this);
}

protected override void OnClosed(EventArgs e)
{
mLayerInfo.Dispose();
}

[DllImport("user32.dll")]
Expand Down
Loading

0 comments on commit 1b6ca39

Please sign in to comment.