/// <summary>
 /// Převede serialtext na long hodnotu.
 /// </summary>
 /// <param name="list"></param>
 /// <param name="name"></param>
 /// <param name="defValue"></param>
 /// <returns></returns>
 protected static System.Drawing.Color?GetValue(string text, System.Drawing.Color? defValue)
 {
     //  "AAA.RRR.GGG.BBB"
     if (String.IsNullOrEmpty(text))
     {
         return(defValue);
     }
     if (text == SerialNull)
     {
         return(defValue);
     }
     if (text.Length != 15)
     {
         return(defValue);
     }
     if (Int32.TryParse(text.Substring(0, 3), out int ca) &&
         Int32.TryParse(text.Substring(4, 3), out int cr) &&
         Int32.TryParse(text.Substring(8, 3), out int cg) &&
         Int32.TryParse(text.Substring(12, 3), out int cb))
     {
         if (ca >= 0 && ca < 256 &&
             cr >= 0 && cr < 256 &&
             cg >= 0 && cg < 256 &&
             cb >= 0 && cb < 256)
         {
             return(System.Drawing.Color.FromArgb(ca, cr, cg, cb));
         }
     }
     return(defValue);
 }
 private void ChangeWindowTitleColorAsync(System.Drawing.Color?color)
 {
     Application.Current?.Dispatcher?.InvokeAsync(() =>
     {
         ChangeWindowTitleColor(color);
     });
 }
Beispiel #3
0
        public static ExcelNamedStyleXml AddStyle([NotNull] ExcelWorkbook wb, string name,
                                                  ExcelBorderStyle borderStyle  = ExcelBorderStyle.Medium,
                                                  System.Drawing.Color?bckColor = null, int size    = 11, bool bold = false,
                                                  bool borderByGost             = true, bool center = true)
        {
            var style = wb.Styles.CreateNamedStyle(name);

            style.Style.Font.Name = "Arial";
            style.Style.Font.Size = size;
            style.Style.WrapText  = true;
            style.Style.Font.Bold = bold;
            if (center)
            {
                style.Style.SetStyleCenterAlignment();
            }
            if (borderByGost)
            {
                style.Style.SetBorderByGost(borderStyle);
            }
            else
            {
                style.Style.SetBorderByGost(borderStyle, borderStyle);
            }
            if (bckColor != null)
            {
                style.Style.Fill.PatternType = ExcelFillStyle.Solid;
                style.Style.Fill.BackgroundColor.SetColor(bckColor.Value);
            }
            return(style);
        }
Beispiel #4
0
        public void LoadTexture(string filePath, System.Drawing.Color?transparentColor = null, TextureParameterName textureParameterName = TextureParameterName.TextureMinFilter, TextureMinFilter textureMinFilter = TextureMinFilter.Nearest)
        {
            //get rid of any existing texture
            Dispose(); //dangerous - the unmanaged resource named by textureID could be share if .Clone() or .Copy(Material sourceMaterial) was used

            System.Drawing.Bitmap image = new System.Drawing.Bitmap(filePath);

            origionalTextureFilePath = filePath; //keep a record of where this image came from

            ///use XML to specify image files & if they should be transparent :)
            if (transparentColor != null)
            {
                image.MakeTransparent((System.Drawing.Color)transparentColor);
                containsTransparency = true;
            }

            textureID = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, textureID);
            BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
            image.UnlockBits(data);
            image.Dispose();

            GL.TexParameter(TextureTarget.Texture2D, textureParameterName, (int)textureMinFilter);
            GL.TexParameter(TextureTarget.Texture2D, textureParameterName, (int)textureMinFilter);
        }
