private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (lineMode)
         {
             NextImage();
         }
         else
         {
             wheelGuess = CursorControl.GetGlobalCursorPos();
             EnableLine();
         }
     }
     else if (Input.GetMouseButtonDown(1))
     {
         NextImage();
     }
     else if (Input.GetMouseButtonDown(2))
     {
         ResetMode();
     }
     if (!lineMode)
     {
         dot.transform.position = Input.mousePosition;
     }
     else
     {
         line.GetComponent <RectTransform>().sizeDelta = new Vector2(dot.transform.position.x - Input.mousePosition.x, 100);
     }
 }
Exemple #2
0
 /// <summary>
 /// Sets the local cursor position to the current x and y position input fields
 /// </summary>
 public void SetLocalCursorPos()
 {
     if (TryParsePos())
     {
         CursorControl.SetLocalCursorPos(_pos);
     }
 }
        public void GlobalPosTest()
        {
            Vector2 pos = new Vector2(100, 200);

            CursorControl.SetGlobalCursorPos(pos);
            Assert.AreEqual(pos, CursorControl.GetGlobalCursorPos());
        }
Exemple #4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemple #5
0
        private void btnUpLoad_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (MessageDialog.ShowEnquiryMessage("您是否要上传【文件编号】:" + txtFileNo.Text
                                                         + " 【文件名称】:" + txtFileName.Text + "?") == DialogResult.No)
                    {
                        return;
                    }

                    Guid   guid             = new Guid();
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(openFileDialog1.FileName))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    guid = Guid.NewGuid();
                    m_serverFileBasic.AddFile(guid, strFtpServerPath + guid.ToString(), fileType);

                    CursorControl.SetWaitCursor(this);
                    m_serverFileBasic.FileUpLoad(openFileDialog1.FileName, strFtpServerPath, guid.ToString(), fileType);
                    this.Cursor = System.Windows.Forms.Cursors.Arrow;

                    if (GetError())
                    {
                        FM_FileList fileInfo = new FM_FileList();

                        fileInfo.DeleteFlag = false;
                        fileInfo.Department = txtDepartment.Tag.ToString();
                        fileInfo.FileName   = txtFileName.Text;
                        fileInfo.FileNo     = txtFileNo.Text;
                        fileInfo.FileUnique = guid;
                        fileInfo.SortID     = Convert.ToInt32(txtSort.Tag);
                        fileInfo.Version    = txtVersion.Text;

                        if (m_serverFileBasic.AddFileList(fileInfo, out m_strErr))
                        {
                            treeView1_AfterSelect(null, null);
                            MessageDialog.ShowPromptMessage("上传成功");
                        }
                        else
                        {
                            throw new Exception(m_strErr);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }
        }
