コード例 #1
0
    protected void ShowOrHideAll_Click(object sender, EventArgs e)
    {
        //switch visibility icon All rows .
        String HideOrShow = switchVisible_Invisible(null, "hf_OrganVisibility", gvScore);
        string contact    = "7 " + HideOrShow; //send "6 Hide realOrganName" to 3DBuilder


        /*
         * string a = "abcdd";
         *
         * //use JS alert() in C#
         * ScriptManager.RegisterStartupScript(
         * this,
         * typeof(Page),
         * "Alert",
         * "<script>alert('" + a + "');</script>",
         * false);
         * /////
         */

        //send hide 3D organ msg to 3DBuilder
        //string contact = "7 " + HideOrShow;//send "7 Hide realOrganName" to 3DBuilder
        //string contact = "6 " + HideOrShow ;



        //string contact = "6 hide Left Popliteal Vein";

        NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
    }
コード例 #2
0
    protected void syncOrganVisibility23DBuilder(Object sender, EventArgs e)
    {
        //int index = Convert.ToInt32(e.CommandArgument);
        //Get the button that raised the event
        HtmlInputControl show_Hide_Icon = (HtmlInputControl)sender;

        //Get the row that contains this button
        GridViewRow selectedRow = (GridViewRow)show_Hide_Icon.NamingContainer;


        // Get the last name of the selected author from the appropriate
        // cell in the GridView control.


        var organIndicator = selectedRow.FindControl("LBTextBox_OrganName") as Label;

        string correctOrganName = organIndicator.Text;

        //If the organ is set to be visible
        if ((selectedRow.FindControl("hf_OrganVisibility") as HiddenField).Value == "true")
        {
            string contact = "6 " + "show" + " " + correctOrganName; //send "6 Hide realOrganName" to 3DBuilder

            NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
        }

        //If the organ is set to be invisible
        else
        {
            string contact = "6 " + "hide" + " " + correctOrganName; //send "6 Hide realOrganName" to 3DBuilder

            NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
        }
    }
コード例 #3
0
    //Show 3D Labels in 3DBuilder
    protected void ShowOrHide3DLabels()
    {
        string contact = "8 " + "Show_3D_Labels"; //send "6 Hide realOrganName" to 3DBuilder



        NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
    }
コード例 #4
0
    //Call all the required functions to clear resources before the user leaves the page
    public void leaveThePage()
    {
        //It can call the function to shut down the currently used Named pipe
        NamedPipe_IPC_Connection.killCorrespondingCSNamedPipe();


        //redirect back to the Paper_MainPage.aspx (the exam paper editing page) in Hints.
        redirectBack2HintsPaper_MainPage("Save the Question");
    }
コード例 #5
0
    //make 3DBuilder load the target Organ XML file and display it
    //and send the randomized organ question number to the organs displayed in 3DBuilder
    private void loadOrganXMLIn3DBuilderForExamMode(string strRandomQuestionNo)
    {
        //send protocol,Data to 3DBuilder.
        NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + questionXMLPath + ".xml" + "_" + NameOrNumberAnsweringMode_Session + strRandomQuestionNo);

        //sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + questionXMLPath + ".xml" + "_" + strRandomQuestionNo);//send protocol,Data to 3DBuilder.

        //sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + questionXMLPath + ".xml" + "_" + "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15");//send protocol,Data to 3DBuilder.
    }
コード例 #6
0
    private void ActivateSaveSceneAsIn3DBuilder()
    {
        //switch visibility icon All rows .
        //String hideOrShow3DLabels = switchVisible_Invisible(null, "InOrVisible", gvScore);
        string contact = "9 " + "Activate_Save_Scene_As"; //send "6 Hide realOrganName" to 3DBuilder



        NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
    }
コード例 #7
0
    //Show 3D Labels in 3DBuilder
    protected void ShowOrHide3DLabels()
    {
        string contact = "8 " + "Show_3D_Labels";



        NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);

        // Thread.Sleep(1000); //Delay 1秒
    }
