Ejemplo n.º 1
0
    public void OnClickDoneButton()
    {
        ProteinDisplayView view = GetView <ProteinDisplayView>();

        view.CompleteAdjustProtein();
        CoreAPI.SendCommand <MainConsoleModule, RegisterHoldHandlerCommand>(new RegisterHoldHandlerCommand());
    }
Ejemplo n.º 2
0
            public void InvalidVariable()
            {
                CoreAPI core = Helper.GetCoreAPI();

                // call non-existant function
                core.GetVariableInt("xxxxxx");
            }
Ejemplo n.º 3
0
    public void OnSelectedDisplayMode()
    {
        MainConsoleView  view        = GetView <MainConsoleView>();
        MainConsoleModel model       = GetModel <MainConsoleModel>();
        DisplayMode      displayMode = default(DisplayMode);
        string           keyword     = view.GetSelectedDisplayMode();

        if (keyword == "BallStick")
        {
            displayMode = DisplayMode.BallStick;
        }
        else if (keyword == "SpaceFill")
        {
            displayMode = DisplayMode.Spacefill;
        }
        else if (keyword == "Sticks")
        {
            displayMode = DisplayMode.Sticks;
        }
        else
        {
            throw new System.Exception(string.Format("Unknown radial keyword : {0}", keyword));
        }
        model.DisplayMode = displayMode;
        CoreAPI.SendCommand <ProteinDisplayModule, ShowProteinCommand>(new ShowProteinCommand());
    }
Ejemplo n.º 4
0
    public void OnClickAdjustButton()
    {
        ProteinDisplayView view = GetView <ProteinDisplayView>();

        view.StartAdjustProtein();
        CoreAPI.SendCommand <MainConsoleModule, UnRegisterHoldHandlerCommand>(new UnRegisterHoldHandlerCommand());
    }
Ejemplo n.º 5
0
    /// <summary>显示蛋白质</summary>
    public void ShowProtein()
    {
        ProteinDisplayModel model       = GetModel <ProteinDisplayModel>();
        Protein             protein     = CoreAPI.PostCommand <PdbLoaderModule, GetProteinDataCommand, Protein>(new GetProteinDataCommand());
        DisplayMode         displayMode = CoreAPI.PostCommand <MainConsoleModule, GetDisplayModeCommand, DisplayMode>(new GetDisplayModeCommand());

        //若蛋白质数据还未加载 则直接返回
        if (protein == null)
        {
            return;
        }
        //若当前ProteinData与DisplayMode均是最新则直接返回,否则销毁重新Create
        if (model.DisplayedProteinData != null && model.DisplayedProteinData.ID == protein.ID && model.DisplayedDisplayMode == displayMode)
        {
            return;
        }
        else
        {
            DestroyProtein();
        }
        model.DisplayedProteinData = protein;
        model.DisplayedDisplayMode = displayMode;
        ProteinDisplayView view = GetView <ProteinDisplayView>();

        view.CreateProtein(protein, displayMode);
    }
Ejemplo n.º 6
0
 public void OnButtonClick()
 {
     // 调用PdbLoaderModule里的OnLoadLocalPdbFileCommand方法,反射实现的
     CoreAPI.SendCommand <PdbLoaderModule, LoadLocalPdbFileCommand>(new LoadLocalPdbFileCommand(() =>
     {
         CoreAPI.SendCommand <ProteinDisplayModule, ShowProteinCommand>(new ShowProteinCommand());
     }));
 }
Ejemplo n.º 7
0
    public void HideMainConsole()
    {
        MainConsoleView view = GetView <MainConsoleView>();

        view.gameObject.Active(false); //GameObject在OnDisable动画播放完毕后再SetActive false
        InputManager.Instance.AddGlobalListener(this.gameObject);
        CoreAPI.SendCommand <ProteinDisplayModule, SetPolymerInfoDisplayerActiveCommand>(new SetPolymerInfoDisplayerActiveCommand(true));
    }
Ejemplo n.º 8
0
    public void ShowMainConsole()
    {
        MainConsoleView  view  = GetView <MainConsoleView>();
        MainConsoleModel model = GetModel <MainConsoleModel>();

        view.gameObject.Active(true);
        InputManager.Instance.RemoveGlobalListener(this.gameObject);
        CoreAPI.SendCommand <ProteinDisplayModule, SetPolymerInfoDisplayerActiveCommand>(new SetPolymerInfoDisplayerActiveCommand(false));
    }
Ejemplo n.º 9
0
    private async void Init()
    {
        await PolymerModelAPI.LoadDataAsync();

        Debug.Log("加载PolymerModel完成");
        CoreAPI.SendCommand <MainConsoleModule, RegisterHoldHandlerCommand>(new RegisterHoldHandlerCommand());
        CoreAPI.SendCommand <MainConsoleModule, ShowMainConsoleCommand>(new ShowMainConsoleCommand());
        StartCoroutine(LaunchHelpDialog());
    }
