Skip to content

Commit

Permalink
1、简化配置;2、解决BUG。
Browse files Browse the repository at this point in the history
  • Loading branch information
newdraw committed Feb 26, 2021
1 parent 812ac2e commit 6b95b1c
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 166 deletions.
3 changes: 2 additions & 1 deletion AppTime/AppTime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationVersion>0.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -269,6 +269,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="webui\content\review.html" />
<Content Include="webui\img\icon.png" />
<Content Include="webui\index.html" />
</ItemGroup>
<ItemGroup>
Expand Down
21 changes: 15 additions & 6 deletions AppTime/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,20 @@ where @v0 between timeStart and timeEnd
};
}

static byte[] defaultIcon;

public byte[] getIcon(int appId, bool large)
{
var path = Recorder.GetIconPath(appId, large);
if (File.Exists(path))
{
return File.ReadAllBytes(path);
}
return null;
if (defaultIcon == null)
{
defaultIcon = File.ReadAllBytes("./webui/img/icon.png");
}
return defaultIcon;
}

static byte[] imageNone = null;
Expand Down Expand Up @@ -472,15 +478,18 @@ public byte[] getImage(TimeInfo info)

//从文件系统找
{
var path = Recorder.getFileName(info.timeSrc);
var files = (from f in Directory.GetFiles(Path.GetDirectoryName(path), "????????." + Recorder.ExName) orderby f select f).ToArray();
var needtime = info.timeSrc.TimeOfDay;// getTime(path);
var match = find(files, i => getTime(i) > needtime);
var path = Recorder.getFileName(info.timeSrc);
var needtime = info.timeSrc.TimeOfDay;
var needtimetext = needtime.ToString("hhmmss");
var match = (from f in Directory.GetFiles(Path.GetDirectoryName(path), "????????." + Recorder.ExName)
where Path.GetFileNameWithoutExtension(f).CompareTo(needtimetext) < 0
orderby f
select f).LastOrDefault();
if (match != null)
{
var time = needtime - getTime(match);
var data = Ffmpeg.Snapshot(match, time);
if (data != null)
if (data != null && data.Length > 0)
{
return data;
}
Expand Down
2 changes: 1 addition & 1 deletion AppTime/Ffmpeg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void Save(string file, params Frame[] images)
}

var rate = images.Length / ((images.Last().Time - images.First().Time).TotalSeconds + 1);
var crf = (100 - Settings.Default.ImageQuality) / 100d * 63;
var crf = Settings.Default.ImageQuality;//0-质量最高 63-质量最低 实测40质量也不错且体积较小

var tempfile = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + ".tmp");

Expand Down
134 changes: 23 additions & 111 deletions AppTime/FrmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions AppTime/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ private void FrmMain_Load(object sender, EventArgs e)
new {Text="不留存", Value=0},
};
cboRecordScreen.DisplayMember = "Text";
cboRecordScreen.ValueMember = "Value";
cboRecordScreen.ValueMember = "Value";

cboImageQuality.DataSource = new[] {
new {Text="最省磁盘", Value=63},
new {Text="均衡", Value=50},
new {Text="高质量", Value=40},
};
cboImageQuality.DisplayMember = "Text";
cboImageQuality.ValueMember = "Value";
}

private void btnOpen_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -88,8 +96,7 @@ private void btnOK_Click(object sender, EventArgs e)
{
MessageBox.Show("数据存储位置无效,请重新选择。");
}
Settings.Default.BufferSeconds = trackBufferSeconds.Value;
Settings.Default.ImageQuality = trackImageQuality.Value;
Settings.Default.ImageQuality = (int) cboImageQuality.SelectedValue;
Settings.Default.RecordScreenDays = (int)cboRecordScreen.SelectedValue;
Settings.Default.Save();

Expand Down Expand Up @@ -130,10 +137,8 @@ private void btnSetting_Click(object sender, EventArgs e)
{
txtDataPath.Text = Settings.Default.DataPath;
}
cboRecordScreen.SelectedValue = Settings.Default.RecordScreenDays;
trackBufferSeconds.Value = Settings.Default.BufferSeconds;
trackImageQuality.Value = Settings.Default.ImageQuality;
trackBufferSeconds_Scroll(null, null);
cboRecordScreen.SelectedValue = Settings.Default.RecordScreenDays;
cboImageQuality.SelectedValue = Settings.Default.ImageQuality;

using var reg = Registry.CurrentUser.CreateSubKey(regkey);
chkAutoRun.Checked = (reg.GetValue(appname) as string) == Application.ExecutablePath;
Expand All @@ -144,7 +149,7 @@ private void btnSetting_Click(object sender, EventArgs e)

private void btnAbout_Click(object sender, EventArgs e)
{
MessageBox.Show($"AppTime桌面时间管理\r\n\r\n联系作者:[email protected]", "关于", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show($"AppTime桌面时间管理\r\nV{Application.ProductVersion}\r\n\r\n联系作者:[email protected]", "关于", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

private void btnDataPath_Click(object sender, EventArgs e)
Expand All @@ -153,12 +158,8 @@ private void btnDataPath_Click(object sender, EventArgs e)
if(dlg.ShowDialog()== DialogResult.OK)
{
txtDataPath.Text = dlg.SelectedPath;
}
}

private void trackBufferSeconds_Scroll(object sender, EventArgs e)
{
lblBufferSeconds.Text = Math.Round(TimeSpan.FromSeconds(trackBufferSeconds.Value).TotalMinutes) + "分钟";
}
}

}
}
Loading

0 comments on commit 6b95b1c

Please sign in to comment.