コード例 #8
0
    //initiate 3DBuilder:  Set Mode to Practice Mode in 3DBuilder for initialization
    private void setModeIn3DBuilderForInit()
    {
        //originating from ALHomePage.aspx
        NamedPipe_IPC_Connection.sendMsg23DBuilder("1 2");

        /*
         * wait for the 3DBuilder to finish initialization before sending the AIQ XML file path to it to load the 3D organs
         * otherwise an error will occur in the 3DBuilder for loading 3D organs without waiting for the initialization to be finished.
         */
        NamedPipe_IPC_Connection.sleepUntil3DBuilderFinishInit();
    }
    //wait for the 3DBuilder to finish initialization
    public static void sleepUntil3DBuilderFinishInit()
    {
        string messageFrom3DBuilder;
        int    sleepTimeCounter = 0;

        while (true)
        {
            //increase sleep time counter
            sleepTimeCounter++;

            //read message sent from the 3DBuilder from the CSNamedPipe.exe
            messageFrom3DBuilder = NamedPipe_IPC_Connection.readMsgFrom3DBuilder();


            //use JS alert() in C# to alert "Read message from named pipe failed." when we failed to read message from the 3DBuilder.
            if (messageFrom3DBuilder == "Read message from named pipe failed.")
            {
                /*
                 * ScriptManager.RegisterStartupScript(
                 * this,
                 * typeof(Page),
                 * "Alert",
                 * "<script>alert('" + messageFrom3DBuilder + "');</script>",
                 * false);
                 */
                break;
            }
            else if (messageFrom3DBuilder == "3DBuilder init is finished.")
            {
                /*
                 * ScriptManager.RegisterStartupScript(
                 * this,
                 * typeof(Page),
                 * "Alert",
                 * "<script>alert('" + messageFrom3DBuilder + "');</script>",
                 * false);
                 */
                break;
            }

            //keep sleeping until we successfully /fail to get the message from the 3DBuilder or
            Thread.Sleep(1);
        }

        /*
         * //alert how long it slept
         * ScriptManager.RegisterStartupScript(
         *       this,
         *       typeof(Page),
         *       "Alert",
         *       "<script>alert('The AIQ slept for " + sleepTimeCounter + " millisecond to wait for the 3DBuilder Init.');</script>",
         *       false);
         */
    }
コード例 #10
0
 //initiate 3DBuilder:  Set Mode to Practice Mode in 3DBuilder for initialization
 private void setModeIn3DBuilderForInit()
 {
     /*
      * //originating from ALHomePage.aspx
      * StreamWriter wr = (StreamWriter)Session["Writer"];
      * //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + os.StartInfo.RedirectStandardInput + os.Id + "');</script>");
      * //StreamWriter wr = os.StandardInput;
      *
      * wr.WriteLine("1 2");
      * */
     NamedPipe_IPC_Connection.sendMsg23DBuilder("1 2");
 }
コード例 #11
0
    //Call all the required functions to clear resources before the user leaves the page, and redirect to the desired page.
    public void leaveThePage(object sender = null, EventArgs e = null)
    {
        //It can call the function to shut down the currently used Named pipe
        NamedPipe_IPC_Connection.killCorrespondingCSNamedPipe();

        /*removes all the objects stored in a Session.
         * If you do not call the Abandon method explicitly, the server removes these objects and destroys the session when the session times out.
         * It also raises events like Session_End.*/
        Session.Abandon();



        //clear sessionStorage and redirect back to the exam paper
        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "JSRedirectBack2ExamPaper(); ", true);
    }
