Skip to content

Commit

Permalink
1.修正文件命名规则在没有 imgp[n] 时(除图册外)添加页数的BUG
Browse files Browse the repository at this point in the history
2.增加文件命名规则设置中快捷插入格式标签
3.屏蔽Pixiv站点在 TagFull 搜索无结果时的报错提示
  • Loading branch information
usaginya committed Jun 9, 2017
1 parent 699bd7c commit c1b42d8
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 88 deletions.
21 changes: 16 additions & 5 deletions MoeLoaderDelta/Control/DownloadControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,29 @@ private void RefreshList()
path = saveLocation + "\\";
}

//检查路径长度
//检查目录长度
if (path.Length > 248)
{
downloadItems[downloadItems.Count - numLeft].StatusE = DLStatus.Failed;
downloadItems[downloadItems.Count - numLeft].Size = "路径太长";
WriteErrText(url + ": 路径太长");
j--;
}
else
{
dlitem.LocalFileName = ReplaceInvalidPathChars(file, path, 0);
file = dlitem.LocalName = path + dlitem.LocalFileName;

dlitem.LocalFileName = ReplaceInvalidPathChars(file, path, 0);
file = dlitem.LocalName = path + dlitem.LocalFileName;

//检查全路径长度
if (file.Length > 258)
{
downloadItems[downloadItems.Count - numLeft].StatusE = DLStatus.Failed;
downloadItems[downloadItems.Count - numLeft].Size = "路径太长";
WriteErrText(url + ": 路径太长");
j--;
}
}

