Exemplo n.º 1
0
        public Form2()
        {
            InitializeComponent();
            isVideo     = false;
            videoHandle = -1;
            appstate    = appState.NOVID;

            // Инициализируем коллекцию траекторий
            tracks = new TrackList();
            tracks.videoFilePath = "none";
            tracks.Add(1, new Track());
            tracks[1].Add(1, new TrackNode());
            tracks[1].Add(2, new TrackNode());
            tracks.Add(2, new Track());
            tracks[2].Add(1, new TrackNode());
            tracks[2].Add(2, new TrackNode());

            // Выполняем сериализацию списка траекторий
            XmlTextWriter writer = new XmlTextWriter("tracks.xml", Encoding.Unicode);

            tracks.WriteXml(writer);
            writer.Close();

            // Выполняем десериализацию списка траекторий
            XmlTextReader reader  = new XmlTextReader("tracks.xml");
            TrackList     tracks2 = new TrackList();

            tracks2.ReadXml(reader);

            // Выполняем повторную сериализацию (для контроля)
            XmlTextWriter writer2 = new XmlTextWriter("tracks2.xml", Encoding.Unicode);

            tracks2.WriteXml(writer2);
            writer2.Close();
        }
Exemplo n.º 2
0
    void SetText()
    {
        if (data.VocabularysList[count].Vocabulary_en != null)
        {
            VocabularyText.GetComponent <Text>().text = data.VocabularysList[count].Vocabulary_tw;
        }

        if (data.VocabularysList[count].Sentence_en != null)
        {
            SentenceText.GetComponent <Text>().text = data.VocabularysList[count].Sentence_tw;
        }

        if (data.VocabularysList[count].Synonyms != null)
        {
            SynonymsText.GetComponent <Text>().text = data.VocabularysList[count].Vocabulary_tw;
        }

        if (data.VocabularysList[count].Antonym != null)
        {
            AntonymText.GetComponent <Text>().text = "有反義字";
        }

        if (data.VocabularysList[count].Extension_en != null)
        {
            ExtensionText.GetComponent <Text>().text = data.VocabularysList[count].Extension_tw;
        }

        state = appState.waitForInput;
    }
Exemplo n.º 3
0
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                statusMessage("Cancelled.");
                toolStripProgressBar_progress.Value = 0;
            }
            else
            {
                ControllerArgs res = (ControllerArgs)e.Result;

                if (res.error)
                {
                    statusMessage("Error.");
                    toolStripProgressBar_progress.Value = 0;
                }
                else
                {
                    statusMessage("Completed.");
                }
            }

            if (!args.single)
            {
                rand.restartPlaintextPrng();
            }

            ctrl.Close();
            sw.Stop();
            state = appState.Idle;
            updateFormEnabling();
            toolStripProgressBar_progress.Style = ProgressBarStyle.Blocks;
        }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        data = new Data();
        data.setVocabularysArray();

        count = 0;
        state = appState.wait;
    }
Exemplo n.º 5
0
    void Reset()
    {
        count = 0;

        VocabularyText.GetComponent <Text>().text = "VocabularyText";
        SentenceText.GetComponent <Text>().text   = "SentenceText";
        SynonymsText.GetComponent <Text>().text   = "SynonymsText";
        AntonymText.GetComponent <Text>().text    = "AntonymText";
        ExtensionText.GetComponent <Text>().text  = "ExtensionText";

        state = appState.wait;
    }
Exemplo n.º 6
0
    void Pass()
    {
        CleanAllInput();
        CleanAllText();
        count++;

        if (count >= data.VocabularysList.Count)
        {
            state = appState.over;
        }
        else
        {
            state = appState.input;
        }
    }
Exemplo n.º 7
0
 public void PressSubmit()
 {
     state = appState.check;
 }
Exemplo n.º 8
0
 public void PressStart()
 {
     state = appState.input;
 }
Exemplo n.º 9
0
 void Wrong()
 {
     CleanAllInput();
     state = appState.waitForInput;
 }
