예제 #1
0
 public StaticTileBrushCollection(LibraryX.TileBrushCollectionX <LibraryX.StaticTileBrushX> proxy, TilePoolManager tileManager)
     : base(proxy.Uid, proxy.Name)
 {
     if (proxy.Brushes != null)
     {
         foreach (var brush in proxy.Brushes)
         {
             Brushes.Add(StaticTileBrush.FromXProxy(brush, tileManager));
         }
     }
 }
예제 #2
0
 public DynamicTileBrushCollection(LibraryX.TileBrushCollectionX <LibraryX.DynamicTileBrushX> proxy, TilePoolManager tileManager, DynamicTileBrushClassRegistry registry)
     : base(proxy.Uid, proxy.Name)
 {
     if (proxy.Brushes != null)
     {
         foreach (var brush in proxy.Brushes)
         {
             Brushes.Add(DynamicTileBrush.FromXProxy(brush, tileManager, registry));
         }
     }
 }
예제 #3
0
        public void AddBrush(Brush brush)
        {
            string key = brush.Type.ToString();

            if (Brushes.ContainsKey(key))
            {
                System.Windows.MessageBox.Show("已存在该类型的笔刷!", "提示");
                return;
            }

            Brushes.Add(key, brush);

            isModified = true;

            OnBrushModified?.Invoke();
        }
예제 #4
0
 public PenTool(BitmapManager bitmapManager)
 {
     Cursor              = Cursors.Pen;
     ActionDisplay       = "Click and move to draw.";
     Toolbar             = new PenToolbar();
     toolSizeSetting     = Toolbar.GetSetting <SizeSetting>("ToolSize");
     pixelPerfectSetting = Toolbar.GetSetting <BoolSetting>("PixelPerfectEnabled");
     ClearPreviewLayerOnEachIteration = false;
     BitmapManager   = bitmapManager;
     paint.BlendMode = SKBlendMode.Src;
     Brushes.Add(new CircleBrush());
     Brush    = Brushes[0];
     lineTool = new LineTool
     {
         AutomaticallyResizeCanvas = AutomaticallyResizeCanvas
     };
 }
예제 #5
0
        public Brush GetBrush(bool freezing = true)
        {
            if (freezing)
            {
                SolidColorBrush brush;
                if (Brushes.TryGetValue(Color, out brush))
                {
                    return(brush);
                }

                brush = new SolidColorBrush(Color);
                brush.Freeze();
                Brushes.Add(Color, brush);
                return(brush);
            }

            return(new SolidColorBrush(Color));
        }
예제 #6
0
        internal AddPolygonMutationChanges AddPolygon()
        {
            AddPolygonMutationChanges changes = new AddPolygonMutationChanges();

            changes.OldNegativeFitness = this.NegativeFitness;
            int numberOfPoints = 3 + random.Next(RandSeed);

            Point[] polygon = getPoints(numberOfPoints);

            Brush brush = getRandomBrush();

            changes.Index = Polygons.Count;

            Polygons.Add(polygon);
            Brushes.Add(brush);

            changes.NewPolygon = polygon;
            changes.NewBrush   = brush;

            this.NegativeFitness       = computeNegativeFittness();
            changes.NewNegativeFitness = this.NegativeFitness;
            return(changes);
        }
예제 #7
0
        public void PopulateBrushes()
        {
            Brushes.Clear();
            // Need to automate this to find all png files in res folder (make it res/tiles?)
            string[]      files = Directory.GetFiles(@"..\..\..\Test\res\sprites\tiles", "*.png", SearchOption.TopDirectoryOnly);
            List <string> ls    = new List <string>(files);

            ls.AddRange(Directory.GetFiles(@"..\..\..\Test\res\sprites\entities", "*.png", SearchOption.TopDirectoryOnly));
            foreach (var x in ls)
            {
                ImageBrush  brush = new ImageBrush();
                BitmapImage bmi   = new BitmapImage(new Uri(x, UriKind.Relative));
                if (bmi.PixelWidth > 32 || bmi.PixelHeight > 32)
                {
                    BitmapSource bms = new CroppedBitmap(bmi, new Int32Rect(0, 32, 32, 32));
                    brush.ImageSource = bms;
                }
                else
                {
                    brush.ImageSource = bmi;
                }
                Brushes.Add(x.Split('\\').Last(), brush);
            }
        }
예제 #8
0
 private void AddBrush() => Brushes.Add(brush);