| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | using MECF.Framework.Common.RecipeCenter;using CyberX8_Core;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Diagnostics;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;namespace CyberX8_Themes.UserControls{    /// <summary>    /// RecipeLoad.xaml 的交互逻辑    /// </summary>    public partial class RecipeLoadControl : UserControl    {        public RecipeLoadControl()        {            InitializeComponent();        }        public static readonly DependencyProperty SelectedRecipeNodeProperty = DependencyProperty.Register( "SelectedRecipeNode", typeof(RecipeNode), typeof(RecipeLoadControl),               new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 当前选中recipe节点        /// </summary>        public RecipeNode SelectedRecipeNode        {            get            {                return (RecipeNode)this.GetValue(SelectedRecipeNodeProperty);            }            set            {                this.SetValue(SelectedRecipeNodeProperty, value);            }        }        public static readonly DependencyProperty RecipeTypeProperty = DependencyProperty.Register(            "RecipeType", typeof(string), typeof(RecipeLoadControl),new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// recipe类型        /// </summary>        public string RecipeType        {            get            {                return (string)this.GetValue(RecipeTypeProperty);            }            set            {                this.SetValue(RecipeTypeProperty, value);            }        }        public static readonly DependencyProperty RecipeNodesProperty = DependencyProperty.    Register("RecipeNodes", typeof(ObservableCollection<RecipeNode>), typeof(RecipeLoadControl));        public ObservableCollection<RecipeNode> RecipeNodes        {            get { return (ObservableCollection<RecipeNode>)this.GetValue(RecipeNodesProperty); }            set { this.SetValue(RecipeNodesProperty, value); }        }        private void Self_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)        {            if (e.NewValue != null)            {                bool result = (bool)e.NewValue;                if (result)                {                    if (!string.IsNullOrEmpty(RecipeType))                    {                        RecipeNodes = RecipeClient.Instance.Service.GetRecipesByType(RecipeType);                    }                }            }        }        public static readonly DependencyProperty IsEngineeringModeProperty = DependencyProperty.Register(            "IsEngineeringMode", typeof(bool), typeof(RecipeLoadControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsEngineeringMode        /// </summary>        public bool IsEngineeringMode        {            get            {                return (bool)this.GetValue(IsEngineeringModeProperty);            }            set            {                this.SetValue(IsEngineeringModeProperty, value);            }        }        public static readonly DependencyProperty IsProductionModeProperty = DependencyProperty.Register(         "IsProductionMode", typeof(bool), typeof(RecipeLoadControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsProductionMode        /// </summary>        public bool IsProductionMode        {            get            {                return (bool)this.GetValue(IsProductionModeProperty);            }            set            {                this.SetValue(IsProductionModeProperty, value);            }        }        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)        {            RecipeNode recipeNode = (RecipeNode)e.NewValue;            if (recipeNode != null)            {                if(recipeNode.NodeType== RecipeNodeType.File)                {                    SelectedRecipeNode = recipeNode;                }                else                {                    SelectedRecipeNode = null;                }            }            else            {                SelectedRecipeNode = null;            }        }    }}
 |