Exemplo n.º 10
0
        private void setVisibility(appState currentState)
        {
            switch (currentState)
            {
            case appState.Initial:
                // All off except Connection Buttons and DataGrid
                btnConnectMain.Enabled = true;
                btnConnectSF.Enabled   = true;

                btnBack.Visible       = false;
                dtFrom.Enabled        = false;
                btnCopyDate.Enabled   = false;
                dtTo.Enabled          = false;
                tbAmount.Enabled      = false;
                tbCheckNumber.Enabled = false;
                cbOrgName.Enabled     = false;

                btnSearch.Enabled     = false;
                btnGetImages.Enabled  = false;
                btnSaveImages.Enabled = false;

                dgvResults.Visible = true;
                tbResults.Visible  = false;
                pbImage1.Visible   = false;
                pbImage2.Visible   = false;
                pbImage3.Visible   = false;
                pbImage4.Visible   = false;
                pbImage5.Visible   = false;
                pbImage6.Visible   = false;
                rbMySnap.Visible   = false;

                dgvInfo.Visible    = false;
                tcMitekDGV.Visible = false;

                lblImage.Visible = false;

                break;

            case appState.Connect:
                // Conencted to DB, Enable Search and Criteria
                btnBack.Visible        = false;
                btnConnectMain.Enabled = false;
                btnConnectSF.Enabled   = true;
                goto ConnectContinue;

            case appState.ConnectSF:
                btnBack.Visible        = false;
                btnConnectMain.Enabled = true;
                btnConnectSF.Enabled   = false;

ConnectContinue:
                dtFrom.Enabled        = true;
                btnCopyDate.Enabled   = true;
                dtTo.Enabled          = true;
                tbAmount.Enabled      = true;
                tbCheckNumber.Enabled = true;
                cbOrgName.Enabled     = true;

                btnSearch.Enabled     = true;
                btnGetImages.Enabled  = false;
                btnSaveImages.Enabled = false;

                dgvResults.Visible = true;
                tbResults.Visible  = false;
                pbImage1.Visible   = false;
                pbImage2.Visible   = false;
                pbImage3.Visible   = false;
                pbImage4.Visible   = false;
                pbImage5.Visible   = false;
                pbImage6.Visible   = false;
                rbMySnap.Visible   = false;

                dgvInfo.Visible    = false;
                tcMitekDGV.Visible = false;

                lblImage.Visible = false;

                break;

            case appState.Search:
                // Search Complete, enable GetImages btn
                dtFrom.Enabled        = true;
                btnCopyDate.Enabled   = true;
                dtTo.Enabled          = true;
                tbAmount.Enabled      = true;
                tbCheckNumber.Enabled = true;
                cbOrgName.Enabled     = true;

                btnBack.Visible       = false;
                btnSearch.Enabled     = true;
                btnGetImages.Enabled  = true;
                btnSaveImages.Enabled = false;

                dgvResults.Visible = true;
                tbResults.Visible  = false;
                pbImage1.Visible   = false;
                pbImage2.Visible   = false;
                pbImage3.Visible   = false;
                pbImage4.Visible   = false;
                pbImage5.Visible   = false;
                pbImage6.Visible   = false;
                rbMySnap.Visible   = false;

                dgvInfo.Visible    = false;
                tcMitekDGV.Visible = false;

                lblImage.Visible = false;

                break;

            case appState.Images:
                // Show Images and enable SaveImages btn
                btnBack.Visible       = true;
                dtFrom.Enabled        = true;
                btnCopyDate.Enabled   = true;
                dtTo.Enabled          = true;
                tbAmount.Enabled      = true;
                tbCheckNumber.Enabled = true;
                cbOrgName.Enabled     = true;

                btnSearch.Enabled     = true;
                btnGetImages.Enabled  = false;
                btnSaveImages.Enabled = true;

                dgvResults.Visible = false;
                tbResults.Visible  = false;
                pbImage1.Visible   = true;
                pbImage2.Visible   = true;
                pbImage3.Visible   = true;
                pbImage4.Visible   = true;
                pbImage5.Visible   = true;
                pbImage6.Visible   = true;
                rbMySnap.Visible   = true;

                dgvInfo.Visible        = true;
                tcMitekDGV.Visible     = true;
                tcMitekDGV.SelectedTab = tabResults;

                lblImage.Visible = true;

                break;

            case appState.ImageError:
                // No Images
                dtFrom.Enabled        = true;
                btnCopyDate.Enabled   = true;
                dtTo.Enabled          = true;
                tbAmount.Enabled      = true;
                tbCheckNumber.Enabled = true;
                cbOrgName.Enabled     = true;

                btnSearch.Enabled     = true;
                btnGetImages.Enabled  = false;
                btnSaveImages.Enabled = false;

                dgvResults.Visible = false;
                tbResults.Visible  = true;
                pbImage1.Visible   = false;
                pbImage2.Visible   = false;
                pbImage3.Visible   = false;
                pbImage4.Visible   = false;
                pbImage5.Visible   = false;
                pbImage6.Visible   = false;
                rbMySnap.Visible   = false;

                dgvInfo.Visible    = false;
                tcMitekDGV.Visible = false;

                lblImage.Visible = false;

                break;

            default:
                break;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            prevKS = currKS;
            currKS = Keyboard.GetState();

            switch (currentState)
            {
            case appState.SELECT:
                GA.generation = 0;
                if (currKS.IsKeyDown(Keys.Space))
                {
                    SelectOption(currentSelection);
                    if (currentSelection != 0)
                    {
                        GA.InitPopulation();
                        GA.SetTarget(ImageData.ScanImage(targetImage));
                        currentState = appState.DRAW;
                    }
                }
                else if (currKS.IsKeyDown(Keys.Down))
                {
                    if (prevKS.IsKeyUp(Keys.Down))
                    {
                        currentSelection++;
                        currentSelection = currentSelection % maxNumOptions;
                    }
                }
                else if (currKS.IsKeyDown(Keys.Up))
                {
                    if (prevKS.IsKeyUp(Keys.Up))
                    {
                        currentSelection--;
                        if (currentSelection < 0)
                        {
                            currentSelection = currentSelection + maxNumOptions;
                        }
                    }
                }
                break;

            case appState.DRAW:
                if (!GA.complete)
                {
                    GA.Update();
                }
                else
                {
                    currentState = appState.COMPLETE;
                }
                break;

            case appState.COMPLETE:
                if (currKS.IsKeyDown(Keys.Q))
                {
                    this.Exit();
                }
                else if (prevKS.IsKeyDown(Keys.D))
                {
                    currentState = appState.SELECT;
                }
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 12
0
 // Метод смены состояния приложения
 private void enterAppState(appState newstate)
 {
     appstate = newstate;
 }
Exemplo n.º 13
0
 private void button_stop_Click(object sender, EventArgs e)
 {
     state = appState.Stop;
     updateFormEnabling();
     ctrl.Cancel();
 }
Exemplo n.º 14
0
 private void button_start_Click(object sender, EventArgs e)
 {
     state = appState.Running;
     updateFormEnabling();
     run(false);
 }
Exemplo n.º 15
0
        private void run(bool single)
        {
            args = new ControllerArgs();

            try
            {
                uint port = 0;
                if (String.Compare("USB", textBox_interface.Text.Substring(0, 3), true) == 0)
                {
                    if (!uint.TryParse(textBox_interface.Text.Substring(3), out port))
                    {
                        throw new Exception("Error: Invalid Interface.");
                    }
                }
                else
                {
                    throw new Exception("Error: Invalid Interface.");
                }

                ctrl.Open(port);
                ctrl.AddProgressChangedEventHandler(new ProgressChangedEventHandler(worker_ProgressChanged));
                ctrl.AddCompletedEventHandler(new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted));

                args.single  = single;
                args.traces  = Convert.ToInt64(textBox_traces.Text);
                args.endless = checkBox_endless.Checked;
                if (!args.single)
                {
                    rand.restartPlaintextPrng();
                }

                sw.Start();
                statusMessage("Running...");

                toolStripProgressBar_progress.Value = 0;
                if (args.endless)
                {
                    toolStripProgressBar_progress.Style = ProgressBarStyle.Marquee;
                }
                else
                {
                    toolStripProgressBar_progress.Style = ProgressBarStyle.Blocks;
                }

                args.key              = Utils.stringToByteArray(textBox_key.Text);
                args.plaintext        = Utils.stringToByteArray(textBox_plaintext.Text);
                args.randomGeneration = checkBox_randomgeneration.Checked;
                args.wait             = Convert.ToInt32(textBox_wait.Text);
                args.continueIfError  = checkBox_continueiferror.Checked;
                args.check            = !checkBox_check.Checked;
                args.path             = textBox_path.Text;
                args.CurrentNum       = Convert.ToInt64(textBox_CurrentNum.Text);
                args.Algorithm        = comboBox1.SelectedItem.ToString();
                if (checkBox_rewrite.Checked)
                {
                    FileStream fs_ct = new FileStream("ciphertext.txt", FileMode.Create);
                    fs_ct.Close();
                    FileStream fs_key = new FileStream("key.txt", FileMode.Create);
                    fs_key.Close();
                    FileStream fs_pt = new FileStream("plaintext.txt", FileMode.Create);
                    fs_pt.Close();
                }

                if (Directory.Exists(args.path + "\\backup") == false)
                {
                    Directory.CreateDirectory(args.path + "\\backup");
                }

                //随机数生成,在每次重新run的时候重新随机获取种子
                Random  randc = new Random();
                RandGen randb = new RandGen(randc.Next(887667), randc.Next(434343));
                args.rand = randb;


                ctrl.Run(args);
            }
            catch (Exception ex)
            {
                statusMessage(ex.Message);
                toolStripProgressBar_progress.Value = 0;
                toolStripProgressBar_progress.Style = ProgressBarStyle.Blocks;
                state = appState.Idle;
                updateFormEnabling();
            }
        }