//******************************************************************************************************// ProtocolGroupUserControl.xaml.cs - Gbtc//// Copyright © 2010, Grid Protection Alliance. All Rights Reserved.//// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See// the NOTICE file distributed with this work for additional information regarding copyright ownership.// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may// not use this file except in compliance with the License. You may obtain a copy of the License at://// http://www.opensource.org/licenses/MIT//// Unless agreed to in writing, the subject software distributed under the License is distributed on an// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the// License for the specific language governing permissions and limitations.//// Code Modification History:// ----------------------------------------------------------------------------------------------------// 05/17/2011 - Magdiel Lorenzo// Generated original version of source code.////****************************************************************************************************** using System.Windows;using System.Windows.Controls;using System.Windows.Input;using GSF.TimeSeries.UI.ViewModels; namespace GSF.TimeSeries.UI.UserControls{ /// <summary> /// Interaction logic for ProtocolGroupUserControl.xaml /// </summary> public partial class ProtocolGroupUserControl : UserControl { #region [ Constructor ] /// <summary> /// Creates an instance of <see cref="ProtocolGroupUserControl"/> class. /// </summary> public ProtocolGroupUserControl() { InitializeComponent(); this.DataContext = new Protocols(10); } #endregion #region [ Methods ] /// <summary> /// Handles key down event on the datagrid object. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">Arguments of the event.</param> private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { DataGrid dataGrid = sender as DataGrid; if (dataGrid.SelectedItems.Count > 0) { if (MessageBox.Show("Are you sure you want to delete " + dataGrid.SelectedItems.Count + " selected item(s)?", "Delete Selected Items", MessageBoxButton.YesNo) == MessageBoxResult.No) e.Handled = true; } } } private void GridDetailView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((this.DataContext as Protocols).IsNewRecord) DataGridList.SelectedIndex = -1; } #endregion }}
//******************************************************************************************************
// ProtocolGroupUserControl.xaml.cs - Gbtc
//
// Copyright © 2010, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 05/17/2011 - Magdiel Lorenzo
// Generated original version of source code.
//
//******************************************************************************************************
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using GSF.TimeSeries.UI.ViewModels;
namespace GSF.TimeSeries.UI.UserControls
{
/// <summary>
/// Interaction logic for ProtocolGroupUserControl.xaml
/// </summary>
public partial class ProtocolGroupUserControl : UserControl
{
#region [ Constructor ]
/// <summary>
/// Creates an instance of <see cref="ProtocolGroupUserControl"/> class.
/// </summary>
public ProtocolGroupUserControl()
{
InitializeComponent();
this.DataContext = new Protocols(10);
}
#endregion
#region [ Methods ]
/// <summary>
/// Handles key down event on the datagrid object.
/// </summary>
/// <param name="sender">Source of the event.</param>
/// <param name="e">Arguments of the event.</param>
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete)
{
DataGrid dataGrid = sender as DataGrid;
if (dataGrid.SelectedItems.Count > 0)
{
if (MessageBox.Show("Are you sure you want to delete " + dataGrid.SelectedItems.Count + " selected item(s)?", "Delete Selected Items", MessageBoxButton.YesNo) == MessageBoxResult.No)
e.Handled = true;
}
}
}
private void GridDetailView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if ((this.DataContext as Protocols).IsNewRecord)
DataGridList.SelectedIndex = -1;
}
#endregion
}
}