Пример #1
0
        //#############---METHOD---############
        public StationShape(Canvas pCanvas, dtBuffer buffer)
        {
            //SHAPE
            ToolTip         = "";
            ToolTipOpening += ChangeToolTipContent;
            //BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF1F1F"));
            BorderBrush           = new SolidColorBrush(Colors.Lime);
            BorderThickness       = new Thickness(1, 0, 1, 1);
            CornerRadius          = new CornerRadius(0);
            RenderTransformOrigin = new Point(0, 0);
            Background            = new SolidColorBrush(Colors.Transparent);

            //PROPERTIES
            props                                 = new Props();
            props.bufferDb                        = buffer;
            props._stationGrid                    = new Grid();
            props._stationInfoBorder              = new Border();
            props._stationInfoBorder.Background   = new SolidColorBrush(Colors.Red);
            props._stationInfoBorder.CornerRadius = new CornerRadius(1.3);
            props._stationInfoBorder.Height       = 5;
            Grid.SetColumn(props._stationInfoBorder, 0);
            //Name = props.bufferDb.bufferName.Trim().Replace(" ", ""); //Object name

            //ContextMenu = new ContextMenu();

            //MenuItem propertiesItem = new MenuItem();
            //propertiesItem.SetResourceReference(MenuItem.HeaderProperty, "Station_Menu_Item_Properties");
            //propertiesItem.Click += PropertiesMenu;

            //MenuItem editItem = new MenuItem();
            //editItem.SetResourceReference(MenuItem.HeaderProperty, "Station_Menu_Item_Edit");
            //editItem.Click += EditMenu;

            //MenuItem removeItem = new MenuItem();
            //removeItem.SetResourceReference(MenuItem.HeaderProperty, "Station_Menu_Item_Remove");
            //removeItem.Click += RemoveMenu;

            //MenuItem rotateItem = new MenuItem();
            //rotateItem.SetResourceReference(MenuItem.HeaderProperty, "Station_Menu_Item_Rotate");
            //rotateItem.Click += RotateMenu;

            //ContextMenu.Items.Add(propertiesItem);
            //ContextMenu.Items.Add(editItem);
            //ContextMenu.Items.Add(rotateItem);
            //ContextMenu.Items.Add(removeItem);
            //====================EVENT=====================
            //MouseLeave += MouseLeaveStation;
            //MouseMove += MouseHoverStation;
            //MouseLeftButtonDown += MouseLeftButtonDownStation;
            //MouseRightButtonDown += MouseRightButtonDownStation;
            //===================CREATE=====================
            Width                       = StaticWidth * props.bufferDb.maxBay;
            Height                      = StaticHeight * props.bufferDb.maxRow;
            props.NameID                = props.bufferDb.bufferName; //label
            props._palletList           = new SortedDictionary <string, PalletShape>();
            props._myTransformGroup     = new TransformGroup();
            props._myRotateTransform    = new RotateTransform();
            props._myTranslateTransform = new TranslateTransform();
            //stationProperties = new Properties(this);
            //Add Pallet to Grid
            for (int bayIndex = 0; bayIndex < props.bufferDb.maxBay; bayIndex++) //Column Index
            {
                //Create a Col
                ColumnDefinition colTemp = new ColumnDefinition();
                //colTemp.Name = Name + "xL" + bayIndex;
                props._stationGrid.ColumnDefinitions.Add(colTemp);

                // Create BorderLine
                Border borderLine = new Border();
                Grid.SetColumn(borderLine, bayIndex);
                //Create GridLine
                Grid gridLine = new Grid();
                borderLine.Child = gridLine;
                //
                props._stationGrid.Children.Add(borderLine);
                if (bayIndex > 0)
                {
                    borderLine.BorderBrush     = new SolidColorBrush(Colors.Black);
                    borderLine.BorderThickness = new Thickness(0.3, 0, 0, 0);
                }
                //Add Pallet to GridPallet ==> add GridPallet to BorderLine
                for (int rowIndex = 0; rowIndex < props.bufferDb.maxRow; rowIndex++) //Row Index, start from 1, Row 0 use for Infomation
                {
                    //Create Rows for Col
                    RowDefinition rowTemp = new RowDefinition();
                    //rowTemp.Name = Name + "xR" + rowIndex;
                    //rowTemp.MinHeight = 10;
                    gridLine.RowDefinitions.Add(rowTemp);
                    //=============
                    //if(rowIndex>0)
                    {
                        //PalletShape palletTemp = new PalletShape(Name + "x" + lineIndex + "x" + palletIndex);
                        PalletShape palletTemp = new PalletShape("Pallet" + "x" + bayIndex + "x" + rowIndex);
                        Grid.SetRow(palletTemp, rowIndex);
                        gridLine.Children.Add(palletTemp);
                        props._palletList.Add(palletTemp.name, palletTemp);
                    }
                }
            }
            //==================SPECIALPOINT===================
            //props._eightCorner = new List<Point>();
            //for (int i = 0; i < 8; i++)
            //{
            //    Point temp = new Point();
            //    props._eightCorner.Add(temp);
            //}

            //==================CHILDREN===================
            //props._stationGrid.Children.Add(props._stationInfoBorder);
            Child = props._stationGrid;
            props._myTransformGroup.Children.Add(props._myRotateTransform);
            props._myTransformGroup.Children.Add(props._myTranslateTransform);
            RenderTransform = props._myTransformGroup;

            SetCoorAndRotate();

            props._canvas = pCanvas;
            props._canvas.Children.Add(this);
        }