Exemple #6
0
        public void Print(Image <Rgba32> image, int rezx, int rezy)
        {
            //sort the dots by index
            List <Dot>[] dotsByIndex = new List <Dot> [Program.selectedPalette.colors.Length];
            for (int i = 0; i < dotsByIndex.Length; i++)
            {
                dotsByIndex[i] = new List <Dot>();
            }

            for (int i = 0; i < rezx; i++)
            {
                for (int j = 0; j < rezy; j++)
                {
                    int cindex = Program.GetNearestColorIndex(image[i, j]);
                    if (cindex == -1)
                    {
                        continue;
                    }
                    dotsByIndex[cindex].Add(new Dot(i, j));
                }
            }

            //shuffle because it looks cooler
            for (int i = 0; i < dotsByIndex.Length; i++)
            {
                dotsByIndex[i].Shuffle();
            }

            float offsetx = 0.5f / rezx;
            float offsety = 0.5f / rezy;

            //paint
            Dot lastDot = new Dot(-999999, -999999);

            for (int i = 0; i < dotsByIndex.Length; i++)
            {
                Program.SelectColor(i);//select the right color

                foreach (Dot dot in dotsByIndex[i])
                {
                    double distance = Math.Sqrt((dot.x - lastDot.x) * (dot.x - lastDot.x) + (dot.y - lastDot.y) * (dot.y - lastDot.y));
                    if (distance <= doubleclickPreventionDistance)
                    {
                        Thread.Sleep(doubleclickPreventionDelay);
                    }
                    lastDot = dot;
                    CursorControl.SetCursorPos01(offsetx + (double)dot.x / rezx, offsety + (double)dot.y / rezy);
                    Thread.Sleep(posDownDelay);
                    CursorControl.sendMouseDown();
                    Thread.Sleep(downUpDelay);
                    CursorControl.sendMouseUp();
                    Thread.Sleep(upPosDelay);
                }
            }
        }
 void Update()
 {
     if (InputDeviceManager.IsKeyDown(menuKey) && !DialogueManager.isConversationActive && !IsQuestLogOpen())
     {
         SetMenuStatus(!isMenuOpen);
     }
     if (lockCursorDuringPlay)
     {
         CursorControl.SetCursorActive(DialogueManager.isConversationActive || isMenuOpen || IsQuestLogOpen());
     }
 }
        //创建文件
        private void createnewfile_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid guid = Guid.NewGuid();

                    string fileName = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1,
                                                                         openFileDialog1.FileName.LastIndexOf(".") - (openFileDialog1.FileName.LastIndexOf("\\") + 1));
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    CursorControl.SetWaitCursor(this);
                    m_serverFTP.Upload(openFileDialog1.FileName, strFtpServerPath + guid);
                    this.Cursor = System.Windows.Forms.Cursors.Arrow;

                    if (GetError())
                    {
                        m_serverFileBasic.AddFile(guid, strFtpServerPath + guid, fileType);

                        this.listView1.LabelEdit = true;

                        ZL_Database_FileStruct tempLnq = new ZL_Database_FileStruct();

                        tempLnq.BillNo         = txtBillNo.Text;
                        tempLnq.CreationTime   = ServerTime.Time;
                        tempLnq.FileUnique     = guid;
                        tempLnq.FileName       = fileName;
                        tempLnq.ID             = Guid.NewGuid();
                        tempLnq.LastModifyTime = ServerTime.Time;
                        tempLnq.ParentID       = currentParentID == "" ? null : (Guid?)(new Guid(currentParentID));

                        m_serverQylityDatabase.InsertFileStruct(tempLnq);

                        ListViewItem item = new ListViewItem(new String[] { tempLnq.FileName,
                                                                            m_serverFTP.GetFileSize(strFtpServerPath + guid).ToString(), fileType,
                                                                            tempLnq.CreationTime.ToString(), tempLnq.LastModifyTime.ToString(), tempLnq.ID.ToString(),
                                                                            strFtpServerPath + guid, tempLnq.ParentID.ToString() }, 0);

                        SetListViewItemExtention(fileType, ref item);

                        this.listView1.Items.Add(item);
                        this.listView1.Items[this.listView1.Items.Count - 1].BeginEdit();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }
        }
Exemple #9
0
        /// <summary>
        /// 显示数据
        /// </summary>
        /// <param name="i">显示方式 0:返回查询信息 1:返回最新信息</param>
        void ShowDate(int i)
        {
            string  strNy = cmbYear.Text.Trim() + cmbMonth.Text.Trim();
            DataRow dr    = m_serverPurPlan.GetBill(strNy);

            if (dr == null || i != 0)
            {
                lbDJZT.Text = "新建计划";
            }
            else
            {
                lbDJZT.Text  = dr["DJZT"].ToString();
                lb_BZR.Text  = dr["BZR"].ToString();
                lb_BZRQ.Text = dr["BZRQ"].ToString();
                lb_PZR.Text  = dr["PZR"].ToString();
                lb_PZRQ.Text = dr["PZRQ"].ToString();
                lb_SHR.Text  = dr["SHR"].ToString();
                lb_SHRQ.Text = dr["SHRQ"].ToString();
            }

            DataTable dt = new DataTable();

            if (i == 0)
            {
                dt = m_serverPurPlan.GetList(strNy);
            }
            else
            {
                if (!m_serverPurPlan.IsFinish(strNy, out m_err))
                {
                    MessageDialog.ShowPromptMessage(m_err);
                    ClearDate();
                    return;
                }

                CursorControl.SetWaitCursor(this);
                dt          = m_serverPurPlan.GetNewList(strNy, out m_err);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                if (dt == null)
                {
                    MessageDialog.ShowPromptMessage(m_err);
                    ClearDate();
                    return;
                }
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                lbPrice.Text = Convert.ToDecimal(dt.Compute("sum([订货金额])", "")).ToString();
            }

            RefreshDataGirdView(dt);
        }
    public void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        Cursor.visible = false;
    }
