public override void Upgrade() { for (int y = 0; y < Tools.array.GetLength(0); y++) { for (int x = 0; x < Tools.array.GetLength(1); x++) { MyButton button = new MyButton(); button.ButtonContainner = BombPlanter(); button.Size = new System.Drawing.Size(20, 20); button.Location = new System.Drawing.Point(20 * x, 20 * y + 60); _form1.Controls.Add(button); Tools.array[y, x] = button; } } base.Upgrade(); }
public bool Defused(MyButton button) { MyButton myButton = Tools.array[button.CoordinateY, button.CoordinateX]; if (!button.Defused) { myButton.BackgroundImage = SetPicture.SetBackgroundPicture("defused"); myButton.Defused = true; Tools.defuseKitNumber -= 1; return false; } else { myButton.Defused = false; myButton.Enabled = true; myButton.BackgroundImage = null; Tools.defuseKitNumber += 1; return true; } }
public void GameOver(MyButton button) { for (int x = 0; x < Tools.array.GetLength(1); x++) { for (int y = 0; y < Tools.array.GetLength(0); y++) { Tools.array[y, x].Enabled = false; Tools.array[y, x].FlatStyle = FlatStyle.Popup; if (Tools.array[y, x].Defused == true) { Tools.array[y, x].BackgroundImage = SetPicture.SetBackgroundPicture(Tools.array[y, x].ButtonContainner + "defused"); } else { Tools.array[y, x].BackgroundImage = SetPicture.SetBackgroundPicture(Tools.array[y, x].ButtonContainner); } } } button.BackgroundImage = SetPicture.SetBackgroundPicture("boom"); form1.GameOver(); }
private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Firmware)); this.pictureBoxAPM = new ArdupilotMega.ImageLabel(); this.pictureBoxQuad = new ArdupilotMega.ImageLabel(); this.pictureBoxHexa = new ArdupilotMega.ImageLabel(); this.pictureBoxTri = new ArdupilotMega.ImageLabel(); this.pictureBoxY6 = new ArdupilotMega.ImageLabel(); this.lbl_status = new System.Windows.Forms.Label(); this.progress = new System.Windows.Forms.ProgressBar(); this.label2 = new System.Windows.Forms.Label(); this.pictureBoxHeli = new ArdupilotMega.ImageLabel(); this.BUT_setup = new ArdupilotMega.MyButton(); this.pictureBoxHilimage = new System.Windows.Forms.PictureBox(); this.pictureBoxAPHil = new System.Windows.Forms.PictureBox(); this.pictureBoxACHil = new System.Windows.Forms.PictureBox(); this.pictureBoxACHHil = new System.Windows.Forms.PictureBox(); this.pictureBoxOcta = new ArdupilotMega.ImageLabel(); this.pictureBoxOctav = new ArdupilotMega.ImageLabel(); this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHilimage)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAPHil)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxACHil)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxACHHil)).BeginInit(); this.SuspendLayout(); // // pictureBoxAPM // this.pictureBoxAPM.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxAPM.Image = null; resources.ApplyResources(this.pictureBoxAPM, "pictureBoxAPM"); this.pictureBoxAPM.Name = "pictureBoxAPM"; this.pictureBoxAPM.TabStop = false; this.pictureBoxAPM.Click += new System.EventHandler(this.pictureBoxAPM_Click); // // pictureBoxQuad // this.pictureBoxQuad.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxQuad.Image = null; resources.ApplyResources(this.pictureBoxQuad, "pictureBoxQuad"); this.pictureBoxQuad.Name = "pictureBoxQuad"; this.pictureBoxQuad.TabStop = false; this.pictureBoxQuad.Click += new System.EventHandler(this.pictureBoxQuad_Click); // // pictureBoxHexa // this.pictureBoxHexa.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxHexa.Image = null; resources.ApplyResources(this.pictureBoxHexa, "pictureBoxHexa"); this.pictureBoxHexa.Name = "pictureBoxHexa"; this.pictureBoxHexa.TabStop = false; this.pictureBoxHexa.Click += new System.EventHandler(this.pictureBoxHexa_Click); // // pictureBoxTri // this.pictureBoxTri.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxTri.Image = null; resources.ApplyResources(this.pictureBoxTri, "pictureBoxTri"); this.pictureBoxTri.Name = "pictureBoxTri"; this.pictureBoxTri.TabStop = false; this.pictureBoxTri.Click += new System.EventHandler(this.pictureBoxTri_Click); // // pictureBoxY6 // this.pictureBoxY6.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxY6.Image = null; resources.ApplyResources(this.pictureBoxY6, "pictureBoxY6"); this.pictureBoxY6.Name = "pictureBoxY6"; this.pictureBoxY6.TabStop = false; this.pictureBoxY6.Click += new System.EventHandler(this.pictureBoxY6_Click); // // lbl_status // resources.ApplyResources(this.lbl_status, "lbl_status"); this.lbl_status.Name = "lbl_status"; // // progress // resources.ApplyResources(this.progress, "progress"); this.progress.Name = "progress"; this.progress.Step = 1; // // label2 // resources.ApplyResources(this.label2, "label2"); this.label2.Name = "label2"; // // pictureBoxHeli // this.pictureBoxHeli.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxHeli.Image = null; resources.ApplyResources(this.pictureBoxHeli, "pictureBoxHeli"); this.pictureBoxHeli.Name = "pictureBoxHeli"; this.pictureBoxHeli.TabStop = false; this.pictureBoxHeli.Click += new System.EventHandler(this.pictureBoxHeli_Click); // // BUT_setup // resources.ApplyResources(this.BUT_setup, "BUT_setup"); this.BUT_setup.Name = "BUT_setup"; this.BUT_setup.UseVisualStyleBackColor = true; this.BUT_setup.Click += new System.EventHandler(this.BUT_setup_Click); // // pictureBoxHilimage // this.pictureBoxHilimage.Image = global::ArdupilotMega.Properties.Resources.hil; resources.ApplyResources(this.pictureBoxHilimage, "pictureBoxHilimage"); this.pictureBoxHilimage.Name = "pictureBoxHilimage"; this.pictureBoxHilimage.TabStop = false; // // pictureBoxAPHil // this.pictureBoxAPHil.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxAPHil.Image = global::ArdupilotMega.Properties.Resources.hilplane; resources.ApplyResources(this.pictureBoxAPHil, "pictureBoxAPHil"); this.pictureBoxAPHil.Name = "pictureBoxAPHil"; this.pictureBoxAPHil.TabStop = false; this.pictureBoxAPHil.Click += new System.EventHandler(this.pictureBoxAPHil_Click); // // pictureBoxACHil // this.pictureBoxACHil.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxACHil.Image = global::ArdupilotMega.Properties.Resources.hilquad; resources.ApplyResources(this.pictureBoxACHil, "pictureBoxACHil"); this.pictureBoxACHil.Name = "pictureBoxACHil"; this.pictureBoxACHil.TabStop = false; this.pictureBoxACHil.Click += new System.EventHandler(this.pictureBoxACHil_Click); // // pictureBoxACHHil // this.pictureBoxACHHil.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxACHHil.Image = global::ArdupilotMega.Properties.Resources.hilheli; resources.ApplyResources(this.pictureBoxACHHil, "pictureBoxACHHil"); this.pictureBoxACHHil.Name = "pictureBoxACHHil"; this.pictureBoxACHHil.TabStop = false; this.pictureBoxACHHil.Click += new System.EventHandler(this.pictureBoxACHHil_Click); // // pictureBoxOcta // this.pictureBoxOcta.Image = null; resources.ApplyResources(this.pictureBoxOcta, "pictureBoxOcta"); this.pictureBoxOcta.Name = "pictureBoxOcta"; this.pictureBoxOcta.TabStop = false; this.pictureBoxOcta.Click += new System.EventHandler(this.pictureBoxOcta_Click); // // pictureBoxOctav // this.pictureBoxOctav.Image = null; resources.ApplyResources(this.pictureBoxOctav, "pictureBoxOctav"); this.pictureBoxOctav.Name = "pictureBoxOctav"; this.pictureBoxOctav.TabStop = false; this.pictureBoxOctav.Click += new System.EventHandler(this.pictureBoxOctav_Click); // // label1 // resources.ApplyResources(this.label1, "label1"); this.label1.Name = "label1"; // // Firmware // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.label1); this.Controls.Add(this.BUT_setup); this.Controls.Add(this.label2); this.Controls.Add(this.lbl_status); this.Controls.Add(this.progress); this.Controls.Add(this.pictureBoxACHHil); this.Controls.Add(this.pictureBoxACHil); this.Controls.Add(this.pictureBoxAPHil); this.Controls.Add(this.pictureBoxHilimage); this.Controls.Add(this.pictureBoxOctav); this.Controls.Add(this.pictureBoxOcta); this.Controls.Add(this.pictureBoxHeli); this.Controls.Add(this.pictureBoxY6); this.Controls.Add(this.pictureBoxTri); this.Controls.Add(this.pictureBoxHexa); this.Controls.Add(this.pictureBoxQuad); this.Controls.Add(this.pictureBoxAPM); this.MinimumSize = new System.Drawing.Size(1008, 461); this.Name = "Firmware"; this.Load += new System.EventHandler(this.Firmware_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHilimage)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAPHil)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxACHil)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxACHHil)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }
private static void AddButtonsToForm(Form msgBoxFrm, MessageBoxButtons buttons) { Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle); int titleHeight = screenRectangle.Top - msgBoxFrm.Top; var t = Type.GetType("Mono.Runtime"); if ((t != null)) titleHeight = 25; switch (buttons) { case MessageBoxButtons.OK: var but = new MyButton { Size = new Size(75, 23), Text = "OK", Left = msgBoxFrm.Width - 75 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; but.Click += delegate { _state = DialogResult.OK; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(but); msgBoxFrm.AcceptButton = but; break; case MessageBoxButtons.YesNo: if (msgBoxFrm.Width < (75 * 2 + FORM_X_MARGIN * 3)) msgBoxFrm.Width = (75 * 2 + FORM_X_MARGIN * 3); var butyes = new MyButton { Size = new Size(75, 23), Text = "Yes", Left = msgBoxFrm.Width - 75 * 2 - FORM_X_MARGIN * 2, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butyes.Click += delegate { _state = DialogResult.Yes; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butyes); msgBoxFrm.AcceptButton = butyes; var butno = new MyButton { Size = new Size(75, 23), Text = "No", Left = msgBoxFrm.Width - 75 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butno.Click += delegate { _state = DialogResult.No; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butno); msgBoxFrm.CancelButton = butno; break; default: throw new NotImplementedException("Only MessageBoxButtons.OK and YesNo supported at this time"); } }
public static MyPanel TestButton(object test, Sprite sprite, LoadingData data, Sprite backgroundTest) { var headPanel = new MyPanel(sprite, new Rect(0, 0, 0, 0)); Destroy(headPanel.Element.GetComponent<Image>()); headPanel.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); headPanel.Element.AddComponent<VerticalLayoutGroup>(); var headPanelContentSizeFilter = headPanel.Element.AddComponent<ContentSizeFitter>(); headPanelContentSizeFilter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; if ((test as Folder) != null) { var mainPanel = new MyPanel(sprite, new Rect(0, 0, 0, 0)); Destroy(mainPanel.Element.GetComponent<Image>()); mainPanel.Element.SetActive(((Folder)test).IsOpen); mainPanel.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); mainPanel.Element.AddComponent<LayoutElement>(); mainPanel.Element.AddComponent<VerticalLayoutGroup>().padding.left = 20; var buttonArea = new MyPanel(sprite, new Rect(0, 0, 0, 0)); UIElement.SetSize(buttonArea.Element.GetComponent<RectTransform>(), new Vector2(60, 32)); buttonArea.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); buttonArea.Element.AddComponent<HorizontalLayoutGroup>(); var button = new MyButton( () => { mainPanel.Element.SetActive(!mainPanel.Element.activeSelf); ((Folder)test).IsOpen = !((Folder)test).IsOpen; Debug.Log(((Folder)test).Name + " : " + mainPanel.Element.activeSelf); } , sprite, new Rect(0, 0, 0, 0), " <color=#00000060>►</color> " + ((Folder)test).Name); button.Element.AddComponent<LayoutElement>(); var buttonRunTestIn = new MyButton( () => { TestDispatcher.RunAnyTests(((Folder)test).GetChildrenTests().Select(e => e.NameTest), data); foreach(var e in ((Folder)test).GetChildrenTests().Select(e => e.NameTest)) ((Test) test).State = TestDispatcher.LastTestExecution[e] ? 1 : -1; } , sprite, new Rect(0, 0, 0, 0), " <color=#00ff0060>►</color> "); buttonRunTestIn.Element.AddComponent<LayoutElement>(); buttonArea.AddElement(button); buttonArea.AddElement(buttonRunTestIn); button.Element.GetComponentInChildren<Text>().alignment = TextAnchor.MiddleLeft; UIElement.SetSize(button.Element.GetComponent<RectTransform>(), new Vector2(60, 32)); button.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); var layoutElement = button.Element.AddComponent<LayoutElement>(); layoutElement.minHeight = 30; headPanel.AddElement(buttonArea); foreach (var e in ((Folder)test).GetChildren()) mainPanel.AddElement(TestButton(e, sprite, data, backgroundTest)); headPanel.AddElement(mainPanel); } else { var testName = ((Test)test).NameTest; var button = new MyButton( () => { TestDispatcher.RunOneTest(data, testName); if (TestDispatcher.LastTestExecution.ContainsKey(testName)) if (TestDispatcher.LastTestExecution[testName]) ((Test)test).State = 1; else ((Test)test).State = -1; else ((Test)test).State = 0; ((Test)test).State = TestDispatcher.LastTestExecution[testName] ? 1 : -1; }, sprite, new Rect(0, 0, 0, 0), testName.Split('_').Last()); button.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); button.Element.AddComponent<LayoutElement>(); var testStateImage = new MyPanel(backgroundTest, new Rect(0, 0, 0, 0)); testStateImage.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); button.AddElement(testStateImage); testStateImage.Element.transform.SetAsFirstSibling(); //testStateImage.Element.GetComponent<Image>().color = new Color32(0, 0, 0, 100); testStateImage.Element.GetComponent<Image>().color = GetTestColor(testName); button.Element.GetComponent<Button>().onClick.AddListener(() => testStateImage.Element.GetComponent<Image>().color = GetTestColor(testName)); headPanel.AddElement(button); UIElement.SetSize(button.Element.GetComponent<RectTransform>(), new Vector2(60, 32)); button.SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); var layoutElement = button.Element.AddComponent<LayoutElement>(); layoutElement.minHeight = 30; } return headPanel; }
void Start() { if (!serverIsRunned) { Server(); serverIsRunned = true; } mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height)); MakeState(); windowTests = MakeTests(); windowTests.SetActive(stateMenu.IsOpenTestsWindow); var buttonWindowTests = new MyButton(() => windowTests.SetActive(!windowTests.isOpen), ButtonSprite, new Rect(0, 0, 64, 48), "Tests"); var rectB = buttonWindowTests.Element.GetComponent<RectTransform>(); var inputField = new MyInputField("Input", ButtonSprite, new Rect(0, 0, 160, 25)); buttonWindowTests.SetAnchor(new Vector2(0, 1), new Vector2(0, 1)); var buttonLog = new MyButton( () => Dispatcher.AddRunner(new LogRunner(inputField.Element.GetComponent<InputField>().text)), ButtonSprite, new Rect(0, 0, 64, 48), "Log play"); var rectLog = buttonLog.Element.GetComponent<RectTransform>(); buttonLog.SetAnchor(0, 0, 0, 0); rectLog.anchoredPosition = new Vector2(300, 40); rectB.offsetMin = new Vector2(100, -200); UIElement.SetSize(rectB, new Vector2(120, 30)); var buttonTutorial = new MyButton( () => Dispatcher.AddRunner(new TutorialRunner(new LoadingData { AssemblyName = "RoboMovies", Level = "Test" })), ButtonSprite, new Rect(0, 00, 120, 48), "Tutorial"); buttonTutorial.SetAnchor(new Vector2(0, 1), new Vector2(0, 1)); rectB = buttonTutorial.Element.GetComponent<RectTransform>(); rectB.offsetMin = new Vector2(100, -300); UIElement.SetSize(rectB, new Vector2(120, 30)); dropDownListAssembly = Instantiate(DropDownList); dropDownListAssembly.name = "BambaLeilo"; dropDownListAssembly.transform.localPosition = new Vector3(0, 0); var dropDown = dropDownListAssembly.GetComponent<Dropdown>(); dropDown.GetComponent<RectTransform>().position = new Vector3(0, 0, 0); dropDown.options = new List<Dropdown.OptionData>(); foreach (var e in Dispatcher.Loader.Levels.Keys) dropDown.options.Add(new Dropdown.OptionData(e)); for (var i = 0; i < dropDown.options.Count; i++) if (dropDown.options[i].text == stateMenu.CurrentAssembly) dropDown.value = i; dropDownListLevel = Instantiate(DropDownList); dropDownListLevel.name = "BambaLeiloLevel"; dropDownListLevel.transform.localPosition = new Vector3(0, 0); var dropDownList = dropDownListLevel.GetComponent<Dropdown>(); dropDownList.GetComponent<RectTransform>().position = new Vector3(0, 0, 0); dropDownList.options = new List<Dropdown.OptionData>(); foreach (var e in Dispatcher.Loader.Levels[stateMenu.CurrentAssembly].Keys) dropDownList.options.Add(new Dropdown.OptionData(e)); for (var i = 0; i < dropDownList.options.Count; i++) if (dropDownList.options[i].text == stateMenu.CurrentLevel) { dropDownList.value = i; dropDownList.options[i] = new Dropdown.OptionData(stateMenu.CurrentLevel); } var backGround = new MyImage(menuBackground, new Rect(0, 0, menuBackground.textureRect.width, menuBackground.textureRect.height)); mainCanvas.AddElement(backGround); mainCanvas.AddElement(inputField); mainCanvas.AddElement(windowTests.Head); mainCanvas.AddElement(buttonWindowTests); mainCanvas.AddElement(buttonTutorial); mainCanvas.AddElement(buttonLog); dropDownListLevel.transform.SetParent(mainCanvas.Element.transform); dropDown.transform.SetParent(mainCanvas.Element.transform); var rectDrop = dropDownListAssembly.GetComponent<RectTransform>(); rectDrop.anchorMin = new Vector2(0, 1); rectDrop.anchorMax = new Vector2(0, 1); rectDrop.anchoredPosition = new Vector3(100, -40, 0); rectDrop = dropDownListLevel.GetComponent<RectTransform>(); rectDrop.anchorMin = new Vector2(0, 1); rectDrop.anchorMax = new Vector2(0, 1); rectDrop.anchoredPosition = new Vector3(300, -40, 0); rectDrop = inputField.Element.GetComponent<RectTransform>(); inputField.SetAnchor(0, 0, 0, 0); rectDrop.anchoredPosition = new Vector3(100, 40, 0); }
private void InitializeComponent() { this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.lbl_header = new System.Windows.Forms.Label(); this.myLabel1 = new System.Windows.Forms.Label(); this.txt_username = new System.Windows.Forms.TextBox(); this.myLabel3 = new System.Windows.Forms.Label(); this.txt_password = new System.Windows.Forms.TextBox(); this.myLabel2 = new System.Windows.Forms.Label(); this.cmb_server = new System.Windows.Forms.ComboBox(); this.but_verify = new MissionPlanner.Controls.MyButton(); this.chk_enable = new System.Windows.Forms.CheckBox(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // flowLayoutPanel1 // this.flowLayoutPanel1.Controls.Add(this.lbl_header); this.flowLayoutPanel1.Controls.Add(this.myLabel1); this.flowLayoutPanel1.Controls.Add(this.txt_username); this.flowLayoutPanel1.Controls.Add(this.myLabel3); this.flowLayoutPanel1.Controls.Add(this.txt_password); this.flowLayoutPanel1.Controls.Add(this.myLabel2); this.flowLayoutPanel1.Controls.Add(this.cmb_server); this.flowLayoutPanel1.Controls.Add(this.but_verify); this.flowLayoutPanel1.Controls.Add(this.chk_enable); this.flowLayoutPanel1.Location = new System.Drawing.Point(68, 22); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Size = new System.Drawing.Size(190, 136); this.flowLayoutPanel1.TabIndex = 0; // // lbl_header // this.lbl_header.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbl_header.Location = new System.Drawing.Point(3, 0); this.lbl_header.Name = "lbl_header"; this.lbl_header.Size = new System.Drawing.Size(181, 23); this.lbl_header.TabIndex = 7; this.lbl_header.Text = "AirMarket - FLYSAFE"; // // myLabel1 // this.myLabel1.Location = new System.Drawing.Point(3, 23); this.myLabel1.Name = "myLabel1"; this.myLabel1.Size = new System.Drawing.Size(75, 23); this.myLabel1.TabIndex = 0; this.myLabel1.Text = "Username"; // // txt_username // this.txt_username.Location = new System.Drawing.Point(84, 26); this.txt_username.Name = "txt_username"; this.txt_username.Size = new System.Drawing.Size(100, 20); this.txt_username.TabIndex = 3; // // myLabel3 // this.myLabel3.Location = new System.Drawing.Point(3, 49); this.myLabel3.Name = "myLabel3"; this.myLabel3.Size = new System.Drawing.Size(75, 23); this.myLabel3.TabIndex = 2; this.myLabel3.Text = "Password"; // // txt_password // this.txt_password.Location = new System.Drawing.Point(84, 52); this.txt_password.Name = "txt_password"; this.txt_password.PasswordChar = '*'; this.txt_password.Size = new System.Drawing.Size(100, 20); this.txt_password.TabIndex = 4; this.txt_password.UseSystemPasswordChar = true; // // myLabel2 // this.myLabel2.Location = new System.Drawing.Point(3, 75); this.myLabel2.Name = "myLabel2"; this.myLabel2.Size = new System.Drawing.Size(75, 23); this.myLabel2.TabIndex = 1; this.myLabel2.Text = "Server"; // // cmb_server // this.cmb_server.FormattingEnabled = true; this.cmb_server.Items.AddRange(new object[] { "teck.airmarket.io", "flysafe-pl.airmarket.io" }); this.cmb_server.Location = new System.Drawing.Point(84, 78); this.cmb_server.Name = "cmb_server"; this.cmb_server.Size = new System.Drawing.Size(100, 21); this.cmb_server.TabIndex = 5; // // but_verify // this.but_verify.Location = new System.Drawing.Point(3, 105); this.but_verify.Name = "but_verify"; this.but_verify.Size = new System.Drawing.Size(75, 23); this.but_verify.TabIndex = 6; this.but_verify.Text = "Verify"; this.but_verify.UseVisualStyleBackColor = true; this.but_verify.Click += new System.EventHandler(this.but_verify_Click); // // chk_enable // this.chk_enable.AutoSize = true; this.chk_enable.Location = new System.Drawing.Point(84, 105); this.chk_enable.Name = "chk_enable"; this.chk_enable.Size = new System.Drawing.Size(65, 17); this.chk_enable.TabIndex = 8; this.chk_enable.Text = "Enabled"; this.chk_enable.UseVisualStyleBackColor = true; this.chk_enable.CheckedChanged += new System.EventHandler(this.chk_enable_CheckedChanged); // // AirMarketUI // this.Controls.Add(this.flowLayoutPanel1); this.Name = "AirMarketUI"; this.Size = new System.Drawing.Size(321, 195); this.flowLayoutPanel1.ResumeLayout(false); this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); }
private void flightPlannerToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Control ctl in splitContainer1.Panel2.Controls) { ctl.Visible = false; } foreach (MainSwitcher.Screen sc in MainV2.View.screens) { if (sc.Name == "FlightPlanner") { MyButton but = new MyButton() { Location = new Point(splitContainer1.Panel2.Width / 2, 0), Text = "Close" }; but.Click += new EventHandler(but_Click); splitContainer1.Panel2.Controls.Add(but); splitContainer1.Panel2.Controls.Add(sc.Control); ThemeManager.ApplyThemeTo(sc.Control); sc.Control.Dock = DockStyle.Fill; sc.Control.Visible = true; if (sc.Control is IActivate) { ((IActivate)(sc.Control)).Activate(); } but.BringToFront(); break; } } }
static void Main() { MyButton btn = new MyButton(); btn.ClickEvent += new MyHandler(btnClick); btn.RaiseOnClick(); }
private static void AddButtonsToForm(Form msgBoxFrm, MessageBoxButtons buttons) { Rectangle screenRectangle = msgBoxFrm.RectangleToScreen(msgBoxFrm.ClientRectangle); int titleHeight = screenRectangle.Top - msgBoxFrm.Top; var t = Type.GetType("Mono.Runtime"); if ((t != null)) { titleHeight = 25; } switch (buttons) { case MessageBoxButtons.OK: var but = new MyButton { Size = new Size(75, 23), Text = "OK", Left = msgBoxFrm.Width - 100 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 40 - FORM_Y_MARGIN - titleHeight }; but.Click += delegate { _state = DialogResult.OK; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(but); msgBoxFrm.AcceptButton = but; break; case MessageBoxButtons.YesNo: if (msgBoxFrm.Width < (75 * 2 + FORM_X_MARGIN * 3)) { msgBoxFrm.Width = (75 * 2 + FORM_X_MARGIN * 3); } var butyes = new MyButton { Size = new Size(75, 23), Text = "Yes", Left = msgBoxFrm.Width - 75 * 2 - FORM_X_MARGIN * 2, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butyes.Click += delegate { _state = DialogResult.Yes; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butyes); msgBoxFrm.AcceptButton = butyes; var butno = new MyButton { Size = new Size(75, 23), Text = "No", Left = msgBoxFrm.Width - 75 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butno.Click += delegate { _state = DialogResult.No; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butno); msgBoxFrm.CancelButton = butno; break; case MessageBoxButtons.OKCancel: if (msgBoxFrm.Width < (75 * 2 + FORM_X_MARGIN * 3)) { msgBoxFrm.Width = (75 * 2 + FORM_X_MARGIN * 3); } var butok = new MyButton { Size = new Size(75, 23), Text = "OK", Left = msgBoxFrm.Width - 75 * 2 - FORM_X_MARGIN * 2, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butok.Click += delegate { _state = DialogResult.OK; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butok); msgBoxFrm.AcceptButton = butok; var butcancel = new MyButton { Size = new Size(75, 23), Text = "Cancel", Left = msgBoxFrm.Width - 75 - FORM_X_MARGIN, Top = msgBoxFrm.Height - 23 - FORM_Y_MARGIN - titleHeight }; butcancel.Click += delegate { _state = DialogResult.Cancel; msgBoxFrm.Close(); }; msgBoxFrm.Controls.Add(butcancel); msgBoxFrm.CancelButton = butcancel; break; default: throw new NotImplementedException("Only MessageBoxButtons.OK and YesNo supported at this time"); } }
//↑と同義 // static void SayHelloFromDeligater() { // Console.WriteLine("hi!"); // } //////////////////// // //////////////////// static void Main() { //変数 string msg = "Hello World"; Console.WriteLine(msg); //定数 const string CONST_MSG = "CONST MESSAGE"; Console.WriteLine(CONST_MSG); //============================== // 型 //============================== // 文字列、文字 // string, char string s = "hello"; char c = 'a'; // 整数値 // byte, short, int, long int i1 = 100; // 浮動小数点数 // float, double double d = 52342.34; float f = 23.3f; // 論理値 // bool -> true, false bool flag1 = true; // 型推論 var m1 = 5; // int var n1 = "world"; // string Console.WriteLine(s); Console.WriteLine(c); Console.WriteLine(i1); Console.WriteLine(d); Console.WriteLine(f); Console.WriteLine(flag1); Console.WriteLine(m1); Console.WriteLine(n1); //============================== // 演算 //============================== // + - * / % var x = 10; // int Console.WriteLine(x / 3); // 3 Console.WriteLine(x % 3); // 1 Console.WriteLine(x / 3.0); // 3.333.... Console.WriteLine(x / (double)3); // 3.333.... // ++ -- var y = 5; y++; Console.WriteLine(y); // 6 y--; Console.WriteLine(y); // 5 var z = 6; // z = z + 10; z += 10; // AND OR NOT // && || ! var flag = true; Console.WriteLine(!flag); //============================== // 文字列 //============================== Console.WriteLine("hello " + "world"); // \n, \t 改行、タブ Console.WriteLine("hell\no wo\trld"); var name1 = "taguchi"; var score1 = 52.3; Console.WriteLine(string.Format("{0} [{1}]", name1, score1)); // taguchi [52.3] Console.WriteLine($"{name1} [{score1}]"); //C# 6以降 Console.WriteLine($"{name1, -10} [{score1, 10}]"); Console.WriteLine($"{name1, -10} [{score1, 10:0.00}]"); Console.WriteLine($"{name1, -10} [{score1 + 25, 10:0.00}]"); //============================== // if //============================== // var score2 = int.Parse(Console.ReadLine()); var score2 = int.Parse("90"); // > >= < <= == != if (score2 > 80) { Console.WriteLine("Great!"); } else if (score2 > 60) { Console.WriteLine("Good!"); } else { Console.WriteLine("so so ...!"); } Console.WriteLine((score2 > 80) ? "Great" : "so so ..."); //============================== // switch //============================== // var signal = Console.ReadLine(); var signal = "red"; switch (signal) { case "red": Console.WriteLine("Stop!"); break; case "blue": case "green": Console.WriteLine("Go!"); break; case "yellow": Console.WriteLine("Caution!"); break; default: Console.WriteLine("wrong signal!"); break; } //============================== // while //============================== // var i2 = 0; var i2 = 100; while (i2 < 10) { Console.WriteLine($"loop:{i2}"); i2++; } do { Console.WriteLine($"loop2:{i2}"); i2++; } while (i2 < 10); //============================== // for //============================== // continue それ以降の処理を中止して次のループへ // break ループ自体を抜ける for (int i = 0; i < 10; i++) { if (i == 3) { continue; } if (i == 5) { break; } Console.WriteLine(i); } //============================== // 配列 //============================== // 配列 int[] scoresA1 = new int[3]; scoresA1[0] = 10; scoresA1[1] = 30; scoresA1[2] = 20; int[] scoresA2 = new int[] { 10, 30, 20 }; int[] scoresA3 = { 10, 30, 20 }; var scoresA4 = new[] { 10, 30, 20 }; scoresA4[1] = 40; Console.WriteLine(scoresA4[1]); Console.WriteLine(scoresA2); Console.WriteLine(scoresA3); //============================== // foreach //============================== var scoresB1 = new[] { 10, 30, 20 }; // for (int i = 0; i < scores.Length; i++) { // Console.WriteLine(scores[i]); // } foreach (int score in scoresB1) { Console.WriteLine(score); } //============================== // メソッド //============================== SayHi1(); Console.WriteLine(SayHi2()); Console.WriteLine(SayHi3()); SayHi4("Tom", 30); // tom 30 SayHi4("Bob"); // bob 23 SayHi4(age: 26, name: "Steve"); // steve 26 //============================== // クラス //============================== User user = new User(); // インスタンス Console.WriteLine(user.name); // me user.SayHi(); // hi! me user.name = "taguchi"; user.SayHi(); // hi! taguchi User tom = new User("Tom"); tom.SayHi(); User user2 = new User(); user2.SayHi(); AdminUser bob = new AdminUser("Bob"); bob.SayHi(); bob.SayHello(); //============================== // プロパティ //============================== Staff staff = new Staff(); Console.WriteLine(staff.Name); staff.Name = "taguchi"; Console.WriteLine(staff.Name); staff.Post = "Chief "; Console.WriteLine(staff.Post); //============================== // インデクサ //============================== Team giants = new Team(); giants[0] = "taguchi"; giants[1] = "fkoji"; giants[2] = "dotinstall"; Console.WriteLine(giants[1]); User.GetCount(); // 0 User userA1 = new User(); User userA2 = new User(); User userA3 = new User(); User.GetCount(); // 3 Console.WriteLine(userA1); Console.WriteLine(userA2); Console.WriteLine(userA3); //============================== // 抽象クラス //============================== Japanese aki = new Japanese(); aki.SayHi(); American mike = new American(); mike.SayHi(); //============================== // インターフェース //============================== Partner partner = new Partner(); partner.Share(); //============================== // ジェネリック //============================== MyData <string> s1 = new MyData <string>(); s1.GetThree("hello"); MyData <double> g1 = new MyData <double>(); g1.GetThree(23.3); MyInteger mi = new MyInteger(); mi.GetThree(55); //============================== // 名前空間 //============================== DotinstallNamespace.Player player1 = new DotinstallNamespace.Player(); Player player2 = new Player(); //using宣言しておけば、namespace省略可。 player1.SayHi(); player2.SayHi(); //============================== // 構造体 //============================== Point p1 = new Point(5, 3); Point p2 = new Point(12, 4); p1.GetInfo(); p2.GetInfo(); //============================== // 列挙型 //============================== Direction dir = Direction.Right; Console.WriteLine((int)Direction.Right); switch (dir) { case Direction.Stay: // そのまま break; case Direction.Right: // 右へ break; case Direction.Left: // 左へ break; } //============================== // 例外 //============================== MyExceptionPractice.Div(10, 0); MyExceptionPractice.Div(10, -3); //============================== // デリゲート //============================== MyDelegate ShowMessage; ShowMessage = SayHiFromDeligater; // デリゲートにメソッドを登録 ShowMessage += SayHelloFromDeligater; //メソッドを追加(マルチキャストデリゲート) ShowMessage -= SayHelloFromDeligater; //登録の解除 ShowMessage(); // 実行 //============================== // 匿名メソッド //============================== MyDelegate ShowMessage2; ShowMessage2 = delegate { Console.WriteLine("hi!(Anonymous methods)"); }; ShowMessage2(); //============================== // ラムダ式 //============================== MyDelegate ShowMessage3; // ラムダ式: 引数 => 処理 ShowMessage3 = () => { Console.WriteLine("hi!(Lambda expression)"); }; ShowMessage3 += () => Console.WriteLine("hello!(Lambda expression)"); ShowMessage3(); //============================== // イベント //============================== MyButton btn = new MyButton(); // メソッドを登録できる(以下ではラムダ式を使用している) btn.MyEvent += () => Console.WriteLine("Button Clicked!"); btn.OnClicked(); //============================== // Collection // - List(データの集合) // - HashSet(順番を持たない、かつ重複を許さないデータの集合。順番を指定してアクセスする事はできない。) // - Dictionary(キーと値でデータを管理していくデータの集合) //※要using System.Collections.Generic; //============================== //------------ // List //------------ List <int> scoresA = new List <int>(); scoresA.Add(30); scoresA.Add(80); scoresA.Add(60); List <int> scoresB = new List <int>() { 30, 80, 60 }; scoresB[1] = 100; Console.WriteLine(scoresB.Count); foreach (var score in scoresB) { Console.WriteLine(score); } //------------ // HashSet //------------ HashSet <int> answers = new HashSet <int>() { 3, 5, 8, 5 }; //重複分は無視される answers.Add(10); // 3, 5, 8, 10 answers.Remove(3); // 5, 8, 10 Console.WriteLine(answers.Contains(3)); // false foreach (var answer in answers) { Console.WriteLine(answer); } //------------ // Dictionary //------------ Dictionary <string, int> registrants = new Dictionary <string, int>() { { "taguchi", 50 }, { "fkoji", 80 }, }; registrants.Add("dotinstall", 40); Console.WriteLine(registrants["fkoji"]); // 80 registrants["taguchi"] = 60; foreach (KeyValuePair <string, int> registrant in registrants) { Console.WriteLine($"{registrant.Key}: {registrant.Value}"); } //============================== // LINQ //============================== //要 using System.Linq; List <double> prices = new List <double>() { 53.2, 48.2, 32.8 }; //------------ // SQL //------------ var resultsA = from price in prices where price * 1.08 > 50.0 select price * 1.08; foreach (var result in resultsA) { Console.WriteLine(result); } //------------ // Method //------------ var results = prices .Select(n => n * 1.08) .Where(n => n > 50.0); foreach (var result in results) { Console.WriteLine(result); } //-----< Sample01 >----- List <Customer> _customers = new List <Customer>(); _customers.Add(new Customer { Name = "Fukuzawa", Age = 35, IsMarried = true, }); _customers.Add(new Customer { Name = "Higuchi", Age = 28, IsMarried = true, }); _customers.Add(new Customer { Name = "Noda", Age = 42, IsMarried = false, }); _customers.Add(new Customer { Name = "Igawa", Age = 21, IsMarried = false, }); _customers.Add(new Customer { Name = "Sawada", Age = 31, IsMarried = true, }); Console.WriteLine("===================="); // All foreach (var customer in _customers) { Console.WriteLine(customer.Name); } Console.WriteLine("===================="); // フィルタリング1 foreach (var customer in _customers.Where(n => n.IsMarried)) { Console.WriteLine(customer.Name); } Console.WriteLine("===================="); // フィルタリング2 foreach (var customer in _customers .Where(n => n.IsMarried) .Where(n => n.Age > 30) ) { Console.WriteLine(customer.Name); } Console.WriteLine("===================="); }
public void MultipleStylesCanShareTheSameClassName() { var buttonStyle = new Style(typeof(Button)) { Setters = { new Setter { Property = Button.TextColorProperty, Value = Color.Pink }, }, Class = "pink", ApplyToDerivedTypes = true, }; var labelStyle = new Style(typeof(Label)) { Setters = { new Setter { Property = Button.BackgroundColorProperty, Value = Color.Pink }, }, Class = "pink", ApplyToDerivedTypes = false, }; var button = new Button { StyleClass = new [] { "pink" }, }; var myButton = new MyButton { StyleClass = new [] { "pink" }, }; var label = new Label { StyleClass = new [] { "pink" }, }; var myLabel = new MyLabel { StyleClass = new [] { "pink" }, }; new StackLayout { Resources = new ResourceDictionary { buttonStyle, labelStyle }, Children = { button, label, myLabel, myButton, } }; Assert.AreEqual(Color.Pink, button.TextColor); Assert.AreEqual(Color.Default, button.BackgroundColor); Assert.AreEqual(Color.Pink, myButton.TextColor); Assert.AreEqual(Color.Default, myButton.BackgroundColor); Assert.AreEqual(Color.Pink, label.BackgroundColor); Assert.AreEqual(Color.Default, label.TextColor); Assert.AreEqual(Color.Default, myLabel.BackgroundColor); Assert.AreEqual(Color.Default, myLabel.TextColor); }
private void Update() { if (_nodeDictionary[_currNode].GetMainText() != null) { if (_canControlTextDisplay) { if (_displayText.Contains("INSERTOBJECTONE")) { _displayText = _displayText.Replace("INSERTOBJECTONE", UseItemManager.GetItemInUse().name); } ControlOverallTextDisplay(_displayText); } _mainLogText = _displayText; } //print(MyName.GetName()); if (IsShowing()) { if (Input.GetKeyDown(KeyCode.Mouse0)) { if (_clickCounter < 2) { _clickCounter += 1; if (_clickCounter == 1) { if (!SceneManager.GetActiveScene().name.Equals("Prologue")) { string logText = GameObject.Find("LogContent").GetComponent <Text>().text; MainText myCurrNode = _nodeDictionary[_currNode]; logText += "\n" + myCurrNode.GetCurrCharacter() + ":"; logText += "\n" + _mainLogText + "\n"; GameObject.Find("LogContent").GetComponent <Text>().text = logText; } } } if (_clickCounter == 2) { MainText currNode = _nodeDictionary[_currNode]; if (currNode.HasChoice() == false) { currNode.InvokeOnClickedEvent(); if (currNode.goToConsecutiveNodeOnClick) { ChangeNode(int.Parse(currNode.gameObject.transform.GetChild(0).GetComponent <Text>().text) + 1); } } } } } MyButton returnButton = null; if (GameObject.Find("BackArrow") != null) { returnButton = GameObject.Find("BackArrow").GetComponent <MyButton>(); } if (returnButton != null) { if (IsShowing()) { InteractionZone.SetInteractionOn(false); if (returnButton != null) { returnButton.Hide(); } } else { InteractionZone.SetInteractionOn(true); if (returnButton != null && GameObject.Find("Classroom") != null && GameObject.Find("Classroom").GetComponent <SpriteRenderer>().color.a < 1) { returnButton.Show(); } } } if (GameObject.Find("Classroom") != null && GameObject.Find("Classroom").GetComponent <SpriteRenderer>().color.a == 1) { if (returnButton != null) { returnButton.Hide(); } } }
private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Firmware)); this.pictureBoxAPM = new System.Windows.Forms.PictureBox(); this.pictureBoxAPMHIL = new System.Windows.Forms.PictureBox(); this.pictureBoxQuad = new System.Windows.Forms.PictureBox(); this.pictureBoxHexa = new System.Windows.Forms.PictureBox(); this.pictureBoxTri = new System.Windows.Forms.PictureBox(); this.pictureBoxY6 = new System.Windows.Forms.PictureBox(); this.lbl_status = new System.Windows.Forms.Label(); this.progress = new System.Windows.Forms.ProgressBar(); this.lbl_AP = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.lbl_APHil = new System.Windows.Forms.Label(); this.lbl_ACQuad = new System.Windows.Forms.Label(); this.lbl_ACHexa = new System.Windows.Forms.Label(); this.lbl_ACTri = new System.Windows.Forms.Label(); this.lbl_ACY6 = new System.Windows.Forms.Label(); this.lbl_Heli = new System.Windows.Forms.Label(); this.pictureBoxHeli = new System.Windows.Forms.PictureBox(); this.lbl_ACHil = new System.Windows.Forms.Label(); this.pictureBoxQuadHil = new System.Windows.Forms.PictureBox(); this.BUT_setup = new ArdupilotMega.MyButton(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAPM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAPMHIL)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuad)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHexa)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTri)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxY6)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHeli)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuadHil)).BeginInit(); this.SuspendLayout(); // // pictureBoxAPM // this.pictureBoxAPM.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxAPM.Image = global::ArdupilotMega.Properties.Resources.APM_airframes_001; resources.ApplyResources(this.pictureBoxAPM, "pictureBoxAPM"); this.pictureBoxAPM.Name = "pictureBoxAPM"; this.pictureBoxAPM.TabStop = false; this.pictureBoxAPM.Click += new System.EventHandler(this.pictureBoxAPM_Click); // // pictureBoxAPMHIL // this.pictureBoxAPMHIL.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxAPMHIL.Image = global::ArdupilotMega.Properties.Resources.APM_airframes_002; resources.ApplyResources(this.pictureBoxAPMHIL, "pictureBoxAPMHIL"); this.pictureBoxAPMHIL.Name = "pictureBoxAPMHIL"; this.pictureBoxAPMHIL.TabStop = false; this.pictureBoxAPMHIL.Click += new System.EventHandler(this.pictureBoxAPMHIL_Click); // // pictureBoxQuad // this.pictureBoxQuad.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxQuad.Image = global::ArdupilotMega.Properties.Resources.frames_03; resources.ApplyResources(this.pictureBoxQuad, "pictureBoxQuad"); this.pictureBoxQuad.Name = "pictureBoxQuad"; this.pictureBoxQuad.TabStop = false; this.pictureBoxQuad.Click += new System.EventHandler(this.pictureBoxQuad_Click); // // pictureBoxHexa // this.pictureBoxHexa.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxHexa.Image = global::ArdupilotMega.Properties.Resources.frames_07; resources.ApplyResources(this.pictureBoxHexa, "pictureBoxHexa"); this.pictureBoxHexa.Name = "pictureBoxHexa"; this.pictureBoxHexa.TabStop = false; this.pictureBoxHexa.Click += new System.EventHandler(this.pictureBoxHexa_Click); // // pictureBoxTri // this.pictureBoxTri.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxTri.Image = global::ArdupilotMega.Properties.Resources.frames_05; resources.ApplyResources(this.pictureBoxTri, "pictureBoxTri"); this.pictureBoxTri.Name = "pictureBoxTri"; this.pictureBoxTri.TabStop = false; this.pictureBoxTri.Click += new System.EventHandler(this.pictureBoxTri_Click); // // pictureBoxY6 // this.pictureBoxY6.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxY6.Image = global::ArdupilotMega.Properties.Resources.frames_08; resources.ApplyResources(this.pictureBoxY6, "pictureBoxY6"); this.pictureBoxY6.Name = "pictureBoxY6"; this.pictureBoxY6.TabStop = false; this.pictureBoxY6.Click += new System.EventHandler(this.pictureBoxY6_Click); // // lbl_status // resources.ApplyResources(this.lbl_status, "lbl_status"); this.lbl_status.Name = "lbl_status"; // // progress // resources.ApplyResources(this.progress, "progress"); this.progress.Name = "progress"; this.progress.Step = 1; // // lbl_AP // resources.ApplyResources(this.lbl_AP, "lbl_AP"); this.lbl_AP.Name = "lbl_AP"; // // label2 // resources.ApplyResources(this.label2, "label2"); this.label2.Name = "label2"; // // lbl_APHil // resources.ApplyResources(this.lbl_APHil, "lbl_APHil"); this.lbl_APHil.Name = "lbl_APHil"; // // lbl_ACQuad // resources.ApplyResources(this.lbl_ACQuad, "lbl_ACQuad"); this.lbl_ACQuad.Name = "lbl_ACQuad"; // // lbl_ACHexa // resources.ApplyResources(this.lbl_ACHexa, "lbl_ACHexa"); this.lbl_ACHexa.Name = "lbl_ACHexa"; // // lbl_ACTri // resources.ApplyResources(this.lbl_ACTri, "lbl_ACTri"); this.lbl_ACTri.Name = "lbl_ACTri"; // // lbl_ACY6 // resources.ApplyResources(this.lbl_ACY6, "lbl_ACY6"); this.lbl_ACY6.Name = "lbl_ACY6"; // // lbl_Heli // resources.ApplyResources(this.lbl_Heli, "lbl_Heli"); this.lbl_Heli.Name = "lbl_Heli"; // // pictureBoxHeli // this.pictureBoxHeli.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxHeli.Image = global::ArdupilotMega.Properties.Resources.APM_airframes_08; resources.ApplyResources(this.pictureBoxHeli, "pictureBoxHeli"); this.pictureBoxHeli.Name = "pictureBoxHeli"; this.pictureBoxHeli.TabStop = false; this.pictureBoxHeli.Click += new System.EventHandler(this.pictureBoxHeli_Click); // // lbl_ACHil // resources.ApplyResources(this.lbl_ACHil, "lbl_ACHil"); this.lbl_ACHil.Name = "lbl_ACHil"; // // pictureBoxQuadHil // this.pictureBoxQuadHil.Cursor = System.Windows.Forms.Cursors.Hand; this.pictureBoxQuadHil.Image = global::ArdupilotMega.Properties.Resources.new_frames_09; resources.ApplyResources(this.pictureBoxQuadHil, "pictureBoxQuadHil"); this.pictureBoxQuadHil.Name = "pictureBoxQuadHil"; this.pictureBoxQuadHil.TabStop = false; this.pictureBoxQuadHil.Click += new System.EventHandler(this.pictureBoxQuadHil_Click); // // BUT_setup // resources.ApplyResources(this.BUT_setup, "BUT_setup"); this.BUT_setup.Name = "BUT_setup"; this.BUT_setup.UseVisualStyleBackColor = true; this.BUT_setup.Click += new System.EventHandler(this.BUT_setup_Click); // // Firmware // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.lbl_ACHil); this.Controls.Add(this.pictureBoxQuadHil); this.Controls.Add(this.BUT_setup); this.Controls.Add(this.lbl_Heli); this.Controls.Add(this.pictureBoxHeli); this.Controls.Add(this.lbl_ACY6); this.Controls.Add(this.lbl_ACTri); this.Controls.Add(this.lbl_ACHexa); this.Controls.Add(this.lbl_ACQuad); this.Controls.Add(this.lbl_APHil); this.Controls.Add(this.label2); this.Controls.Add(this.lbl_AP); this.Controls.Add(this.lbl_status); this.Controls.Add(this.progress); this.Controls.Add(this.pictureBoxY6); this.Controls.Add(this.pictureBoxTri); this.Controls.Add(this.pictureBoxHexa); this.Controls.Add(this.pictureBoxQuad); this.Controls.Add(this.pictureBoxAPMHIL); this.Controls.Add(this.pictureBoxAPM); this.MinimumSize = new System.Drawing.Size(1008, 461); this.Name = "Firmware"; this.Load += new System.EventHandler(this.FirmwareVisual_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAPM)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAPMHIL)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuad)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHexa)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTri)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxY6)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHeli)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxQuadHil)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); }
void Start() { Dispatcher.RoundStart(); timeOnStartSession = Time.fixedTime; curWorldTime = 0; Behaviour = this; CameraCreator(); ScoresFieldsCreator(); var mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height)); var buttonGO = new MyButton(() => Dispatcher.SetGameOver(), button, new Rect(100, -100, 100, 30), "Back to menu"); buttonGO.SetAnchor(new Vector2(0,1), new Vector2(0, 1)); mainCanvas.AddElement(buttonGO); world = Dispatcher.CurrentRunner.World; if (world != null) Debugger.Log(DebuggerMessageType.Unity, "World loaded"); else Debugger.Log(DebuggerMessageType.Unity, "Fail. World not loaded"); CollisionInfo = new Tuple<string, string, int>(null, null, 0); Time.timeScale = 1; // вот почему так? //в момент повторного запуска время уже не нулевое }
/// <summary> /// Creates a new instance of an animated + button /// </summary> /// <param name="callback">action to call when the animation is complete</param> public VertsButton(Action callback = null, string stored = "0") { // create the layout _layout = new StackLayout { HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, Padding = new Thickness(-20, 5, 20, 5), WidthRequest = Definitions.HeaderHeight, }; var circleButton = new MyButton { Text = stored, BorderColor = Color.FromHex(Definitions.TextColor), TextColor = Color.FromHex(Definitions.PrimaryColor), BackgroundColor = Color.FromHex(Definitions.TextColor), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, AnchorY = (double)TextAlignment.Center, FontSize = 14, BorderRadius = 30, HeightRequest = 60, WidthRequest = 60, }; var _inner = new StackLayout { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Padding = new Thickness(13, 0, -13, 0) }; _image = new Image { Source = "Resources/verts2.png", HorizontalOptions = LayoutOptions.EndAndExpand, }; if (stored == "0") { _layout.Padding = new Thickness(-25, 5, 25, 5); circleButton.IsVisible = false; } _inner.Children.Add(circleButton); _layout.Children.Add(_inner); _layout.Children.Add(_image); // add a gester reco this.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async (o) => { await this.ScaleTo(0.95, 50, Easing.CubicOut); await this.ScaleTo(1, 50, Easing.CubicIn); if (callback != null) callback.Invoke(); }) }); // set the content this.Content = _layout; }
public MyWindow(Sprite sprite, string title, Rect rect) : base() { isOpen = true; Head = new MyPanel(sprite, rect); Head.Element.name = "Window" + title; var trans = Head.Element.GetComponent<RectTransform>(); Head.SetAnchor(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f)); trans.anchoredPosition3D = new Vector3(0, 0, 0); trans.anchoredPosition = new Vector2(0, 0); trans.localPosition = new Vector3(0, 0, 0); trans.localScale = new Vector3(1, 1, 1); SetSize(trans, rect.size); var header = new MyPanel(sprite, rect); trans = header.Element.GetComponent<RectTransform>(); header.Element.GetComponent<Image>().color = new Color32(230, 230, 230, 200); header.SetAnchor(new Vector2(0, 1), new Vector2(1, 1)); trans.anchoredPosition3D = new Vector3(0, 0, 0); trans.anchoredPosition = new Vector2(0, 0); trans.offsetMin = new Vector2(0, 0); trans.offsetMax = new Vector2(0, 0); trans.localPosition = new Vector3(0, -10, 0); trans.sizeDelta = new Vector2(0, 20); trans.localScale = new Vector3(1, 1, 1); var titleWindow = new MyText(title); header.AddElement(titleWindow); var buttonClosed = new MyButton(() => SetActive(false), sprite, new Rect(0, 0, 64, 48), "X"); var rectButton = buttonClosed.Element.GetComponent<RectTransform>(); buttonClosed.SetAnchor(new Vector2(1, 1), new Vector2(1, 1)); rectButton.sizeDelta = new Vector2(50, 20); rectButton.localPosition = new Vector3(-25, -10, 0); //rectButton.pivot = new Vector2(1, 1); var buttonScript = buttonClosed.Element.GetComponent<Button>(); buttonScript.transition = Selectable.Transition.ColorTint; var selColor = new ColorBlock(); selColor.normalColor = buttonClosed.Element.GetComponent<Button>().colors.normalColor; selColor.pressedColor = new Color32(255, 80, 80, 255); selColor.highlightedColor = new Color32(255, 0, 0, 255); selColor.colorMultiplier = 1; selColor.fadeDuration = 0.2f; buttonClosed.Element.GetComponent<Button>().colors = selColor; Element = new MyPanel(sprite, rect).Element; var transM = Element.GetComponent<RectTransform>(); SetAnchor(new Vector2(0, 0), new Vector2(1, 1)); transM.anchoredPosition3D = new Vector3(0, 0, 0); transM.anchoredPosition = new Vector2(0, 0); transM.sizeDelta = new Vector2(0, 0); transM.localPosition = new Vector3(0, -20, 0); transM.offsetMin = new Vector2(transM.offsetMin.x, 0); transM.localScale = new Vector3(1, 1, 1); header.AddElement(buttonClosed); Head.AddElement(header); Head.AddElement(this); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogBrowse)); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.zg1 = new ZedGraph.ZedGraphControl(); this.Graphit = new ArdupilotMega.MyButton(); this.BUT_cleargraph = new ArdupilotMega.MyButton(); this.BUT_loadlog = new ArdupilotMega.MyButton(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; resources.ApplyResources(this.dataGridView1, "dataGridView1"); this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView1.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_RowEnter); // // zg1 // resources.ApplyResources(this.zg1, "zg1"); this.zg1.Name = "zg1"; this.zg1.ScrollGrace = 0D; this.zg1.ScrollMaxX = 0D; this.zg1.ScrollMaxY = 0D; this.zg1.ScrollMaxY2 = 0D; this.zg1.ScrollMinX = 0D; this.zg1.ScrollMinY = 0D; this.zg1.ScrollMinY2 = 0D; // // Graphit // resources.ApplyResources(this.Graphit, "Graphit"); this.Graphit.Name = "Graphit"; this.toolTip1.SetToolTip(this.Graphit, resources.GetString("Graphit.ToolTip")); this.Graphit.UseVisualStyleBackColor = true; this.Graphit.Click += new System.EventHandler(this.Graphit_Click); // // BUT_cleargraph // resources.ApplyResources(this.BUT_cleargraph, "BUT_cleargraph"); this.BUT_cleargraph.Name = "BUT_cleargraph"; this.toolTip1.SetToolTip(this.BUT_cleargraph, resources.GetString("BUT_cleargraph.ToolTip")); this.BUT_cleargraph.UseVisualStyleBackColor = true; this.BUT_cleargraph.Click += new System.EventHandler(this.BUT_cleargraph_Click); // // BUT_loadlog // resources.ApplyResources(this.BUT_loadlog, "BUT_loadlog"); this.BUT_loadlog.Name = "BUT_loadlog"; this.toolTip1.SetToolTip(this.BUT_loadlog, resources.GetString("BUT_loadlog.ToolTip")); this.BUT_loadlog.UseVisualStyleBackColor = true; this.BUT_loadlog.Click += new System.EventHandler(this.BUT_loadlog_Click); // // LogBrowse // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.BUT_loadlog); this.Controls.Add(this.BUT_cleargraph); this.Controls.Add(this.Graphit); this.Controls.Add(this.zg1); this.Controls.Add(this.dataGridView1); this.Name = "LogBrowse"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); }
// CONSTRUCTOR public MenuGame() : base() { switch (Settings.gameMode) { case GameMODE.SKY: this.background = new Sprite("background_sky", 0, 0); this.ground = new Ground(0, 1100, new Sprite("ground_sky")); this.player = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO), new AnimatedSprite("bird", 125, 70, 1, SheetOrientation.HORIZONTAL, 20, 20)); break; case GameMODE.SEA: this.background = new Sprite("background_sea", 0, 0); this.ground = new Ground(0, 1100, new Sprite("ground_sea")); this.player = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO), new AnimatedSprite("submarine", 125, 90, 1, SheetOrientation.HORIZONTAL, 20, 20)); break; case GameMODE.JUNGLE: this.background = new Sprite("background_jungle", 0, 0); this.ground = new Ground(0, 1100, new Sprite("ground_jungle")); this.player = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO), new AnimatedSprite("bug", 125, 100, 1, SheetOrientation.HORIZONTAL, 20, 20)); break; case GameMODE.SPACE: this.background = new Sprite("background_space", 0, 0); this.ground = new Ground(0, 1100, new Sprite("ground_space")); this.player = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO), new AnimatedSprite("alien", 125, 73, 1, SheetOrientation.HORIZONTAL, 20, 20)); break; default: this.background = new Sprite("background_sky", 0, 0); this.ground = new Ground(0, 1100, new Sprite("ground_sky")); this.player = new Bird((int)(150 * Settings.PIXEL_RATIO), (int)(600 * Settings.PIXEL_RATIO), new AnimatedSprite("bird", 125, 70, 1, SheetOrientation.HORIZONTAL, 20, 20)); break; } this.getReady = new Sprite("getready", (int)(80 * (int)Settings.PIXEL_RATIO), 230); this.pipes = new List <Pipe>(); this.start = false; this.gameover = false; this.setRotation = false; this.timer = 0; this.random = new Random(); this.gameOver = new Sprite("gameover", (int)(80 * (int)Settings.PIXEL_RATIO), 230); scoreBoxX = 50 * (int)Settings.PIXEL_RATIO; scoreBoxY = 400; this.scoreBox = new Sprite("score_box", scoreBoxX, scoreBoxY); this.baseScoreX = scoreBoxX; this.baseScoreY = scoreBoxY; this.retryButton = new MyButton(scoreBoxX + 100, scoreBoxY + 350, new AnimatedSprite("game_buttons", 120, 120, 1, SheetOrientation.HORIZONTAL, 0, 0)); this.menuButton = new MyButton(scoreBoxX + 350, scoreBoxY + 350, new AnimatedSprite("game_buttons", 120, 120, 2, SheetOrientation.HORIZONTAL, 0, 0)); this.score = 0; this.highscore = 0; this.newHighscore = false; this.medal = new AnimatedSprite("medals", 135, 156, 0, SheetOrientation.HORIZONTAL, scoreBoxX + 62, scoreBoxY + 105); this.newScore = new Sprite("new", scoreBoxX + 230, scoreBoxY + 180); }