Пример #2
0
        public void ReDraw(dtBuffer buffer)
        {
            if ((buffer.bufferId == this.props.bufferDb.bufferId) && (buffer.bufferName == this.props.bufferDb.bufferName))
            {
                if ((this.props.bufferDb.maxBay != buffer.maxBay) || ((this.props.bufferDb.maxRow != buffer.maxRow)))
                {
                    props.bufferDb = buffer;

                    props._palletList.Clear();
                    props._stationGrid.Children.Clear();
                    props._stationGrid.RowDefinitions.Clear();
                    props._stationGrid.ColumnDefinitions.Clear();

                    Width  = StaticWidth * props.bufferDb.maxBay;
                    Height = StaticHeight * props.bufferDb.maxRow;


                    for (int bayIndex = 0; bayIndex < props.bufferDb.maxBay; bayIndex++) //Column Index
                    {
                        //Create a Col
                        ColumnDefinition colTemp = new ColumnDefinition();
                        //colTemp.Name = Name + "xL" + bayIndex;
                        props._stationGrid.ColumnDefinitions.Add(colTemp);
                        //Create GridLine
                        Grid gridLine = new Grid();
                        // Create BorderLine
                        Border borderLine = new Border();
                        Grid.SetColumn(borderLine, bayIndex);
                        borderLine.Child = gridLine;
                        //
                        props._stationGrid.Children.Add(borderLine);
                        if (bayIndex > 0)
                        {
                            borderLine.BorderBrush     = new SolidColorBrush(Colors.Black);
                            borderLine.BorderThickness = new Thickness(0.3, 0, 0, 0);
                        }
                        //Add Pallet to GridPallet ==> add GridPallet to BorderLine
                        for (int rowIndex = 0; rowIndex < props.bufferDb.maxRow; rowIndex++) //Row Index, start from 1, Row 0 use for Infomation
                        {
                            //Create Rows for Col
                            RowDefinition rowTemp = new RowDefinition();
                            //rowTemp.Name = Name + "xR" + rowIndex;
                            //rowTemp.MinHeight = 10;
                            gridLine.RowDefinitions.Add(rowTemp);

                            //PalletShape palletTemp = new PalletShape(Name + "x" + lineIndex + "x" + palletIndex);
                            PalletShape palletTemp = new PalletShape("Pallet" + "x" + bayIndex + "x" + rowIndex);
                            Grid.SetRow(palletTemp, rowIndex);
                            gridLine.Children.Add(palletTemp);
                            props._palletList.Add(palletTemp.name, palletTemp);
                        }
                    }
                }
                else
                {
                    props.bufferDb = buffer;
                    Dispatcher.BeginInvoke(new ThreadStart(() =>
                    {
                        props._myRotateTransform.Angle      = props._rotate;
                        props._myTranslateTransform         = new TranslateTransform(props._posision.X, props._posision.Y);
                        props._myTransformGroup.Children[0] = props._myRotateTransform;
                        props._myTransformGroup.Children[1] = props._myTranslateTransform;
                    }));
                }
            }
            //dynamic bufferData = JsonConvert.DeserializeObject(props.bufferDb.bufferData);
            //props._posision = Global_Object.CoorCanvas(new Point(((bufferData != null) ? (((double)bufferData.x)) : 0), ((bufferData != null) ? (((double)bufferData.y)) : 0)));
            //props._rotate = (bufferData != null) ? (((double)bufferData.angle)) : 0;
            SetCoorAndRotate();
            UpdateAllPalletStatus(props.bufferDb.pallets);
        }