Exemple #11
0
        public virtual void Equip(Transform root, Animator anim, bool swapEvent = false)
        {
            transform.SetParent(root);
            ResetTransforms();
            CursorControl.SetLookAtCursor(true);
            this.anim = anim;
            anim.runtimeAnimatorController = controller;

            if (swapEvent && swapAbilityCooldown.finished)
            {
                SwapAbility();
                swapAbilityCooldown.Restart();
            }
        }
    void NextImage()
    {
        Texture2D texture = Resources.Load <Texture2D>(fileNames[index]);

        index++;
        var sprite = new Sprite();

        sprite                 = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100f);
        image.sprite           = sprite;
        dot.transform.position = wheelGuess;
        CursorControl.SetGlobalCursorPos(wheelGuess);
        lineMode = false;
        line.gameObject.SetActive(false);
    }
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            SetDefaultCursor();
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Exemple #14
0
    void CheckJoystickInput()
    {
        _x = Input.GetAxis("JoystickMouseX");
        _y = Input.GetAxis("JoystickMouseY");

        if (_x > 0.02 || _x < -0.02 || _y > 0.02 || _y < -0.02)
        {
            float   cursorX      = CursorControl.GetGlobalCursorPos().x;
            float   cursorY      = CursorControl.GetGlobalCursorPos().y;
            float   newX         = cursorX - ((cursorX * _x) / 4);
            float   newY         = cursorY - ((cursorY * _y) / 4);
            Vector2 newCursorPos = new Vector2(newX, newY);
            CursorControl.SetGlobalCursorPos(newCursorPos);
        }
    }
Exemple #15
0
 /// <summary>
 /// Simulates mouse clicks when keyboard buttons are pressed
 /// </summary>
 private void SimulateMouseClicks()
 {
     if (Input.GetKeyDown(KeyCode.L))
     {
         CursorControl.SimulateLeftClick();
     }
     if (Input.GetKeyDown(KeyCode.M))
     {
         CursorControl.SimulateMiddleClick();
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         CursorControl.SimulateRightClick();
     }
 }
Exemple #16
0
    void FixedUpdate()
    {
        horizontal = Input.GetAxisRaw("Horizontal");
        vertical   = Input.GetAxisRaw("Vertical");
        Vector2 currCursPos = CursorControl.GetGlobalCursorPos();


        Vector2 cursPos = new Vector2(currCursPos.x + horizontal * cursSpeed, currCursPos.y + vertical * cursSpeed * -1.0f);

        if (tel.teleTrigger == true)
        {
            CursorControl.SetGlobalCursorPos(cursPos);

            //cam.transform.position += new Vector3 (horizontal * Time.deltaTime * cursSpeed, vertical * Time.deltaTime * cursSpeed, -10.0f);
        }
    }
    public void Start()
    {
        CursorControl CC = GameObject.Find("Cursor Manager(Clone)").GetComponent <CursorControl>();

        byte[] id    = CC.selectedID();
        int    count = 0;

        for (int i = 0; i < 4; ++i)
        {
            if (125 != id[i])
            {
                count++;
            }
        }

        SelectManager SM = GameObject.Find("Select Manager(Clone)").GetComponent <SelectManager>();

        ch = SM.LoadToScene(id, count);

        GameObject tmp = GameObject.Find("Selected Character Status(Clone)");

        if (null == tmp)
        {
            tmp = Instantiate(CharacterInfoSet);
        }

        CharacterSet CS = tmp.GetComponent <CharacterSet>();

        CS.init(ch);

        for (int i = 0; i < 4; ++i)
        {
            PI[i].init();

            if (125 != ch[i].ch_type)
            {
                PI[i].connected = true;
            }
            PI[i].nickname = CC.nickname[i];
            CS.nickname[i] = CC.nickname[i];
            PI[i].level    = ch[i].clearedround;
            PI[i].ch_type  = ch[i].ch_type;

            PI[i].show();
        }
    }
