Exemple #1
0
    void onClick_connect()
    {
        if (PortConnectManager.GetInstance().IsConnected())
        {
            AlertMananger.GetInstance().ShowConfirmDialog("Disconnect", "Are you sure you want to disconnect? The printing will fail if you disconnect when printing.", this);
            return;
        }

        if (PortConnectManager.GetInstance().IsConnecting())
        {
            AlertMananger.GetInstance().ShowToast("Connecting, wait a minute.");
            return;
        }

        if (PortConnectManager.GetAllPortNames().Count == 0)
        {
            Debug.LogWarning("No port found" + "\n");
            AlertMananger.GetInstance().ShowToast("Please connect the printer to your computer using the provided USB cable.");
            return;
        }

        if (dropdown_port.value >= PortConnectManager.GetAllPortNames().Count)
        {
            AlertMananger.GetInstance().ShowToast("Selelct a port first.");
            return;
        }

        //try to connect
        _loadingMsgId = AlertMananger.GetLoadingMsgId();
        AlertMananger.GetInstance().ShowAlertLoading("Connecting...", _loadingMsgId);

        string portName = PortConnectManager.GetAllPortNames()[dropdown_port.value];

        PortConnectManager.GetInstance().Connect(portName);
    }
    private void doExportGcode(object obj)
    {
        List <string> list       = (List <string>)obj;
        string        originPath = list[0];
        string        exportPath = list[1];

        _loadingMsgId = AlertMananger.GetLoadingMsgId();
        AlertMananger.GetInstance().ShowAlertLoading("Exporting...", _loadingMsgId);
        //todo: may exception occured
        Debug.Log("Gcode export: " + originPath + "--->" + exportPath + "\n");
        File.Copy(originPath, exportPath, true);

        AlertMananger.GetInstance().DismissAlertLoading(_loadingMsgId);
        AlertMananger.GetInstance().ShowToast("Successfully export gcode.");
    }