Ejemplo n.º 1
0
        private void Part4ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selected = e.AddedItems.OfType <ColorSelectionItem>().First();
            var index    = selected.Index;
            var path     = _pathPointLayers.SelectMany(cl => cl.Value.Paths.Select(p => new { Color = cl.Key, p.Points })).Where((cp, i) => i == index).Single();
            var color    = path.Color.Color;
            var image    = DrawPointsImage(path.Points, _loadedImage.Width + 1, _loadedImage.Height + 1, color);

            PathPointsCount.Content   = path.Points.Count;
            CanvasScroller.Visibility = Visibility.Hidden;
            ImageDisplay.Source       = BitmapToImageSource(image);

            LineGrid.Children.Clear();
            //http://stackoverflow.com/a/1165145/294804
            //var oppositeColor = ColorExtensions.FromAhsb(color.A, 360 - color.GetHue(), color.GetSaturation(), color.GetBrightness());
            //var oppositeColor = color.Invert();
            //http://jacobmsaylor.com/?p=1250
            var    oppositeColor = MColor.FromRgb((byte)~color.R, (byte)~color.G, (byte)~color.B);
            var    oppositeBrush = new SolidColorBrush(MColor.FromArgb(oppositeColor.A, oppositeColor.R, oppositeColor.G, oppositeColor.B));
            double gridWidth     = _loadedImage.Width;
            double gridHeight    = _loadedImage.Height;
            var    offset        = CalculateScaledOffsets(ref gridWidth, ref gridHeight);
            var    points        = path.Points.Select(p => new Point <double> {
                X = p.X, Y = p.Y
            }).ToList();
            var lines = CreateOverlayLines(points, offset, oppositeBrush);

            LineGrid.Width  = gridWidth;
            LineGrid.Height = gridHeight;
            LineGrid.Children.AddRange(lines);
        }
        private Color LogFailureLevelToColor(LogFailureLevel level)
        {
            switch (level)
            {
            case LogFailureLevel.Undefined:
                return(Color.FromRgb(SystemColors.Control.R, SystemColors.Control.G, SystemColors.Control.B));

            case LogFailureLevel.Warning:
                return(Colors.DarkOrange);

            case LogFailureLevel.Error:
                return(Colors.Red);

            case LogFailureLevel.Critical:
                return(Colors.Red);

            case LogFailureLevel.ProactiveWarning:
                return(Colors.DarkOrange);

            case LogFailureLevel.ProactiveError:
                return(Colors.Red);

            case LogFailureLevel.ProactiveCritical:
                return(Colors.Red);

            default:
                throw new ArgumentOutOfRangeException(nameof(level), level, null);
            }
        }