if (File.Exists(file))
{
downloadItems[downloadItems.Count - numLeft].StatusE = DLStatus.IsHave;
Expand Down Expand Up @@ -406,7 +417,7 @@ private void WriteErrText(string content)
{
try
{
File.AppendAllText(saveLocation + "\\moeloder_error.log", content + "\r\n");
File.AppendAllText(saveLocation + "\\moedl_error.log", content + "\r\n");
}
catch { }
}
Expand Down
21 changes: 15 additions & 6 deletions MoeLoaderDelta/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ private void PlayPreNextAnimation(int btnid)
btna.Duration = TimeSpan.FromMilliseconds(666);
switch (btnid)
{

case 0:
{
Storyboard sb = FindResource("sbShowPageBtnPrev") as Storyboard;
Expand Down Expand Up @@ -1957,14 +1957,23 @@ private string GenFileName(Img img)
{
result = mc[i];
imgpPatter = result.Groups["all"].ToString();
zerofill = Int32.Parse(result.Groups["zf"].ToString());
if (img.ImgP != "")
file = file.Replace(imgpPatter, img.ImgP.PadLeft(zerofill, '0'));
else
zerofill = int.Parse(result.Groups["zf"].ToString());
if (string.IsNullOrWhiteSpace(img.ImgP))
file = file.Replace(imgpPatter, "0".PadLeft(zerofill, '0'));
else
file = file.Replace(imgpPatter, img.ImgP.PadLeft(zerofill, '0'));
}

if (resc < 1)
file += img.ImgP.PadLeft(3, '0');
{
//如果图册有数量就强制加序号
if (int.Parse(img.ImgP) > 0)
file += img.ImgP.PadLeft(4, '0');

//移除错误的标签格式
reg = new Regex(@"%imgp\[.*?\]+");
file = reg.Replace(file, "");
}
}
catch { }
#endregion
Expand Down
69 changes: 59 additions & 10 deletions MoeLoaderDelta/OptionWnd.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="Window"
Width="400"
Height="465"
Closing="Window_Closing"
Height="505"
Icon="m.ico"
ResizeMode="NoResize"
ShowInTaskbar="True"
Expand All @@ -18,7 +17,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="135" />
<!--<RowDefinition Height="70"/>-->
<RowDefinition Height="131" />
<RowDefinition Height="168" />
<RowDefinition Height="120" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
Expand Down Expand Up @@ -180,15 +179,9 @@
IsEnabled="False"
Text="127.0.0.1:1080"
TextWrapping="NoWrap" />
<!--<CheckBox x:Name="chkProxy" HorizontalAlignment="Left" Content="地址" Margin="10,0,0,0" VerticalAlignment="Center" Click="chkProxy_Click"/>-->
</Grid>
</GroupBox>
<!--<GroupBox Header="老板键设置" Margin="5,2" Grid.Row="1">
<Grid>
<TextBox x:Name="txtBossKey" Margin="100,13,20,9" Text="" TextWrapping="NoWrap" VerticalAlignment="Center" PreviewKeyDown="txtBossKey_PreviewKeyDown"/>
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="老板键" Margin="10,0,0,0" VerticalAlignment="Center"/>
</Grid>
</GroupBox>-->

<GroupBox
Grid.Row="1"
Margin="5,2"
Expand Down Expand Up @@ -285,6 +278,62 @@
MouseDown="textNameHelp_MouseDown"
Text="?"
TextDecorations="Underline" />
<Button
x:Name="FNRsite"
Margin="97,0,0,24"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%site"
ToolTip="插入 站点 格式" />
<Button
x:Name="FNRid"
Margin="136,0,0,24"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%id"
ToolTip="插入 作品ID 格式" />
<Button
x:Name="FNRtag"
Margin="165,0,0,24"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%tag"
ToolTip="插入 作品标签 格式" />
<Button
x:Name="FNRdesc"
Margin="202,0,0,24"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%desc"
ToolTip="插入 作品描述 格式" />
<Button
x:Name="FNRauthor"
Margin="247,0,0,24"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%author"
ToolTip="插入 作者名 格式" />
<Button
x:Name="FNRdate"
Margin="304,0,0,24"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%date"
ToolTip="插入 上载时间 格式" />
<Button
x:Name="FNRimgp"
Margin="97,0,0,2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="%imgp[n]"
ToolTip="插入 图片页数[补0个数] 格式" />
<Button
x:Name="FNRcut"
Margin="160,0,0,2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Content="&lt;!&lt;"
ToolTip="插入 文件名裁剪符 格式" />
</Grid>
</GroupBox>
<TextBlock
Expand Down
93 changes: 44 additions & 49 deletions MoeLoaderDelta/OptionWnd.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

Expand All @@ -23,18 +24,8 @@ public OptionWnd(MainWindow main)
FontFamily = new FontFamily("Microsoft YaHei");
}

//if (System.Environment.OSVersion.Version.Major >= 6)
//{
// if (GlassHelper.DwmIsCompositionEnabled())
// {
// chkAero.IsEnabled = true;
// }
//}

//SetColor(main.GetColor());
//chkPos.IsChecked = main.rememberPos;
txtProxy.Text = MainWindow.Proxy;
//chkProxy.IsChecked = MainWindow.ProxyEnable;

rtNoProxy.IsChecked = true;
if (MainWindow.ProxyType == ProxyType.System)
{
Expand Down Expand Up @@ -99,26 +90,18 @@ public OptionWnd(MainWindow main)
+ "<!< 裁剪符号【注意裁剪符号 <!< 只能有一个】\r\n"
+ "表示从 <!< 左边所有名称进行过长裁剪、避免路径过长问题\r\n"
+ "建议把裁剪符号写在 标签%tag 或 描述%desc 后面";
}

//private void SetColor(Color c)
//{
// sr.Value = c.R;
// sg.Value = c.G;
// sb.Value = c.B;
// sa.Value = c.A;
//}

//private void SetMainColor()
//{
// Color c = Color.FromArgb((byte)sa.Value, (byte)sr.Value, (byte)sg.Value, (byte)sb.Value);
// main.SetBackColorLive(c);
//}

//private void s_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
//{
// SetMainColor();
//}
#region 文件名规则格式按钮绑定
FNRsite.Click += new RoutedEventHandler(FNRinsert);
FNRid.Click += new RoutedEventHandler(FNRinsert);
FNRtag.Click += new RoutedEventHandler(FNRinsert);
FNRdesc.Click += new RoutedEventHandler(FNRinsert);
FNRauthor.Click += new RoutedEventHandler(FNRinsert);
FNRdate.Click += new RoutedEventHandler(FNRinsert);
FNRimgp.Click += new RoutedEventHandler(FNRinsert);
FNRcut.Click += new RoutedEventHandler(FNRinsert);
#endregion
}

private void Button_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -227,39 +210,29 @@ private void Button_Click(object sender, RoutedEventArgs e)
main.bgImg.AlignmentX = main.bgHe;
main.bgImg.AlignmentY = main.bgVe;
}
//Color c = Color.FromArgb((byte)sa.Value, (byte)sr.Value, (byte)sg.Value, (byte)sb.Value);
//OK
//main.SetBackColor(c);
//main.isAero = chkAero.IsChecked.Value;

PreFetcher.CachedImgCount = int.Parse(txtCount.Text);