Beispiel #5
0
        public void DrawImage(int x, int y, float scale, float angle, System.Drawing.Color?color, DXImage image)
        {
            //Debug.Assert(_initialized);
            if (!_initialized)
            {
                return;
            }

            SharpDX.Mathematics.Interop.RawColor4 blendFactor = new Color4(1.0f);
            SharpDX.Mathematics.Interop.RawColor4 backupBlendFactor;
            int backupMask;

            using (var backupBlendState = _deviceContext.OutputMerger.GetBlendState(out backupBlendFactor, out backupMask))
            {
                _deviceContext.OutputMerger.SetBlendState(_transparentBS, blendFactor);

                try
                {
                    BeginBatch(image.GetSRV());

                    Draw(new Rectangle(x, y, (int)(scale * image.Width), (int)(scale * image.Height)),
                         new Rectangle(0, 0, image.Width, image.Height),
                         color.HasValue ? ToColor4(color.Value) : Color4.White, 1.0f, angle);
                }
                finally
                {
                    EndBatch();
                }
                _deviceContext.OutputMerger.SetBlendState(backupBlendState, backupBlendFactor, backupMask);
            }
        }
Beispiel #6
0
 public Font(string name, ushort?size, string style, System.Drawing.Color?color)
 {
     Name  = name;
     Size  = size;
     Style = style;
     Color = color;
 }
Beispiel #7
0
 public static void Color(Config cfg)
 {
     while (true)
     {
         var arg = Console.ReadLine();
         System.Drawing.Color?colour = null;
         var rgb = arg.Split(new [] { ',' });
         if (rgb.Length == 3)
         {
             colour = System.Drawing.Color.FromArgb(0, Convert.ToInt32(rgb[0]), Convert.ToInt32(rgb[1]), Convert.ToInt32(rgb[2]));
         }
         else if (System.Text.RegularExpressions.Regex.IsMatch(arg, @"^\d+$"))
         {
             colour = System.Drawing.Color.FromArgb(Convert.ToInt32(arg));
         }
         else if (cfg.Materials.ContainsKey(arg))
         {
             colour = cfg.Materials[arg][0];
         }
         if (colour != null)
         {
             var color = (System.Drawing.Color)colour;
             Console.WriteLine(String.Format("{0}, {1}, {2}\n{3}", color.R, color.G, color.B, color.ToArgb()));
         }
     }
 }
Beispiel #8
0
        public void SetTitleBarColor(System.Drawing.Color?color)
        {
            UpdateTitleBar(new TitleBarData());
#if false
            try
            {
                CalculateColors(color, out Brush backgroundColor, out Brush textColor);

                if (titleBar != null)
                {
                    System.Reflection.PropertyInfo propertyInfo = titleBar.GetType().GetProperty(ColorPropertyName);
                    propertyInfo.SetValue(titleBar, backgroundColor, null);
                }
                else if (titleBarBorder != null)
                {
                    System.Reflection.PropertyInfo propertyInfo = this.titleBarBorder.GetType().GetProperty(ColorPropertyName);
                    propertyInfo.SetValue(this.titleBarBorder, backgroundColor, null);
                }

                if (titleBarTextBox != null)
                {
                    //titleBarTextBox.Foreground = textColor;
                }
            }
            catch
            {
                System.Diagnostics.Debug.Fail("TitleBarModel.SetTitleBarColor - couldn't :(");
            }
#endif
        }
Beispiel #9
0
        public async Task BroadcastAsync(IUser sender, string message, System.Drawing.Color?color = null,
                                         params object[] arguments)
        {
            await BroadcastAsync(sender, Players.Select(d => d.User), message, color, arguments);

            logger.LogInformation("[Broadcast] " + message);
        }
Beispiel #10
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var windowActivated = (bool)value;

            if (windowActivated)
            {
                if (_color1 == null)
                {
                    //_color1 = ColorExtension.GetChromeColor();
                    _color1 = System.Drawing.Color.Black;
                }
                if (_color1 != null)
                {
                    var color   = _color1.Value;
                    var average = (color.R + color.G + color.B) / 3f;
                    return(average >= 128
                        ? new SolidColorBrush(Color.FromArgb(25, 0, 0, 0))
                        : new SolidColorBrush(Color.FromArgb(25, 255, 255, 255)));
                }

                return(new SolidColorBrush(Color.FromArgb(25, 255, 255, 255)));
            }

            return(new SolidColorBrush(Color.FromArgb(25, 0, 0, 0)));
        }
