public override void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { base.LoadCacheUIItem(operateEnum, parameter); if (m_UICachePrefabScript == null) { return; } //设置Button的相关属性 Button button = GetAttachComponent <Button>(); if (button == null) { return; } // Debug.Log("UIButtonWithoutTextCacheItemMark"); m_ButtonEffect = m_UICachePrefabScript.transform.GetAddComponent <ButtonEffect>(); m_ButtonEffect.enabled = m_ButtonSetting.m_IsBtnEffectEnable; button.transition = m_ButtonSetting.m_Transition; if (button.transition == Selectable.Transition.SpriteSwap) { SpriteState spriteState = button.spriteState; if (m_ButtonSetting.m_DisabledSpritePath != string.Empty) { //2017/11/27注释掉 // spriteState.disabledSprite = ResourceMgr.instance.LoadSprite(m_ButtonSetting.m_DisabledSpritePath); button.spriteState = spriteState; } } }
public static void SaveSetting(ButtonEffect effect, ColorMatrix cm, int FontColour) { string key = AppController.ApplicationRegistryKeyName; string subkey = effect.ToString(); RegistryKey reg = Registry.CurrentUser.CreateSubKey(key + @"\UserColours\" + subkey); if (reg == null) return; reg.SetValue("FontColour", FontColour); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { string name = "Matrix" + i.ToString(System.Globalization.CultureInfo.InvariantCulture) + j.ToString(System.Globalization.CultureInfo.InvariantCulture); object value = cm.GetType().GetProperty(name).GetValue(cm, null); // Console.WriteLine("i: {0}, j: {1}, value: {2}", i, j, value); reg.SetValue(name, (float)System.Decimal.Parse(value.ToString(), System.Globalization.CultureInfo.InvariantCulture)); } } RaiseColoursChangedEvent(); }
public static void ShowColourEditorForm(string message) { string effectname = message.Substring(0, message.IndexOf(" ", StringComparison.Ordinal)); string text = message.Substring(message.IndexOf(" ", StringComparison.Ordinal) + 1); ButtonEffect effect = (ButtonEffect)Enum.Parse(typeof(ButtonEffect), effectname); ColourEditor newForm; if (editorForms.ContainsKey(effect)) { if (editorForms.TryGetValue(effect, out newForm)) { newForm.BringToFront(); return; } } newForm = new ColourEditor(effect, text); PositionColourEditorForm(newForm); editorForms.Add(effect, newForm); newForm.FormClosed += ChildFormClosed; newForm.Show(_mainForm); }
public static void SaveSetting(ButtonEffect effect, ColorMatrix cm, int FontColour) { string key = AppController.ApplicationRegistryKeyName; string subkey = effect.ToString(); RegistryKey reg = Registry.CurrentUser.CreateSubKey(key + @"\UserColours\" + subkey); if (reg == null) { return; } reg.SetValue("FontColour", FontColour); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { string name = "Matrix" + i.ToString(System.Globalization.CultureInfo.InvariantCulture) + j.ToString(System.Globalization.CultureInfo.InvariantCulture); object value = cm.GetType().GetProperty(name).GetValue(cm, null); // Console.WriteLine("i: {0}, j: {1}, value: {2}", i, j, value); reg.SetValue(name, (float)decimal.Parse(value.ToString(), System.Globalization.CultureInfo.InvariantCulture)); } } RaiseColoursChangedEvent(); }
private void TryGetEffect() { buttonEffect = GetComponentInChildren <ButtonEffect>(); if (buttonEffect == null) { Debug.Log("У кнопки нет дочернего buttonEffect " + this.gameObject.name); } }
private void SetDirection() { Vector2 dir = MouseUtils.MouseWorldPosition - PlacedOne.Position; PlacedOne.SetDirection(dir); ReleseAction(); ButtonEffect.CancelEffect(); }
public void ShowMenu() { if (ButtonManager.Instance.FunctionButtonActiveNow != null) { ButtonManager.Instance.FunctionButtonActiveNow.CloseMenu(); } menu.Show(); ButtonManager.Instance.FunctionButtonActiveNow = this; ButtonEffect.SelectedEffect(); }
private static Bitmap ApplyEffect(Bitmap bmp, ButtonEffect effect) { ColorMatrix cm = GetMatrix(effect); if (cm == null) { return(bmp); } return(Transform(bmp, cm)); }
private void ButtonAction() { if (ButtonManager.Instance.MenuButtonActiveNow != null && ButtonManager.Instance.MenuButtonActiveNow.GameObject.activeSelf) { ButtonManager.Instance.MenuButtonActiveNow.ReleseAction(); ButtonManager.Instance.MenuButtonActiveNow.ButtonEffect.CancelEffect(); } PressAction(); ButtonManager.Instance.MenuButtonActiveNow = this; ButtonEffect.SelectedEffect(); }
private static UserColourSetting GetColourSettingFromRegistry(ButtonEffect effect) { // Need to be defensively minded as user could change, // delete, or change type of registry settings. string subkey = AppController.ApplicationRegistryKeyName + @"\UserColours\" + effect.ToString(); RegistryKey reg = Registry.CurrentUser.OpenSubKey(subkey); if (reg == null) // No settings have been defined for this effect return null; UserColourSetting setting = new UserColourSetting(); // User may have changed type of FontColour // Using nullable int as any possible integer value could be a valid // ToARGB() result (well, I'm assuming it could anyway) int? fontColourArgb; object value = reg.GetValue("FontColour"); if (value == null || reg.GetValueKind("FontColour") != RegistryValueKind.DWord) fontColourArgb = Color.Black.ToArgb(); else fontColourArgb = (int?)value; setting.FontColour = Color.FromArgb((int)fontColourArgb); ColorMatrix cm = new ColorMatrix(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { string name = "Matrix" + i.ToString(System.Globalization.CultureInfo.InvariantCulture) + j.ToString(System.Globalization.CultureInfo.InvariantCulture); value = reg.GetValue(name); if (value != null) { Single svalue; if (System.Single.TryParse(value.ToString(), out svalue)) { cm.GetType().GetProperty(name).SetValue(cm, svalue, null); } } } } setting.Matrix = cm; return setting; }
private void AddButton(string text, ButtonEffect effect) { var pb = new PictureBox { Image = ButtonImages.GetButtonImage (BlankButton.MediumWideBlank, buttonScaleFactor, text, effect) }; pb.Height = pb.Image.Height; pb.Width = pb.Image.Width; // If there is only one button, contain it in the centre of the form (the minimum size for a form // is bigger than a button until button scale gets to 0.6 or so which is too big for small resolutions) if (buttonCount == 1) { // Forms have a minimum size of 123. Applying a slight kludge factor too. pb.Left = (((123 - SystemInformation.BorderSize.Width - buttonWidth) / 2) - 5); pb.Top = padding; } else { int position; int line; // First, see which line the button is in and what position in the line it occupies. if (numberOfLines == 1 || currentButton <= buttonsPerLine) { position = currentButton; line = 1; } else { position = currentButton - buttonsPerLine; line = 2; } pb.Left = ((position - 1) * buttonWidth) + (position * padding); pb.Top = ((line - 1) * buttonHeight) + (line * padding); } pb.Tag = effect.ToString() + " " + text; if (AppController.UserCannotWriteToApplicationRegistryKey == false) { pb.DoubleClick += PictureBoxDoubleClick; } Controls.Add(pb); toolTip.SetToolTip(pb, toolTipText); currentButton++; }
private void AddButton(string text, ButtonEffect effect) { PictureBox pb = new PictureBox { Image = ButtonImages.GetButtonImage (BlankButton.MediumWideBlank, _buttonScaleFactor, text, effect) }; pb.Height = pb.Image.Height; pb.Width = pb.Image.Width; // If there is only one button, contain it in the centre of the form (the minimum size for a form // is bigger than a button until button scale gets to 0.6 or so which is too big for small resolutions) if (_buttonCount == 1) { // Forms have a minimum size of 123. Applying a slight kludge factor too. pb.Left = (((123 - SystemInformation.BorderSize.Width - _buttonWidth) / 2) - 5); pb.Top = _padding; } else { int position; int line; // First, see which line the button is in and what position in the line it occupies. if (_numberOfLines == 1 || _currentButton <= _buttonsPerLine) { position = _currentButton; line = 1; } else { position = _currentButton - _buttonsPerLine; line = 2; } pb.Left = ((position - 1) * _buttonWidth) + (position * _padding); pb.Top = ((line - 1) * _buttonHeight) + (line * _padding); } pb.Tag = effect.ToString() + " " + text; if (AppController.UserCannotWriteToApplicationRegistryKey == false) pb.DoubleClick += PictureBoxDoubleClick; Controls.Add(pb); _toolTip.SetToolTip(pb, _toolTipText); _currentButton++; }
public ColourEditor(ButtonEffect effect, string caption) { InitializeComponent(); Effect = effect; this.caption = caption; Text = "Editing the " + caption + " button"; LoadSetting(); UserColourSettingManager.ColoursChanged += delegate(object sender, EventArgs e) { OnColoursChanged(); }; }
public static Color GetFontColour(ButtonEffect effect, bool ignoreUserSettings) { if (ignoreUserSettings == false) { UserColourSetting setting = UserColourSettingManager.GetColourSettings(effect); if (setting != null) { return(setting.FontColour); } } return(Color.Black); }
public ColourEditor(ButtonEffect effect, string caption) { InitializeComponent(); _effect = effect; _caption = caption; Text = "Editing the " + caption + " button"; LoadSetting(); UserColourSettingManager.ColoursChanged += delegate(object sender, EventArgs e) { OnColoursChanged(); }; }
public static UserColourSetting GetColourSettings(ButtonEffect effect) { if (_loaded == false) { LoadColours(); _loaded = true; } if (settings.ContainsKey(effect)) return settings[effect]; return null; }
public static UserColourSetting GetColourSettings(ButtonEffect effect) { if (_loaded == false) { LoadColours(); _loaded = true; } if (settings.ContainsKey(effect)) { return(settings[effect]); } return(null); }
protected override void Update() { base.Update(); if (!IsStartChecking) { return; } if (!menu.GameObject.activeSelf && !IsClosed) { IsClosed = true; IsStartChecking = false; ButtonEffect.CancelEffect(); } }
public static ColorMatrix GetMatrix(ButtonEffect effect, bool ignoreUserSettings = false) { if (ignoreUserSettings == false) { UserColourSetting setting = UserColourSettingManager.GetColourSettings(effect); if (setting != null) { return(setting.Matrix); } } ColorMatrix cm = null; switch (effect) { case ButtonEffect.None: cm = new ColorMatrix(); break; case ButtonEffect.Mapped: cm = Blue(); break; case ButtonEffect.Disabled: cm = Darken(-0.3F); break; case ButtonEffect.MappedPending: cm = GreenyBlue(); break; case ButtonEffect.UnmappedPending: cm = Golden(); break; case ButtonEffect.DisabledPending: cm = DarkGold(); break; case ButtonEffect.EnabledPending: cm = GoldenDarken(); break; } return(cm); }
// This (private) method does the work. private static Bitmap GetButtonImage(int scancode, int extended, BlankButton button, int horizontalStretch, int verticalStretch, float scale, ButtonEffect effect, string caption) { Bitmap bmp = GetBitmap(button, horizontalStretch, verticalStretch, scale, effect, true); Color fontColour = GetFontColour(effect); Bitmap bmpWithCaption; if (String.IsNullOrEmpty(caption)) { bmpWithCaption = WriteCaption(bmp, scancode, extended, fontColour); } else { bmpWithCaption = WriteCaption(bmp, caption, false, false, fontColour); } return bmpWithCaption; }
// This (private) method does the work. private static Bitmap GetButtonImage(int scancode, int extended, BlankButton button, int horizontalStretch, int verticalStretch, float scale, ButtonEffect effect, string caption) { Bitmap bmp = GetBitmap(button, horizontalStretch, verticalStretch, scale, effect, true); Color fontColour = GetFontColour(effect); Bitmap bmpWithCaption; if (String.IsNullOrEmpty(caption)) { bmpWithCaption = WriteCaption(bmp, scancode, extended, fontColour); } else { bmpWithCaption = WriteCaption(bmp, caption, false, false, fontColour); } return(bmpWithCaption); }
protected void HandleButtonEffect() { if (_drag) //dont trigger an effect when the user is interacting with the button { return; } if (effectOptions.effectOne.useEffect) { _activeEffect = ButtonEffect.ONE; } else if (effectOptions.effectTwo.useEffect) { _activeEffect = ButtonEffect.TWO; } else if (effectOptions.effectThree.useEffect) { _activeEffect = ButtonEffect.THREE; } switch (_activeEffect) { case ButtonEffect.ONE: StopCoroutine("RunEffectOne"); StartCoroutine("RunEffectOne"); break; case ButtonEffect.TWO: StopCoroutine("RunEffectTwo"); StartCoroutine("RunEffectTwo"); break; case ButtonEffect.THREE: StopCoroutine("RunEffectThree"); StartCoroutine("RunEffectThree"); break; } }
void Awake() { _image = GetComponent <Image>(); if (overrideImage != null) { _image = overrideImage; } _rect = GetComponent <RectTransform>(); ApplyItemModifications(spriteOptions.restSprite, colorOptions.restColor, orientationOptions.restOrientation); if (effectOptions.effectOne.useEffect) { _activeEffect = ButtonEffect.ONE; } else if (effectOptions.effectTwo.useEffect) { _activeEffect = ButtonEffect.TWO; } else if (effectOptions.effectThree.useEffect) { _activeEffect = ButtonEffect.THREE; } }
public static Color GetFontColour(ButtonEffect effect) { return GetFontColour(effect, false); }
public static Color GetFontColour(ButtonEffect effect) { return(GetFontColour(effect, false)); }
public static Color GetFontColour(ButtonEffect effect, bool ignoreUserSettings) { if (ignoreUserSettings == false) { UserColourSetting setting = UserColourSettingManager.GetColourSettings(effect); if (setting != null) return setting.FontColour; } return Color.Black; }
// Offers full control over the button scale and stretch. public static Bitmap GetButtonImage (int scancode, int extended, BlankButton button, int horizontalStretch, int verticalStretch, float scale, ButtonEffect effect) { return(GetButtonImage (scancode, extended, button, horizontalStretch, verticalStretch, scale, effect, String.Empty)); }
private static Bitmap GetBitmap(BlankButton button, int horizontalStretch, int verticalStretch, float scale, ButtonEffect effect, bool transform) { if (Math.Abs(scale - lastScale) > Single.Epsilon) { FontSize.SetFontSizes(scale); } Bitmap bmp; // Cache bitmap until scale or button changes (as long as no stretch is applied) if (horizontalStretch != 0 || verticalStretch != 0) { // IF this image needs to be stretched, force the height and width to even numbers // (This only seems to affect height?) bool forceEvenNumber = (verticalStretch != 0); bmp = ResizeBitmap(GetBitmap(button), scale, forceEvenNumber); bmp = StretchBitmap(bmp, horizontalStretch, verticalStretch); // _lastButton = BlankButton.None; } else { bmp = ResizeBitmap(GetBitmap(button), scale, false); } // Now all decisions have been made.. lastScale = scale; if (transform) { bmp = ApplyEffect(bmp, effect); } return(bmp); }
// Specific scaled button with custom caption public static Bitmap GetButtonImage(BlankButton button, float scale, string caption, ButtonEffect effect) { return(GetButtonImage(-1, -1, button, 0, 0, scale, effect, caption)); }
// Specific scaled button with custom caption public static Bitmap GetButtonImage(BlankButton button, float scale, string caption, ButtonEffect effect) { return GetButtonImage(-1, -1, button, 0, 0, scale, effect, caption); }
private static Bitmap GetBitmap(BlankButton button, int horizontalStretch, int verticalStretch, float scale, ButtonEffect effect, bool transform) { if (Math.Abs(scale - lastScale) > Single.Epsilon) { FontSize.SetFontSizes(scale); } Bitmap bmp; // Cache bitmap until scale or button changes (as long as no stretch is applied) if (horizontalStretch != 0 || verticalStretch != 0) { // IF this image needs to be stretched, force the height and width to even numbers // (This only seems to affect height?) bool forceEvenNumber = (verticalStretch != 0); bmp = ResizeBitmap(GetBitmap(button), scale, forceEvenNumber); bmp = StretchBitmap(bmp, horizontalStretch, verticalStretch); // _lastButton = BlankButton.None; } else { bmp = ResizeBitmap(GetBitmap(button), scale, false); } // Now all decisions have been made.. lastScale = scale; if (transform) bmp = ApplyEffect(bmp, effect); return bmp; }
// Offers full control over the button scale and stretch. public static Bitmap GetButtonImage (int scancode, int extended, BlankButton button, int horizontalStretch, int verticalStretch, float scale, ButtonEffect effect) { return GetButtonImage (scancode, extended, button, horizontalStretch, verticalStretch, scale, effect, String.Empty); }
protected void OnDisable() { ReleseAction(); ButtonEffect?.CancelEffect(); }
private void SetButtonImages() { // Set the buttons' bitmap as required. Always call SetImage as that // handles releasing the existing bitmap if any.. // From key is straightforward. float scale = (DpiInfo.Dpi / 96F); if (FromKeyPictureBox.Image == null && map.IsEmpty()) { FromKeyPictureBox.SetImage(ButtonImages.GetButtonImage (-1, -1, BlankButton.Blank, 0, 0, scale, ButtonEffect.None)); } else { FromKeyPictureBox.SetImage(ButtonImages.GetButtonImage (map.From.Scancode, map.From.Extended, BlankButton.Blank, 0, 0, scale, ButtonEffect.None)); } // To Key depends more on state int scancode = 0; int extended = 0; ButtonEffect effect = ButtonEffect.None; // 'Disabled' is a special case of 'Mapped' if (disabled) { effect = MappingsManager.IsMappingPending(map) ? ButtonEffect.DisabledPending : ButtonEffect.Disabled; } else { if (!mapped) { // Not mapped. What are we doing then?? if (capturingToKey) { scancode = map.To.Scancode; extended = map.To.Extended; if (map.To.Scancode == 0) { // Can't map to a disabled key - show button as disabled.. effect = ButtonEffect.Disabled; } else { effect = ButtonEffect.MappedPending; } } else if (capturingFromKey) { if (map.IsEmpty()) { // Show a blank key. scancode = -1; extended = -1; } } } else { // Mapped to a specific key scancode = map.To.Scancode; extended = map.To.Extended; effect = MappingsManager.IsMappingPending(map) ? ButtonEffect.MappedPending : ButtonEffect.Mapped; } } ToKeyPictureBox.SetImage(ButtonImages.GetButtonImage(scancode, extended, BlankButton.Blank, 0, 0, scale, effect)); }
public void CloseMenu() { menu.Close(); ButtonEffect.CancelEffect(); }
private static Bitmap ApplyEffect(Bitmap bmp, ButtonEffect effect) { ColorMatrix cm = GetMatrix(effect); if (cm == null) { return bmp; } return Transform(bmp, cm); }
private static UserColourSetting GetColourSettingFromRegistry(ButtonEffect effect) { // Need to be defensively minded as user could change, // delete, or change type of registry settings. string subkey = AppController.ApplicationRegistryKeyName + @"\UserColours\" + effect.ToString(); RegistryKey reg = Registry.CurrentUser.OpenSubKey(subkey); if (reg == null) // No settings have been defined for this effect { return(null); } UserColourSetting setting = new UserColourSetting(); // User may have changed type of FontColour // Using nullable int as any possible integer value could be a valid // ToARGB() result (well, I'm assuming it could anyway) int?fontColourArgb; object value = reg.GetValue("FontColour"); if (value == null || reg.GetValueKind("FontColour") != RegistryValueKind.DWord) { fontColourArgb = Color.Black.ToArgb(); } else { fontColourArgb = (int?)value; } setting.FontColour = Color.FromArgb((int)fontColourArgb); ColorMatrix cm = new ColorMatrix(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { string name = "Matrix" + i.ToString(System.Globalization.CultureInfo.InvariantCulture) + j.ToString(System.Globalization.CultureInfo.InvariantCulture); value = reg.GetValue(name); if (value != null) { float svalue; if (float.TryParse(value.ToString(), out svalue)) { cm.GetType().GetProperty(name).SetValue(cm, svalue, null); } } } } setting.Matrix = cm; return(setting); }
public static ColorMatrix GetMatrix(ButtonEffect effect, bool ignoreUserSettings = false) { if (ignoreUserSettings == false) { UserColourSetting setting = UserColourSettingManager.GetColourSettings(effect); if (setting != null) { return setting.Matrix; } } ColorMatrix cm = null; switch (effect) { case ButtonEffect.None: cm = new ColorMatrix(); break; case ButtonEffect.Mapped: cm = Blue(); break; case ButtonEffect.Disabled: cm = Darken(-0.3F); break; case ButtonEffect.MappedPending: cm = GreenyBlue(); break; case ButtonEffect.UnmappedPending: cm = Golden(); break; case ButtonEffect.DisabledPending: cm = DarkGold(); break; case ButtonEffect.EnabledPending: cm = GoldenDarken(); break; } return cm; }