Ejemplo n.º 10
0
    public void OnClickSelectFileButton()
    {
        MainConsoleView view = GetView <MainConsoleView>();

        CoreAPI.SendCommand <PdbLoaderModule, LoadLocalPdbFileCommand>(new LoadLocalPdbFileCommand((id) => {
            view.SetPDBFileNameText(id);
            CoreAPI.SendCommand <ProteinDisplayModule, ShowProteinCommand>(new ShowProteinCommand());
        }));
    }
Ejemplo n.º 11
0
    private async void LoadData()
    {
        await PolymerModelAPI.LoadDataAsync();

        Debug.Log("加载数据完成");
        CoreAPI.SendCommand <PdbLoaderModule, LoadDefaultPdbFileCommand>(new LoadDefaultPdbFileCommand("6dce", () => {
            CoreAPI.SendCommand <ProteinDisplayModule, ShowDisplayViewCommand>(new ShowDisplayViewCommand());
            CoreAPI.SendCommand <ProteinDisplayModule, ShowProteinCommand>(new ShowProteinCommand());
        }));
    }
Ejemplo n.º 12
0
    public void OnClickDownloadButton()
    {
        MainConsoleView view  = GetView <MainConsoleView>();
        string          input = view.GetInputPdbId();

        CoreAPI.SendCommand <PdbLoaderModule, LoadNetworkPdbFileCommand>(new LoadNetworkPdbFileCommand(input, () => {
            view.SetPDBFileNameText(input);
            CoreAPI.SendCommand <ProteinDisplayModule, ShowProteinCommand>(new ShowProteinCommand());
        }));
    }
Ejemplo n.º 13
0
    public void OnClickExampleButton()
    {
        string          pdbName = "2nc3";
        MainConsoleView view    = GetView <MainConsoleView>();

        CoreAPI.SendCommand <PdbLoaderModule, LoadDefaultPdbFileCommand>(new LoadDefaultPdbFileCommand(pdbName, () => {
            view.SetPDBFileNameText(pdbName);
            CoreAPI.SendCommand <ProteinDisplayModule, ShowProteinCommand>(new ShowProteinCommand());
        }));
    }
Ejemplo n.º 14
0
    public void OnInputClicked(InputClickedEventData eventData)
    {
        PolymerSelectMode selectMode = CoreAPI.PostCommand <MainConsoleModule, GetSelectModeCommand, PolymerSelectMode>(new GetSelectModeCommand());

        //Chain是可选取的最顶层,若事件传导到ChainDisplayer则一定是SelectMode.Chain 有可能选择的Bond传导上去了
        //if(selectMode!= SelectMode.Chain) {
        //    throw new System.Exception("Logic Error");
        //}
        CoreAPI.SendCommand <ProteinDisplayModule, SetSelectedDisplayerCommand>(new SetSelectedDisplayerCommand(this));
    }
Ejemplo n.º 15
0
            public void InvalidFunction()
            {
                CoreAPI core = Helper.GetCoreAPI();

                // test we can access the core by asking its name
                Assert.AreEqual(core.GetCoreInfo().Name, Helper.GetCoreName());

                // call non-existant function
                core.CallFunctionInt("xxxxxx", "none");
            }
Ejemplo n.º 16
0
        public static CoreAPI GetCoreAPI()
        {
            CoreAPI core;

            AppSettingsReader reader = new AppSettingsReader();

            core = new CoreAPI(reader.GetValue("AccessToken", typeof(string)).ToString(),
                               reader.GetValue("CoreID", typeof(string)).ToString());

            return(core);
        }
Ejemplo n.º 17
0
    public void OnInputClicked(InputClickedEventData eventData)
    {
        PolymerSelectMode selectMode  = CoreAPI.PostCommand <MainConsoleModule, GetSelectModeCommand, PolymerSelectMode>(new GetSelectModeCommand());
        DisplayMode       displayMode = CoreAPI.PostCommand <MainConsoleModule, GetDisplayModeCommand, DisplayMode>(new GetDisplayModeCommand());

        //只有棍模型下的棍支持选取
        if (displayMode != DisplayMode.Sticks)
        {
            return;
        }
        AminoacidDisplayer aminoacidDisplayer = transform.parent.GetComponent <AminoacidDisplayer>();

        aminoacidDisplayer.OnInputClicked(eventData);
    }
