Exemplo n.º 1
0
 public Game()
 {
     inputField.AddField("重力", gravity.ToString()).TextChanged                   += (o, e) => { try { gravity = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
     inputField.AddField("可見障礙物數量", obstacleCount.ToString()).TextChanged        += (o, e) => { try { obstacleCount = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
     inputField.AddField("存活區的範圍", rangeY.ToString()).TextChanged                += (o, e) => { try { rangeY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
     inputField.AddField("障礙物距離的範圍", obstacleDistance.ToString()).TextChanged    += (o, e) => { try { obstacleDistance = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
     inputField.AddField("障礙物寬度(通過時間)的範圍", obstacleWidth.ToString()).TextChanged += (o, e) => { try { obstacleWidth = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
     inputField.AddField("障礙物通道底部高度的範圍", obstacleY.ToString()).TextChanged       += (o, e) => { try { obstacleY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
     inputField.AddField("障礙物通道寬度的範圍", obstacleHeight.ToString()).TextChanged    += (o, e) => { try { obstacleHeight = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
 }
Exemplo n.º 2
0
 public Game()
 {
     controlPanel = new MyTableLayoutPanel(3, 1, "AAS300", "A");
     {
         {
             imageFeedBack         = new MyCheckBox("Image Feed Back");
             imageFeedBack.Checked = true;
             controlPanel.AddControl(imageFeedBack, 0, 0);
         }
         {
             showImageFeedBack                 = new MyCheckBox("Show Image Feed Back");
             showImageFeedBack.Checked         = false;
             showImageFeedBack.CheckedChanged += ShowImageFeedBack_CheckedChanged;
             controlPanel.AddControl(showImageFeedBack, 0, 0);
         }
         {
             Panel pnl = new Panel();
             {
                 pnl.Dock       = DockStyle.Fill;
                 pnl.AutoScroll = true;
                 {
                     generalSettings      = new MyInputField();
                     generalSettings.Dock = DockStyle.Top;
                     generalSettings.AddField("Image Feed Back Width", imageFeedBackSize.Width.ToString()).TextChanged   += (o, e) => { try { imageFeedBackSize.Width = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("Image Feed Back Height", imageFeedBackSize.Height.ToString()).TextChanged += (o, e) => { try { imageFeedBackSize.Height = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("Port", SocketHandler.port.ToString()).TextChanged           += (o, e) => { try { SocketHandler.port = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("darryMode", darryMode.ToString()).TextChanged               += (o, e) => { try { darryMode = bool.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("max_upward_speed", max_upward_speed.ToString()).TextChanged += (o, e) => { try { max_upward_speed = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("alpha", alpha.ToString()).TextChanged                  += (o, e) => { try { alpha = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("重利", gravity.ToString()).TextChanged                   += (o, e) => { try { gravity = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("升力", liftForce.ToString()).TextChanged                 += (o, e) => { try { liftForce = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("可見障礙物數量", obstacleCount.ToString()).TextChanged        += (o, e) => { try { obstacleCount = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("存活區的範圍", rangeY.ToString()).TextChanged                += (o, e) => { try { rangeY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("障礙物距離的範圍", obstacleDistance.ToString()).TextChanged    += (o, e) => { try { obstacleDistance = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("障礙物寬度(通過時間)的範圍", obstacleWidth.ToString()).TextChanged += (o, e) => { try { obstacleWidth = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("障礙物通道底部高度的範圍", obstacleY.ToString()).TextChanged       += (o, e) => { try { obstacleY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     generalSettings.AddField("障礙物通道寬度的範圍", obstacleHeight.ToString()).TextChanged    += (o, e) => { try { obstacleHeight = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
                     pnl.Controls.Add(generalSettings);
                 }
             }
             controlPanel.AddControl(pnl, 2, 0);
         }
     }
     Reset();
     Update(true);
 }
Exemplo n.º 3
0
 public SATabPage() : base("SA")
 {
     //InitializeComponent();
     TLPmain.Controls.Add(TLPtop, 0, 0);
     {
         TLPtop.Controls.Add(TXBin, 0, 0);
         TLPtop.Controls.Add(new MyPanel()
         {
             Controls = { TLPctrl }, AutoScroll = true, Dock = DockStyle.Top
         }, 1, 0);
         {
             //TLPctrl.SetRowSpan(TXBin, TLPctrl.RowCount);
             int row = 0;
             TLPctrl.Controls.Add(CBmethod, 0, row++);
             {
                 CBmethod.Items.Add("Count Word");
                 CBmethod.Items.Add("List Words");
                 CBmethod.Items.Add("Send Socket");
                 CBmethod.Items.Add("Cut by Code");
             }
             TLPctrl.Controls.Add(BTNexportSA, 0, row++);
             TLPctrl.Controls.Add(BTNsave, 0, row++);
             TLPctrl.Controls.Add(BTNload, 0, row++);
             TLPctrl.Controls.Add(BTNexportList, 0, row++);
             TLPctrl.Controls.Add(BTNnew, 0, row++);
             TLPctrl.Controls.Add(CHBdebugMode, 0, row++);
             TLPctrl.Controls.Add(CHBreplaceWithEmptyExceptChinese, 0, row++);
             TLPctrl.Controls.Add(CHBremoveEmpty, 0, row++);
             TLPctrl.Controls.Add(CHBverbose, 0, row++);
             TLPctrl.Controls.Add(IFdata, 0, row++);
             {
                 IFdata.AddField("maxWordLength", maxWordLength.ToString());
             }
             TLPctrl.Controls.Add(CBprobType, 0, row++);
             {
                 foreach (var s in SentenceSplitter.probTypeString.Split('\n'))
                 {
                     CBprobType.Items.Add(s);
                 }
                 CBprobType.SelectedValueChanged += (sender, e) =>
                 {
                     probType = Enum.GetValues(typeof(SentenceSplitter.ProbTypeEnum)).Cast <SentenceSplitter.ProbTypeEnum>().FirstOrDefault(v => CBprobType.Text.IndexOf($"probType == ProbTypeEnum.{v}") != -1);
                     //MessageBox.Show(probType.ToString());
                 };
             }
             TLPctrl.Controls.Add(CHBsplit, 0, row++);
         }
     }
     TLPmain.Controls.Add(TXBout, 0, 1);
     TLPmain.Controls.Add(TXBdata, 0, 2);
     //TXBdata.TextChanged += TXBdata_TextChanged;
     TXBdata.MouseDoubleClick += TXBdata_MouseDoubleClick;
     TXBin.TextChanged        += TXBin_TextChanged;
     TXBin.KeyDown            += TXBin_KeyDown;
     TXBin.ContextMenu         = new ContextMenu(new[] { new MenuItem("sample code", delegate { TXBin.Text = sampleCode; }) });
     BTNexportSA.Click        += BTNexportSA_Click;
     BTNexportList.Click      += BTNexportList_Click;
     CHBsplit.CheckedChanged  += CHBsplit_CheckedChanged;
     BTNsave.Click            += BTNsave_Click;
     BTNload.Click            += BTNload_Click;
     BTNnew.Click             += BTNnew_Click;
     this.Controls.Add(TLPmain);
     //sam = new SAM();
     //sam.StatusChanged += (s) => { this.Invoke(new Action(() => this.Text = $"[*] {s}")); };
     //sm = new SimpleMethod();
     //sm.StatusChanged += (s) => { this.Invoke(new Action(() => this.Text = $"[*] {s}")); };
     //sa.StatusChanged += (s) => { this.Invoke(new Action(() => this.Text = $"[*] {s}")); };
     sa = new SuffixArray();
     ss = new SentenceSplitter(sa);
     StartServices();
 }
Exemplo n.º 4
0
 public Game()
 {
     controlPanel = new MyTableLayoutPanel(2, 1, "AA", "A");
     {
         generalSettings = new MyInputField();
         generalSettings.AddField("Port", SocketHandler.port.ToString()).TextChanged           += (o, e) => { try { SocketHandler.port = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("darryMode", darryMode.ToString()).TextChanged               += (o, e) => { try { darryMode = bool.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("max_upward_speed", max_upward_speed.ToString()).TextChanged += (o, e) => { try { max_upward_speed = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("alpha", alpha.ToString()).TextChanged                  += (o, e) => { try { alpha = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("重利", gravity.ToString()).TextChanged                   += (o, e) => { try { gravity = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("升力", liftForce.ToString()).TextChanged                 += (o, e) => { try { liftForce = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("可見障礙物數量", obstacleCount.ToString()).TextChanged        += (o, e) => { try { obstacleCount = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("存活區的範圍", rangeY.ToString()).TextChanged                += (o, e) => { try { rangeY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("障礙物距離的範圍", obstacleDistance.ToString()).TextChanged    += (o, e) => { try { obstacleDistance = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("障礙物寬度(通過時間)的範圍", obstacleWidth.ToString()).TextChanged += (o, e) => { try { obstacleWidth = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("障礙物通道底部高度的範圍", obstacleY.ToString()).TextChanged       += (o, e) => { try { obstacleY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         generalSettings.AddField("障礙物通道寬度的範圍", obstacleHeight.ToString()).TextChanged    += (o, e) => { try { obstacleHeight = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } };
         controlPanel.AddControl(generalSettings, 1, 0);
     }
     Reset();
     Update(true);
 }
Exemplo n.º 5
0
        public TrieTabPage() : base("Trie")
        {
            TLPmain.Controls.Add(TLPtop, 0, 0);
            {
                TLPtop.Controls.Add(TXBin, 0, 0);
                TLPtop.Controls.Add(new MyPanel()
                {
                    Controls = { TLPctrl }, AutoScroll = true, Dock = DockStyle.Top
                }, 1, 0);
                {
                    //TLPctrl.SetRowSpan(TXBin, TLPctrl.RowCount);
                    int row = 0;
                    TLPctrl.Controls.Add(CBmethod, 0, row++);
                    {
                        CBmethod.Items.Add("Count Word");
                        CBmethod.Items.Add("Cut by Code");
                    }
                    TLPctrl.Controls.Add(BTNexportList, 0, row++);
                    TLPctrl.Controls.Add(BTNsave, 0, row++);
                    TLPctrl.Controls.Add(BTNload, 0, row++);
                    TLPctrl.Controls.Add(BTNnew, 0, row++);
                    TLPctrl.Controls.Add(BTNiteration, 0, row++);
                    TLPctrl.Controls.Add(CHBdebugMode, 0, row++);
                    TLPctrl.Controls.Add(CHBverbose, 0, row++);
                    TLPctrl.Controls.Add(IFdata, 0, row++);
                    {
                        IFdata.AddField("maxWordLength", default_maxWordLength.ToString());
                        IFdata.AddField("baseDataLength", default_baseDataLength.ToString());
                        IFdata.AddField("decayRatio", default_decayRatio.ToString());
                    }
                    TLPctrl.Controls.Add(CBprobType, 0, row++);
                    {
                        foreach (var s in SentenceSplitter.probTypeString.Split('\n'))
                        {
                            CBprobType.Items.Add(s);
                        }
                        CBprobType.SelectedValueChanged += (sender, e) =>
                        {
                            probType = Enum.GetValues(typeof(SentenceSplitter.ProbTypeEnum)).Cast <SentenceSplitter.ProbTypeEnum>().FirstOrDefault(v => CBprobType.Text.IndexOf($"probType == ProbTypeEnum.{v}") != -1);
                            //MessageBox.Show(probType.ToString());
                        };
                    }
                    TLPctrl.Controls.Add(CHBsplit, 0, row++);
                }
            }
            TLPmain.Controls.Add(TXBout, 0, 1);
            TLPmain.Controls.Add(TXBdata, 0, 2);
            //TXBdata.TextChanged += TXBdata_TextChanged;
            TXBdata.MouseDoubleClick += TXBdata_MouseDoubleClick;
            TXBin.TextChanged        += TXBin_TextChanged;
            //BTNexportSA.Click += BTNexportSA_Click;
            BTNexportList.Click     += BTNexportList_Click;
            CHBsplit.CheckedChanged += CHBsplit_CheckedChanged;
            //CHBbems.CheckedChanged += CHBbems_CheckedChanged;
            BTNsave.Click += BTNsave_Click;
            BTNload.Click += BTNload_Click;
            //BTNnew.Click += BTNnew_Click;
            BTNnew.Click += async delegate
            {
                try
                {
                    Trace.Indent();
                    await NewData();

                    //System.Diagnostics.Trace.WriteLine("A");
                    //string s;
                    //System.Diagnostics.Trace.WriteLine("B");

                    //string s = "";
                    //string v = new string('0', 10000000);
                    //while (true)
                    //{
                    //    System.Diagnostics.Trace.WriteLine($"{s.Length}");
                    //    s += v;
                    //}
                }
                finally { Trace.Unindent(); }
            };
            BTNiteration.Click += BTNiteration_Click;
            this.Controls.Add(TLPmain);
        }
Exemplo n.º 6
0
 private void InitializeControls()
 {
     this.FormClosing += Form1_FormClosing;
     {
         TLP = new MyTableLayoutPanel(5, 1, "PAAAA", "P");
         {
             {
                 LBL    = new MyLabel("");
                 status = "Q, W, O: control\r\nP: restart all";
                 TLP.AddControl(LBL, 0, 0);
             }
             {
                 MyTableLayoutPanel tlp = new MyTableLayoutPanel(1, 2, "A", "AA");
                 {
                     PBX          = new PictureBox();
                     PBX.Dock     = DockStyle.Fill;
                     PBX.SizeMode = PictureBoxSizeMode.AutoSize;
                     PBX.Image    = Properties.Resources.buttonDark;
                     tlp.AddControl(PBX, 0, 0);
                 }
                 {
                     Panel pnl = new Panel();
                     pnl.Dock         = DockStyle.Fill;
                     pnl.AutoSize     = true;
                     pnl.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                     PictureBox pbx = new PictureBox();
                     pbx.Dock     = DockStyle.Fill;
                     pbx.SizeMode = PictureBoxSizeMode.Zoom;
                     pbx.Image    = Properties.Resources.computer;
                     MyLabel lbl = new MyLabel("");
                     lbl.Font      = new Font("Consolas", 8, FontStyle.Bold);
                     lbl.Dock      = DockStyle.None;
                     lbl.ForeColor = Color.FromArgb(64, 0, 0, 0);
                     lbl.BackColor = Color.Transparent;
                     lbl.Parent    = pbx;
                     //{
                     //    Bitmap bmp = new Bitmap(1, 1);
                     //    bmp.SetPixel(0, 0, Color.Transparent);
                     //    lbl.BackgroundImage = bmp;
                     //}
                     //pnl.Controls.Add(lbl);
                     pnl.Controls.Add(pbx);
                     tlp.AddControl(pnl, 0, 1);
                     Thread thread = new Thread(() =>
                     {
                         Thread.Sleep(3000);
                         while (true)
                         {
                             Thread.Sleep(20);
                             StringBuilder s = new StringBuilder();
                             for (int i = 0; i < 10; i++)
                             {
                                 for (int j = 0; j < 30; j++)
                                 {
                                     s.Append(random.Next(0, 2) == 0 ? '0' : '1');
                                 }
                                 s.Append("\r\n");
                             }
                             lbl.Invoke(new Action(() => { lbl.Text = s.ToString(); }));
                         }
                     });
                     thread.IsBackground = true;
                     thread.Start();
                 }
                 TLP.AddControl(tlp, 1, 0);
             }
             {
                 TB         = new TrackBar();
                 TB.Dock    = DockStyle.Fill;
                 TB.Minimum = 0;
                 TB.Maximum = 1000;
                 TLP.AddControl(TB, 2, 0);
             }
             {
                 TXB              = new MyTextBox(false);
                 TXB.KeyDown     += Form1_KeyDown;
                 TXB.KeyUp       += Form1_KeyUp;
                 TXB.TextChanged += (object s, EventArgs e1) => { TXB.Text = null; };
                 TLP.AddControl(TXB, 3, 0);
             }
             {
                 IFD = new MyInputField();
                 IFD.AddField("Play speed (FPS)", FPS.ToString()).TextChanged += (object s, EventArgs e1) => {
                     double t;
                     if (!double.TryParse((s as TextBox).Text, out t))
                     {
                         MessageBox.Show("格式不正確");
                     }
                     else
                     {
                         FPS = t;
                     }
                 };
                 TLP.AddControl(IFD, 4, 0);
             }
         }
         this.Controls.Add(TLP);
     }
 }