Example #1
0
 public void OnGoldSelected(bool value)
 {
     if (value)
     {
         selectedColor = SelectedColor.Gold;
     }
 }
Example #2
0
        public Square(string fileName, bool isTouchEnabled, SelectedColor color, PositionInGame position) : base()
        {
            _sprite = new CCSprite(fileName);
            //_square.AnchorPoint = point;

            _sprite.ContentSize = new CCSize(200, 200);
            ColorType           = color;
            CurrentPosition     = position;

            AddChild(_sprite);


            if (isTouchEnabled)
            {
                IsTouchEnabled = isTouchEnabled;
                var touchListener = new CCEventListenerTouchAllAtOnce();
                touchListener.OnTouchesBegan = OnTouchesBegan;

                AddEventListener(touchListener, this);
            }
            else //signal squares
            {
                //TODO: add +1 to square _sprite.AddChild
                _plusOneLabel          = new CCLabel("+1", "Fonts/arial", 36, CCLabelFormat.SpriteFont);
                _plusOneLabel.Position = new CCPoint(100, 100);
                _plusOneLabel.Visible  = false;
                _sprite.AddChild(_plusOneLabel, 1);
            }
        }
Example #3
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (CellBase != null)
                {
                    CellBase.PropertyChanged -= CellPropertyChanged;
                    if (CellParent != null)
                    {
                        CellParent.PropertyChanged -= ParentPropertyChanged;
                    }

                    if (CellBase.Section != null)
                    {
                        CellBase.Section.PropertyChanged -= SectionPropertyChanged;
                        CellBase.Section = null;
                    }
                }

                BackgroundColor.Dispose();
                SelectedColor.Dispose();
                Ripple.Dispose();

                Background?.Dispose();
                Background = null;
            }

            base.Dispose(disposing);
        }
        private void ChangeColorByMouse(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Focus();
                _selectedColorCoord = new Point((int)MathC.Clamp((e.X / _paletteCellWidth), 0, PaletteSize.Width - 1),
                                                (int)MathC.Clamp((e.Y / _paletteCellHeight), 0, PaletteSize.Height - 1));

                if (_editor.SelectedObject is LightInstance)
                {
                    var light = _editor.SelectedObject as LightInstance;
                    if (!(_editor.Level.Settings.GameVersion.Legacy() <= TRVersion.Game.TR4 && light.Type == LightType.FogBulb))
                    {
                        light.Color = SelectedColor.ToFloat3Color() * 2.0f;
                        light.Room.RebuildLighting(_editor.Configuration.Rendering3D_HighQualityLightPreview);
                        _editor.ObjectChange(light, ObjectChangeType.Change);
                    }
                }
                else if (_editor.SelectedObject is StaticInstance)
                {
                    var instance = _editor.SelectedObject as StaticInstance;
                    instance.Color = SelectedColor.ToFloat3Color() * 2.0f;
                    _editor.ObjectChange(instance, ObjectChangeType.Change);
                }
                else if (_editor.Level.Settings.GameVersion == TRVersion.Game.TR5Main && _editor.SelectedObject is MoveableInstance)
                {
                    var instance = _editor.SelectedObject as MoveableInstance;
                    instance.Color = SelectedColor.ToFloat3Color() * 2.0f;
                    _editor.ObjectChange(instance, ObjectChangeType.Change);
                }

                _editor.LastUsedPaletteColourChange(SelectedColor);
                Invalidate();
            }
        }