Beispiel #11
0
        //public int Owner { get; set; }

        public Chip(Grid grid, double speed, System.Drawing.Color?color = null)
        {
            canMoveH = true;

            this.speed = speed;

            circle.Width  = grid.ChipSize;
            circle.Height = grid.ChipSize;

            if (color == null)
            {
                circle.Fill = Brushes.Red;
            }
            else
            {
                System.Drawing.Color c = (System.Drawing.Color)color;

                RadialGradientBrush brush = new RadialGradientBrush();
                brush.GradientOrigin = new System.Windows.Point(0.75, 0.25);
                brush.GradientStops.Add(new GradientStop(Colors.White, 0.0));
                brush.GradientStops.Add(new GradientStop(Colors.Beige, 0.2));
                brush.GradientStops.Add(new GradientStop(Color.FromArgb(c.A, c.R, c.G, c.B), 1.0));

                circle.Fill = brush;
            }

            Canvas.SetLeft(circle, grid.MarginLeft);
            Canvas.SetTop(circle, grid.MarginTop - 5);
        }
Beispiel #12
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            System.Drawing.Color?color = value as System.Drawing.Color?;
            SolidColorBrush      brush = new SolidColorBrush(Color.FromRgb(color.Value.R, color.Value.G, color.Value.B));

            return(brush);
        }
Beispiel #13
0
 public void WriteText(string text,
                       List <KeyValuePair <string, bool> > highlightedTerms = null,
                       System.Drawing.Color?higlightedTextColor             = null,
                       System.Drawing.Color?backgroundHighlightedTextColor  = null, bool bold = false)
 {
     WriteText(text, highlightedTerms, higlightedTextColor, backgroundHighlightedTextColor, bold, 0);
 }
        private static System.Drawing.Color ReadColor(XmlReader reader, System.Drawing.Color?defaultColor = null)
        {
            var tmpColorResult = System.Drawing.Color.Empty;

            var tmpNodeContent = reader.ReadElementString();

            if (string.IsNullOrEmpty(tmpNodeContent))
            {
                if (defaultColor.HasValue)
                {
                    tmpColorResult = defaultColor.Value;
                }
            }
            else
            {
                try
                {
                    tmpColorResult = HuiruiSoft.Drawing.ColorTranslator.FromHtml(tmpNodeContent);
                }
                catch (System.Exception)
                {
                    if (defaultColor.HasValue)
                    {
                        tmpColorResult = defaultColor.Value;
                    }
                }
            }

            return(tmpColorResult);
        }
Beispiel #15
0
        private bool handleColorValue(HALHandleContext ctx)
        {
            if (this._instance == null)
            {
                return(false);
            }

            System.Drawing.Color?c = null;

            if (ctx.Value is LumosColor lc)
            {
                c = lc.ColorValue;
            }
            else if (ctx.Value is System.Drawing.Color _c)
            {
                c = _c;
            }

            if (c.HasValue)
            {
                this.ColorValue = c.Value;
                return(true);
            }
            return(false);
        }
Beispiel #16
0
 /// <summary>
 /// Draw rectangle on the layer with layer index.
 /// </summary>
 /// <param name="layerIndex"></param>
 /// <param name="rectangle"></param>
 /// <param name="borderColor"></param>
 /// <param name="fillColor"></param>
 /// <param name="opacity"></param>
 /// <param name="fillPattern"></param>
 /// <param name="patternSize"></param>
 public void Draw(int layerIndex, System.Drawing.RectangleF rectangle, System.Drawing.Color?borderColor, System.Drawing.Color?fillColor, float opacity, xPFT.Charting.Base.FillPattern fillPattern, float patternSize)
 {
     if (prevWidth != rectangle.Height)
     {
         prevWidth    = rectangle.Height;
         filler.Width = prevWidth;
     }
     if (fillColor != null)
     {
         SharpDX.Vector2[] points = { new SharpDX.Vector2(rectangle.X,                   rectangle.Y + rectangle.Height / 2),
                                      new SharpDX.Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height / 2) };
         if (filler != null)
         {
             filler.Begin();
             filler.Draw(points, Convertor.ColorConvertor((System.Drawing.Color)fillColor, opacity));
             filler.End();
         }
     }
     if (borderColor != null)
     {
         SharpDX.Vector2[] points = { new SharpDX.Vector2(rectangle.X,                   rectangle.Y),
                                      new SharpDX.Vector2(rectangle.X + rectangle.Width, rectangle.Y),
                                      new SharpDX.Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height),
                                      new SharpDX.Vector2(rectangle.X,                   rectangle.Y + rectangle.Height),
                                      new SharpDX.Vector2(rectangle.X,                   rectangle.Y), };
         if (line != null)
         {
             line.Begin();
             line.Draw(points, Convertor.ColorConvertor((System.Drawing.Color)borderColor, opacity));
             line.End();
         }
     }
 }