DownloadControl.SaveLocation = txtSaveLocation.Text;
main.downloadC.IsSepSave = chkSepSave.IsChecked.Value;
main.downloadC.IsSaSave = chkSaSave.IsChecked.Value;
main.downloadC.NumOnce = int.Parse(txtParal.Text);
//main.rememberPos = chkPos.IsChecked.Value;

Close();
}

private void Button1_Click(object sender, RoutedEventArgs e)
{
//cancel
//main.RestoreColor();
this.Close();
}

private void Button2_Click(object sender, RoutedEventArgs e)
{
//default
//SetColor(Color.FromArgb(0x21, 0x7C, 0x9E, 0xBE));
txtProxy.Text = "127.0.0.1:1080";
txtPattern.Text = MainWindow.DefaultPatter;
txtBossKey.Text = System.Windows.Forms.Keys.F9.ToString();
//chkProxy.IsChecked = false;
rtNoProxy.IsChecked = true;
//txtProxy.IsEnabled = false;
//chkPos.IsChecked = false;
//chkAero.IsChecked = true;
txtCount.Text = "6";
chkProxy_Click(null, null);
txtParal.Text = "2";
Expand All @@ -269,11 +242,6 @@ private void Button2_Click(object sender, RoutedEventArgs e)
txtSaveLocation.Text = "MoeLoaderGallery";
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//main.RestoreColor();
}

private void txtBossKey_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.System && e.Key != Key.LeftAlt && e.Key != Key.LeftCtrl && e.Key != Key.LeftShift
Expand Down Expand Up @@ -343,7 +311,7 @@ private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
+ "\r\nMoeLoader ©2008-2013 esonic All rights reserved.\r\n\r\n"
+ "Δ Version by YIU\r\n"
+ "Email: degdod@qq.com\r\nSite: http://usaginya.lofter.com/"
+ "\r\nMoeLoaderΔ ©2016-2017 Moekai All rights reserved.\r\n\r\n"
+ "\r\nMoeLoader Δ ©2016-2017 Moekai All rights reserved.\r\n\r\n"
, MainWindow.ProgramName + " - About", MessageBoxButton.OK, MessageBoxImage.Information);
}

Expand Down Expand Up @@ -371,7 +339,7 @@ private void textNameHelp_MouseDown(object sender, MouseButtonEventArgs e)

private void TextBlock_MouseDown_1(object sender, MouseButtonEventArgs e)
{
MessageBox.Show(this, "将图片文件重命名为 bg.png 或 bg.jpg 后放入 MoeLoaderDelta.exe 所在目录,重启 MoeLoaderDelta Δ 即可",
MessageBox.Show(this, "将图片文件重命名为 bg.png 或 bg.jpg 后放入 MoeLoaderDelta.exe 所在目录,重启 MoeLoader Δ 即可",
MainWindow.ProgramName, MessageBoxButton.OK, MessageBoxImage.Information);
}

Expand All @@ -380,5 +348,32 @@ private void chkSepSave_Click(object sender, RoutedEventArgs e)
chkSaSave.IsEnabled = chkSepSave.IsChecked == null ? false : (bool)chkSepSave.IsChecked;
}

/// <summary>
/// 插入格式到规则文本框
/// </summary>
private void FNRinsert(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
string format = btn.Content.ToSafeString();
int selectstart = txtPattern.SelectionStart;

if (string.IsNullOrWhiteSpace(txtPattern.SelectedText))
{
if (format.Contains("imgp"))
txtPattern.Text = txtPattern.Text.Insert(selectstart, format.Replace("n", "3"));
else
txtPattern.Text = txtPattern.Text.Insert(selectstart, format);
}
else
{
if (format.Contains("imgp"))
txtPattern.SelectedText = format.Replace("n", "3");
else
txtPattern.SelectedText = format;
txtPattern.SelectionLength = 0;
}
txtPattern.SelectionStart = selectstart + format.Length;
txtPattern.Focus();
}
}
}
4 changes: 2 additions & 2 deletions MoeLoaderDelta/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.4.2")]
[assembly: AssemblyFileVersion("7.0.4.2")]
[assembly: AssemblyVersion("7.0.4.3")]
[assembly: AssemblyFileVersion("7.0.4.3")]
[assembly: GuidAttribute("e1b87586-4b7e-4f4a-be97-55d3349ed5a6")]
4 changes: 2 additions & 2 deletions SitePack/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.4")]
[assembly: AssemblyFileVersion("1.0.4.4")]
[assembly: AssemblyVersion("1.0.4.5")]
[assembly: AssemblyFileVersion("1.0.4.5")]
Loading

0 comments on commit c1b42d8

Please sign in to comment.