Ejemplo n.º 3
0
        public static MediaColor?GetUserColour(IGuildUser user, IGuild guild, bool faded = false)
        {
            if (user != null && App.Config.General.UserColours)
            {
                IEnumerable <IRole> mentionedUserRoles = guild.Roles.Where(r => user.RoleIds.Contains(r.Id));
                IRole mentionedColouredRole            = mentionedUserRoles.OrderByDescending(r => r.Position).FirstOrDefault(r => r.Color.RawValue != Discord.Color.Default.RawValue && r.Color.RawValue != 3553598);

                if (mentionedColouredRole != null)
                {
                    if (faded)
                    {
                        return(MediaColor.FromArgb(64, mentionedColouredRole.Color.R, mentionedColouredRole.Color.G, mentionedColouredRole.Color.B));
                    }
                    else
                    {
                        return(MediaColor.FromRgb(mentionedColouredRole.Color.R, mentionedColouredRole.Color.G, mentionedColouredRole.Color.B));
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
 private static void ThreadSys(Brush bg, Dispatcher dispatcher, Color defaultColor)
 {
     while (ShouldRun)
     {
         while (Changing)
         {
             dispatcher.Invoke(() =>
             {
                 Random random            = new Random();
                 ColorAnimation animation = new ColorAnimation();
                 animation.From           = ((SolidColorBrush)bg).Color;
                 animation.To             = Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255),
                                                          (byte)random.Next(0, 255));
                 animation.Duration = new Duration(TimeSpan.FromSeconds(1));
                 bg.BeginAnimation(SolidColorBrush.ColorProperty, animation);
             });
             Thread.Sleep(1000);
         }
         if (!Changing)
         {
             dispatcher.Invoke(() =>
             {
                 // Random random = new Random();
                 ColorAnimation animation = new ColorAnimation();
                 animation.From           = ((SolidColorBrush)bg).Color;
                 animation.To             = defaultColor;
                 animation.Duration       = new Duration(TimeSpan.FromSeconds(1));
                 bg.BeginAnimation(SolidColorBrush.ColorProperty, animation);
             });
         }
     }
 }
Ejemplo n.º 5
0
        private void PlaceForWordTextBlock_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var textBlock = (TextBlock)sender;
            int count     = 0;

            foreach (var border in _listOfWordBorders)
            {
                if (count == 1)
                {
                    continue;
                }

                if (border.Visibility == Visibility.Visible)
                {
                    continue;
                }
                var term = (SimpleTerm)border.Tag;
                if (term.Word == textBlock.Text)
                {
                    border.Visibility = Visibility.Visible;
                    count++;
                }
            }
            textBlock.Text       = "";
            textBlock.Background = new SolidColorBrush(Color.FromRgb(202, 207, 210));

            var smallStackPanel  = (StackPanel)textBlock.Parent;
            var dockPanel        = (DockPanel)smallStackPanel.Parent;
            var correctOrNotSign = (TextBlock)dockPanel.Children.OfType <TextBlock>().First();

            correctOrNotSign.Background = default;
        }
Ejemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var    paletteHelper = new PaletteHelper();
            ITheme theme         = paletteHelper.GetTheme();

            theme.SetBaseTheme(Theme.Dark);
            theme.SecondaryMid = new ColorPair(Color.FromRgb(0x66, 0x66, 0x66), Colors.White);
            theme.PrimaryMid   = new ColorPair(Color.FromRgb(0x66, 0x66, 0x66), Colors.White);
            paletteHelper.SetTheme(theme);

            try
            {
                StreamReader sr        = File.OpenText(CurrentDirectory + "\\setting.json");
                string       configStr = sr.ReadToEnd();
                sr.Close();
                Setting setting = JsonConvert.DeserializeObject <Setting>(configStr);
                if (setting.LastSize)
                {
                    Width  = setting.LastWidth;
                    Height = setting.LastHeight;
                }
                Sim.SelectedIndex        = setting.LastSim;
                Format.SelectedIndex     = setting.LastFormat;
                OffsetList.Visibility    = setting.LastOffsetColorShow ? Visibility.Visible : Visibility.Collapsed;
                ColorInfo.AllOffsetColor = setting.LastAllOffset;
                ColorInfo.BrushMode      = setting.LastHintColorShow;
            }
            catch { }

            showTimer.Tick    += new EventHandler(HintMessage_Closed);
            showTimer.Interval = new TimeSpan(0, 0, 0, 5);
            showTimer.Start();
        }
        /// <summary>
        /// Get the brush color associated with the desired GuiColor and match our
        /// dialog style colors to it.
        /// </summary>
        /// <param name="colorManager"></param>
        /// <param name="guiColor"></param>
        /// <returns></returns>
        private static Brush GetUiColorBrush(IIColorManager colorManager, GuiColors guiColor)
        {
            var color      = colorManager.GetColor(guiColor);
            var mcolorText = MediaColor.FromRgb(color.R, color.G, color.B);

            return(new SolidColorBrush(mcolorText));
        }
Ejemplo n.º 8
0
        private void CreateLights()
        {
            _lightsModel3DGroup = new Model3DGroup();

            var ambientLight = new System.Windows.Media.Media3D.AmbientLight(Color.FromRgb(25, 25, 25));

            _lightsModel3DGroup.Children.Add(ambientLight);


            _lightHorizontalAngle = 0;
            _lightVerticalAngle   = 30;

            _lightDistance = 500;
            _lightRange    = 2000;

            _directionalLight = new System.Windows.Media.Media3D.DirectionalLight();

            _shadowSpotLight = new System.Windows.Media.Media3D.SpotLight();
            _shadowSpotLight.InnerConeAngle = 40;
            _shadowSpotLight.OuterConeAngle = 50;


            var modelVisual3D = new ModelVisual3D();

            modelVisual3D.Content = _lightsModel3DGroup;

            MainDXViewportView.Viewport3D.Children.Add(modelVisual3D);

            UpdateLights();
            UpdateCastingShadowLight();
        }