コード例 #12
0
    protected void btnBack_Click(object sender, EventArgs e)
    {
        //kill the corresponding running CsNamedPipe.exe process which is created when the teacher clicks "connect to 3DBuilder" to edit the AITypeQuestion in 3DBuilder.
        NamedPipe_IPC_Connection.killCorrespondingCSNamedPipe();


        /*removes all the objects stored in a Session.
         * If you do not call the Abandon method explicitly, the server removes these objects and destroys the session when the session times out.
         * It also raises events like Session_End.*/
        Session.Abandon();

        //direct back the Hints exam editing page
        //redirect back to the Paper_MainPage.aspx (the exam paper editing page) in Hints.
        redirectBack2HintsPaper_MainPage("Back");
    }
コード例 #13
0
    //run the CSNamedPipe.exe
    private void runCSNamedPipe()
    {
        NamedPipe_IPC_Connection IPC_Connection = new NamedPipe_IPC_Connection(Request.MapPath("~/"), Request.MapPath("App_Code/CSNamedPipe/bin/Debug/CSNamedPipe.exe"), strUserID);

        /*
         * //store the StreamWriter of the CSNamedPipe.exe to a session variable
         * //for writing message to CSNamedPipe.exe, and CSNamedPipe.exe will send it to the 3DBuilder.
         * Session["Writer"] = IPC_Connection.CSNamedPipeWriter;
         *
         * //store the StreamReader of the CSNamedPipe.exe to a session variable
         * //for reading message from CSNamedPipe.exe
         * //because 3DBuilder can send message to the CSNamedPipe.exe with named pipe.
         * Session["Reader"] = IPC_Connection.CSNamedPipeReader;
         *
         * //store the process of CSNamedPipe.exe to a session variable
         * //so that we can access it in other AIQ pages.
         * Session["Process"] = IPC_Connection.CSNamedPipeProcess;
         *
         * //get process ID of the CSNamedPipe, and store it in a session var so that we can kill the CSNamedPipe process after the user finishes using the connection with 3DBuilder
         * Session["ProcessID"] = IPC_Connection.CSNamedPipePID;
         *
         */
    }
コード例 #14
0
 //make 3DBuilder load the target Organ XML file and display it
 //because it's not of Exam Mode, so we don't need to send the randomized organ question number to 3DBuilder.
 private void loadOrganXMLIn3DBuilderFor_Non_ExamMode()
 {
     NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + questionXMLPath + ".xml");//send protocol,Data to 3DBuilder.
 }
コード例 #15
0
 //make 3DBuilder load the target Organ XML file and display it
 private void loadOrganXMLIn3DBuilder(string absoluteKneeXMLFolder, string selectedAITypeQuestionMode)
 {
     //send protocol,Data to 3DBuilder.
     NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + questionXMLPath + "_" + selectedAITypeQuestionMode);
 }
