コード例 #1
0
        public void ReloadAllStation()
        {
            for (int i = 0; i < list_Station.Count; i++)
            {
                //Console.WriteLine(i);
                StationShape temp = list_Station.ElementAt(i).Value;
                Console.WriteLine("Remove: " + list_Station.ElementAt(i).Key);
                temp.Remove();
            }
            list_Station.Clear();

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global_Object.url + "buffer/getListBuffer");

            request.Method      = "GET";
            request.ContentType = @"application/json";
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;

            using (Stream responseStream = response.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                string       result = reader.ReadToEnd();

                DataTable buffers = JsonConvert.DeserializeObject <DataTable>(result);
                foreach (DataRow dr in buffers.Rows)
                {
                    dtBuffer tempBuffer = new dtBuffer
                    {
                        creUsrId = int.Parse(dr["creUsrId"].ToString()),
                        creDt    = dr["creDt"].ToString(),
                        updUsrId = int.Parse(dr["updUsrId"].ToString()),
                        updDt    = dr["updDt"].ToString(),

                        bufferId        = int.Parse(dr["bufferId"].ToString()),
                        bufferName      = dr["bufferName"].ToString(),
                        bufferNameOld   = dr["bufferNameOld"].ToString(),
                        bufferCheckIn   = dr["bufferCheckIn"].ToString(),
                        bufferData      = dr["bufferData"].ToString(),
                        maxBay          = int.Parse(dr["maxBay"].ToString()),
                        maxBayOld       = int.Parse(dr["maxBayOld"].ToString()),
                        maxRow          = int.Parse(dr["maxRow"].ToString()),
                        maxRowOld       = int.Parse(dr["maxRowOld"].ToString()),
                        bufferReturn    = bool.Parse(dr["bufferReturn"].ToString()),
                        bufferReturnOld = bool.Parse(dr["bufferReturnOld"].ToString()),
                        //pallets
                    };
                    if (list_Station.ContainsKey(tempBuffer.bufferName.ToString().Trim()))
                    {
                        list_Station[tempBuffer.bufferName.ToString().Trim()].props.bufferDb = tempBuffer;
                        Console.WriteLine("Upadte bufferDb station ReloadAllStation:" + tempBuffer.bufferName);
                    }
                    else
                    {
                        StationShape tempStation = new StationShape(map, tempBuffer);
                        //tempStation.ReDraw();
                        //tempStation.RemoveHandle += StationRemove;
                        list_Station.Add(tempStation.props.bufferDb.bufferName.ToString().Trim(), tempStation);
                        Console.WriteLine("Add them station ReloadAllStation:" + tempBuffer.bufferName);
                    }
                }
            }
        }
コード例 #2
0
        void Statectrl_MouseDown(MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                //EditObject();
            }
            Point mousePos       = e.GetPosition(map);
            var   mouseWasDownOn = e.Source as FrameworkElement;

            switch (Global_Mouse.ctrl_MouseDown)
            {
            case Global_Mouse.STATE_MOUSEDOWN._ADD_STATION:
            {
                if (Global_Mouse.ctrl_MouseDown == Global_Mouse.STATE_MOUSEDOWN._ADD_STATION)
                {
                    StationShape stationTemp = null;
                    //stationTemp = new StationShape(map, "MIX" + stationCount, 2, 7, 0);
                    stationCount++;
                    stationTemp.Move(mousePos);
                    //map.Children.Add(stationTemp);
                }
                break;
            }

            case Global_Mouse.STATE_MOUSEDOWN._KEEP_IN_OBJECT:
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    if (elementName != "")
                    {
                        Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._MOVE_STATION;
                        Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._GET_OUT_OBJECT;
                    }
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_STRAIGHT_P1:
                //pathTemp = new StraightShape(map, new Point(0, 0), new Point(0, 0));
                //pathTemp.RemoveHandle += PathRemove;
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    if (elementName != "")
                    {
                        draw_StartPoint             = mousePos;
                        Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_STRAIGHT_FINISH;
                        Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._HAND_DRAW_STRAIGHT;
                    }
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEUP_P1:
                //pathTemp = new CurveShape(map, new Point(0, 0), new Point(0, 0), true);
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    if (elementName != "")
                    {
                        draw_StartPoint             = mousePos;
                        Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEUP_FINISH;
                        Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._HAND_DRAW_CURVE;
                    }
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEDOWN_P1:
                //pathTemp = new CurveShape(map, new Point(0, 0), new Point(0, 0), false);
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    if (elementName != "")
                    {
                        draw_StartPoint             = mousePos;
                        Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEDOWN_FINISH;
                        Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._HAND_DRAW_CURVE;
                    }
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_JOINPATHS_P1:
                //pathTemp = new CurveShape(map, new Point(0, 0), new Point(0, 0), false);
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    string type        = (e.Source.GetType().Name);
                    if ((elementName != "") && ((type == "StraightPath") || (elementName.Split('x')[0] == "StraightPath")))
                    {
                        //draw_StartPoint = list_Path[elementName].props.cornerPoints[4];
                        Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_JOINPATHS_FINISH;
                        Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._HAND_DRAW_JOINPATHS;
                    }
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_STRAIGHT_FINISH:
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_STRAIGHT_P1;
                    Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._NORMAL;     //stop draw
                    //pathTemp.props._oriMousePos = pathTemp.props.cornerPoints[0];
                    //pathTemp.props._desMousePos = pathTemp.props.cornerPoints[4];
                    //list_Path.Add(pathTemp.Name, pathTemp);
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEUP_FINISH:
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEUP_P1;
                    Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._NORMAL;     //stop draw
                    //pathTemp.props._oriMousePos = pathTemp.props.cornerPoints[7];
                    //pathTemp.props._desMousePos = pathTemp.props.cornerPoints[5];
                    //list_Path.Add(pathTemp.Name, pathTemp);
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEDOWN_FINISH:
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_CURVEDOWN_P1;
                    Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._NORMAL;     //stop draw
                    //pathTemp.props._oriMousePos = pathTemp.props.cornerPoints[7];
                    //pathTemp.props._desMousePos = pathTemp.props.cornerPoints[5];
                    //list_Path.Add(pathTemp.Name, pathTemp);
                }
                break;

            case Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_JOINPATHS_FINISH:
                if (mouseWasDownOn != null)
                {
                    string elementName = mouseWasDownOn.Name;
                    string type        = (e.Source.GetType().Name);
                    if ((elementName != "") && ((type == "StraightPath") || (elementName.Split('x')[0] == "StraightPath")))
                    {
                        Global_Mouse.ctrl_MouseDown = Global_Mouse.STATE_MOUSEDOWN._HAND_DRAW_JOINPATHS_P1;
                        Global_Mouse.ctrl_MouseMove = Global_Mouse.STATE_MOUSEMOVE._NORMAL;     //stop draw
                        //pathTemp.props._oriMousePos = pathTemp.props.cornerPoints[7];
                        //pathTemp.props._desMousePos = pathTemp.props.cornerPoints[5];
                        //list_Path.Add(pathTemp.Name, pathTemp);
                    }
                    else
                    {
                        MessageBox.Show("JoinPaths is only accept between two StraightPath! \n And only link Tail-Head");
                    }
                }
                break;

            default:
            {
                break;
            }
            }
        }