Ejemplo n.º 9
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            byte r, g, b;

            Utils.Graphics.UnpackRgbInt((int)value, out r, out g, out b);
            return(new SolidColorBrush(Color.FromRgb(r, g, b)));
        }
Ejemplo n.º 10
0
        private void DisplayHsl()
        {
            var rgb = HlsToRgb(HSL1Slider.Value, HSL2Slider.Value / 100, HSL3Slider.Value / 100);

            ColorPanel.Background = new SolidColorBrush(Color.FromRgb((byte)RGB1Slider.Value, (byte)RGB2Slider.Value, (byte)RGB3Slider.Value));
            var cmyk = ConvertRgbToCmyk((byte)RGB1Slider.Value, (byte)RGB2Slider.Value, (byte)RGB3Slider.Value);

            CMYK1Slider.Value = cmyk[0] * 100;
            CMYK2Slider.Value = cmyk[1] * 100;
            CMYK3Slider.Value = cmyk[2] * 100;
            CMYK4Slider.Value = cmyk[3] * 100;
            CLabel.Content    = Math.Round(CMYK1Slider.Value, 2).ToString(CultureInfo.InvariantCulture);
            MLabel.Content    = Math.Round(CMYK2Slider.Value, 2).ToString(CultureInfo.InvariantCulture);
            YLabel.Content    = Math.Round(CMYK3Slider.Value, 2).ToString(CultureInfo.InvariantCulture);
            KLabel.Content    = Math.Round(CMYK4Slider.Value, 2).ToString(CultureInfo.InvariantCulture);
            RGB1Slider.Value  = rgb[0];
            RGB2Slider.Value  = rgb[1];
            RGB3Slider.Value  = rgb[2];
            RLabel.Content    = rgb[0].ToString(CultureInfo.InvariantCulture);
            GLabel.Content    = rgb[1].ToString(CultureInfo.InvariantCulture);
            BLabel.Content    = rgb[2].ToString(CultureInfo.InvariantCulture);

            HLabel.Content     = Math.Floor(HSL1Slider.Value).ToString(CultureInfo.InvariantCulture);
            LabelLabel.Content = Math.Round(HSL2Slider.Value, 2).ToString(CultureInfo.InvariantCulture);
            SLabel.Content     = Math.Round(HSL3Slider.Value, 2).ToString(CultureInfo.InvariantCulture);
        }
Ejemplo n.º 11
0
        private void DrawMulticoloredPixels(MainViewModel context)
        {
            double sizeX = (DrawCanvas.Width / _numberOfColumns);
            double sizeY = (DrawCanvas.Height / _numberOfRows);

            for (int i = 0; i < context.GraphicalObjects.Count; i++)
            {
                GraphicalObject obj = context.GraphicalObjects[i];
                for (int j = 0; j < obj.ObjectModel.Width; j++)
                {
                    for (int k = 0; k < obj.ObjectModel.Height; k++)
                    {
                        if (obj.ObjectModel[j, k].Value > 0)
                        {
                            Draw(
                                DrawCanvas,
                                (obj.Position.X + j) * sizeX - 1,
                                (obj.Position.Y + k) * sizeY - 1,
                                new LinearGradientBrush(
                                    Color.FromRgb(
                                        (byte)obj.ObjectColor.Red,
                                        (byte)obj.ObjectColor.Green,
                                        (byte)obj.ObjectColor.Blue),
                                    Darken(obj.ObjectColor),
                                    45.0));
                        }
                    }
                }

                DrawLabels(context, sizeX, sizeY);
            }
        }
Ejemplo n.º 12
0
        void Config()
        {
            ComponentInfo.SetLicense("FREE-LIMITED-KEY");                          // To make GemBox library work

            page1.AcceptsTab           = true;                                     // To make TAB key work
            page1.SpellCheck.IsEnabled = true;                                     // Checks spelling
            page1.Focus();                                                         // Cursor starts in the richtextbox
            page1.BorderThickness = new Thickness(0);                              // No border

            cmbFonts.SelectedItem = 0;                                             // Starts from none

            cmbFontSize.SelectedIndex = 4;                                         // Fontsize when loaded: 16

            cbZoom.SelectedIndex = 90;                                             // Starts at 100%

            foregroundColor.ShowDropDownButton = false;
            backgroundColor.ShowDropDownButton = false;

            try
            {
                foregroundColor.SelectedColor = Color.FromRgb(0, 0, 0);            // Black color as foreground for text
                backgroundColor.SelectedColor = Color.FromRgb(255, 255, 255);      // White color as background for text
            }
            catch { }
        }
