ScanGraphCircular.xaml.cs 7.27 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

using FLY.ControlLibrary;
using FLY.Thick.BulkDataModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using ThickTcpUiInWindow.UIModule;

namespace FLY.Thick.BlowingScan.UI.Client.UIModule
{
    /// <summary>
    /// ScanGraphCircular.xaml 的交互逻辑
    /// </summary>
    public partial class ScanGraphCircular : UserControl
    {
26
        TDGage gage;
潘栩锋's avatar
潘栩锋 committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
        ScanGraphCircularParam graphparam;
        public ScanGraphCircular()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        public void Init(int id)
        {
            //查找参数
            graphparam = ScanGraphCircularParams.Current.Items.Find(p => p.ID == id);
            if (graphparam == null)
            {
                graphparam = new ScanGraphCircularParam() { ID = id };
                ScanGraphCircularParams.Current.Items.Add(graphparam);
                ScanGraphCircularParams.Current.Save();
            }

            //获取设备
49
            gage = Application.Current.Properties["ThickGage"] as TDGage;
潘栩锋's avatar
潘栩锋 committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143


            GraphScanCircular graph = graphscan;

            graph.DataContext = graphparam;
            graph.SetBinding(GraphScanCircular.TitleProperty, new Binding("Title"));
            graph.SetBinding(Grid.ColumnProperty, new Binding("Column"));
            graph.SetBinding(Grid.RowProperty, new Binding("Row"));
            graph.SetBinding(Grid.ColumnSpanProperty, new Binding("ColumnSpan"));
            graph.SetBinding(Grid.RowSpanProperty, new Binding("RowSpan"));
            graph.SetBinding(GraphScanCircular.BoltNoWithManual1stProperty, new Binding("BoltNoWithManual1st"));
            graph.SetBinding(GraphScanCircular.ManualCntProperty, new Binding("ManualCnt"));
            graph.SetBinding(GraphScanCircular.MPIsRightProperty, new Binding("MPIsRight"));

            //TODO
            graph.SetBinding(GraphScanCircular.BoltCntProperty, new Binding("NBolts") { Source = gage.mRenZiJiaService });
            graph.SetBinding(GraphScanCircular.OrgBoltNoProperty, new Binding("OrgBoltNo") { Source = gage.mRenZiJiaService });
            
            graph.SetBinding(GraphScanCircular.TargetProperty, new Binding("Target") { Source = gage.mDynArea });
            graph.SetBinding(GraphScanCircular.AlarmProperty, new Binding("Alarm") { Source = gage.mDynArea });




            //bulkdata 数据绑定!!!
            BulkDataServiceClientAdv.BulkDataGraphFrame bulkdata_client = new BulkDataServiceClientAdv.BulkDataGraphFrame();
            //graphparam 绑定到 bulkdataclient
            Misc.BindingOperations.SetBinding(graphparam, "BM", bulkdata_client, "BM");
            Misc.BindingOperations.SetBinding(graphparam, "Mix", bulkdata_client, "Mix");
            graph.SetBinding(GraphScanCircular.Title2Property, new Binding("Info") { Source = bulkdata_client });
            graph.DataSource = bulkdata_client.Frame;


            graph.ShowSettingDialogEvent += new EventHandler(delegate (object sender, EventArgs e)
            {
                ScanGraphCircularConfig window = new ScanGraphCircularConfig();
                window.Init((sender as GraphScanCircular).DataContext as ScanGraphCircularParam);
                window.Owner = FLY.ControlLibrary.COMMON.GetWindow(graph);
                window.ShowDialog();
            });

            gage.mBulkDataClient.Add(bulkdata_client);
        }
    }
    public class UIModule_ScanGraphCircular : FLY.UI.Module.IUIModule
    {
        /// <summary>
        /// 控件标题
        /// 它的值取决于culture
        /// </summary>
        public string Title
        {
            get
            {
                return Application.Current.FindResource("strScanGraphCircular") as string;
            }
        }

        /// <summary>
        /// 控件
        /// 创建时,需要给它唯一ID,让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FrameworkElement GetComponent(int id)
        {
            ScanGraphCircular graph = new ScanGraphCircular();
            graph.Init(id);
            return graph;
        }

        /// <summary>
        /// 控件缩略图,用于编辑界面时,大致看看
        /// 创建时,需要给它唯一ID,让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FrameworkElement GetThumbnail(int id)
        {
            return new System.Windows.Controls.Grid();
        }


        /// <summary>
        /// 给出全部控件ID, 控件自行删除没有的参数
        /// </summary>
        /// <param name="IDs"></param>
        public void MatchParam(int[] IDs)
        {
            ScanGraphCircularParams.Current.MatchParam(IDs);
        }
    }
    public class ScanGraphCircularParam : UIModuleParam
    {
144

潘栩锋's avatar
潘栩锋 committed
145 146 147
        /// <summary>
        /// 标题
        /// </summary>
148 149 150
        public string Title { get; set; } = "环形扫描图";


潘栩锋's avatar
潘栩锋 committed
151 152 153
        /// <summary>
        /// 混合数
        /// </summary>
154 155 156
        public int Mix { get; set; } = 1;


潘栩锋's avatar
潘栩锋 committed
157 158 159
        /// <summary>
        /// 记录点
        /// </summary>
160 161 162
        public int BM { get; set; } = -1;


潘栩锋's avatar
潘栩锋 committed
163 164 165
        /// <summary>
        /// 模头手动调节的螺丝对应的分区号
        /// </summary>
166 167 168
        public int BoltNoWithManual1st { get; set; } = 1;


潘栩锋's avatar
潘栩锋 committed
169 170 171
        /// <summary>
        /// 模头手动调节的螺丝个数
        /// </summary>
172 173
        public int ManualCnt { get; set; } = 8;

潘栩锋's avatar
潘栩锋 committed
174 175 176 177
        private bool mPIsRight = true;
        /// <summary>
        /// 探头在右边
        /// </summary>
178 179
        public bool MPIsRight { get; set; } = true;

潘栩锋's avatar
潘栩锋 committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string[] GetSavePropertyNames()
        {
            List<string> names = new List<string>(base.GetSavePropertyNames());
            names.AddRange(new string[]{
                "Title",
                "BM","Mix",
                "BoltNoWithManual1st",
                "ManualCnt",
                "MPIsRight"
            });
            return names.ToArray();
        }
    }

    /// <summary>
    /// 全部扫描图的参数
    /// </summary>
    public class ScanGraphCircularParams : UIModuleParams<ScanGraphCircularParam>
    {
        static ScanGraphCircularParams()
        {
            Misc.SaveToXmlHepler.Regist(typeof(ScanGraphCircularParams));
        }
        public ScanGraphCircularParams()
        {
            string path = System.IO.Path.Combine(FLYLayout.BasePath, "scangraphcircular.xml");
            FilePath = path;
        }

        static ScanGraphCircularParams current = null;
        public static ScanGraphCircularParams Current
        {
            get
            {
                if (current == null)
                {
                    current = new ScanGraphCircularParams();
                    current.Load();
                }
                return current;
            }
        }
    }
}