Example #5
0
        public void SaveSettings()
        {
            var xml = new StringBuilder();

            xml.AppendLine(@"<Settings>");
            if (!String.IsNullOrEmpty(SelectedColor))
            {
                xml.AppendLine(@"<SelectedColor>" + SelectedColor.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SelectedColor>");
            }
            xml.AppendLine(@"<UseSlideMaster>" + UseSlideMaster + @"</UseSlideMaster>");
            xml.AppendLine(@"<BroadcastCalendarSettings>" + BroadcastCalendarSettings.Serialize() + @"</BroadcastCalendarSettings>");
            if (!String.IsNullOrEmpty(SalesRep))
            {
                xml.AppendLine(@"<SalesRep>" + SalesRep.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SalesRep>");
            }
            if (!String.IsNullOrEmpty(SelectedStarOutputItemsEncoded))
            {
                xml.AppendLine(@"<SelectedStarOutputItemsEncoded>" + SelectedStarOutputItemsEncoded.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SelectedStarOutputItemsEncoded>");
            }
            if (!String.IsNullOrEmpty(SelectedShiftOutputItemsEncoded))
            {
                xml.AppendLine(@"<SelectedShiftOutputItemsEncoded>" + SelectedShiftOutputItemsEncoded.Replace(@"&", "&#38;").Replace("\"", "&quot;") + @"</SelectedShiftOutputItemsEncoded>");
            }
            xml.AppendLine(@"<ApplyThemeForAllSlideTypes>" + ApplyThemeForAllSlideTypes + @"</ApplyThemeForAllSlideTypes>");
            xml.AppendLine(_themeSaveHelper.Serialize());
            xml.AppendLine(@"</Settings>");
            using (var sw = new StreamWriter(Asa.Common.Core.Configuration.ResourceManager.Instance.AppSettingsFile.LocalPath, false))
            {
                sw.Write(xml);
                sw.Flush();
            }
        }
        private async void OnTabSelectionChanged()
        {
            if (SelectedTabIndex == 1)
            {
                ShowLoadingProcess = Visibility.Visible;
                var symbolCollections = await GetSymbolCollection();

                // Handle edge-case where project has no styles:
                if (symbolCollections == null)
                {
                    AllSymbolCollections = new ObservableCollection <Symbol>();
                    ShowLoadingProcess   = Visibility.Collapsed;
                    return;
                }

                SymbolCollections     = new ObservableCollection <Symbol>(symbolCollections);
                AllSymbolCollections  = new ObservableCollection <Symbol>(symbolCollections);
                SelectedStyleItem     = (SelectedSymbolObject == null) ? SymbolCollections.FirstOrDefault() : SelectedSymbolObject;
                SelectedSymbolText    = SelectedStyleItem.SymbolText;
                ColorPickerCollection = new ObservableCollection <PropertyInfo>(typeof(System.Windows.Media.Brushes).GetProperties());
                SelectedColor         = (SelectedColorObject == null) ? ColorPickerCollection.Where(x => x.Name == "Red").FirstOrDefault() : SelectedColorObject;
                SelectedBrush         = (System.Windows.Media.Brush)SelectedColor.GetValue(null, null);
                ShowLoadingProcess    = Visibility.Collapsed;
            }
        }
 protected virtual void OnHexadecimalStringChanged(string oldValue, string newValue)
 {
     if (!SelectedColor.ToString().Equals(newValue))
     {
         UpdateSelectedColor((Color)ColorConverter.ConvertFromString(newValue));
     }
 }
Example #8
0
        private void Canvas_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            var aint = new SKPaint()
            {
                Color    = new SKColor(255, 255, 255, 0),
                IsStroke = false
            };

            e.Surface.Canvas.Clear();
            if (selCoord == null)
            {
                return;
            }

            var pt = (UniPoint)selCoord;
            var uc = SelectedColor.GetUniColor();

            uc = ((uint)uc) ^ 0x00ffffff;

            pt.X *= ((e.Info.Width / Width));
            pt.Y *= ((e.Info.Height / Height));

            aint.Color = new SKColor(uc);

            aint.IsStroke    = true;
            aint.StrokeWidth = 6;

            e.Surface.Canvas.DrawCircle(new SKPoint((float)pt.X, (float)pt.Y), 32, aint);
        }
Example #9
0
 public void OnRedSelected(bool value)
 {
     if (value)
     {
         selectedColor = SelectedColor.Red;
     }
 }
Example #10
0
 void alphaDisplay_AlphaChanged(object sender, ColorPicker.EventArgs <byte> e)
 {
     SetValue(SelectedColorProperty, SelectedColor.WithAlpha(e.Value));
     if (SelectedColorChanged != null)
     {
         SelectedColorChanged(this, new EventArgs <Color>(SelectedColor));
     }
 }
Example #11
0
 private void OnMouseDownCommandEx(MouseButtonEventArgs args)
 {
     SelectedPath = args.OriginalSource as Path;
     if (SelectedPath != null)
     {
         PathViewModel path = SelectedPath.DataContext as PathViewModel;
         path.Fill = SelectedColor.ToString();
     }
 }
Example #12
0
        public ColorPicker()
        {
            InitializeComponent();
            vm = new ColorViewModel(SelectedColor.GetUniColor());
            vm.PropertyChanged += Vm_PropertyChanged;

            ControlGrid.DataContext = vm;
            Rearrange();
        }
Example #13
0
 public override void UpdateSelf(GameTime gameTime)
 {
     base.UpdateSelf(gameTime);
     _hex.Text      = "#" + SelectedColor.Hex4();
     _preview.Color = SelectedColor;
     if (Info != null && Target != null)
     {
         Info.SetValue(Target, SelectedColor);
     }
 }
Example #14
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);
            Color?color = ViewManager.ShowColorDialog(Caption, SelectedColor.GetColor(ColorSchema));

            if (color != null)
            {
                SelectedColor.SetColor(color.Value, ColorSchema);
                SelectedColor = new SkyColor(SelectedColor);
            }
        }
