Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自動予約登録一覧で、「削除(予約ごと削除)」をボタンとコンテキストメニューに追加 #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions EpgTimer/EpgTimer/UserCtrlView/EpgAutoAddView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</ContextMenu>
<ContextMenu x:Key="itemMenu" x:Name="cmdMenu" >
<MenuItem Header="削除" Click="button_del_Click" InputGestureText="Delete" />
<MenuItem Header="削除(予約ごと削除)" Click="button_del2_Click" />
<MenuItem Header="変更" Click="button_change_Click" InputGestureText="Enter "/>
</ContextMenu>
</UserControl.Resources>
Expand Down Expand Up @@ -124,9 +125,10 @@
</ListView.View>
</ListView>
<StackPanel Grid.Column="1" Name="stackPanel_button">
<Button Content="追加" Height="23" Name="button_add" Margin="0,10,0,10" Click="button_add_Click" Style="{StaticResource ButtonStyle1}" />
<Button Content="削除" Height="23" Name="button_del" Margin="0,10,0,10" Click="button_del_Click" Style="{StaticResource ButtonStyle1}" />
<Button Content="変更" Height="23" Name="button_change" Margin="0,10,0,10" Click="button_change_Click" Style="{StaticResource ButtonStyle1}" />
<Button Content="追加" Height="23" Name="button_add" Margin="0,10,0,5" Click="button_add_Click" Style="{StaticResource ButtonStyle1}" />
<Button Content="削除" Height="23" Name="button_del" Margin="0,5,0,5" Click="button_del_Click" Style="{StaticResource ButtonStyle1}" />
<Button Content="削除(予約ごと削除)" Height="23" Name="button_del2" Margin="0,5,0,5" Click="button_del2_Click" Style="{StaticResource ButtonStyle1}" />
<Button Content="変更" Height="23" Name="button_change" Margin="0,5,0,10" Click="button_change_Click" Style="{StaticResource ButtonStyle1}" />
<!--<Button Content="↑" Height="23" Name="button_up" Margin="0,20,0,5" Click="button_up_Click" Style="{StaticResource ButtonStyle1}" />-->
<!--<Button Content="↓" Height="23" Name="button_down" Margin="0,5,0,10" Click="button_down_Click" Style="{StaticResource ButtonStyle1}" />-->
<Button Content="↑" Height="23" Name="button_up" Margin="0,20,0,5" Click="button_up_Click2" Style="{StaticResource ButtonStyle1}" ToolTip="Ctrl + ↑" />
Expand Down
71 changes: 71 additions & 0 deletions EpgTimer/EpgTimer/UserCtrlView/EpgAutoAddView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,77 @@ private void button_del_Click(object sender, RoutedEventArgs e)
}
}

private void button_del2_Click(object sender, RoutedEventArgs e)
{
if (listView_key.SelectedItems.Count == 0) { return; }

string text1 = "予約項目ごと削除してよろしいですか?\r\n"
+ "(無効の「自動予約登録項目」による予約は削除されません。)";
string caption1 = "削除(予約ごと削除)の確認";
if (MessageBox.Show(text1, caption1, MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation, MessageBoxResult.OK) != MessageBoxResult.OK)
{
return;
}

try
{
//配下の予約の削除

//検索リストの取得
List<EpgSearchKeyInfo> keyList = new List<EpgSearchKeyInfo>();
List<EpgEventInfo> list = new List<EpgEventInfo>();

foreach (EpgAutoDataItem info in listView_key.SelectedItems)
{
if (info.KeyEnabled == "はい")
{
keyList.Add(info.EpgAutoAddInfo.searchInfo);
}
}

if( keyList.Count>0 )//ここが0(=全て無効)でも予約項目自体の削除あるのでreturnはしない。
{
cmd.SendSearchPg(keyList, ref list);

List<UInt32> dellist = new List<UInt32>();

foreach (EpgEventInfo info in list)
{
if (info.start_time.AddSeconds(info.durationSec) > DateTime.Now)
{
foreach (ReserveData info2 in CommonManager.Instance.DB.ReserveList.Values)
{
if (info.original_network_id == info2.OriginalNetworkID &&
info.transport_stream_id == info2.TransportStreamID &&
info.service_id == info2.ServiceID &&
info.event_id == info2.EventID)
{
//重複したEpgEventInfoは送られてこないので、登録時の重複チェックは不要
dellist.Add(info2.ReserveID);
break;
}
}
}
}

if (dellist.Count > 0)
{
cmd.SendDelReserve(dellist);
CommonManager.Instance.DB.SetUpdateNotify((UInt32)UpdateNotifyItem.ReserveInfo);
CommonManager.Instance.DB.ReloadReserveInfo();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
}

//自動予約登録項目自体の削除
button_del_Click(sender, e);
}

private void button_change_Click(object sender, RoutedEventArgs e)
{
try
Expand Down