Ejemplo n.º 13
0
        private void BtnStroke_Click(object sender, RoutedEventArgs e)
        {
            StylusPointCollection stylusPointCollection = new StylusPointCollection();

//            StylusPoint stylusPoint = new StylusPoint(100, 200, .2f);

            stylusPointCollection.Add(new StylusPoint(100, 200, .2f));
            stylusPointCollection.Add(new StylusPoint(100, 250, .5f));
            stylusPointCollection.Add(new StylusPoint(100, 300, .9f));
            Stroke stroke = new Stroke(stylusPointCollection);

            stroke.DrawingAttributes = new DrawingAttributes {
                Width = 25, Height = 25, Color = Color.FromRgb(0, 0, 0)
            };
            this.inkCanvas.Strokes.Add(stroke);


            stylusPointCollection = new StylusPointCollection();
            //            StylusPoint stylusPoint = new StylusPoint(100, 200, .2f);

            stylusPointCollection.Add(new StylusPoint(200, 200, .2f));
            stylusPointCollection.Add(new StylusPoint(200, 250, .5f));
            stylusPointCollection.Add(new StylusPoint(200, 300, .9f));
            stroke = new Stroke(stylusPointCollection);
            stroke.DrawingAttributes = new DrawingAttributes {
                Width = 25, Height = 25, Color = Color.FromRgb(0, 0, 0)
            };
            this.inkCanvas.Strokes.Add(stroke);
        }
Ejemplo n.º 14
0
        public RegionSelector(IVideoSourcePicker VideoSourcePicker)
        {
            _videoSourcePicker = VideoSourcePicker;

            InitializeComponent();

            _regionItem = new RegionItem(this);

            // Prevent Closing by User
            Closing += (S, E) => E.Cancel = true;

            InitDimensionBoxes();

            // Setting MainViewModel as DataContext from XAML causes crash.
            Loaded += (S, E) => MainControls.DataContext = ServiceProvider.Get <MainViewModel>();

            ModesBox.ItemsSource = new[]
            {
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.None, "Pointer"),
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.Ink, "Pencil"),
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.EraseByPoint, "Eraser"),
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.EraseByStroke, "Stroke Eraser")
            };

            ModesBox.SelectedIndex    = 0;
            ColorPicker.SelectedColor = Color.FromRgb(27, 27, 27);
            SizeBox.Value             = 10;

            InkCanvas.DefaultDrawingAttributes.FitToCurve = true;
        }
