/// <summary> /// 移除指定按钮 /// </summary> /// <param name="btn"></param> public void Remove(SkinButton btn) { if (this.Controls.Contains(btn)) { this.Controls.Remove(btn); } }
/// <summary> /// 添加单个类型 /// </summary> /// <param name="category"></param> public virtual void AddCategory(Category category) { if (category == null) { return; } SkinButton btn = new SkinButton(); btn.AllowDrop = true; btn.Tag = category; btn.Text = category.CCategoryName; btn.BackColor = colors[rd.Next(colors.Count)]; //btn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; btn.BaseColor = colors[rd.Next(colors.Count)]; //btn.Width = (int)(category.CCategoryName.Length * btn.Font.Size * 2) + 8; btn.Width = (int)Commons.UICommon.GetControlWidth(btn.Text, btn.Font, this) + 10; //事件 btn.Click += Btn_Click; //btn.DragDrop += Btn_DragDrop; //btn.DragEnter += Btn_DragEnter; this.Controls.Add(btn); }
public void Initialize(Skin skin, GameObject playerPref, SkinSelectionMenu skinSelection) { this.skinSelection = skinSelection; mySkin = skin; GetComponent <Image>().color = skin.characterColor; myKey = skin.characterColor.ToString(); if (PlayerPrefs.HasKey(myKey)) { if (PlayerPrefs.GetInt(myKey) == 1) { myText.text = "unlocked"; } else if (PlayerPrefs.GetInt(myKey) == 2) { myText.text = "selected"; playerPref.GetComponent <SpriteRenderer>().color = mySkin.characterColor; playerPref.GetComponentInChildren <TrailRenderer>().colorGradient = mySkin.trailCol; if (selectedSkinButton != null) { selectedSkinButton.myText.text = "unlocked"; PlayerPrefs.SetInt(selectedSkinButton.myKey, 1); } selectedSkinButton = this; } } else { myText.text = skin.cost.ToString(); } this.playerPref = playerPref; }
public static void LightGrayButton(SkinButton btn) { btn.BaseColor = Color.LightGray; btn.BorderColor = Color.LightGray; btn.DownBaseColor = Color.Silver; btn.MouseBaseColor = Color.Gainsboro; }
//新建设置两个 private void skinButton() { string btnKind = btnComboBox1.Text; int num = 1; switch (btnKind) { case "确定": num = 1; break; case "取消": num = 2; break; case "转速设置": num = 3; break; case "开关电机": num = 4; break; case "解除堵转": num = 5; break; } SkinButton skinButton = new SkinButton(); skinButton.Text = btnName.Text; skinButton.Font = fontNew; skinButton.ForeColor = colorNew; skinButton.AutoSize = true; btnTranlate(skinButton, num); this.Close(); }
public static void OrangeButton(SkinButton btn) { btn.BaseColor = Color.FromArgb(255, 128, 0); btn.BorderColor = Color.FromArgb(255, 128, 0); btn.DownBaseColor = Color.FromArgb(192, 64, 0); btn.MouseBaseColor = Color.FromArgb(255, 192, 128); }
/// <summary> /// 构造对话框按钮 /// </summary> /// <param name="Text">显示文本</param> /// <param name="Name">名称</param> /// <param name="TabIndex">Tab序号</param> /// <param name="eHandler">点击事件</param> /// <param name="btnResult">对话框响应</param> /// <returns></returns> public Button GenComandBtn(string Text, string Name, int TabIndex, EventHandler eHandler, DialogResult?btnResult = null) { SkinButton Btn = new SkinButton(); Btn.IsDrawGlass = false; Btn.BaseColor = Color.Gainsboro; Btn.MouseBaseColor = Color.WhiteSmoke; Btn.DownBaseColor = Color.Silver; Btn.BorderColor = Color.Silver; Btn.ForeColor = Color.FromArgb(255, 45, 45, 45); Btn.Text = Text; Btn.Size = new Size(100, 30); Btn.Height = 30; Btn.Width = (int)Btn.CreateGraphics().MeasureString(Text, Btn.Font).Width + 80; Btn.Name = Name; Btn.TabIndex = 0; Btn.TabIndex = TabIndex; Btn.UseVisualStyleBackColor = true; if (btnResult.HasValue) { Btn.DialogResult = btnResult.GetValueOrDefault(DialogResult.None); } Btn.Click += eHandler; return(Btn); }
private void btnAdvanced_operations_MouseLeave(object sender, EventArgs e) { //Button变小 SkinButton current_button = sender as SkinButton; current_button.Size = new Size(current_button.Size.Width - 10, current_button.Size.Height - 10); current_button.Radius -= 10; }
void ToggleUnlockButton(bool activate, SkinButton selectedButton) { TMP_Text text = unlockButton.GetComponentInChildren <TMP_Text>(); text.text = selectedButton.skin.cost.ToString(); unlockButton.GetComponent <Button>().interactable = GameState.numCoins >= selectedButton.skin.cost; unlockButton.SetActive(activate); }
private void skinButton1_Click(object sender, EventArgs e)//公用页面处理 { SkinButton skinButton = (SkinButton)sender; _ = new Windowclass(new Form3(), new SkinButton[] { this.skinButton1, this.skinButton2, this.skinButton3, this.skinButton4, this.skinButton5, this.skinButton6, this.skinButton7 }, new Form[] { new Form3(), new Form4(), new Form5() , new Form6(), new Form7(), new 生产设置画面.Form8(), new 参数设置画面.Form9() }, this.skinLabel1, skinButton); }
// 这样就可以修改了这里我设置为1000毫秒 //int value = 5; private void btnAdvanced_operations_MouseEnter(object sender, EventArgs e) { //Button变大 SkinButton current_button = sender as SkinButton; current_button.Size = new Size(current_button.Size.Width + 10, current_button.Size.Height + 10); current_button.Radius += 10; }
Point getNewButtonPoint(SkinButton sb) { int w = getAddedButtonWidth(); int h = getAddedButtonHeight(sb); return(new Point(0, 0)); //TODO; }
private void bt_Confirm_Click(object sender, EventArgs e) { SkinButton bt = sender as SkinButton; Size s = bt.Size; Size size = bt.ImageSize; Animation.窗体动画.Leave_Animate(this.Handle, Animation.Leave_Animations.自右向左滑动, 500); this.Close(); }
public void SelectSkin() { GameObject selectedButtonObj = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject; SkinButton selectedButton = selectedButtonObj.GetComponent <SkinButton>(); gameManager.SetPlayerSkin(selectedButton.skin.skinName); //ShowPlayerSkin(selectedButton.skin.skinName); SetSelectedSkinButton(selectedButton); }
void setChecked(SkinButton sb) { foreach (Control ctl in this.panel_option.Controls) { if (ctl is SkinButton && !((SkinButton)ctl).Equals(sb)) { ctl.Font = setButtonStyle(0, (SkinButton)ctl); } } }
/// <summary> /// 类型按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void controlCategory1_OnCategroyButtonClick(object sender, EventArgs e) { SkinButton btn = (SkinButton)sender; Category c = (Category)btn.Tag; lblMessage.Text = c.CCategoryName; //处理,将选中的内容放置到右边的类型选择框中 skinPnlCategory.AddCategory(c); }
public void selectSkin(SkinButton button) { if (PlayerPrefs.GetInt(skins[button.GetNum()].name) == 0) { return; } skinNum = button.GetNum(); currentSkinButton.Deselect(); button.Select(); currentSkinButton = button; }
int getAddedButtonHeight(SkinButton sb) { int totalWeight = getAddedButtonWidth(); if (totalWeight + space + sb.Width > this.panel_option.Width) { return(30 + 30 + 30); } return(30); }
//add a btn setting form private void btn_newBtn_Click(object sender, EventArgs e) { BtnForm btnForm = new BtnForm(); btnForm.btnTranlate += new btnTranslateEventHandler(btn_Translate); btnForm.ShowDialog(); SkinButton btnNew = btnSkinButton; skinSplitContainer1.Panel2.Controls.Add(btnNew); DragControlClass obj = new DragControlClass(btnNew); }
Font setButtonStyle(int flag, SkinButton sb) { if (flag < 1) { sb.BaseColor = System.Drawing.Color.Yellow; return(new Font(FontFamily.GenericMonospace, 15, FontStyle.Regular)); } else { sb.BaseColor = System.Drawing.Color.Red; return(new Font(FontFamily.GenericMonospace, 15, FontStyle.Bold)); } }
public void Init() { EventBroker.OnChangeSkin += EventBroker_OnChangeSkin; _equippedSkinId = GameManager.SaveData.EquippedSkinId; _skinButtons = new List <SkinButton>(); SkinData[] skinDatas = ContentManager.instance.skinDatas; for (int i = 0; i < skinDatas.Length; i++) { SkinButton skinButton = Instantiate(_skinButtonPrefab, _container); skinButton.Set(skinDatas[i].ShopSprite, i); _skinButtons.Add(skinButton); } }
private void LoadLocks() { if (SkinButtons.Count > 0) { for (int i = 0; i < SkinButtons.Count; i++) { SkinButton sb = SkinButtons[i].GetComponent <SkinButton>(); if (IsSkinUnlocked(sb.GetTextureName())) { SkinButtons[i].interactable = false; sb.Lock(); } } } }
public void SetSkin() { playerPref.GetComponent <SpriteRenderer>().color = mySkin.characterColor; playerPref.GetComponentInChildren <TrailRenderer>().colorGradient = mySkin.trailCol; myText.text = "selected"; PlayerPrefs.SetInt(myKey, 2); if (selectedSkinButton != null) { selectedSkinButton.myText.text = "unlocked"; PlayerPrefs.SetInt(selectedSkinButton.myKey, 1); } selectedSkinButton = this; bounceAnim.StartAnimation(); PlayerPrefs.SetString(GameMaster.instance.GetCurrSkinKey(), myKey); }
private void SetBtn(SkinButton btn) { if (btn_Download.ControlState == CCWin.SkinClass.ControlState.Pressed) { btn_Download.ControlState = CCWin.SkinClass.ControlState.Normal; } btn_Download.BackColor = Color.Transparent; btn_Download.Enabled = true; btn_Limit.BackColor = Color.Transparent; btn_Limit.Enabled = true; if (btn.BackColor != btn.DownBaseColor) { btn.BackColor = btn.DownBaseColor; btn.Enabled = false; } }
/// <summary> /// 创建支持位图区域的控件(目前有button和form) /// </summary> /// <param name="control">控件</param> /// <param name="bitmap">位图</param> /// <param name="Alpha">小于此透明值的去除</param> public static void CreateControlRegion(Control control, Bitmap bitmap, int Alpha) { //判断是否存在控件和位图 if (control == null || bitmap == null) { return; } control.Width = bitmap.Width; control.Height = bitmap.Height; //当控件是form时 if (control is System.Windows.Forms.Form) { //强制转换为FORM Form form = (Form)control; //当FORM的边界FormBorderStyle不为NONE时,应将FORM的大小设置成比位图大小稍大一点 form.Width = control.Width; form.Height = control.Height; //没有边界 form.FormBorderStyle = FormBorderStyle.None; //将位图设置成窗体背景图片 form.BackgroundImage = bitmap; //计算位图中不透明部分的边界 GraphicsPath graphicsPath = CalculateControlGraphicsPath(bitmap, Alpha); //应用新的区域 form.Region = new Region(graphicsPath); } //当控件是button时 else if (control is SkinButton) { //强制转换为 button SkinButton button = (SkinButton)control; //计算位图中不透明部分的边界 GraphicsPath graphicsPath = CalculateControlGraphicsPath(bitmap, Alpha); //应用新的区域 button.Region = new Region(graphicsPath); } else if (control is SkinProgressBar) { //强制转换为 SkinProgressBar SkinProgressBar Progressbar = (SkinProgressBar)control; //计算位图中不透明部分的边界 GraphicsPath graphicsPath = CalculateControlGraphicsPath(bitmap, Alpha); //应用新的区域 Progressbar.Region = new Region(graphicsPath); } }
private void LoadTxtFile(string txtPath) { if (string.IsNullOrWhiteSpace(txtPath)) { txtPath = $@"{DirectoryUtil.GetCurrentDirectory()}\Docs\protocol.txt"; } if (!FileUtil.FileIsExist(txtPath)) { return; } string sFullText = FileUtil.FileToString(txtPath); string[] arrComms = sFullText.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); flowPanelComms.Controls.Clear(); foreach (string str in arrComms) { SkinButton btn = new SkinButton(); #region btnStyle btn.IsDrawGlass = false; btn.AutoSize = true; btn.InnerBorderColor = Color.Transparent; btn.RoundStyle = CCWin.SkinClass.RoundStyle.All; btn.Radius = 4; btn.BorderColor = Color.FromArgb(250, 250, 250); btn.BaseColor = Color.FromArgb(2, 79, 142);; btn.DownBaseColor = Color.FromArgb(2, 79, 142); btn.MouseBaseColor = Color.FromArgb(2, 79, 142); btn.FadeGlow = false; btn.ForeColor = Color.White; btn.Font = new Font("Tahoma", 9); btn.Cursor = Cursors.Hand; btn.Click += Btn_Click; #endregion ArrayList al = StringUtil.ExtractInnerContent(str, "[", "]"); btn.Text = al[0].ToString(); btn.Tag = al[1].ToString(); flowPanelComms.Controls.Add(btn); } }
public FrmMain(ChatListSubItem UserItem, SkinButton BtnState) { InitializeComponent(); //获取屏幕宽高 SW = Screen.PrimaryScreen.Bounds.Width; SH = Screen.PrimaryScreen.Bounds.Height; //赋值传来的登录用户 this.UserItem = UserItem; //获取当前登录帐号与头像 lblName.Text = UserItem.NicName; //获取当前状态 btnState.Image = BtnState.Image; btnState.Tag = BtnState.Tag; //调整图标位置 btnState.Left = lblName.Right; lblLv.Left = btnState.Right; imgSvip.Left = lblLv.Right; }
private void AddWindows(UserControl f, SkinButton button) { if (button != null) { button.BaseColor = Color.GreenYellow; } HideAllControlInPanel(); Control c = IsExitWindowsInPanel(f); if (c == null) { panelMain.Controls.Add(f); f.Dock = DockStyle.Fill; } else { c.Show(); } }
private SkinButton InnerCreateButton(string text, DialogResult result) { SkinButton button = new SkinButton(); button.DownBack = Properties.Resources.btn_down; button.MouseBack = Properties.Resources.btn_hover; button.NormlBack = Properties.Resources.btn_normal; button.DrawType = CCWin.SkinControl.DrawStyle.Img; button.Palace = true; button.Size = new Size(60, BUTTON_HEIGHT); button.UseVisualStyleBackColor = false; button.InheritColor = true; button.ForeColorSuit = true; button.Text = text; button.DialogResult = result; button.Click += new EventHandler(BtnClick); base.Controls.Add(button); return(button); }
/// <summary> /// Add Button's To Array /// </summary> /// <param name="Btn">Button Object</param> /// <returns></returns> private Button[] AddButton(SkinButton Btn) { if (this._ButtonArray == null) { this._ButtonArray = new Button[0]; } int newIndex = this._ButtonArray.Length + 1; Type t = this._ButtonArray.GetType().GetElementType(); Array newArray = Array.CreateInstance(t, newIndex); Array.Copy(this._ButtonArray, 0, newArray, 0, Math.Min(this._ButtonArray.Length, newIndex)); this._ButtonArray = (Button[])newArray; newIndex--; Btn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left))); Btn.TabIndex = newIndex; Btn.TabStop = false; this._ButtonArray[newIndex] = Btn; return(this._ButtonArray); }