Example #15
0
        private void CreateBackgroundColor()
        {
            var background = new BackgroundViewModel()
            {
                Type           = BackgroundType.SolidColor,
                BackgroundData = SelectedColor.ToString()
            };

            UserData.Backgrounds.Add(background);
            HideCreateView();
        }
Example #16
0
        private void SetColor(bool isPlusEnabled = false)
        {
            SelectedColor randomColor = GetRandomColor();

            while (randomColor == _lastActiveColor && GetSignalSquare(randomColor).IsActive)
            {
                randomColor = GetRandomColor();
            }


            SetVisibleSignalColor(randomColor, isPlusEnabled);
        }
Example #17
0
        internal void SetVisibleSignalColor(SelectedColor randomColor, bool plusOnLive = false)
        {
            _lastActiveColor = randomColor;

            var square = GetSignalSquare(randomColor);

            square.IsActive = true;
            if (plusOnLive)
            {
                square.PlusOneEnabled = true;
            }
        }
        private void CalculateColor(Point p)
        {
            HsvColor hsv = new HsvColor(360 - _spectrumSlider.Value, 1, 1)
            {
                S = p.X, V = 1 - p.Y
            };
            var currentColor = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V);

            currentColor.A    = A;
            SelectedColor     = currentColor;
            HexadecimalString = SelectedColor.ToString();
        }
Example #19
0
        /// <summary>
        /// 明度バー描画
        /// </summary>
        /// <param name="g">グラフィックオブジェクト</param>
        private void DrawBBar(Graphics g)
        {
            // 色配列を作成
            var colors = new List <Color>();

            for (int i = 0; i < BBarStepCount; i++)
            {
                colors.Add(ColorUtil.FromHSB(SelectedColor.GetHue(), SelectedColor.GetSaturation(), (float)i / BBarStepCount));
            }

            // 描画
            DrawBar(g, BBar, colors, ColorUtil.GetBrightnessStep(SelectedColor, BBarStepCount));
        }
Example #20
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            //Get the Selected Color
            SelectedColor = (Color)imgcanvas?.SelectedColor;
            //Convert Selected Color to string
            Hex = SelectedColor.ToString();
            //Create an Html Hex Color
            HtmlHex = Hex.Replace("#FF", "#");
            //Call the OnSelectedColor
            OnColorSelected?.Invoke(SelectedColor);

            base.OnPropertyChanged(e);
        }
Example #21
0
        protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
        {
            base.OnApplyTemplate(e);

            //gets slider
            AlphaSlider = this.GetControl <Slider>(e, "PART_AlphaSlider");

            HexTextBox = this.GetControl <TextBox>(e, "PART_HexTextBox");

            ValueSaturationPicker = this.GetControl <HuePickerBase>(e, "PART_SaturationValuePicker");

            HueSlider = this.GetControl <RadialColorSlider>(e, "PART_HueSlider");

            SelectNewColor(PreviewColor, UpdatedColorReason.ColorPickerInitializated);

            RadialColorSlider.ValueProperty.Changed.AddClassHandler <RadialColorSlider>((x, e) =>
            {
                if (e.Sender == HueSlider)
                {
                    SelectNewColor(new HSV(HueSlider.Value, S, V).ToColor(), UpdatedColorReason.HueChanged);
                }
            });
            HuePickerBase.ValueColorProperty.Changed.AddClassHandler <HuePickerBase>((x, e) =>
            {
                if (e.Sender == ValueSaturationPicker)
                {
                    SelectNewColor(new HSV(H, (byte)ValueSaturationPicker.Saturation, (byte)ValueSaturationPicker.ValueColor).ToColor(), UpdatedColorReason.ValueAndSaturationChanged);
                }
            });
            Slider.ValueProperty.Changed.AddClassHandler <Slider>((x, e) =>
            {
                if (e.Sender == AlphaSlider)
                {
                    SelectNewColor(Color.FromArgb((byte)AlphaSlider.Value, (byte)R, (byte)G, (byte)B), UpdatedColorReason.AChanged);
                }
            });

            HexTextBox.TextInput += delegate
            {
                var isValid = Color.TryParse(HexTextBox.Text, out Color color);
                if (isValid)
                {
                    SelectNewColor(color, UpdatedColorReason.HexChanged);
                }
                else
                {
                    HexTextBox.Text = SelectedColor.ToString();
                }
            };
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                SelectedColor?.Dispose();
                SelectedColor = null;

                StartingColor?.Dispose();
                StartingColor = null;

                ColorPicked = null;
            }
        }
Example #23
0
 /// <summary>
 /// Update color and focus when control made visible
 /// </summary>
 private void tmbColorMarker_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if ((bool)e.NewValue)
     {
         (sender as UIElement)?.Focus();
         if (this.DataContext is ColorChooser cc)
         {
             SelectedColor = cc.StoredColor;
         }
         HexadecimalString = SelectedColor.ToString(CultureInfo.InvariantCulture);
         this.updateMarkerPosition(SelectedColor);
         m_color = SelectedColor;
     }
 }
