5.一覧表画面
一覧表画面
画面は下記の通りです。
クリックすると拡大します
61~63行目で、Activatedを宣言しています。263~278行目がListBoxの宣言ですが、273行目が、 行を
Wクリックした時のコマンドです。
View
<ccl:CustomChromeWindow x:Class="LivetWPFChromeHelpDesk1.Views.Window10" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell" xmlns:ccl="clr-namespace:CustomChromeLibrary;assembly=CustomChromeLibrary" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:l="http://schemas.livet-mvvm.net/2011/wpf" xmlns:core="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" xmlns:v="clr-namespace:LivetWPFChromeSupportDesk1.Views" xmlns:vm="clr-namespace:LivetWPFChromeHelpDesk1.ViewModels" WindowStartupLocation="CenterScreen" Title="Window10" Height="714" Width="1035"> <shell:WindowChrome.WindowChrome> <shell:WindowChrome ResizeBorderThickness="6" CaptionHeight="43" CornerRadius="0,0,0,0" GlassFrameThickness="0"> </shell:WindowChrome> </shell:WindowChrome.WindowChrome> <Window.Resources> <ResourceDictionary> <vm:CaptionButtonRectToMarginConverter x:Key="CaptionButtonMarginConverter"/> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Resources/Styles2.xaml"/> <ResourceDictionary Source="/Resources/StylesBG.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources> <i:Interaction.Triggers> <l:InteractionMessageTrigger MessageKey="MessageKey20" Messenger="{Binding Messenger}"> <l:TransitionInteractionMessageAction WindowType="{x:Type v:Window20}" Mode="Modal"/> </l:InteractionMessageTrigger> <l:InteractionMessageTrigger MessageKey="MessageKey21" Messenger="{Binding Messenger}"> <l:TransitionInteractionMessageAction WindowType="{x:Type v:Window20}" Mode="Modal"/> </l:InteractionMessageTrigger> <!--WindowのContentRenderedイベントのタイミングでViewModelのInitialize メソッドが呼ばれます--> <i:EventTrigger EventName="ContentRendered"> <l:LivetCallMethodAction MethodTarget="{Binding}" MethodName= "Initialize"/> </i:EventTrigger> <!-- 下記がないと、タスクバーが1つにならない --> <i:EventTrigger EventName="Loaded"> <i:InvokeCommandAction Command="{Binding Path=Loaded}" CommandParameter="{Binding Mode=OneTime,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"/> <i:EventTrigger EventName="Activated" " <i:InvokeCommandAction Command="{Binding ActivatedCommand}" /" </i:EventTrigger" </i:EventTrigger> <i:EventTrigger EventName="Closing"> <i:InvokeCommandAction Command="{Binding Path=Closing}" CommandParameter="{Binding Mode=OneTime,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"/> </i:EventTrigger> <l:InteractionMessageTrigger MessageKey="Close" Messenger="{Binding Messenger}"> <l:WindowInteractionMessageAction/> </l:InteractionMessageTrigger> </i:Interaction.Triggers> <!-- Grid-1 --> <Grid> <!-- WindowChrome Start --> <Border Grid.RowSpan="2" BorderThickness="3" BorderBrush="Black"> <Border.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="Black" Offset="0" /> <GradientStop Color="Black" Offset="1" /> </LinearGradientBrush> </Border.Background> </Border> <Border BorderThickness="3,3,3,1" BorderBrush="Black" Margin="{Binding Path=CaptionButtonMargin}"> <Border.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="Black" Offset="0" /> <GradientStop Color="Black" Offset="1" /> </LinearGradientBrush> </Border.Background> <!--Window Icon and Title--> <StackPanel Orientation="Horizontal" Margin="0" VerticalAlignment="Top"> <TextBlock Text=" Help Desk" FontFamily="Calibri" FontWeight="Bold" FontSize="26" Foreground="Blue" /> </StackPanel> </Border> <ccl:CaptionButtons /> <!-- WindowChrome End --> <!-- Grid-2 --> <!--Content--> <Grid Grid.Row="1"> <TextBox Text="{Binding Path=txt本日}" TextAlignment="Center" Foreground="White" Background="Black" Height="17" HorizontalAlignment="Center" Name="txt本日" VerticalAlignment="Top" Width="81" Margin="809,3,123,0" /> <!-- ★★★ --> <Button Command="{Binding Path=Goto21Command}" BorderBrush="{x:Null}" Content="詳細" Foreground="Black" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="891,113,0,0" Name="btn詳細" Width="75"> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="UIElement.IsMouseOver" Value="True"> <Setter Property="Control.Background" Value="DarkGoldenrod" /> </Trigger> </Style.Triggers> <Setter Property="Control.Background" Value="YellowGreen" /> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Control.Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Button.Style> </Button> <Button Command="{Binding Path=Goto20Command}" BorderBrush="{x:Null}" Content="新規登録" Foreground="Black" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="891,54,0,0" Name="新規登録" Width="75"> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="UIElement.IsMouseOver" Value="True"> <Setter Property="Control.Background" Value="DarkGoldenrod" /> </Trigger> </Style.Triggers> <Setter Property="Control.Background" Value="YellowGreen" /> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Control.Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Button.Style> </Button> <Button Command="{Binding Path=データバックアップCommand}" BorderBrush="{x:Null}" Content="バックアップ" Foreground="White" Height="25" Width="77" HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalContentAlignment="Left" Margin="15,498,0,0" Name="btnデータバックアップ" > <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="UIElement.IsMouseOver" Value="True"> <Setter Property="Control.Background" Value="DarkGoldenrod" /> </Trigger> </Style.Triggers> <Setter Property="Control.Background" Value="Green" /> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Control.Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Button.Style> </Button> <Button Command="{Binding Path=SearchInquiryClearCommand}" Content="Clear" Name="btnSearchInquiryClear" Height="24" Width="36" Margin="744,54,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{x:Null}" Foreground="White" > <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="Background" Value="DarkGreen"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="DarkGoldenrod"/> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> <Button Command="{Binding Path=ReRoadCommand}" Content="再表示" Name="btnReRead" Height="24" Width="75" Margin="786,54,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{x:Null}" Foreground="White" > <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="Background" Value="DarkGreen"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="DarkGoldenrod"/> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> <Button Command="{Binding Path=DeleteDataCommand}" Content="削除" Name="btnDelete" Height="25" Width="77" Margin="15,577,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{x:Null}" Foreground="Black" > <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="Background" Value="YellowGreen"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="DarkGoldenrod"/> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> <TextBox Text="{Binding Path=txtReceiptNumber, Mode=TwoWay}" Name="txtReceiptNumber" Height="24" Width="105" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="114,54,0,0" VerticalAlignment="Top" Foreground="White" Background="Black" /> <Label Content="回目" Foreground="White" Height="31" HorizontalAlignment="Left" Margin="313,53,0,0" Name="label11" VerticalAlignment="Top" Width="40" /> <TextBox Text="{Binding Path=txtNumber, Mode=TwoWay}" Name="txtNumber" Height="24" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="281,53,0,0" VerticalAlignment="Top" Width="31" Foreground="White" Background="Black" /> <Label Content="件数" Foreground="White" Height="24" HorizontalAlignment="Left" Margin="16,83,0,0" Name="label2" VerticalAlignment="Top" Width="62" /> <TextBox Text="{Binding Path=txt件数, Mode=TwoWay}" Name="txt件数" Height="24" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="114,84,0,0" VerticalAlignment="Top" Width="105" Foreground="White" Background="Black" /> <Label Content="対応状況" Foreground="White" HorizontalAlignment="Left" Margin="15,113,0,531" Name="label3" Width="63" /> <TextBox Text="{Binding Path=txtState, Mode=TwoWay}" Name="txtState" VerticalContentAlignment="Center" Height="24" HorizontalAlignment="Left" Margin="114,114,0,0" VerticalAlignment="Top" Width="105" Foreground="Yellow" Background="Black" /> <Label Content="タイトル" Foreground="White" Height="31" HorizontalAlignment="Left" Margin="16,173,0,0" Name="label6" VerticalAlignment="Top" Width="92" /> <TextBox Text="{Binding Path=txtTitle2, Mode=TwoWay}" Name="txtTitle20" Height="24" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="114,174,0,0" VerticalAlignment="Top" Width="852" Foreground="White" Background="Black" /> <ListBox x:Name="listBox1" ItemsSource="{Binding QuestionListView}" Foreground="White" Background="Black" HorizontalContentAlignment="Stretch" Margin="114,204,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="854" Height="420"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}"> <TextBlock.InputBindings> <MouseBinding Gesture="LeftDoubleClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBox}}, Path=DataContext.Goto21Command}"/> </TextBlock.InputBindings> </TextBlock> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Label Content="受付番号" Foreground="White" Height="31" HorizontalAlignment="Left" Margin="15,52,0,0" Name="label1" VerticalAlignment="Top" Width="63" /> <Label Content="質問部分検索" Foreground="White" Height="31" InputMethod.PreferredImeState="Off" HorizontalAlignment="Left" Margin="357,54,0,0" Name="label99" VerticalAlignment="Top" Width="81" /> <TextBox Text="{Binding Path=txtSearchInquiry, Mode=TwoWay}" Name="txtSearchInquiry" VerticalContentAlignment="Center" Background="Black" Foreground="White" Height="24" HorizontalAlignment="Left" Margin="444,54,0,0" VerticalAlignment="Top" Width="294" /> <Label Content="XMLデータパス" Foreground="White" Height="31" HorizontalAlignment="Left" Margin="15,631,0,0" Name="lblPath" VerticalAlignment="Top" Width="92" /> <TextBox Text="{Binding Path=txtPath, Mode=TwoWay}" Name="txtPath" VerticalContentAlignment="Center" Background="Black" Foreground="White" Height="24" HorizontalAlignment="Left" Margin="114,631,0,0" VerticalAlignment="Top" Width="643" /> <TextBox Text="{Binding Path=txtMessage, Mode=TwoWay}" VerticalContentAlignment="Center" Background="Black" Foreground="White" Height="24" HorizontalAlignment="Left" Margin="763,631,0,0" VerticalAlignment="Top" Width="205" /> <GroupBox Height="50" Width="391" Margin="281,93,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"> <GroupBox.Header> <TextBlock FontSize="14" Foreground="#FF1E90FF" FontWeight="Bold" FontFamily="Times New Roman">対応状況</TextBlock> </GroupBox.Header> <Grid Height="24" Width="351" Background="Black"> <Grid.RowDefinitions> <RowDefinition Height="17*" /> <RowDefinition Height="13*" /> </Grid.RowDefinitions> <RadioButton IsChecked="{Binding Path=Button下書IsChecked, Mode=TwoWay}" Name="rbtn下書" Content="下書" Foreground="White" Grid.RowSpan="2" HorizontalAlignment="Left" Margin="10,6,0,3" Width="48" /> <RadioButton IsChecked="{Binding Path=Button対応中IsChecked, Mode=TwoWay}" Name="rbtn対応中" Content="対応中" Foreground="White" Margin="72,6,0,3" Width="58" HorizontalAlignment="Left" Grid.RowSpan="2" /> <RadioButton IsChecked="{Binding Path=Button完了済IsChecked, Mode=TwoWay}" Name="rbtn完了済" Content="完了済" Foreground="White" Margin="0,6,69,6" Width="62" HorizontalAlignment="Right" Grid.RowSpan="2" /> <RadioButton IsChecked="{Binding Path=Button検証中IsChecked, Mode=TwoWay}" Name="rbtn検証中" Content="検証中" Foreground="White" Grid.RowSpan="2" HorizontalAlignment="Left" Margin="154,6,0,6" Width="60" /> <RadioButton IsChecked="{Binding Path=Button全てIsChecked, Mode=TwoWay}" Name="rbtn全て" Content="全て" Foreground="White" Height="22" Margin="293,6,6,2" Grid.RowSpan="2" /> </Grid> </GroupBox> <!-- ★★★ --> </Grid> </Grid> </ccl:CustomChromeWindow>
224~238行目で、Activatedの処理を記述しています。これによって、詳細で変更があっても、
この一覧画面に戻ったきた時はActivatedが効いて、再度読み込みが起こり、変更が反映されます。
RadioButtonのIsCheckedプロパティの変化は、ボタンがONとOFFになった時に発生しますので、1回だけ処理する再読み込みはvalueがtrueの時だけ実行させます。
ViewModel
using System;
// ObservableCollection
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//INotifyPropertyChanged
//PropertyChanged
using System.ComponentModel;
//参照設定が必要
//using System.Configuration;
using Livet;
using Livet.Commands;
using Livet.Messaging;
//CloseCommand
using Livet.Messaging.Windows;
//MessageBox
using System.Windows;
//using Livet.Messaging.IO;
//using Livet.EventListeners;
//ICommand
using System.Windows.Input;
// ListCollectionView
using System.Windows.Data;
//ArrayList
using System.Collections;
//XmlReader
using System.Xml;
//XDocument
using System.Xml.Linq;
//XPathDocument
using System.Xml.XPath;
using LivetWPFChromeHelpDesk1.Models;
using LivetWPFChromeHelpDesk1.Views;
using LivetWPFChromeHelpDesk1.ViewModels;
namespace LivetWPFChromeHelpDesk1.ViewModels
{
class ViewModel10 : ViewModel
{
#region 変更通知プロパティ
//-----------------------------------------------
//public string txtMessage { get; set; }
private string _txtMessage;
public string txtMessage
{
get { return _txtMessage; }
set
{
if (_txtMessage != value)
{
_txtMessage = value;
RaisePropertyChanged("txtMessage");
}
}
}
public string txt本日 { get; set; }
public bool IsEnabled { get; set; }
// public string txtTitle2 { get; set; }
private string _txtTitle2;
public string txtTitle2
{
get { return _txtTitle2; }
set
{
if (_txtTitle2 != value)
{
_txtTitle2 = value;
RaisePropertyChanged("txtTitle2");
}
}
}
//
//public string txtState { get; set; }
private string _txtState;
public string txtState
{
get { return _txtState; }
set
{
if (_txtState != value)
{
_txtState = value;
RaisePropertyChanged("txtState");
}
}
}
//
private string _txtSearchInquiry;
public string txtSearchInquiry
{
get { return _txtSearchInquiry; }
set
{
if (_txtSearchInquiry != value)
{
_txtSearchInquiry = value;
RaisePropertyChanged("txtSearchInquiry");
}
}
}
//
private string _txt件数;
public string txt件数
{
get { return _txt件数; }
set
{
if (_txt件数 != value)
{
_txt件数 = value;
RaisePropertyChanged("txt件数");
}
}
}
//
private string _txtPath;
public string txtPath
{
get { return _txtPath; }
set
{
if (_txtPath != value)
{
_txtPath = value;
RaisePropertyChanged("txtPath");
}
}
}
//
private string _txtReceiptNumber;
public string txtReceiptNumber
{
get { return _txtReceiptNumber; }
set
{
if (_txtReceiptNumber != value)
{
_txtReceiptNumber = value;
RaisePropertyChanged("txtReceiptNumber");
}
}
}
//
private string _txtNumber;
public string txtNumber
{
get { return _txtNumber; }
set
{
if (_txtNumber != value)
{
_txtNumber = value;
RaisePropertyChanged("txtNumber");
}
}
}
//-----------------------------------------------
#endregion
#region Argument変更通知プロパティ
private Argument _argument;
public Argument argument
{
get { return _argument; }
set
{
if (_argument == value)
return;
_argument = value;
RaisePropertyChanged("argument");
}
}
#endregion
#region IsButtonVisible変更通知プロパティ
private bool _IsButtonVisible;
public bool IsButtonVisible
{
get { return _IsButtonVisible; }
set
{
_IsButtonVisible = value;
RaisePropertyChanged("IsButtonVisible");
}
}
#endregion
Window win = null;
public ViewModel10()
{
Loaded = new Livet.Commands.ListenerCommand<Window>((w) =>
{
if (NeedHideOwner && w.Owner != null && w.Owner.Visibility == Visibility.Visible)
{
win = w;
//w.Owner.Hide();
}
});
Closing = new Livet.Commands.ListenerCommand<Window>((w) =>
{
if (NeedHideOwner && w.Owner != null)
{
w.Owner.Show();
}
});
Activated = new Livet.Commands.ListenerCommand<Window>((w) =>
{
if (win != null) win.Owner.Hide();
//★ListCollectionView 5-2
this.QuestionList = new List<string>();
SetPath();
Read();
//★ListCollectionView 5-4
this.QuestionListView = new ListCollectionView(this.QuestionList);
this.QuestionListView.CurrentChanged += QuestionListView_CurrentChanged;
//下記のRefreshでListBoxへバインドを実行させます
this.QuestionListView.Refresh();
});
//Initialize()では表示されない
txt本日 = Convert.ToString(DateTime.Today.ToShortDateString());
txtState = "対応中";
Button対応中IsChecked = true;
txtSearchInquiry = "";
txtReceiptNumber = "";
txtNumber = "";
}
public bool NeedHideOwner { get; set; }
public ICommand Loaded { get; private set; }
public ICommand Closing { get; private set; }
public ICommand Activated { get; private set; }
#region QuestionListView 質問一覧(ListBox)
//★ListCollectionView 5-1
private List<string> QuestionList;
private ListCollectionView _QuestionListView;
// 質問一覧(ListBox)
public ListCollectionView QuestionListView
{
get
{ return _QuestionListView; }
set
{
if (_QuestionListView == value)
return;
_QuestionListView = value;
RaisePropertyChanged("QuestionListView");
}
}
// リストの位置が変わった
void QuestionListView_CurrentChanged(object sender, EventArgs e)
{
this.QuestionListView.Refresh();
//
var lv = sender as ICollectionView;
if (lv.CurrentPosition < 0)
{
System.Diagnostics.Trace.WriteLine("選択無し");
return;
}
var item = lv.CurrentItem as string;
txtTitle2 = item;
//
int iCNT = item.IndexOf(":");
txtReceiptNumber = item.Substring(0, iCNT);
txtNumber = item.Substring(iCNT + 1, 1);
int iCNT2 = item.IndexOf(":", iCNT + 3);
txtTitle2 = "";
txtTitle2 = item.Substring(iCNT + 3, iCNT2 - (iCNT + 3));
}
#endregion
#region ButtonIsChecked
int iGClick = 0;
private bool _Button下書IsChecked;
public bool Button下書IsChecked
{
get { return _Button下書IsChecked; }
set
{
_Button下書IsChecked = value;
if (value == true)
{
txtState = "下書";
if (iGClick > 0)
{
Read();
}
iGClick++;
}
RaisePropertyChanged("Button下書IsChecked");
}
}
//
private bool _Button対応中IsChecked;
public bool Button対応中IsChecked
{
get { return _Button対応中IsChecked; }
set
{
_Button対応中IsChecked = value;
if (value == true)
{
txtState = "対応中";
if (iGClick > 0)
{
Read();
}
iGClick++;
}
RaisePropertyChanged("Button対応中IsChecked");
}
}
//
private bool _Button完了済IsChecked;
public bool Button完了済IsChecked
{
get { return _Button完了済IsChecked; }
set
{
_Button完了済IsChecked = value;
if (value == true)
{
txtState = "完了済";
if (iGClick > 0)
{
Read();
}
iGClick++;
}
RaisePropertyChanged("Button完了済IsChecked");
}
}
//
private bool _Button検証中IsChecked;
public bool Button検証中IsChecked
{
get { return _Button検証中IsChecked; }
set
{
_Button検証中IsChecked = value;
if (value == true)
{
txtState = "検証中";
if (iGClick > 0)
{
Read();
}
iGClick++;
}
RaisePropertyChanged("Button検証中IsChecked");
}
}
//
private bool _Button全てIsChecked;
public bool Button全てIsChecked
{
get { return _Button全てIsChecked; }
set
{
_Button全てIsChecked = value;
if (value == true)
{
txtState = "全て";
if (iGClick > 0)
{
Read();
}
iGClick++;
}
RaisePropertyChanged("Button全てIsChecked");
}
}
#endregion
#region SetPath
string strPath = "";
private void SetPath()
{
strPath = System.Windows.Forms.Application.StartupPath;
strPath += @"\HelpDesk.xml";
txtPath = strPath;
}
#endregion
#region SearchInquiryClearCommand
private ViewModelCommand _SearchInquiryClearCommand;
public ViewModelCommand SearchInquiryClearCommand
{
get
{
if (_SearchInquiryClearCommand == null)
{
_SearchInquiryClearCommand = new ViewModelCommand(SearchInquiryClear);
}
return _SearchInquiryClearCommand;
}
}
public void SearchInquiryClear()
{
txtSearchInquiry = "";
}
#endregion
#region Read
private void Read()
{
XDocument xmlDoc = XDocument.Load(strPath);
string str = "";
try
{
//★ListCollectionView 5-3
ListCollectionViewData.Remove(this.QuestionListView);
}
catch
{
}
//
try
{
if (txtState.Trim().Substring(0, 2) == "下書")
{
if (txtSearchInquiry == "")
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
//.Where(node => (string)node.Attribute("state") == "下書")
where entry.Attribute("state").Value.StartsWith("下書")
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-3
this.QuestionList.Add(str);
}
}
else
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
//.Where(node => (string)node.Attribute("state") == "下書")
where entry.Attribute("state").Value.StartsWith("下書")
where entry.Element("inquiry").Value.Contains(txtSearchInquiry)
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-3
this.QuestionList.Add(str);
}
}
//★ListCollectionView 5-4
txt件数 = this.QuestionList.Count().ToString();
if (this.QuestionListView.Count > 0)
{
this.QuestionListView.MoveCurrentToPosition(0);
}
}
else if (txtState.Trim().Substring(0, 2) == "対応")
{
if (txtSearchInquiry == "")
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
.Where(node => (string)node.Attribute("state") == "対応中")
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
else
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
//.Where(node => (string)node.Attribute("state") == "対応中")
where entry.Attribute("state").Value.StartsWith("対応中")
where entry.Element("inquiry").Value.Contains(txtSearchInquiry)
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
}
}
txt件数 = this.QuestionList.Count().ToString();
if (this.QuestionListView.Count > 0)
{
this.QuestionListView.MoveCurrentToPosition(0);
}
//★ListCollectionView 5-5
}
else if (txtState.Trim().Substring(0, 2) == "完了")
{
if (txtSearchInquiry == "")
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
.Where(node => (string)node.Attribute("state") == "完了済")
//where entry.Attribute("state").Value.StartsWith("完了")
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
else
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
//.Where(node => (string)node.Attribute("state") == "完了済")
where entry.Attribute("state").Value.StartsWith("完了済")
where entry.Element("inquiry").Value.Contains(txtSearchInquiry)
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
txt件数 = this.QuestionList.Count().ToString();
if (this.QuestionListView.Count > 0)
{
this.QuestionListView.MoveCurrentToPosition(0);
}
}
else if (txtState.Trim().Substring(0, 2) == "検証")
{
if (txtSearchInquiry == "")
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
.Where(node => (string)node.Attribute("state") == "検証中")
//where entry.Attribute("state").Value.StartsWith("検証中")
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
else
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
//.Where(node => (string)node.Attribute("state") == "検証中")
where entry.Attribute("state").Value.StartsWith("検証中")
where entry.Element("inquiry").Value.Contains(txtSearchInquiry)
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
txt件数 = this.QuestionList.Count().ToString();
this.QuestionListView.Refresh();
if (this.QuestionListView.Count > 0)
{
this.QuestionListView.MoveCurrentToPosition(0);
}
}
else
{
if (txtSearchInquiry == "")
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
// .Where(node => (string)node.Attribute("number") == "1")
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
else
{
var tweets = (from entry in xmlDoc.Descendants("helpdesk")
// .Where(node => (string)node.Attribute("number") == "1")
where entry.Element("inquiry").Value.Contains(txtSearchInquiry)
orderby
(string)entry.Attribute("receiptnumber")
select new
{
ReceiptNumber = entry.Attribute("receiptnumber").Value,
Number = entry.Attribute("number").Value,
ReceiptDate = entry.Attribute("receiptdate").Value,
Completingdate = entry.Attribute("completingdate").Value,
State = entry.Attribute("state").Value,
ProductName = entry.Element("productname").Value,
Title = entry.Element("title").Value,
Inquiry = entry.Element("inquiry").Value,
Correspondence = entry.Element("correspondence").Value,
}
);
foreach (var k in tweets)
{
str = k.ReceiptNumber + ":" + k.Number + ":" + k.Title + ":" + k.State;
//★ListCollectionView 5-4
this.QuestionList.Add(str);
}
}
txt件数 = this.QuestionList.Count().ToString();
if (this.QuestionListView.Count > 0)
{
this.QuestionListView.MoveCurrentToPosition(0);
}
}
}
catch
{
}
}
#endregion
#region DeleteDataCommand
private ViewModelCommand _DeleteDataCommand;
public ViewModelCommand DeleteDataCommand
{
get
{
if (_DeleteDataCommand == null)
{
_DeleteDataCommand = new ViewModelCommand(CheckDeleteData);
}
return _DeleteDataCommand;
}
}
public void CheckDeleteData()
{
MessageBoxResult result = System.Windows.MessageBox.Show("本当に削除しますか?", "削除の確認", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
// Do something for No
}
else if (result == MessageBoxResult.Yes)
{
DeleteData();
Read();
}
}
public void DeleteData()
{
var xelm = XElement.Load(strPath);
var tweets = from entry in xelm.Descendants("helpdesk")
//where entry.Attribute("receiptnumber").Value == txtReceiptNumber
//where entry.Attribute("number").Value == txtNumber
.Where(node => (string)node.Attribute("receiptnumber") == txtReceiptNumber)
.Where(node => (string)node.Attribute("number") == txtNumber)
select entry;
tweets.Remove();
xelm.Save(strPath);
//
txtNumber = "";
}
#endregion
#region ReRoadCommand
private ViewModelCommand _ReRoadCommand;
public ViewModelCommand ReRoadCommand
{
get
{
if (_ReRoadCommand == null)
{
_ReRoadCommand = new ViewModelCommand(ReRoad);
}
return _ReRoadCommand;
}
}
public void ReRoad()
{
Read();
this.QuestionListView.Refresh();
if (this.QuestionListView.Count > 0)
{
this.QuestionListView.MoveCurrentToPosition(0);
}
}
#endregion
#region CopyCommand1
//--------------------------------------
/// <summary>
/// Copy処理のコマンドを定義します。
/// </summary>
private ViewModelCommand _copyCommand1;
public ViewModelCommand CopyCommand1
{
get
{
if (this._copyCommand1 == null)
{
this._copyCommand1 = new ViewModelCommand(CopyExecute, CanCopyExecute);
}
return this._copyCommand1;
}
}
/// <summary>
/// Copy処理のコマンドの実行を行います。
/// </summary>
private void CopyExecute()
{
txtState = "対応中";
// System.Windows.Forms.MessageBox.Show("対応中");
}
/// <summary>
/// Copy処理が実行可能かどうかの判定を行います。
/// </summary>
private bool CanCopyExecute()
{
return true;
}
//---------------------------------------------
#endregion
#region GotoCommand20
public ViewModelCommand Goto20Command
{
get { return new Livet.Commands.ViewModelCommand(Goto20); }
}
public void Goto20()
{
Argument argument = new Argument();
argument.ReceiptNumber = "";
argument.Number = "";
argument.Title = "";
argument.Action = "新規登録";
argument.XMLPath = strPath;
Messenger.Raise(new TransitionMessage(new ViewModel20(argument) { NeedHideOwner = true }, "MessageKey20"));
}
//----------------------------------------------------------------
public ViewModelCommand Goto21Command
{
get { return new Livet.Commands.ViewModelCommand(Goto21); }
}
public void Goto21()
{
if (txt件数 == "0") return;
Argument argument = new Argument();
argument.ReceiptNumber = txtReceiptNumber;
argument.Number = txtNumber;
argument.Title = txtTitle2;
argument.Action = "更新";
argument.XMLPath = strPath;
Messenger.Raise(new TransitionMessage(new ViewModel20(argument) { NeedHideOwner = true }, "MessageKey21"));
}
//----------------------------------------------------------------
#endregion
#region データバックアップCommand
private ViewModelCommand _データバックアップCommand;
public ViewModelCommand データバックアップCommand
{
get
{
if (_データバックアップCommand == null)
{
_データバックアップCommand = new ViewModelCommand(データバックアップ);
}
return _データバックアップCommand;
}
}
public void データバックアップ()
{
System.IO.File.Copy(@strPath, @"D:\ヘルプデスクBK\HelpDesk.xml",true);
}
#endregion
#region CloseCommand
private ViewModelCommand _CloseCommand;
public ViewModelCommand CloseCommand
{
get
{
if (_CloseCommand == null)
{
_CloseCommand = new ViewModelCommand(Close);
}
return _CloseCommand;
}
}
public void Close()
{
var window = System.Windows.Application.Current.Windows.OfType<Window>().SingleOrDefault((w) => w.IsActive);
window.Close();
}
#endregion
}
}