Exemple #18
0
        private void ButtonMouseClicked(object sender, RoutedEventArgs e)
        {
            if (GazeManager.Instance.IsCalibrated == false)
            {
                return;
            }

            if (cursorControl == null)
            {
                cursorControl = new CursorControl(activeScreen, true, true); // Lazy initialization
            }
            else
            {
                cursorControl.Enabled = !cursorControl.Enabled; // Toggle on/off
            }
            UpdateState();
        }
Exemple #19
0
        /// <summary>
        /// 上传文件
        /// </summary>
        string UpdateFile()
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid   guid             = new Guid();
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(openFileDialog1.FileName))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    ConditionUpdateFile(llbFileDownLoad, ref guid, strFtpServerPath, fileType, CE_OperatorMode.添加);

                    CursorControl.SetWaitCursor(this);
                    m_serverFileBasic.FileUpLoad(openFileDialog1.FileName, strFtpServerPath, guid.ToString(), fileType);

                    this.Cursor = System.Windows.Forms.Cursors.Arrow;
                    if (GetError())
                    {
                        MessageDialog.ShowPromptMessage("上传成功");
                        return(guid.ToString());
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return(null);
            }
        }
    // Use this for initialization
    void Start()
    {
        s_arr     = new Socket[4];
        connected = new bool[4] {
            false, false, false, false
        };
        NC = this.GetComponent <NetworkController>();
        DontDestroyOnLoad(gameObject);
        if (null == CC)
        {
            CC = GameObject.Find("Cursor Manager(Clone)").GetComponent <CursorControl>();
        }

        sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        sck.Bind(new IPEndPoint(IPAddress.Any, 8080));
        sck.Listen(100);

        client_sock.Clear();

        sck.BeginAccept(new AsyncCallback(AcceptCallback), sck);
    }
    // Add a controller to the list of initialized controls
    private void AddPlayer(int playerID)
    {
        // Add the player to the array of assigned players. This is mainly just to make sure that the player number is set based on
        // the order of who pressed start. The player's number should be treated separately from the player's controller ID.
        assignedPlayers.Add(ReInput.players.GetPlayer(playerID));

        // Instantiate a cursor control and initialize all of it's values based on the data given.
        GameObject    pFab     = Instantiate(cursorPrefab);
        CursorControl pControl = pFab.GetComponent <CursorControl>();

        pControl.rewiredPlayer = ReInput.players.GetPlayer(playerID);
        pControl.controllerID  = playerID;
        pControl.playerNumber  = assignedPlayers.Count - 1;
        pControl.playerColor   = Player.playerColors[pControl.playerNumber];
        pControl.setSprite(radicleSprites [pControl.playerNumber]);          //Set the radicle's sprite to the appropriate one, based on the list you have.
        pControl.setSelectionDisplay(selectionDisplay[pControl.playerNumber]);


        pControl.rewiredPlayer.isPlaying = true;
        //pControl.GetComponent<SpriteRenderer>().color = pControl.playerColor;

        Debug.Log("created cursor control for player " + pControl.playerNumber + " with controlID " + pControl.controllerID);
    }
