private void OnAddScanner(ScreenPropertyPanel panel)
        {
             ScreenRealParams.ScreenLayer.CLineType = ConnectLineType.Auto;
            int cols = AddColsCount;
            int rows = AddRowsCount;
            ScanBoardProperty scanBdProp = SelectedScannerConfig.ScanBdProp;
            int width = scanBdProp.Width;
            int height = scanBdProp.Height;


            _isMouseLeftButtonDown = true;

            //拖动的区域
            this._dragScope = Application.Current.Windows[Application.Current.Windows.Count-1].Content as FrameworkElement;

            //是否可以拖放
            this._dragScope.AllowDrop = true;
            draghandler = new MouseEventHandler(DragScope_PreviewDragOver);
            //加载处理拖放的路由事件
            this._dragScope.MouseMove += draghandler;
            //鼠标跟随效果的装饰器
            Point mousePoint = new Point();
            mousePoint = Mouse.GetPosition(this._dragScope);
            this._adorner = new DragAdorner(this._dragScope, width * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, IncreaseOrDecreaseIndex), height * Math.Pow(SmartLCTViewModeBase.IncreaseOrDecreaseValue, IncreaseOrDecreaseIndex), rows, cols, mousePoint, 0.5);
            this._adorner.LeftOffset = mousePoint.X;
            this._adorner.TopOffset = mousePoint.Y;
            this._layer = AdornerLayer.GetAdornerLayer(this._dragScope as Visual);
            this._layer.Add(this._adorner);

            NotificationMessageAction<AddReceiveInfo> nsa =
            new NotificationMessageAction<AddReceiveInfo>(this, new AddReceiveInfo(rows, cols, SelectedScannerConfig), MsgToken.MSG_ADDRECEIVE, AddReceiveNotifycationCallBack);
            Messenger.Default.Send(nsa, MsgToken.MSG_ADDRECEIVE);
        }
        private void OnScreenRealParamsSet(DependencyPropertyChangedEventArgs e,ScreenPropertyPanel ctrl)
        {
            if (e.Property == ScreenRealParamsProperty)
            {
                ScreenRealParameters oldParams = e.OldValue as ScreenRealParameters;
                ScreenRealParameters newParams = e.NewValue as ScreenRealParameters;

                if (oldParams != null &&
                    oldParams.ScreenLayer != null &&
                    oldParams.ScreenLayer.ElementCollection != null)
                {
                    oldParams.ScreenLayer.ElementCollection.CollectionChanged -= new NotifyCollectionChangedEventHandler(OnScreenElementCollectionChanged);
                }

                if (newParams != null &&
                    newParams.ScreenLayer != null &&
                    newParams.ScreenLayer.ElementCollection != null)
                {
                    newParams.ScreenLayer.ElementCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(OnScreenElementCollectionChanged);
                    OnScreenElementCollectionChanged(null, null);
                }
                //if (newParams != null &&
                //    newParams.PortLayer != null &&
                //    newParams.PortLayer.ParentElement != null)
                //{
                //    MaxPortHeight = ((RectLayer)newParams.PortLayer.ParentElement).Height;
                //    MaxPortWidth = ((RectLayer)newParams.PortLayer.ParentElement).Width;
                //}
               // ctrl.Cursor = Cursors.Arrow;
                if(newParams!=null &&
                    newParams.ScreenLayer != null)
                {
                    IRectLayer parentLayer = (IRectLayer)newParams.ScreenLayer.ParentElement;
                    while (parentLayer != null && parentLayer.EleType != ElementType.baselayer)
                    {
                        parentLayer = (IRectLayer)parentLayer.ParentElement;
                    }
                    if (parentLayer != null && parentLayer.EleType == ElementType.baselayer)
                    {
                        SmartLCTActionManager = parentLayer.MyActionManager;
                    }
                }
            }

            //if (ScannerCofigCollection == null ||
            //    ScannerCofigCollection.Count == 0)
            //{
            //    ScannerCofigInfo customScannerConfigInfo = new ScannerCofigInfo();
            //    string strCustom = "";
            //    CommonStaticMethod.GetLanguageString("自定义", "Lang_Global_Custom", out strCustom);
            //    customScannerConfigInfo.DisplayName = strCustom;
            //    customScannerConfigInfo.ScanBdSizeType = ScannerSizeType.Custom;       
            //    ScannerCofigCollection = new ObservableCollection<ScannerCofigInfo>();
            //    ScannerCofigCollection.Add(customScannerConfigInfo);
            //}
            //else
            //{
            //    bool isHaveCustom = false;
            //    for (int i = 0; i < ScannerCofigCollection.Count; i++)
            //    {
            //        if (ScannerCofigCollection[i].ScanBdSizeType == ScannerSizeType.Custom)
            //        {
            //            isHaveCustom = true;
            //            break;
            //        }
            //    }
            //    if (!isHaveCustom)
            //    {
            //        ScannerCofigInfo customScannerConfigInfo = new ScannerCofigInfo();
            //        string strCustom = "";
            //        CommonStaticMethod.GetLanguageString("自定义", "Lang_Global_Custom", out strCustom);
            //        customScannerConfigInfo.DisplayName = strCustom;
            //        customScannerConfigInfo.ScanBdSizeType = ScannerSizeType.Custom;
            //        ScannerCofigCollection.Insert(ScannerCofigCollection.Count,customScannerConfigInfo);
            //    }
            //}
            //if (ScannerCofigCollection != null && ScannerCofigCollection.Count == 1)
            //{
            //    SelectedScannerConfig = null;
            //}
            //else if (ScannerCofigCollection != null && ScannerCofigCollection.Count>1 && 
            //    SelectedScannerConfig.ScanBdSizeType == ScannerSizeType.Custom)
            //{
            //    SelectedScannerConfig = ScannerCofigCollection[0];
            //}
           // ctrl.DragOver += new DragEventHandler(ctrl_DragOver);
           // ctrl.Drop += new DragEventHandler(ctrl_Drop);
        }