コード例 #16
0
    //submit current edition to 3DBuilder
    protected void gvScore_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
        // If multiple ButtonField column fields are used, use the
        // CommandName property to determine which button was clicked.
        if (e.CommandName == "Submit")
        {
            //store the msg that will be sent to the 3DBuilder.
            string msgFor3DBuilder = "";

            //if the AITypeQuestion is set to be of "Number Answering Mode"
            if (NameOrNumberAnsweringMode_Session == "Number Answering Mode")
            {
                // Convert the row index stored in the CommandArgument
                // property to an Integer.
                int index = Convert.ToInt32(e.CommandArgument);
                // Get the last name of the selected author from the appropriate
                // cell in the GridView control.
                GridViewRow selectedRow    = gvScore.Rows[index];
                var         answeringField = selectedRow.FindControl("TB_AnsweringField") as TextBox;
                var         organIndicator = selectedRow.FindControl("TB_OrganIndicator") as Label;

                string givenOrganName           = organIndicator.Text;
                string studentOrganNumberAnswer = answeringField.Text;
                //If the student hasn’t answered the organ number, we will prompt the student to answer it before clicking the “Show/Hide” icon of the question organ.
                if (studentOrganNumberAnswer == "")
                {
                    //If we use Response.Write to insert JS code,
                    //JS Bundles/MsAjax error: PRM_ParserErrorDetails will occur on the frontend.

                    /*
                     * Response.Write("<script>alert('Please enter the answer before clicking the 'Show/Hide' icon.');</script>");
                     */


                    //We use ScriptManager to inset JS code can
                    //avoid the JS Bundles/MsAjax error: PRM_ParserErrorDetails
                    ScriptManager.RegisterStartupScript(this,
                                                        typeof(Page),
                                                        "Alert",
                                                        "<script>alert('Please enter the answer before clicking the \"Submit\" icon.');</script>",
                                                        false);



                    //no need to do the rest of the work of the function if the student click the "Show/Hide" icon before answering the organ number
                    return;
                }


                //if what the student entered is not numeric, we show the warning and return at once.
                else if (!checkStringIsNumeric(studentOrganNumberAnswer))
                {
                    ScriptManager.RegisterStartupScript(this,
                                                        typeof(Page),
                                                        "Alert",
                                                        "<script>alert('What you entered is not numeric. Please enter it properly again.');</script>",
                                                        false);

                    return;
                }

                //Here the first para is the same as the third para.
                string correctOrganName = givenOrganName;


                //Replace the " " space in student's answer with "_" so that the 3DBuilder can extract and display the student's answer correctly
                givenOrganName = givenOrganName.Replace(" ", "_");

                //Update student answer to the 3D label in the 3DBuilder
                msgFor3DBuilder = "5 " + givenOrganName + " " + studentOrganNumberAnswer + " " + correctOrganName;
            }

            //if the AITypeQuestion is set to be of "Name Answering Mode"
            else if (NameOrNumberAnsweringMode_Session == "Name Answering Mode")
            {
                //generated random question number with Peter's function
                int[] randQuestionNoList = RandomQuestionNoSession;

                // Convert the row index stored in the CommandArgument
                // property to an Integer.
                int index = Convert.ToInt32(e.CommandArgument);

                // Get the last name of the selected author from the appropriate
                // cell in the GridView control.
                GridViewRow selectedRow    = gvScore.Rows[index];
                var         answeringField = selectedRow.FindControl("TB_AnsweringField") as TextBox;
                var         organIndicator = selectedRow.FindControl("TB_OrganIndicator") as Label;
                /////////////////////////////////////////////
                //text exam mode
                //store the Question number
                string QuestionNo;

                //if it's in the exam mode

                //2019/4/9 Ben commented for using default URL value if no paras provided.
                //if (Request["examMode"] == "Yes")
                if (examMode == "Yes")
                {
                    //get the label number of the target organ that is shown in the Organ Indicator column on the AITypeQuestion response page.
                    QuestionNo = (Array.IndexOf(randQuestionNoList, Int32.Parse(organIndicator.Text)) + 1).ToString();
                }

                //if it's not in the exam mode
                else
                {
                    QuestionNo = organIndicator.Text;
                }
                /////////////////////////////


                //get the corresponding correct organ name
                var rearrangedQuestionOrganNo = selectedRow.FindControl("TB_OrganIndicator") as Label;     //Index of the selected 3D object


                var correctOrganName = CorrectOrganNameSession[Convert.ToInt32(rearrangedQuestionOrganNo.Text) - 1];

                //Replace the " " space in student's answer with "_" so that the 3DBuilder can extract and display the student's answer correctly
                string studentOrganNameAnswer = answeringField.Text.Replace(" ", "_");

                //Update student answer to the 3D label in the 3DBuilder
                msgFor3DBuilder = "5 " + studentOrganNameAnswer + " " + QuestionNo + " " + correctOrganName.ToString();
                //string contact = "5 " + input + " "  + answer.Value.ToString();
            }

            //send the message to the 3DBuilder.
            NamedPipe_IPC_Connection.sendMsg23DBuilder(msgFor3DBuilder);
        }



        //For invisible
        //// If multiple ButtonField column fields are used, use the
        // CommandName property to determine which invisible button was clicked.
        if (e.CommandName == "InvisibleAndVisible")
        {
            // Convert the row index stored in the CommandArgument
            // property to an Integer.
            int index = Convert.ToInt32(e.CommandArgument);



            // Get the last name of the selected author from the appropriate
            // cell in the GridView control.
            GridViewRow selectedRow = gvScore.Rows[index];

            //to store the correct organ name
            var correctOrganName = "";

            if (NameOrNumberAnsweringMode_Session == "Name Answering Mode")
            {
                var rearrangedQuestionOrganNo = selectedRow.FindControl("TB_OrganIndicator") as Label; //Index of the selected 3D object

                //get the corresponding correct organ name
                correctOrganName = CorrectOrganNameSession[Convert.ToInt32(rearrangedQuestionOrganNo.Text) - 1];//The correct name of selected 3D object
            }


            //Step 5-1 When the student clicks the “Show/Hide” icon of a question organ, we will hide the corresponding organ according to the number entered by the student.
            //If the student hasn’t answered the organ number, we will prompt the student to answer it before clicking the “Show/Hide” icon of the question organ.
            else if (NameOrNumberAnsweringMode_Session == "Number Answering Mode")
            {
                TextBox tb = (TextBox)gvScore.Rows[index].FindControl("TB_AnsweringField");
                string  TB_AnsweringField_Content = tb.Text.Trim();

                //do sanity check of student's input.
                //If the student hasn’t answered the organ number, we will prompt the student to answer it before clicking the “Show/Hide” icon of the question organ.
                if (TB_AnsweringField_Content == "")
                {
                    //If we use Response.Write to insert JS code,
                    //JS Bundles/MsAjax error: PRM_ParserErrorDetails will occur on the frontend.

                    /*
                     * Response.Write("<script>alert('Please enter the answer before clicking the 'Show/Hide' icon.');</script>");
                     */

                    //We use ScriptManager to inset JS code can
                    //avoid the JS Bundles/MsAjax error: PRM_ParserErrorDetails
                    ScriptManager.RegisterStartupScript(this,
                                                        typeof(Page),
                                                        "Alert",
                                                        "<script>alert('Please enter the organ number before clicking the \"Show/Hide\" icon.');</script>",
                                                        false);

                    //no need to do the rest of the work of the function if the student click the "Show/Hide" icon before answering the organ number
                    return;
                }

                //if what the student entered is not numeric, we show the warning and return at once.
                else if (!checkStringIsNumeric(TB_AnsweringField_Content) && TB_AnsweringField_Content != "Non Answer Row")
                {
                    ScriptManager.RegisterStartupScript(this,
                                                        typeof(Page),
                                                        "Alert",
                                                        "<script>alert('What you entered is not numeric. Please enter it properly again.');</script>",
                                                        false);

                    return;
                }



                else
                {
                    //if the student wants to hide a 'Non Answer Row' organ,
                    //we hide the correponding 3D organ in the 3DBuilder by getting its organ name from TB_OrganIndicator of that row.
                    if (TB_AnsweringField_Content == "Non Answer Row")
                    {
                        var organIndicator = selectedRow.FindControl("TB_OrganIndicator") as Label;

                        correctOrganName = organIndicator.Text;
                    }

                    //look up the corresponding organ name of the organ number entered by the student.
                    else
                    {
                        int studentNumberAnswer = Int32.Parse(TB_AnsweringField_Content);
                        correctOrganName = NumberAnsweringMode_RandOrganNoNameMapping_Session[studentNumberAnswer].ToString();
                    }
                }
            }


            //switch visibility icon of the selected row .
            String HideOrShow = switchVisible_Invisible(selectedRow, "hf_OrganVisibility", null);

            /*
             * //use JS alert() in C#
             * ScriptManager.RegisterStartupScript(this,
             * typeof(Page),
             * "Alert",
             * "<script>alert('" + (selectedRow.Controls[3]).ImageUrl + "');</script>",
             * false);
             *
             * //send hide 3D organ msg to 3DBuilder
             */

            string contact = "6 " + HideOrShow + " " + correctOrganName.ToString(); //send "6 Hide realOrganName" to 3DBuilder

            NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
        }
        if (e.CommandName == "relay")
        {
            //switch visibility icon All rows .
            String HideOrShow = switchVisible_Invisible(null, "hf_OrganVisibility", gvScore);
            string contact    = "7 " + HideOrShow; //send "6 Hide realOrganName" to 3DBuilder



            NamedPipe_IPC_Connection.sendMsg23DBuilder(contact);
        }
    }