Example #24
0
        private void RecalculateFromRgb()
        {
            if (recalculating)
            {
                return;
            }
            recalculating = true;
            SelectedColor = WMColor.FromArgb(A, R, G, B);
            var hsv = SelectedColor.ToHSV();

            Hue           = hsv.H;
            Sat           = hsv.S;
            Val           = hsv.V;
            recalculating = false;
        }
Example #25
0
        protected override void OnDropDownClosed(EventArgs e)
        {
            base.OnDropDownClosed(e);
            _ColorPickerGrid.Children.RemoveAt(0);

            // Save recent color
            var color = SelectedColor.ToMmColor();
            var list  = RecentUsedColors;

            list.Remove(color);
            list.Insert(0, color);
            while (list.Count > 33)
            {
                list.RemoveAt(list.Count - 1);
            }
        }
Example #26
0
    private void UpdateColorConvertFunc(SelectedColor selectedColor)
    {
        switch (selectedColor)
        {
        case SelectedColor.R:
            this.colorToValueFunc = (color) => {
                return(color.r);
            };
            break;

        case SelectedColor.G:
            this.colorToValueFunc = (color) => {
                return(color.g);
            };
            break;

        case SelectedColor.B:
            this.colorToValueFunc = (color) => {
                return(color.b);
            };
            break;

        case SelectedColor.H:
            this.colorToValueFunc = (color) => {
                float h, s, v;
                Color.RGBToHSV(color, out h, out s, out v);
                return(h);
            };
            break;

        case SelectedColor.S:
            this.colorToValueFunc = (color) => {
                float h, s, v;
                Color.RGBToHSV(color, out h, out s, out v);
                return(s);
            };
            break;

        case SelectedColor.V:
            this.colorToValueFunc = (color) => {
                float h, s, v;
                Color.RGBToHSV(color, out h, out s, out v);
                return(v);
            };
            break;
        }
    }
Example #27
0
        private void SetSelectedColor(UniColor?selc = null)
        {
            UniColor clr;
            string   cname;

            if (selc != null)
            {
                clr = (UniColor)selc;
            }
            else
            {
                clr = SelectedColor.GetUniColor();
            }

            NamedColor nc;

            if (SnapToNamedColor)
            {
                nc = NamedColor.GetClosestColor(clr, 0.05, false);
            }
            else
            {
                nc = NamedColor.FindColor(clr);
            }

            if (nc != null)
            {
                cname = nc.Name;
                clr   = nc.Color;
            }
            else
            {
                cname = clr.ToString("rwH");
            }

            if (SelectedColor != clr.GetWinUIColor())
            {
                SelectedColor = clr.GetWinUIColor();
            }

            if (SelectedColorName != cname)
            {
                SelectedColorName = cname;
            }

            RenderPickerZone();
        }
Example #28
0
        private void SetSelectedColor(UniColor?selc = null)
        {
            UniColor clr;
            string   cname;

            if (selc != null)
            {
                clr = (UniColor)selc;
            }
            else
            {
                clr = SelectedColor.GetUniColor();
            }

            NamedColor nc;

            if (SnapToNamedColor)
            {
                nc = NamedColor.GetClosestColor(clr, 0.05, false);
            }
            else
            {
                nc = NamedColor.FindColor(clr);
            }

            if (nc != null)
            {
                cname = nc.Name;
                clr   = nc.Color;
            }
            else
            {
                cname = clr.GetXamarinColor().ToHex();
            }

            if (SelectedColor != clr.GetXamarinColor())
            {
                SelectedColor = clr.GetXamarinColor();
            }

            if (SelectedColorName != cname)
            {
                SelectedColorName = cname;
            }
        }
Example #29
0
        private void RecalculateFromSelected()
        {
            if (recalculating)
            {
                return;
            }
            recalculating = true;
            A             = SelectedColor.A;
            R             = SelectedColor.R;
            G             = SelectedColor.G;
            B             = SelectedColor.B;
            var hsv = SelectedColor.ToHSV();

            Hue           = hsv.H;
            Sat           = hsv.S;
            Val           = hsv.V;
            recalculating = false;
        }
Example #30
0
        private Square GetSignalSquare(SelectedColor color)
        {
            switch (color)
            {
            case SelectedColor.Red:
                return(_redSignal);

            case SelectedColor.Green:
                return(_greenSignal);

            case SelectedColor.Yellow:
                return(_yellowSignal);

            case SelectedColor.Blue:
                return(_blueSignal);

            default:
                throw new ArgumentException("there is no such color");
            }
        }