Beispiel #17
0
        /// <summary>
        /// Customize legend visibility and styling
        /// </summary>
        public void Legend(
            bool enableLegend = true,
            string fontName   = null,
            float?fontSize    = null,
            bool?bold         = null,
            System.Drawing.Color?fontColor  = null,
            System.Drawing.Color?backColor  = null,
            System.Drawing.Color?frameColor = null,
            Alignment location        = Alignment.LowerRight,
            Alignment shadowDirection = Alignment.LowerRight,
            bool?fixedLineWidth       = null,
            bool?reverseOrder         = null
            )
        {
            settings.CornerLegend.IsVisible      = enableLegend;
            settings.CornerLegend.FontName       = fontName ?? settings.CornerLegend.FontName;
            settings.CornerLegend.FontSize       = fontSize ?? settings.CornerLegend.FontSize;
            settings.CornerLegend.FontColor      = fontColor ?? settings.CornerLegend.FontColor;
            settings.CornerLegend.FillColor      = backColor ?? settings.CornerLegend.FillColor;
            settings.CornerLegend.OutlineColor   = frameColor ?? settings.CornerLegend.OutlineColor;
            settings.CornerLegend.ReverseOrder   = reverseOrder ?? settings.CornerLegend.ReverseOrder;
            settings.CornerLegend.FontBold       = bold ?? settings.CornerLegend.FontBold;
            settings.CornerLegend.FixedLineWidth = fixedLineWidth ?? settings.CornerLegend.FixedLineWidth;
            settings.CornerLegend.Location       = location;

            // TODO: support shadowDirection
        }
