public ColorPaletteSelectPage(Action <ColorPaletteSelectPage> paletteSelectCallback)
        {
            InitializeComponent();

            _paletteSelectCallback = paletteSelectCallback;

            _items = new ObservableCollection <ColorPalette>(ColorPaletteFactory.MakeAllPalettes());

            foreach (var item in _items)
            {
                SKImageInfo info   = new SKImageInfo(100, 20);
                SKBitmap    bitmap = new SKBitmap(info);
                SKCanvas    canvas = new SKCanvas(bitmap);

                var cellWidth = info.Width / item.Colors.Count;
                for (int i = 0; i < item.Colors.Count; i++)
                {
                    var paint = new SKPaint();
                    paint.Color = item.Colors[i];
                    paint.Style = SKPaintStyle.Fill;
                    canvas.DrawRect(new SKRect(i * cellWidth, 0, (i * cellWidth) + cellWidth, info.Height), paint);
                }

                var img     = SKImage.FromBitmap(bitmap);
                var encoded = img.Encode();
                item.Image = ImageSource.FromStream(encoded.AsStream);
            }

            PaletteCollection.SetBinding(CollectionView.ItemsSourceProperty, new Binding {
                Source = _items
            });
        }
        public void LoadPalettes_Retrievable()
        {
            var collection = new PaletteCollection();

            var palettes = new PaletteInfo[]
            {
                new PaletteInfo()
                {
                    Name = "MegaMan", ImagePath = FilePath.FromRelative("a", @"C:\")
                },
                new PaletteInfo()
                {
                    Name = "Enemy", ImagePath = FilePath.FromRelative("b", @"C:\")
                },
                new PaletteInfo()
                {
                    Name = "Menu", ImagePath = FilePath.FromRelative("c", @"C:\")
                },
                new PaletteInfo()
                {
                    Name = "Scene", ImagePath = FilePath.FromRelative("d", @"C:\")
                }
            };

            collection.LoadPalettes(palettes);

            Assert.AreEqual(4, collection.Count);
            Assert.AreEqual("b", collection["Enemy"].ImagePath.Relative);
        }
예제 #3
0
        private void LoadData()
        {
            if (File.Exists("Palette.dat"))
            {
                using (var fs = new FileStream("Palette.dat", FileMode.Open, FileAccess.Read))
                {
                    using (var reader = new StreamReader(fs))
                    {
                        var res = JsonConvert.DeserializeObject <List <Palette> >(reader.ReadToEnd());
                        PaletteCollection.AddRange(res);
                    }
                }
            }

            if (File.Exists("Color.dat"))
            {
                using (var fs = new FileStream("Color.dat", FileMode.Open, FileAccess.Read))
                {
                    using (var reader = new StreamReader(fs))
                    {
                        var res = JsonConvert.DeserializeObject <List <UserColor> >(reader.ReadToEnd());
                        UserColorCollection.AddRange(res);
                    }
                }
            }
        }
예제 #4
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            PaletteCollection collection = value as PaletteCollection;

            if (collection != null)
            {
                return(collection[0].Colors);
            }
            return(null);
        }
        public void LoadPalettes_Duplicate_Exception()
        {
            var collection = new PaletteCollection();

            var palettes = new PaletteInfo[]
            {
                new PaletteInfo() { Name = "MegaMan", ImagePath = FilePath.FromRelative("a", @"C:\") },
                new PaletteInfo() { Name = "MegaMan", ImagePath = FilePath.FromRelative("b", @"C:\") }
            };

            collection.LoadPalettes(palettes);
        }
예제 #6
0
        private void UpdateInnerCircleColor()
        {
            var indexCalculator = IndexCalculatorCollection.CreateByName(Properties.Settings.Default.MapInnerCircleColorType);
            var palette         = PaletteCollection.GetByName(Properties.Settings.Default.MapInnerCirclePalette)
                                  .Palette;
            var colorCalculator = new IndexColorConverter(indexCalculator, palette);

            foreach (var curSystem in _solarSystems)
            {
                curSystem.InnerCircleColor = colorCalculator.GetBrush(curSystem);
            }
        }
예제 #7
0
        static public GfxFileReader DoLoad(string fileId, bool usePli, bool useJil)
        {
            //Console.WriteLine($"Using .jil={useJil}");

            var gfx = new BinaryReader(File.Open(fileId + ".gfx", FileMode.Open), Encoding.Default, true);
            var gil = new BinaryReader(File.Open(fileId + ".gil", FileMode.Open), Encoding.Default, true);

            BinaryReader paletteIndex, palette, directionIndex = null, jobIndex = null;

            if (usePli)
            {
                paletteIndex = new BinaryReader(File.Open(fileId + ".pil", FileMode.Open), Encoding.Default, true);
                palette      = new BinaryReader(File.Open(fileId + ".pa6", FileMode.Open), Encoding.Default, true);
            }
            else
            {
                paletteIndex = new BinaryReader(File.Open(fileId + ".pi4", FileMode.Open), Encoding.Default, true);
                palette      = new BinaryReader(File.Open(fileId + ".p46", FileMode.Open), Encoding.Default, true);
            }

            if (useJil)
            {
                directionIndex = new BinaryReader(File.Open(fileId + ".dil", FileMode.Open), Encoding.Default, true);
                jobIndex       = new BinaryReader(File.Open(fileId + ".jil", FileMode.Open), Encoding.Default, true);
            }



            var gfxIndexList      = new GilFileReader(gil);
            var paletteIndexList  = new PilFileReader(paletteIndex);
            var paletteCollection = new PaletteCollection(palette, paletteIndexList);

            DilFileReader directionIndexList = null;
            JilFileReader jobIndexList       = null;

            if (useJil)
            {
                directionIndexList = new DilFileReader(directionIndex);
                jobIndexList       = new JilFileReader(jobIndex);
            }

            gfxFile = new GfxFileReader(gfx, gfxIndexList, jobIndexList, directionIndexList, paletteCollection);

            gfx?.Close();
            gil?.Close();
            paletteIndex?.Close();
            palette?.Close();
            directionIndex?.Close();
            jobIndex?.Close();

            return(gfxFile);
        }
예제 #8
0
        private void CalculateProperties()
        {
            var circleBorderPalette = PaletteCollection.GetByName(Properties.Settings.Default.MapCircleBorderPalette)
                                      .Palette;
            var innerCirclePalette = PaletteCollection.GetByName(Properties.Settings.Default.MapInnerCirclePalette)
                                     .Palette;

            CircleBorderColor  = circleBorderPalette[_index];
            InnerCircleColor   = innerCirclePalette[_index];
            TriStateVisibility = Properties.Settings.Default.MapCircleMarkerType == typeof(NoTriStateCalculator).Name
                                     ? Visibility.Collapsed
                                     : Visibility.Visible;
        }
예제 #9
0
		public bool Initialize() {
			Logger.Info("Initializing theater of type {0}", _theaterType);

			if (!ModConfig.SetActiveTheater(_theaterType))
				return false;
			Active = this;

			// load palettes and additional mix files for this theater
			_palettes = new PaletteCollection();
			_palettes.IsoPalette = new Palette(VFS.Open<PalFile>(ModConfig.ActiveTheater.IsoPaletteName));
			_palettes.OvlPalette = new Palette(VFS.Open<PalFile>(ModConfig.ActiveTheater.OverlayPaletteName));
            _palettes.UnitPalette = new Palette(VFS.Open<PalFile>(ModConfig.ActiveTheater.UnitPaletteName), ModConfig.ActiveTheater.UnitPaletteName, true);

			foreach (string mix in ModConfig.ActiveTheater.Mixes)
				VFS.Add(mix, CacheMethod.Cache); // we wish for these to be cached as they're gonna be hit often

			_palettes.AnimPalette = new Palette(VFS.Open<PalFile>("anim.pal"));

			_animations = new ObjectCollection(CollectionType.Animation, _theaterType, _engine, _rules, _art,
				_rules.GetSection("Animations"), _palettes);

			_tileTypes = new TileCollection(CollectionType.Tiles, _theaterType, _engine, _rules, _art, ModConfig.ActiveTheater);

			_buildingTypes = new ObjectCollection(CollectionType.Building, _theaterType, _engine, _rules, _art,
				_rules.GetSection("BuildingTypes"), _palettes);

			_aircraftTypes = new ObjectCollection(CollectionType.Aircraft, _theaterType, _engine, _rules, _art,
				_rules.GetSection("AircraftTypes"), _palettes);

			_infantryTypes = new ObjectCollection(CollectionType.Infantry, _theaterType, _engine, _rules, _art,
				_rules.GetSection("InfantryTypes"), _palettes);

			_overlayTypes = new ObjectCollection(CollectionType.Overlay, _theaterType, _engine, _rules, _art,
				_rules.GetSection("OverlayTypes"), _palettes);

			_terrainTypes = new ObjectCollection(CollectionType.Terrain, _theaterType, _engine, _rules, _art,
				_rules.GetSection("TerrainTypes"), _palettes);

			_smudgeTypes = new ObjectCollection(CollectionType.Smudge, _theaterType, _engine, _rules, _art,
				_rules.GetSection("SmudgeTypes"), _palettes);

			_vehicleTypes = new ObjectCollection(CollectionType.Vehicle, _theaterType, _engine, _rules, _art,
				_rules.GetSection("VehicleTypes"), _palettes);

			_tileTypes.InitTilesets();
			_tileTypes.InitAnimations(_animations);

			return true;
		}
        public void LoadPalettes_Retrievable()
        {
            var collection = new PaletteCollection();

            var palettes = new PaletteInfo[]
            {
                new PaletteInfo() { Name = "MegaMan", ImagePath = FilePath.FromRelative("a", @"C:\") },
                new PaletteInfo() { Name = "Enemy", ImagePath = FilePath.FromRelative("b", @"C:\") },
                new PaletteInfo() { Name = "Menu", ImagePath = FilePath.FromRelative("c", @"C:\") },
                new PaletteInfo() { Name = "Scene", ImagePath = FilePath.FromRelative("d", @"C:\") }
            };

            collection.LoadPalettes(palettes);

            Assert.AreEqual(4, collection.Count);
            Assert.AreEqual("b", collection["Enemy"].ImagePath.Relative);
        }
        public void LoadPalettes_Duplicate_Exception()
        {
            var collection = new PaletteCollection();

            var palettes = new PaletteInfo[]
            {
                new PaletteInfo()
                {
                    Name = "MegaMan", ImagePath = FilePath.FromRelative("a", @"C:\")
                },
                new PaletteInfo()
                {
                    Name = "MegaMan", ImagePath = FilePath.FromRelative("b", @"C:\")
                }
            };

            collection.LoadPalettes(palettes);
        }
예제 #12
0
        private void LoadFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "JSON files (.json)|*.json";

            if (dlg.ShowDialog() == true)
            {
                currentFilePath = dlg.FileName;

                paletteFile = JsonConvert.DeserializeObject <PaletteCollection>(File.ReadAllText(dlg.FileName));

                foreach (PaletteGroup entity in paletteFile.PaletteGroups)
                {
                    EntityList.Items.Add(entity.name);
                }
            }
        }
예제 #13
0
		public ObjectCollection(CollectionType type, TheaterType theater, EngineType engine, IniFile rules, IniFile art,
			IniFile.IniSection objectsList, PaletteCollection palettes)
			: base(type, theater, engine, rules, art) {

			Palettes = palettes;
			if (engine >= EngineType.RedAlert2) {
				string fireNames = Rules.ReadString(Engine == EngineType.RedAlert2 ? "AudioVisual" : "General",
					"DamageFireTypes", "FIRE01,FIRE02,FIRE03");
				FireNames = fireNames.Split(new[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
			}

			foreach (var entry in objectsList.OrderedEntries) {
				if (!string.IsNullOrEmpty(entry.Value)) {
					Logger.Trace("Loading object {0}.{1}", objectsList.Name, entry.Value);
					AddObject(entry.Value);
				}
			}
		}
    new public void OnEnable()
    {
        loadButtonTextures();

        myCollection = target as PaletteCollection;
        myCollection.init();

        this.height = 50;

        if (showPalettes == null)
        {
            showPalettes = new bool[myCollection.collectionData.palettes.Count];
            for (int i = 0; i < showPalettes.Length; i++)
            {
                showPalettes [i] = false;
            }
        }
        URL = myCollection.collectionData.paletteURL;
    }
    public override void OnInspectorGUI()
    {
        // uncomment for debugging
        //base.DrawDefaultInspector ();

        myCollection = target as PaletteCollection;

        // margin box before buttons
        GUILayout.Space(10);

        showImporter = EditorGUILayout.Foldout(showImporter, " Import Palette to Collection");

        if (showImporter)
        {
            drawURLImporter();
        }

        drawAllPalettes();

        drawSaveButtons();
    }
        public void Get_NotFound_ReturnsNull()
        {
            var collection = new PaletteCollection();

            Assert.IsNull(collection["NoSuchPalette"]);
        }
        public void Get_NotFound_ReturnsNull()
        {
            var collection = new PaletteCollection();

            Assert.IsNull(collection["NoSuchPalette"]);
        }
예제 #18
0
        public ICollectionFileReader DoLoad(string fileId, bool usePli, bool useJil)
        {
            //Console.WriteLine($"Using .jil={useJil}");

            var gfx = new BinaryReader(File.Open(fileId + ".gfx", FileMode.Open), Encoding.Default, true);
            var gil = new BinaryReader(File.Open(fileId + ".gil", FileMode.Open), Encoding.Default, true);

            BinaryReader paletteIndex, palette, directionIndex = null, jobIndex = null;

            if (usePli)
            {
                paletteIndex = new BinaryReader(File.Open(fileId + ".pil", FileMode.Open), Encoding.Default, true);
                palette      = new BinaryReader(File.Open(fileId + ".pa6", FileMode.Open), Encoding.Default, true);
            }
            else
            {
                paletteIndex = new BinaryReader(File.Open(fileId + ".pi2", FileMode.Open), Encoding.Default, true);
                palette      = new BinaryReader(File.Open(fileId + ".p26", FileMode.Open), Encoding.Default, true);
            }

            if (useJil)
            {
                directionIndex = new BinaryReader(File.Open(fileId + ".dil", FileMode.Open), Encoding.Default, true);
                jobIndex       = new BinaryReader(File.Open(fileId + ".jil", FileMode.Open), Encoding.Default, true);
            }



            var gfxIndexList      = new GilFileReader(gil);
            var paletteIndexList  = new PilFileReader(paletteIndex);
            var paletteCollection = new PaletteCollection(palette, paletteIndexList);

            switch (fileId.Substring(fileId.Length - 2))
            {
            case ("20"):
            case ("21"):
            case ("22"):
            case ("24"):
                paletteCollection.GetPalette().replaceTeamColors = true;
                paletteCollection.GetPalette().team = TeamGFXSetting.SelectedIndex;
                break;
            }

            DilFileReader directionIndexList = null;
            JilFileReader jobIndexList       = null;

            if (useJil)
            {
                directionIndexList = new DilFileReader(directionIndex);
                jobIndexList       = new JilFileReader(jobIndex);
            }

            gfxFile = new GfxFileReader(gfx, gfxIndexList, jobIndexList, directionIndexList, paletteCollection);

            gfx?.Close();
            gil?.Close();
            paletteIndex?.Close();
            palette?.Close();
            directionIndex?.Close();
            jobIndex?.Close();
            gfxFile?.Close();

            return(gfxFile);
        }
예제 #19
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="rom1"></param>
        /// <param name="rom2"></param>
        /// <param name="HMirror"></param>
        /// <param name="VMirror"></param>
        /// <param name="imageSet"></param>
        public NesPpu(byte[] rom1, byte[] rom2, bool HMirror, bool VMirror, Action<uint[]> imageSet)
        {
            this.PatternTables = new PatternTableCollection(rom1, rom2);
            this.NameAttributePairTables = new NameAttributeTablePairCollection();
            this.VirtualNameAttributePairTables = new VirtualNameAttributeTablePairCollection(this.NameAttributePairTables);
            this.Sprites = new SpriteCollection();
            this.BgPalettes = new PaletteCollection();
            this.SpritePalettes = new PaletteCollection();

            this.ControlRegister1 = new NesPpuControlRegister1();
            this.ControlRegister2 = new NesPpuControlRegister2();
            this.StatusRegister = new NesPpuStatusRegister();

            this.DRamAddress = new PpuMemoryAddress();
            this.SpriteAddress = new PpuSpriteAddress();
            this.Scroll = new NesPpuScroll();

            this.HMirror = HMirror;
            this.VMirror = VMirror;

            this.ImageCommitAction = imageSet;
            this.Clock = new NesPpuClock();

            this.PpuImage = new NesPpuImage();
        }
예제 #20
0
 public PaletteData()
 {
     _palette = new PaletteCollection();
 }
        private void ConstructPiePieces()
        {

            if (ItemsSource == null)
                return;
            if (ItemsSource.Count == 0)
                return;

            double halfWidth = this.ActualWidth / 2;
            double innerRadius = halfWidth * HoleSize;

            // compute the total for the property which is being plotted
            double total = 0;
            foreach (DataItem item in ItemsSource)
            {
                total += GetPlottedPropertyValue(item);
            }

            // add the pie pieces
            Container.Children.Clear();
            double accumulativeAngle = 0;
            int index = 0;
            foreach (DataItem item in ItemsSource)
            {
                double wedgeAngle = GetPlottedPropertyValue(item) * 360 / total;
                if (wedgeAngle == 360)
                {
                    wedgeAngle = 359.9;
                }
                PieDataPoint piece = new PieDataPoint()
                {
                    Radius = halfWidth,
                    InnerRadius = innerRadius,
                    CentreX = halfWidth,
                    CentreY = halfWidth,
                    WedgeAngle = wedgeAngle,
                    RotationAngle = accumulativeAngle,
                };
                piece.Tapped += piece_Tapped;
                if (PiePalette == null)
                {
                    PiePalette = PaletteCollection.LoadDefaults();
                }
                piece.Fill = PiePalette.getPalette(index);

                item.Percentage = Math.Round(((item.Value / total) * 100)).ToString() + "%";
                item.Palette = PiePalette.getPalette(index);
                Container.Children.Insert(0, piece);
                piece.Data = item;

                accumulativeAngle += wedgeAngle;
                index++;
            }

        }