Exemple #22
0
    // Update is called once per frame
    void Update()
    {
        if (Cursor.lockState == CursorLockMode.None)
        {
            _pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            if (Input.GetAxis("ControllerX") != 0)
            {
                _pos.x += Input.GetAxis("ControllerX") * sensitivity;
            }
            if (Input.GetAxis("ControllerY") != 0)
            {
                _pos.y += Input.GetAxis("ControllerY") * sensitivity;
            }
            CursorControl.SetLocalCursorPos(_pos);

            if (Input.GetAxisRaw("ControllerA") != 0 && clickBool)
            {
                clickBool = false;
                StartCoroutine(resetClick(clickTime));
                Debug.Log("Pressed button!");
                CursorControl.SimulateLeftClick();
            }

            if (Input.GetAxisRaw("DPadVertical") != 0)
            {
                sensitivity += Input.GetAxisRaw("DPadVertical");
                if (sensitivity <= 0)
                {
                    sensitivity = 1;
                }
                if (sensitivity >= 100)
                {
                    sensitivity = 100f;
                }
            }
        }
    }
    /**
     *  Method to 'teleport' the mouse cursor if it gets stuck on the borders (north, east, south, west)
     *  !not native to Unity! will only work in fullscreen on actuall 1920 / 1080 screen
     *  Dll dependencies (windows only)
     *  left:   0, -
     *  top:    -, 0
     *  right:  1919, -
     *  bottum: -, 1079
     */
    private void continuesMouseIntegration()
    {
        Vector2 currentPosition = CursorControl.GetGlobalCursorPos();
        Vector2 newPosition;

        /** from south to north **/
        if (currentPosition.y <= 5)
        {
            newPosition = new Vector2(currentPosition.x, 1040);
            CursorControl.SetGlobalCursorPos(newPosition);
            resetMousePositions();
        }

        /** from north to south **/
        else if (currentPosition.y >= 1050)
        {
            newPosition = new Vector2(currentPosition.x, 16);
            CursorControl.SetGlobalCursorPos(newPosition);
            resetMousePositions();
        }
        /** from east to west **/
        if (currentPosition.x <= 5)
        {
            newPosition = new Vector2(1790, currentPosition.y);
            CursorControl.SetGlobalCursorPos(newPosition);
            resetMousePositions();
        }

        /** from west to east **/
        else if (currentPosition.x >= 1800)
        {
            newPosition = new Vector2(6, currentPosition.y);
            CursorControl.SetGlobalCursorPos(newPosition);
            resetMousePositions();
        }
    }
 // Use this for initialization
 void Start()
 {
     mainCam  = Camera.main;
     pStats   = GameObject.FindObjectOfType <PlayerStats>();
     cControl = GameObject.FindObjectOfType <CursorControl>();
 }
Exemple #25
0
    public void clicked()
    {
        switch (ButtonType)
        {
        case 0:
            //NEWTWORK DATA SAVE
            //OPTION DATA SAVE
            //CURSOR DATA SAVE
            SceneManager.LoadScene(SceneorPopup);
            break;

        case 1:
            Application.Quit();
            break;

        case 2:    //Character select next button
        {
            CursorControl CC = GameObject.Find("Cursor Manager(Clone)").GetComponent <CursorControl>();
            if (false == CC.characterallselected())
            {
                break;
            }

            SelectManager p_SM = GameObject.Find("Select Manager(Clone)").GetComponent <SelectManager>();
            p_SM.SelfSave();

            SceneManager.LoadScene(SceneorPopup);
            break;
        }

        case 3:    //character select back
        {
            SelectManager p_SM = GameObject.Find("Select Manager(Clone)").GetComponent <SelectManager>();
            p_SM.SelfSave();

            SceneManager.LoadScene(SceneorPopup);
            break;
        }

        case 4:
            //option popup
            GameObject.Find("OPTION POPUP").active = true;
            GameObject.Find("Button").active       = false;
            break;

        case 5:
            //option close
            GameObject.Find("OPTION POPUP").active = false;
            GameObject.Find("Button").active       = true;
            break;

        case 6:
            //Difficulty
            GameObject.Find("SoloPlay Scene Manager").GetComponent <SoloPlaySceneManager>().selectBook(SceneorPopup[0]);
            break;

        case 7:
            //difficulty back
            GameObject.Find("SoloPlay Scene Manager").GetComponent <SoloPlaySceneManager>().cancleBook();
            break;

        case 8:
            //skill
            GameObject.Find("SoloPlay Scene Manager").GetComponent <SoloPlaySceneManager>().selectSkill();
            break;

        case 9:
            //skill back
            GameObject.Find("SoloPlay Scene Manager").GetComponent <SoloPlaySceneManager>().cancleSkill();
            break;

        default:
            break;
        }
    }
        private void ButtonMouseClicked(object sender, RoutedEventArgs e)
        {
            if (GazeManager.Instance.IsCalibrated == false)
                return;

            if (cursorControl == null)
                cursorControl = new CursorControl(activeScreen, true, true); // Lazy initialization
            else
                cursorControl.Enabled = !cursorControl.Enabled; // Toggle on/off

            UpdateState();
        }