Ejemplo n.º 15
0
        public void Blink()
        {
            var storyboard = new Storyboard
            {
                Duration       = TimeSpan.FromSeconds(2),
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            ColorAnimation statusBlinkAnimation = new ColorAnimation();

            //statusBlinkAnimation.From = accentColor;
            //statusBlinkAnimation.From = Mcolor.FromRgb(255,255,255);
            statusBlinkAnimation.To = Mcolor.FromRgb(63, 81, 181);
            //statusBlinkAnimation.To = Mcolor.FromRgb(255,255,255);
            //statusBlinkAnimation.To = stateColor;
            statusBlinkAnimation.From        = stateColor;
            statusBlinkAnimation.Duration    = new Duration(TimeSpan.FromSeconds(0.2));
            statusBlinkAnimation.AutoReverse = true;
            //statusBlinkAnimation.RepeatBehavior = RepeatBehavior.

            this.RegisterName("animatedBrush", stateColorBrush);
            Storyboard.SetTargetName(statusBlinkAnimation, "animatedBrush");
            Storyboard.SetTargetProperty(statusBlinkAnimation, new PropertyPath(SolidColorBrush.ColorProperty));


            storyboard.Children.Add(statusBlinkAnimation);
            storyboard.Begin(this);
        }
Ejemplo n.º 16
0
        public Brush Invert(Color c)
        {
            Color cc = Color.FromArgb(~c.R & 0xff, ~c.G & 0xff, ~c.B & 0xff);

            ModifyControls(cc);
            return(new SolidColorBrush(WpfColor.FromRgb(cc.R, cc.G, cc.B)));
        }
Ejemplo n.º 17
0
        private void applyColorForUI()
        {
            Corel.Interop.VGCore.Color nRGB = DApp.CreateRGBColor(0, 0, 0);
            nRGB.CopyAssign(_shColor);

            if (nRGB.Type != cdrColorType.cdrColorRGB)
            {
                nRGB.ConvertToRGB();
            }
            ShadowColor.Background = new SolidColorBrush(Color.FromRgb((byte)nRGB.RGBRed, (byte)nRGB.RGBGreen, (byte)nRGB.RGBBlue));

            ShadowColor.ToolTip = _shColor.Name + "\n" + _shColor.get_Name(true);

            (this.FindName("toRGB") as MenuItem).IsEnabled  = true;
            (this.FindName("toCMYK") as MenuItem).IsEnabled = true;
            (this.FindName("toGRAY") as MenuItem).IsEnabled = true;

            switch (_shColor.Type.ToString())
            {
            case "cdrColorRGB": (this.FindName("toRGB") as MenuItem).IsEnabled = false; break;

            case "cdrColorCMYK": (this.FindName("toCMYK") as MenuItem).IsEnabled = false; break;

            case "cdrColorGray": (this.FindName("toGRAY") as MenuItem).IsEnabled = false; break;
            }
        }
Ejemplo n.º 18
0
        // Document After Open
        private void dApp_DocumentOpen(Document doc, string FileName)
        {
            UpdIcon(false);
            if (IsNotSup(doc.SourceFormat))
            {
                return;
            }

            if (!db.InDB(FileName))
            {
                db.addInDB(doc, "");
            }
            else
            {
                db.updateInDB(doc, "");
            }

            foreach (CdrFile c in cdrfiles)
            {
                if (FileName == c.cdr_filepath)
                {
                    c.bg_color = new SolidColorBrush(Color.FromRgb(102, 153, 51)); //c.bg_color = Brushes.Orange;
                    c.isOpen   = true;
                    fWin.lst.Items.Refresh();
                    ofiles.Add(new OpenedFile(FileName));
                    break;
                }
            }
        }
Ejemplo n.º 19
0
        protected override Effect GetEffect(FastBitmap source)
        {
            // Get curves either from Curves collection or ACV file.
            CurveCollection curves = GetCurves();

            // Check that there are at least 4 curves.
            if (curves.Count < 4)
            {
                throw new DynamicImageException(
                          "At least 4 curves (corresponding to Composite, Red, Green, Blue) must be specified.");
            }

            // Convert mathematical curve definitions into 4x256 lookup texture (Composite, Red, Green, Blue are the 4 "columns").
            FastBitmap curvesLookup = new FastBitmap(4, 256);

            curvesLookup.Lock();
            for (int x = 0; x < 4; ++x)
            {
                IEnumerable <CurvePoint> points = curves[x].Points;
                float[] xValues     = points.Select(p => (float)p.Input).ToArray();
                float[] yValues     = points.Select(p => (float)p.Output).ToArray();
                float[] derivatives = CubicSplineUtility.CalculateSpline(xValues, yValues);
                for (int y = 0; y < 256; ++y)
                {
                    curvesLookup[x, y] = SWMColor.FromRgb((byte)CubicSplineUtility.InterpolateSpline(xValues, yValues, derivatives, y), 0, 0);
                }
            }
            curvesLookup.Unlock();

            return(new CurvesEffect
            {
                CurvesLookup = new ImageBrush(curvesLookup.InnerBitmap)
            });
        }
Ejemplo n.º 20
0
 public void RefreshEloBuddyStatus()
 {
     UpdateStatusLabel.Content    = LoaderUpdate.StatusString;
     UpdateStatusLabel.Foreground = LoaderUpdate.UpToDate
         ? new SolidColorBrush(Color.FromRgb(64, 209, 81))
         : new SolidColorBrush(Color.FromRgb(255, 0, 0));
 }
Ejemplo n.º 21
0
        public void Draw(Canvas g)
        {
            Color usecolor = ParticleColor;

            if (BirthTime == null)
            {
                BirthTime = DateTime.Now;
            }
            double mslivetime  = (DateTime.Now - BirthTime).Value.TotalMilliseconds;
            double lifetime    = LiveTime.TotalMilliseconds;
            double pencentlife = mslivetime / lifetime;
            int    Alphause    = 255 - (int)(pencentlife * 255);

            ParticleColor = Color.FromRgb((byte)rt.Next(200, 255), (byte)rt.Next(200, 255), (byte)rt.Next(200, 255));
            if (Alphause <= 0)
            {
                Alphause = 0;
            }
            cir                 = new Ellipse();
            cir.Height          = 10;
            cir.Width           = 10;
            cir.StrokeThickness = 2;
            cir.Stroke          = System.Windows.Media.Brushes.AliceBlue;
            Move_Control(g);
            g.Children.Add(cir);
        }
Ejemplo n.º 22
0
        private void DisplayRgb()
        {
            ColorPanel.Background = new SolidColorBrush(Color.FromRgb((byte)RGB1Slider.Value, (byte)RGB2Slider.Value, (byte)RGB3Slider.Value));
            RLabel.Content        = ((byte)RGB1Slider.Value).ToString(CultureInfo.InvariantCulture);
            GLabel.Content        = ((byte)RGB2Slider.Value).ToString(CultureInfo.InvariantCulture);
            BLabel.Content        = ((byte)RGB3Slider.Value).ToString(CultureInfo.InvariantCulture);
            var hls = RgbToHls((byte)RGB1Slider.Value, (byte)RGB2Slider.Value, (byte)RGB3Slider.Value);

            HSL1Slider.Value   = hls[0];
            HSL2Slider.Value   = hls[1] * 100;
            HSL3Slider.Value   = hls[2] * 100;
            HLabel.Content     = Math.Floor(hls[0]).ToString(CultureInfo.InvariantCulture);
            LabelLabel.Content = Math.Round(hls[1], 2).ToString(CultureInfo.InvariantCulture);
            SLabel.Content     = Math.Round(hls[2], 2).ToString(CultureInfo.InvariantCulture);

            var cmyk = ConvertRgbToCmyk((byte)RGB1Slider.Value, (byte)RGB2Slider.Value, (byte)RGB3Slider.Value);

            CMYK1Slider.Value = cmyk[0] * 100;
            CMYK2Slider.Value = cmyk[1] * 100;
            CMYK3Slider.Value = cmyk[2] * 100;
            CMYK4Slider.Value = cmyk[3] * 100;
            CLabel.Content    = Math.Round(cmyk[0] * 100, 2).ToString(CultureInfo.InvariantCulture);
            MLabel.Content    = Math.Round(cmyk[1] * 100, 2).ToString(CultureInfo.InvariantCulture);
            YLabel.Content    = Math.Round(cmyk[2] * 100, 2).ToString(CultureInfo.InvariantCulture);
            KLabel.Content    = Math.Round(cmyk[3] * 100, 2).ToString(CultureInfo.InvariantCulture);
        }
        private void LoadModel(string fileName)
        {
            MainViewport.Children.Clear();

            // Create an instance of AssimpWpfImporter
            var assimpWpfImporter = new AssimpWpfImporter();
            var readModel3D       = assimpWpfImporter.ReadModel3D(fileName, texturesPath: null); // we can also define a textures path if the textures are located in some other directory (this is parameter can be skipped, but is defined here so you will know that you can use it)


            if (readModel3D == null)
            {
                MessageBox.Show("Cannot read file");
                return;
            }

            MainViewport.Children.Add(readModel3D.CreateModelVisual3D());


            if (_fileName != fileName) // Reset camera only when the file is loaded for the first time
            {
                _fileName = fileName;

                Camera1.TargetPosition = readModel3D.Bounds.GetCenterPosition();
                Camera1.Distance       = readModel3D.Bounds.GetDiagonalLength() * 1.2;
            }

            // Add ambient light
            var ambientLight = new AmbientLight(Color.FromRgb(100, 100, 100));

            MainViewport.Children.Add(ambientLight.CreateModelVisual3D());
        }
Ejemplo n.º 24
0
        public static void ParseColor(string colorText, out WpfColor color, out byte opacity)
        {
            if (String.IsNullOrEmpty(colorText) || colorText[0] != '#')
            {
                goto EXIT;
            }
            var l = colorText.Length;

            if (l != 7 && l != 9 && l != 3)
            {
                goto EXIT;
            }
            try {
                byte a, r, g, b;
                switch (l)
                {
                case 3:
                    if (ParseByte(colorText, 1, out a))
                    {
                        opacity = a;
                        color   = WpfColors.Transparent;
                        return;
                    }
                    break;

                case 7:
                    if (ParseByte(colorText, 1, out r) &&
                        ParseByte(colorText, 3, out g) &&
                        ParseByte(colorText, 5, out b))
                    {
                        color   = WpfColor.FromRgb(r, g, b);
                        opacity = 0;
                        return;
                    }
                    break;

                case 9:
                    if (ParseByte(colorText, 1, out a) &&
                        ParseByte(colorText, 3, out r) &&
                        ParseByte(colorText, 5, out g) &&
                        ParseByte(colorText, 7, out b))
                    {
                        if (a == 0)
                        {
                            goto EXIT;
                        }
                        color   = WpfColor.FromRgb(r, g, b);
                        opacity = a;
                        return;
                    }
                    break;
                }
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
            }
EXIT:
            color   = WpfColors.Transparent;
            opacity = 0;
        }
Ejemplo n.º 25
0
        private void Button_Click_fon(object sender, RoutedEventArgs e)
        {
            Random r     = new Random();
            Brush  brush = new SolidColorBrush(Color.FromRgb((byte)r.Next(1, 255), (byte)r.Next(1, 255), (byte)r.Next(1, 233)));

            Background = brush;
        }
Ejemplo n.º 26
0
        private void SimpleLine_Load(object sender, EventArgs e)
        {
            lineChart1.LegendLocation = LegendLocation.Left;

            lineChart1.Series.Add(new LineSeries
            {
                Title  = "A Series",
                Values = new ChartValues <double> {
                    3, 5, 8, 12, 8, 3
                }
            });

            lineChart1.Series.Add(new LineSeries
            {
                Title  = "A Series",
                Values = new ChartValues <double> {
                    4, 2, 10, 11, 9, 4
                }
            });

            lineChart1.AxisX.Labels = new List <string>
            {
                "Day 1",
                "Day 2",
                "Day 3",
                "Day 4",
                "Day 5",
                "Day 6"
            };

            lineChart1.Background = new SolidColorBrush(Color.FromRgb(55, 55, 55));
        }
Ejemplo n.º 27
0
 private void HSelect_paint()
 {
     #if DEBUG
     System.Diagnostics.Debug.WriteLine("HSelect_paint_Start");
     DateTime starttime = DateTime.Now;
     #endif
     ColorConverter CC       = new ColorConverter();
     double         hsHeight = HSelector.ActualHeight;
     double         hsWidth  = HSelector.ActualWidth;
     for (int i = 0; i <= (int)Math.Round(hsHeight); i += linewidth)
     {
         ColorMode.RGB   color = CC.HSV2RGB((i / (double)hsHeight) * 360.0, 1, 1);
         SolidColorBrush brush = new SolidColorBrush(Color.FromRgb(
                                                         (byte)(color.R * 255.0),
                                                         (byte)(color.G * 255.0),
                                                         (byte)(color.B * 255.0)
                                                         ));
         Line line = new Line
         {
             Stroke          = brush,
             StrokeThickness = linewidth,
             X1 = 0,
             X2 = hsWidth,
             Y1 = hsHeight - i,
             Y2 = hsHeight - i
         };
         HSelector.Children.Add(line);
     }
     #if DEBUG
     DateTime stoptime = DateTime.Now;
     TimeSpan span     = stoptime.Subtract(starttime);
     System.Diagnostics.Debug.WriteLine("HSelect_paint_Stop");
     System.Diagnostics.Debug.WriteLine("Use {0} ms", span.TotalMilliseconds);
     #endif
 }
Ejemplo n.º 28
0
        private void BtnQuadratciBezier_Click(object sender, RoutedEventArgs e)
        {
            this.inkCanvas.Strokes.Clear();
            Point p1 = new Point()
            {
                X = 200, Y = 400
            };
            Point p2 = new Point()
            {
                X = 300, Y = 200
            };
            Point p3 = new Point()
            {
                X = 400, Y = 400
            };

            List <Point>          points = BezierHelper.getQuadraticBezierPoints(p1, p2, p3, Convert.ToInt16(txtCount.Text));
            StylusPointCollection stylusPointCollection = new StylusPointCollection();

            for (int i = 0; i < points.Count; i++)
            {
                stylusPointCollection.Add(new StylusPoint(points[i].X, points[i].Y));
            }
            Stroke stroke = new Stroke(stylusPointCollection);

            stroke.DrawingAttributes = new DrawingAttributes {
                Width = 1, Height = 1, Color = Color.FromRgb(0, 0, 0)
            };
            this.inkCanvas.Strokes.Add(stroke);
        }
Ejemplo n.º 29
0
        public RegionSelector(IVideoSourcePicker VideoSourcePicker)
        {
            _videoSourcePicker = VideoSourcePicker;

            InitializeComponent();

            // Prevent Closing by User
            Closing += (S, E) => E.Cancel = true;

            InitDimensionBoxes();

            ModesBox.ItemsSource = new[]
            {
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.None, "Pointer"),
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.Ink, "Pencil"),
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.EraseByPoint, "Eraser"),
                new KeyValuePair <InkCanvasEditingMode, string>(InkCanvasEditingMode.EraseByStroke, "Stroke Eraser")
            };

            ModesBox.SelectedIndex    = 0;
            ColorPicker.SelectedColor = Color.FromRgb(27, 27, 27);
            SizeBox.Value             = 10;

            InkCanvas.DefaultDrawingAttributes.FitToCurve = true;
        }
