UCFlawListOnTime.xaml.cs 1.48 KB
using OS.Spin.Common;
using OS.Spin.ViewModle.Flaw;
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;

namespace OS.Spin.View.MainWindowControls
{
    /// <summary>
    /// UCFlawListOnTime.xaml 的交互逻辑
    /// </summary>
    public partial class UCFlawListOnTime : UserControl
    {

        public static readonly DependencyProperty AllIconsProperty =
            DependencyProperty.Register("AllIcons", typeof(ObservableCollection<MFlaw>), typeof(UCFlawListOnTime), new PropertyMetadata(default(ObservableCollection<MFlaw>)));
        private ObservableCollection<MFlaw> Tmps = new ObservableCollection<MFlaw>();

        private ObservableCollection<MFlaw> AllIcons
        {
            get { return (ObservableCollection<MFlaw>)GetValue(AllIconsProperty); }
            set { SetValue(AllIconsProperty, value); }
        }
        public UCFlawListOnTime()
        {
            InitializeComponent();
            AllIcons = Tmps;
        }

        public void Zero()
        {
            AllIcons.Clear();
        }

        public void AddFlaw(MFlaw flaw)
        {
            try
            {
                flaw.Id = (AllIcons.Count + 1).ToString();
                AllIcons.Add(flaw);
                Flaws.ScrollIntoView(Flaws.Items[Flaws.Items.Count - 1]);
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(string.Format("AddFlaw:{0}", ex.Message));
            }
        }
    }
}