Exemple #27
0
 public void Awake()
 {
     instance = this;
 }
Exemple #28
0
        /// <summary>
        /// 上传文件
        /// </summary>
        string Update(string mode)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid   guid             = new Guid();
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(openFileDialog1.FileName))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    switch (mode)
                    {
                    case "Propoer":

                        if (llbProposerDownLoad.Tag == null || llbProposerDownLoad.Tag.ToString().Trim().Length == 0)
                        {
                            guid = Guid.NewGuid();
                            m_serverFileBasicInfo.AddFile(guid, strFtpServerPath + guid.ToString(), fileType);
                        }
                        else
                        {
                            guid = new Guid(llbProposerDownLoad.Tag.ToString());
                            m_serverFileBasicInfo.UpdateFile(guid, fileType);
                        }
                        break;

                    default:
                        break;
                    }

                    CursorControl.SetWaitCursor(this);

                    m_serverFileBasicInfo.FileUpLoad(openFileDialog1.FileName, strFtpServerPath, guid.ToString(), fileType);

                    this.Cursor = System.Windows.Forms.Cursors.Arrow;

                    if (GetError())
                    {
                        MessageDialog.ShowPromptMessage("上传成功");
                        return(guid.ToString());
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return(null);
            }
        }
        private void txtInport_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                CursorControl.SetWaitCursor(this);
                DataTable dtTemp = ExcelHelperP.RenderFromExcel(openFileDialog1.OpenFile());

                if (dtTemp == null)
                {
                    MessageDialog.ShowPromptMessage(m_strError);
                    return;
                }

                if (CheckTable(dtTemp))
                {
                    List <ZL_Database_Record> listRecord = new List <ZL_Database_Record>();

                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        if (dr["序列号"].ToString().Trim().Length == 0)
                        {
                            continue;
                        }

                        ZL_Database_Record m_lnqRecord = new ZL_Database_Record();

                        m_lnqRecord.BillNo           = openFileDialog1.FileName.Substring(0, openFileDialog1.FileName.LastIndexOf("\\") + 1) + dr["序列号"].ToString().Trim();
                        m_lnqRecord.CreationTime     = ServerTime.Time;
                        m_lnqRecord.AssemblyCartonNo = dr["总成箱号"].ToString().Trim();
                        m_lnqRecord.CauseAnalysis    = dr["原因分析"].ToString().Trim();
                        m_lnqRecord.FaultRatio       = dr["故障比例"].ToString().Trim();
                        m_lnqRecord.Provider         = dr["供应商"].ToString().Trim();
                        m_lnqRecord.FaultDescription = dr["故障描述"].ToString().Trim();
                        m_lnqRecord.FaultType        = dr["故障类型"].ToString().Trim();
                        m_lnqRecord.Finder           = dr["发现人员"].ToString().Trim();
                        m_lnqRecord.FindPlaces       = dr["发现场所"].ToString().Trim();
                        m_lnqRecord.FindRole         = dr["发现者"].ToString().Trim();
                        m_lnqRecord.GoodsCode        = dr["图号型号"].ToString().Trim();
                        m_lnqRecord.GoodsName        = dr["物品名称"].ToString().Trim();
                        m_lnqRecord.Spec             = dr["规格"].ToString().Trim();
                        m_lnqRecord.Mileage          = dr["行驶里程"].ToString().Trim() == "" ? 0 : Convert.ToDecimal(dr["行驶里程"].ToString().Trim());
                        m_lnqRecord.Model            = dr["型号"].ToString().Trim();
                        m_lnqRecord.OccurrenceTime   = dr["发生时间"].ToString().Trim() == ""? null :
                                                       (DateTime?)Convert.ToDateTime(dr["发生时间"].ToString().Trim());
                        m_lnqRecord.TreatmentCountermeasures = dr["处理对策"].ToString().Trim();
                        m_lnqRecord.Type    = dr["不良品类型"].ToString().Trim();
                        m_lnqRecord.Version = dr["版次"].ToString().Trim();

                        listRecord.Add(m_lnqRecord);
                    }

                    m_serverQylityDatabase.BatchInportInfo(listRecord);
                    MessageDialog.ShowPromptMessage("导入成功");
                }

                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }


            btnRefresh_Click(null, null);
        }
        /// <summary>
        /// 通用操作方式
        /// </summary>
        /// <param name="guid">唯一编码</param>
        void ShowOrDownLoad(string guid)
        {
            try
            {
                FM_FilePath lnqTemp = m_serverFileBasicInfo.GetFilePathInfo(new Guid(guid));

                操作方式 frm = new 操作方式(ProcessType.审查);
                frm.ShowDialog();

                if (frm.OperatorFlag == CE_FileOperatorType.在线阅读)
                {
                    FileOperationService.File_Look(new Guid(guid),
                                                   GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                }
                else if (frm.OperatorFlag == CE_FileOperatorType.载)
                {
                    saveFileDialog1.Filter   = "All files (*.*)|*.*";
                    saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-");

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        BackgroundWorker worker = BackgroundWorkerTools.GetWorker("下载文件");
                        worker.RunWorkerAsync();

                        m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName);

                        worker.CancelAsync();

                        if (GetError())
                        {
                            MessageDialog.ShowPromptMessage("下载成功");
                        }
                    }
                }
                else if (frm.OperatorFlag == CE_FileOperatorType.在线编辑)
                {
                    string filePath = "C:\\temp" + lnqTemp.FileType;

                    m_serverFTP.Download(lnqTemp.FilePath, filePath);
                    System.Diagnostics.Process myProcess = new System.Diagnostics.Process();

                    //设置启动进程的初始目录 
                    myProcess.StartInfo.WorkingDirectory = Application.StartupPath;
                    //设置启动进程的应用程序或文档名 
                    myProcess.StartInfo.FileName = filePath;
                    //设置启动进程的参数 
                    myProcess.StartInfo.Arguments = "";

                    myProcess.Start();
                    myProcess.WaitForExit();

                    bool   flag             = false;
                    Guid   guidTemp         = new Guid();
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(filePath))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    if (btnAdd.Visible)
                    {
                        ConditionUpdateFile(llbProposerDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        llbProposerUpLoad.Tag    = guidTemp;
                        llbProposerDownLoad.Tag  = guidTemp;
                        llbProposerDownLoad.Text = BasicInfo.LoginName + "的文件";
                    }
                    else if (btnAudit.Visible)
                    {
                        ConditionUpdateFile(llbAuditorDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        llbAuditorUpLoad.Tag    = guidTemp;
                        llbAuditorDownLoad.Tag  = guidTemp;
                        llbAuditorDownLoad.Text = BasicInfo.LoginName + "的文件";
                    }
                    else if (btnPointAffirm.Visible)
                    {
                        ConditionUpdateFile(llbPointDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        m_serverReviewProcess.PointUpLoadFile(guidTemp, m_strSDBNo);

                        dataGridView1.DataSource = m_serverReviewProcess.GetListInfoTable(txtSDBNo.Text);
                        PositioningRecord(BasicInfo.LoginID);
                    }
                    else if (btnJudge.Visible)
                    {
                        ConditionUpdateFile(llbJudgeDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        llbJudgeUpLoad.Tag    = guidTemp;
                        llbJudgeDownLoad.Tag  = guidTemp;
                        llbJudgeDownLoad.Text = BasicInfo.LoginName + "的文件";
                    }

                    if (flag)
                    {
                        CursorControl.SetWaitCursor(this);
                        m_serverFileBasicInfo.FileUpLoad(filePath, strFtpServerPath, guidTemp.ToString(), lnqTemp.FileType);
                        this.Cursor = System.Windows.Forms.Cursors.Arrow;
                    }

                    File.Delete(filePath);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return;
            }
        }
Exemple #31
0
 override public void Awake()
 {
     cursor = this;
 }