Ejemplo n.º 30
0
        public Avatar(User user)
        {
            this.user = user;
            InitializeComponent();

            var initials = GetInitials();

            InitialsLabel.Content = initials;

            MD5 md5 = MD5.Create();

            byte[] hash = md5.ComputeHash(Encoding.UTF8.GetBytes(user.EmailAddress));
            double hue  = hash[0];

            hue = hue / 256d * 360d;

            var hsl = new Spectrum.Color.HSL(hue, 0.8d, 0.3d);
            var rgb = hsl.ToRGB();

            InitialsLabel.Background = new SolidColorBrush(Color.FromRgb(rgb.R, rgb.G, rgb.B));
            InitialsLabel.Foreground = new SolidColorBrush(Colors.White);

            var image = new BitmapImage(new Uri(new Gravatar().GetUrl(user.EmailAddress, 24, GravatarRating.G, "blank")), new RequestCachePolicy(RequestCacheLevel.Default));

            AvatarImage.Source  = image;
            AvatarImage.ToolTip = user.FullName;
        }
Ejemplo n.º 31
0
        public Feature AddPath(String Id, Latitude Latitude, Longitude Longitude, Double Width, Double Height, Color Color)
        {
            var XY = GeoCalculations.GeoCoordinate2ScreenXY(Latitude, Longitude, MapControl.ZoomLevel);

            var PathGeometry1 = PathGeometry.Parse("M51,42c-5-4-11-7-19-7c-6,0-12,1-20,5l10-35c20-8,30-4,39,2l-10,35z");
            var PathGeometry2 = PathGeometry.Parse("M106,13c-21,9-31,4-40-2l-10,35c9,6,20,11,40,2l10-35z");
            var PathGeometry3 = PathGeometry.Parse("M39,83c-9-6-18-10-39-2l10-35c21-9,31-4,39,2l-10,35z");
            var PathGeometry4 = PathGeometry.Parse("M55,52c9,6,18,10,39,2l-10,35c-21,8-30,3-39-3l10-34z");

            var pathText = PathGeometry1.ToString();

            var GD1 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0xE0, 0x60, 0x30)), null, PathGeometry1);
            var GD2 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0x70, 0xB0, 0x40)), null, PathGeometry2);
            var GD3 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0x40, 0x90, 0xc0)), null, PathGeometry3);
            var GD4 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0xF0, 0xD0, 0x50)), null, PathGeometry4);

            var DrawingGroup = new DrawingGroup();
            DrawingGroup.Children.Add(GD1);
            DrawingGroup.Children.Add(GD2);
            DrawingGroup.Children.Add(GD3);
            DrawingGroup.Children.Add(GD4);

            var DrawingBrush = new DrawingBrush() {
                Drawing  = DrawingGroup,
                TileMode = TileMode.None
            };

            var Feature = new Feature(Id, new RectangleGeometry() { Rect = DrawingGroup.Bounds }) {
                Latitude   = Latitude,
                Longitude  = Longitude,
                Width      = DrawingGroup.Bounds.Width,
                Height     = DrawingGroup.Bounds.Height,
                Fill       = DrawingBrush,
                ToolTip    = Id
            };

            // The position on the map will be set within the PaintMap() method!
            this.Children.Add(Feature);

            return Feature;
        }