Beispiel #18
0
        /// <summary>
        /// Draw polygon on layer with layerIndex Index.
        /// </summary>
        /// <param name="layerIndex"></param>
        /// <param name="points"></param>
        /// <param name="borderColor"></param>
        /// <param name="fillColor"></param>
        /// <param name="opacity"></param>
        /// <param name="fillPattern"></param>
        /// <param name="patternSize"></param>
        public void Draw(int layerIndex, System.Drawing.PointF[] points, System.Drawing.Color?borderColor, System.Drawing.Color?fillColor, float opacity, xPFT.Charting.Base.FillPattern fillPattern, float patternSize)
        {
            if (layerIndex < device.layers.Count)
            {
                var          tmpGeo       = new PathGeometry(device.factory);
                GeometrySink sink1        = tmpGeo.Open();
                Vector2[]    tmpPointList = DrawingBase.Convertor.ToVector2(points);
                sink1.BeginFigure(tmpPointList[0], new FigureBegin());
                sink1.AddLines(tmpPointList);
                sink1.EndFigure(new FigureEnd());
                sink1.Close();

                if (fillColor != null)
                {
                    if (device.renderTarget != prevRenderTarget || fillColor != prevFillColor || fillPattern != prevFillPattern || opacity != prevOpacity)
                    {
                        fillBrush        = BrushMaker.GetPatternBrush(device.renderTarget, (System.Drawing.Color)fillColor, opacity, fillPattern, patternSize);
                        prevFillColor    = (System.Drawing.Color)fillColor;
                        prevFillPattern  = fillPattern;
                        prevOpacity      = opacity;
                        prevRenderTarget = device.renderTarget;
                    }
                    device.layers[layerIndex].FillGeometry(tmpGeo, fillBrush);
                }
                if (borderColor != null)
                {
                    device.layers[layerIndex].DrawGeometry(tmpGeo, new SharpDX.Direct2D1.SolidColorBrush(device.renderTarget, xPFT.DrawingBase.Convertor.ColorConvertor((System.Drawing.Color)borderColor, opacity)), lineWidth);
                }
            }
        }
        private static IColorReference ReferenceFromConstructor(IObjectCreationExpression constructorExpression)
        {
            var constructedType = constructorExpression.TypeReference?.Resolve().DeclaredElement as ITypeElement;

            if (constructedType == null)
            {
                return(null);
            }

            var unityColorTypes = UnityColorTypes.GetInstance(constructedType.Module);

            if (!unityColorTypes.IsUnityColorType(constructedType))
            {
                return(null);
            }

            var arguments = constructorExpression.Arguments;

            if (arguments.Count < 3 || arguments.Count > 4)
            {
                return(null);
            }

            System.Drawing.Color?color = null;
            if (unityColorTypes.UnityColorType != null && unityColorTypes.UnityColorType.Equals(constructedType))
            {
                var baseColor = GetColorFromFloatARGB(arguments);
                if (baseColor == null)
                {
                    return(null);
                }

                color = baseColor.Item1.HasValue
                    ? System.Drawing.Color.FromArgb((int)(255.0 * baseColor.Item1.Value), baseColor.Item2)
                    : baseColor.Item2;
            }
            else if (unityColorTypes.UnityColor32Type != null && unityColorTypes.UnityColor32Type.Equals(constructedType))
            {
                var baseColor = GetColorFromIntARGB(arguments);
                if (baseColor == null)
                {
                    return(null);
                }

                color = baseColor.Item1.HasValue
                    ? System.Drawing.Color.FromArgb(baseColor.Item1.Value, baseColor.Item2)
                    : baseColor.Item2;
            }

            if (color == null)
            {
                return(null);
            }

            var colorElement = new ColorElement(color.Value);
            var argumentList = constructorExpression.ArgumentList;

            return(new UnityColorReference(colorElement, constructorExpression, argumentList, argumentList.GetDocumentRange()));
        }
        public static BitmapSource MakeTransparent(string resource, System.Drawing.Color?backColor = null)
        {
            var image  = new BitmapImage(new Uri(resource));
            var bitmap = image.ToBitmap();

            bitmap.MakeTransparent(backColor ?? System.Drawing.Color.White);
            return(bitmap.ToBitmapSource());
        }
Beispiel #21
0
 public static string HexConverter(this System.Drawing.Color?c)
 {
     if (c == null)
     {
         return(string.Empty);
     }
     return(HexConverter((System.Drawing.Color)c));
 }
Beispiel #22
0
        public static ColorDialogResult ShowDialog(
            System.Drawing.Color?color = null,
            bool ignoreAlpha           = false)
        {
            var wpfColor = color?.ToWPF();

            return(ColorDialogWrapper.ShowDialog(wpfColor, ignoreAlpha));
        }
Beispiel #23
0
        public Task BroadcastAsync(string userType, string message, System.Drawing.Color?color)
        {
            if (!KnownActorTypes.Player.Equals(userType, StringComparison.OrdinalIgnoreCase))
            {
                return(Task.CompletedTask);
            }

            return(BroadcastAsync(message, color));
        }
Beispiel #24
0
        public Task BroadcastAsync(string userType, string message, System.Drawing.Color?color)
        {
            // ReSharper disable once ConvertIfStatementToReturnStatement
            if (!KnownActorTypes.Player.Equals(userType, StringComparison.OrdinalIgnoreCase))
            {
                return(Task.CompletedTask);
            }

            return(BroadcastAsync(message, color));
        }