コード例 #17
0
    //originating from Item.aspx btnKnee_Click()
    private void randomizeQuestionOrganNo()
    {
        //These 2 variables will set by URL parameter or data retrieve from DB in the near future.
        ///////////////////////////////////////////////////////////////////////////////

        bool ExamMode = false;//ExamMode的中控

        //2019/4/9 Ben commented for using default URL value if no paras provided.
        //if (Request["examMode"] == "Yes")
        if (examMode == "Yes")
        {
            ExamMode = true;   //ExamMode的中控
        }
        string ID_Num = "234"; //The last 3 digits of student's ID will be retrieved from DB in the near future.

        //int[] pickedQuestions = { 1, 3, 5 }; //The Question Number of organs  picked by instructor will be retrieved from DB in the near future.


        //////////////////////////////////////////////////////////////////////////

        //Get The Question Number of organs  picked by instructor ( from Question XML file)
        int[] pickedQuestions = getPickedQuestionNumber();



        //if it's in exam mode.
        if (ExamMode)
        {
            //randomize the  Question Numbers picked by instructor using student's ID as seed.
            int[] randomQuestionNo = RandomQuestionNo.rand(ID_Num, pickedQuestions);


            //send randomized  Question Numbers picked by instructor to IPC.aspx through Session
            RandomQuestionNoSession = randomQuestionNo;



            //send randomized  Question Numbers picked by instructor to 3DBuilder .
            string strRandomQuestionNo = "";
            intArray2AString(randomQuestionNo, ref strRandomQuestionNo);

            /*
             * //use JS alert() in C#
             * ScriptManager.RegisterStartupScript(this,
             * typeof(Page),
             * "Alert",
             * "<script>alert('" + "3 " + XMLFolder + questionXMLPath +" "+ strRandomQuestionNo + "');</script>",
             * false);
             */


            /*
             * StreamWriter wr = (StreamWriter)Session["Writer"];
             * wr.WriteLine("3 " + absoluteKneeXMLFolder + QuestionFileName + "_" + strRandomQuestionNo);//send protocol,Data to 3DBuilder.
             */

            NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + QuestionFileName + "_" + strRandomQuestionNo);

            //!!!!//如何將上方兩個參數傳送到3DBuilder那裏的IPCInterface呢? 上行的WriteLine會寫到哪裡呢?

            //head to IPC.aspx
            //Response.Redirect("IPC.aspx");

            ////head to IPC.aspx in exam mode
            //Response.Redirect("IPC.aspx?examMode=Yes");
        }

        else//if it's not in exam mode
        {
            NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + QuestionFileName);

            /*
             * StreamWriter wr = (StreamWriter)Session["Writer"];
             * wr.WriteLine("3 " + absoluteKneeXMLFolder + QuestionFileName);//send protocol,Data to 3DBuilder.
             */
            //!!!!//如何將上方兩個參數傳送到3DBuilder那裏的IPCInterface呢? 上行的WriteLine會寫到哪裡呢?

            //head to IPC.aspx
            //Response.Redirect("IPC.aspx");

            ////head to IPC.aspx in exam mode
            //Response.Redirect("IPC.aspx");
        }
    }