Ejemplo n.º 18
0
    public void OnInputClicked(InputClickedEventData eventData)
    {
        PolymerSelectMode  selectMode         = CoreAPI.PostCommand <MainConsoleModule, GetSelectModeCommand, PolymerSelectMode>(new GetSelectModeCommand());
        AminoacidDisplayer aminoacidDisplayer = transform.parent.GetComponent <AminoacidDisplayer>();

        if (selectMode == PolymerSelectMode.Atom)
        {
            CoreAPI.SendCommand <ProteinDisplayModule, SetSelectedDisplayerCommand>(new SetSelectedDisplayerCommand(this));
        }
        else
        {
            aminoacidDisplayer.OnInputClicked(eventData);
        }
    }
    /// <summary>显示蛋白质</summary>
    public void ShowProtein()
    {
        ProteinDisplayModel model   = GetModel <ProteinDisplayModel>();
        Protein             protein = CoreAPI.PostCommand <PdbLoaderModule, GetProteinDataCommand, Protein>(new GetProteinDataCommand());

        if (model.DisplayedProteinData != null)
        {
            if (model.DisplayedProteinData.ID == protein.ID)
            {
                return;
            }
            else
            {
                DestroyProtein();
            }
        }
        model.DisplayedProteinData = protein;
        ProteinDisplayView view = GetView <ProteinDisplayView>();

        view.ShowProtein(protein);
    }
Ejemplo n.º 20
0
        public async Task <bool> WriteData(String strID)
        {
            PowerPoint.Shapes shapes = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes;
            try
            {
                JObject jsonData = await RequestData.GetPredictData(strID);

                JObject          dataObj = jsonData["data"].ToObject <JObject>();
                PowerPoint.Shape shape   = PPTAPI.getShape(shapes, "Label_1");
                if (shape != null)
                {
                    shape.TextFrame.TextRange.Text = dataObj.Value <String>("labelInfo");
                }
                shape = PPTAPI.getShape(shapes, "DateLabel");
                if (shape != null)
                {
                    String strText = shape.TextFrame.TextRange.Text;
                    strText = strText.Replace("{Date}", dataObj.Value <String>("date"));
                    shape.TextFrame.TextRange.Text = strText;
                }

                shape = PPTAPI.getShape(shapes, "Table_1");
                if (shape != null)
                {
                    PowerPoint.Table table = shape.Table;

                    shape = PPTAPI.getShape(shapes, "Chart_1");
                    PowerPoint.Chart chart      = shape.Chart;
                    var                ws       = chart.ChartData.Workbook.Worksheets[1];
                    JArray             array    = dataObj.Value <JArray>("salesData");
                    List <PredictData> predicts = CoreAPI.Deserialize <List <PredictData> >(array.ToString());

                    int  col      = 2;
                    char colStart = 'B';
                    foreach (PredictData predict in predicts)
                    {
                        int    row  = 1;
                        String step = colStart + row.ToString();
                        ws.Range[step].Value = predict.Month;
                        table.Cell(row, col).Shape.TextFrame.TextRange.Text = predict.Sales;
                        row++;
                        step = colStart + row.ToString();
                        ws.Range[step].Value = predict.Sales;
                        table.Cell(row, col).Shape.TextFrame.TextRange.Text = predict.Ratio;
                        row++;
                        step = colStart + row.ToString();
                        ws.Range[step].Value = predict.Ratio;
                        col++;
                        colStart++;
                    }
                }

                shape = PPTAPI.getShape(shapes, "Image_1");
                if (shape != null)
                {
                    String strUrl = dataObj.Value <String>("imageUrl");
                    if (!String.IsNullOrEmpty(strUrl))
                    {
                        string strPath = Request.HttpDownload(strUrl).Result;
                        shapes.AddPicture(strPath, Microsoft.Office.Core.MsoTriState.msoCTrue, Microsoft.Office.Core.MsoTriState.msoCTrue,
                                          shape.Left, shape.Top, shape.Width, shape.Height);
                        shape.Delete();
                    }
                }
            }
            catch
            {
            }

            return(true);
        }
Ejemplo n.º 21
0
 public Camera(CoreAPI ControlAPI)
 {
     api = ControlAPI;
 }