Beispiel #25
0
        public static void UpdateList(ListView listView, SelectableListNodeList items)
        {
            listView.BeginUpdate();

            if (listView.Items.Count > items.Count)
            {
                // delete some items
                for (int i = listView.Items.Count - 1; i >= items.Count; --i)
                {
                    listView.Items.RemoveAt(i);
                }
            }

            // Update all listitems now
            for (int i = 0; i < items.Count; i++)
            {
                ListViewItem litem;

                if (listView.Items.Count <= i)
                {
                    litem = new ListViewItem(string.Empty);
                    for (int j = 0; j < items[i].SubItemCount; j++)
                    {
                        litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty));
                    }
                    listView.Items.Add(litem);
                }
                else
                {
                    litem = listView.Items[i];
                }

                litem.Text        = items[i].Name;
                litem.ToolTipText = items[i].Description;
                litem.ImageIndex  = items[i].ImageIndex;
                for (int j = 0; j < items[i].SubItemCount; j++)
                {
                    litem.SubItems[j + 1].Text = items[i].SubItemText(j);
                    System.Drawing.Color?col = items[i].SubItemBackColor(j);
                    if (col == null)
                    {
                        litem.SubItems[j + 1].BackColor = litem.BackColor;
                    }
                    else
                    {
                        litem.UseItemStyleForSubItems   = false;
                        litem.SubItems[j + 1].BackColor = (System.Drawing.Color)col;
                    }
                }
                litem.Tag      = items[i];
                litem.Selected = items[i].Selected;
            }
            listView.EndUpdate();
        }
        /// <summary>
        /// Převede DateTime hodnotu do serialtextu
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        protected static string GetSerial(System.Drawing.Color?value)
        {
            if (!value.HasValue)
            {
                return(SerialNull);
            }
            var color = value.Value;

            return(color.A.ToString("000") + "." + color.R.ToString("000") + "." + color.G.ToString("000") + "." + color.B.ToString("000"));
            //  "AAA.RRR.GGG.BBB"
        }
Beispiel #27
0
        public PlottablePopulations(Population[] populations, string label = null, System.Drawing.Color?color = null)
        {
            if (color is null)
            {
                color = System.Drawing.Color.LightGray;
            }

            var ps = new PopulationSeries(populations, label, color.Value);

            popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { ps });
        }
        public App(System.Drawing.Color?primaryColor = null)
        {
            InitializeComponent();

            if (primaryColor != null)
            {
                Application.Current.Resources["NavigationPrimary"] = primaryColor;
            }

            InitNavigation();
        }
Beispiel #29
0
        private void SetColor(ISketchPoint pt, System.Drawing.Color?color)
        {
            int colorRef = 0;

            if (color.HasValue)
            {
                colorRef = ColorUtils.ToColorRef(color.Value);
            }

            pt.Color = colorRef;
        }
Beispiel #30
0
        public void RefreshBreedHintColor(double minBreedValue, double maxBreedValue)
        {
            if (CachedBreedValue == maxBreedValue)
            {
                CreatureBestCandidateColor = DefaultBestBreedHintColor;
            }

            if (mainForm.SelectedSingleCreature != null)
            {
                BreedHintColor = mainForm.CurrentAdvisor.GetHintColor(this, minBreedValue, maxBreedValue);
            }
        }
Beispiel #31
0
        public void RebuildBreedHintColor(double minBreedValue, double maxBreedValue)
        {
            BreedHintColor = null;

            if (CachedBreedValue == maxBreedValue)
                HorseBestCandidateColor = DefaultBestBreedHintColor;
            else HorseBestCandidateColor = null;

            if (MainForm.SelectedSingleHorse != null)
            {
                BreedHintColor = MainForm.CurrentAdvisor.GetHintColor(this, minBreedValue, maxBreedValue);
            }
        }
Beispiel #32
0
 private void checkNulls()
 {
     if (CheckmarkFillColor == null) CheckmarkFillColor = System.Drawing.Color.Green;
     if (CrossSignFillColor == null) CrossSignFillColor = System.Drawing.Color.DarkRed;
 }
        /// <summary>
        /// Creates new instance of <c>GanttElementFrameworkElement</c>.
        /// </summary>
        /// <param name="color">Stop color.</param>
        public GanttElementFrameworkElement(System.Drawing.Color color)
        {
            _children = new VisualCollection(this);

            _color = color;

            _CreateVisuals();
        }