首次上传
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interactivity;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using MECF.Framework.Common.Aitex.Core.RT.EMS;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maintain.Behavior
|
||||
{
|
||||
public class DataGridSelectionChangedScrollChangedBehavior : Behavior<DataGrid>
|
||||
{
|
||||
protected override void OnAttached()
|
||||
{
|
||||
AssociatedObject.SelectionChanged += SelectedOperation;
|
||||
}
|
||||
|
||||
private void SelectedOperation(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count == 1)
|
||||
{
|
||||
if (e.AddedItems[0] is MaintainerItemInfo)
|
||||
{
|
||||
AssociatedObject.ScrollIntoView(e.AddedItems[0]);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interactivity;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using MECF.Framework.Common.Aitex.Core.RT.EMS;
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maintain.Behavior
|
||||
{
|
||||
public class ItemChangedTargetItemChangedBehavior : Behavior<Control>
|
||||
{
|
||||
|
||||
public ListBox TargetListBox
|
||||
{
|
||||
get { return (ListBox)GetValue(TargetListBoxProperty); }
|
||||
set { SetValue(TargetListBoxProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TargetListBoxProperty =
|
||||
DependencyProperty.Register("TargetListBox", typeof(ListBox), typeof(ItemChangedTargetItemChangedBehavior), new PropertyMetadata(null));
|
||||
|
||||
public List<MaintainerItemConfigEnableInfo> Target
|
||||
{
|
||||
get { return (List<MaintainerItemConfigEnableInfo>)GetValue(TargetProperty); }
|
||||
set { SetValue(TargetProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TargetProperty =
|
||||
DependencyProperty.Register("Target", typeof(List<MaintainerItemConfigEnableInfo>), typeof(ItemChangedTargetItemChangedBehavior), new PropertyMetadata(null));
|
||||
|
||||
//public Color FalseColor
|
||||
//{
|
||||
// get { return (Color)GetValue(FalseColorProperty); }
|
||||
// set { SetValue(FalseColorProperty, value); }
|
||||
//}
|
||||
|
||||
//public static readonly DependencyProperty FalseColorProperty =
|
||||
// DependencyProperty.Register("FalseColor", typeof(Color), typeof(ItemChangedTargetItemChangedBehavior), new PropertyMetadata(Colors.Black));
|
||||
|
||||
//public Color TrueColor
|
||||
//{
|
||||
// get { return (Color)GetValue(TrueColorProperty); }
|
||||
// set { SetValue(TrueColorProperty, value); }
|
||||
//}
|
||||
|
||||
//public static readonly DependencyProperty TrueColorProperty =
|
||||
// DependencyProperty.Register("TrueColor", typeof(Color), typeof(ItemChangedTargetItemChangedBehavior), new PropertyMetadata(Colors.Green));
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
if (AssociatedObject is ListBox lb)
|
||||
{
|
||||
lb.SelectionChanged += SelectedOperation;
|
||||
}
|
||||
//else if (AssociatedObject is TabControl tb)
|
||||
//{
|
||||
// tb.SelectionChanged += TabControlSelectedOperation;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
//private void TabControlSelectedOperation(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// var source = e.OriginalSource as TabControl;
|
||||
// if (source.SelectedValue is KeyValuePair<string,ObservableCollection<MaintainerInfo>> kv)
|
||||
// {
|
||||
// var item = kv.Value.ToList().Find(i => i.IsSelected);
|
||||
// if (item != null && Target != null)
|
||||
// {
|
||||
// string type = item.Type;
|
||||
// string name = item.Name;
|
||||
// string module = item.Module;
|
||||
|
||||
// SelectPage(type, name, module);
|
||||
// }
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
private void SelectPage(string type,string name, string module)
|
||||
{
|
||||
//变更checkbox显示内容
|
||||
if (Target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var item in Target)
|
||||
{
|
||||
item.SelectPage(type, name, module);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SelectedOperation(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count == 1)
|
||||
{
|
||||
if (e.AddedItems[0] is MaintainerInfo maintenanceInfo)
|
||||
{
|
||||
string type = maintenanceInfo.Type;
|
||||
string name = maintenanceInfo.Name;
|
||||
string module = maintenanceInfo.Module;
|
||||
SelectPage(type, name, module);
|
||||
|
||||
//选择项高亮显示
|
||||
if (TargetListBox != null)
|
||||
{
|
||||
foreach (var item in TargetListBox.ItemsSource)
|
||||
{
|
||||
var info = item as MaintainerInfo;
|
||||
info.IsSelected = info.Equals(TargetListBox.SelectedItem as MaintainerInfo);
|
||||
info.InvokePropertyChanged(nameof(info.IsSelected));
|
||||
}
|
||||
(TargetListBox.SelectedItem as MaintainerInfo).IsSelected = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interactivity;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using MECF.Framework.Common.Aitex.Core.RT.EMS;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maintain.Behavior
|
||||
{
|
||||
public class SelectionChangedTargetSelectorChangingItemBehavior : Behavior<Selector>
|
||||
{
|
||||
public DataGrid Target
|
||||
{
|
||||
get { return (DataGrid)GetValue(TargetProperty); }
|
||||
set { SetValue(TargetProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TargetProperty =
|
||||
DependencyProperty.Register("Target", typeof(DataGrid), typeof(SelectionChangedTargetSelectorChangingItemBehavior), new PropertyMetadata(null));
|
||||
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
AssociatedObject.SelectionChanged += SelectedOperation;
|
||||
}
|
||||
|
||||
private void SelectedOperation(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count == 1)
|
||||
{
|
||||
if (e.AddedItems[0] is MaintainerInfo mInfo)
|
||||
{
|
||||
string type = mInfo.Type;
|
||||
string name = mInfo.Name;
|
||||
string module = mInfo.Module;
|
||||
if (Target != null)
|
||||
{
|
||||
Target.ItemsSource = mInfo.MaintainerItemInfos;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user