Ejemplo n.º 22
0
        private async void ScanID()
        {
            button1.Enabled = false;
            clearOutput();
            try {
                CoreAPI coreapi = new CoreAPI(API_KEY, API_REGION);

                // Throw exception if API returns error
                coreapi.ThrowAPIException(true);

                // Enable authentication and use 'quick' module to check if ID is authentic
                coreapi.EnableAuthentication(true, "quick");


                /*
                 * coreapi.EnableVault(true, false, false, false);  // enable vault cloud storage to store document information and image
                 * coreapi.SetBiometricThreshold(0.6); // make face verification more strict
                 * coreapi.EnableAuthentication(true, "quick"); // check if document is real using 'quick' module
                 * coreapi.EnableBarcodeMode(false); // disable OCR and scan for AAMVA barcodes only
                 * coreapi.EnableImageOutput(true, true, "url"); // output cropped document and face region in URL format
                 * coreapi.EnableDualsideCheck(true); // check if data on front and back of ID matches
                 * coreapi.SetVaultData("*****@*****.**", "12345" , "AABBCC"); // store custom data into vault
                 * coreapi.RestrictCountry("US,CA,AU"); // accept documents from United States, Canada and Australia
                 * coreapi.RestrictState("CA,TX,WA"); // accept documents from california, texas and washington
                 * coreapi.RestrictType("DI"); // accept only driver license and identification card
                 * coreapi.SetOCRImageResize(0); // disable OCR resizing
                 * coreapi.VerifyExpiry(true); // check document expiry
                 * coreapi.VerifyAge("18-120"); // check if person is above 18
                 * coreapi.VerifyDOB("1990/01/01"); // check if person's birthday is 1990/01/01
                 * coreapi.VerifyDocumentNumber("X1234567"); // check if the person's ID number is X1234567
                 * coreapi.VerifyName("Elon Musk"); // check if the person is named Elon Musk
                 * coreapi.VerifyAddress("123 Sunny Rd, California"); // Check if address on ID matches with provided address
                 * coreapi.VerifyPostcode("90001"); // check if postcode on ID matches with provided postcode
                 * coreapi.EnableAMLCheck(true); // enable AML/PEP check
                 * coreapi.SetAMLDatabase("global_politicians,eu_meps,eu_cors"); // limit AML check to only PEPs
                 * coreapi.EnableAMLStrictMatch(true); // make AML matching more strict to prevent false positives
                 * coreapi.GenerateContract("Template ID", "PDF", new Hashtable { ["somevariable"] = "somevalue" }); // generate a PDF document autofilled with data from user ID
                 */



                // Send document to Core API and get json response
                JObject result = await coreapi.Scan(textBox1.Text, textBox2.Text, textBox3.Text);

                // Print document holder name
                writeOutput(String.Format("Hello your name is {0} {1}", (string)result.SelectToken("result.firstName"), (string)result.SelectToken("result.lastName")));

                // Parse document authentication results
                if (result.ContainsKey("authentication"))
                {
                    if ((double)result.SelectToken("authentication.score") > 0.5)
                    {
                        writeOutput("The document uploaded is authentic");
                    }
                    else if ((double)result.SelectToken("authentication.score") > 0.3)
                    {
                        writeOutput("The document uploaded looks little bit suspicious");
                    }
                    else
                    {
                        writeOutput("The document uploaded is fake");
                    }
                }
                // Parse face verification results
                if (result.ContainsKey("face"))
                {
                    if (result.SelectToken("face.error") != null)
                    {
                        // View complete error codes under API reference: https://developer.idanalyzer.com/coreapi.html
                        writeOutput(String.Format("Face verification failed! Code: {0}, Reason: {1}", (string)result.SelectToken("face.error"), (string)result.SelectToken("face.error_message")));
                    }
                    else
                    {
                        if ((bool)result.SelectToken("face.isIdentical") == true)
                        {
                            writeOutput("Great! Your photo looks identical to the photo on document");
                        }
                        else
                        {
                            writeOutput("Oh no! Your photo looks different to the photo on document");
                        }
                        writeOutput(String.Format("Similarity score: {0}", (string)result.SelectToken("face.confidence")));
                    }
                }
                // Print result
                writeOutput(Environment.NewLine + "Raw JSON Result: ");
                writeOutput(result.ToString());
            }catch (APIException e)
            {
                writeOutput("Error Code: " + e.ErrorCode);
                writeOutput("Error Message: " + e.Message);
            }
            catch (ArgumentException e)
            {
                writeOutput("Input Error: " + e.Message);
            }
            catch (Exception e)
            {
                writeOutput("Unexpected Error: " + e.Message);
            }
            button1.Enabled = true;
        }
Ejemplo n.º 23
0
 public Helper()
 {
     core = new CoreAPI(coreID, accessToken); //, new System.Net.WebProxy("127.0.0.1", 8888));
 }
Ejemplo n.º 24
0
 public void OnPointerExit(PointerEventData data)
 {
     CoreAPI.SendCommand <ProteinDisplayModule, ShowInfoInBoardCommand>(new ShowInfoInBoardCommand(null));
 }
Ejemplo n.º 25
0
    private IEnumerator LaunchHelpDialog()
    {
        yield return(new WaitForSeconds(1.0f)); //等待MainConsole载入完成

        CoreAPI.SendCommand <MainConsoleModule, ShowHelpDialogCommand>(new ShowHelpDialogCommand());
    }
Ejemplo n.º 26
0
 public void TestCombine()
 {
     CoreAPI.SendCommand <PdbLoaderModule, LoadNetworkPdbFileCommand>(new LoadNetworkPdbFileCommand("2nc3", () => {
         Debug.Log("ok");
     }));
 }
Ejemplo n.º 27
0
 public void setApi(CoreAPI value)
 {
     api = value;
 }