示例#1
0
        internal void UpdateSetting()
        {
            zoomSlider.Value = (int)setting.Zoom;
            chkGrid.Checked  = setting.ShowGrid;
            chkSemi.Checked  = setting.SemiControl;

            // Palette List
            lvPalette.Items.Clear();

            List <string> created = new List <string>();

            foreach (var pf in setting.PaletteList)
            {
                string tmp = pf.ToLower();

                if (!created.Contains(tmp) && pf.Length > 0 && File.Exists(pf))
                {
                    PaletteItem item = new PaletteItem(pf);
                    item.Load();
                    CreatePaletteColorItems(item);

                    PaletteManager.AddPalette(item);

                    lvPalette.Items.Add(item.Name);

                    created.Add(tmp);
                }
            }

            SelectPalette(selectedPalette);
        }
示例#2
0
        private static bool Thumbnail(HttpContext context)
        {
            Parameters p = Parameters.Deserialize(context.Request.Params["t"]);

            if (!Utils.CheckTimeKey(p["Key", "?"]))
            {
                return(false);
            }
            long id = p.Get("Id", -1L);

            if (id < 0L)
            {
                return(false);
            }
            PaletteManager mgr = new PaletteManager(Utils.ConnectionString);

            byte[] image = mgr.GetPaletteThumbnail((int)id);
            if (image == null)
            {
                handler.SendBytes(context, "image/gif", handler.emptyGif);
            }
            else
            {
                handler.SendBytes(context, "image/jpeg", image);
            }
            image = null;
            return(true);
        }
示例#3
0
    //save json
    public PaletteContainer CreatePalettes()
    {
        PaletteContainer paletteContainer = new PaletteContainer();

        paletteContainer.Palettes = Palettes;

        if (PaletteManager.Palettes != null)
        {
            PaletteManager.Palettes.Clear();
        }

        foreach (Palette palette in paletteContainer.Palettes)
        {
            Palette _palette = PaletteFactory.CreatePalette(palette.name, palette.Colors, palette.Textures, palette.Shaders);
            PaletteManager.AddPalete(_palette);
        }

        string patch      = "data.json";
        string filePath   = Path.Combine(Application.streamingAssetsPath, patch);
        string dataAsJson = JsonUtility.ToJson(paletteContainer);

        File.WriteAllText(filePath, dataAsJson);

        Debug.Log("Palette saved");
        return(paletteContainer);
    }
示例#4
0
        protected string RenderMessage()
        {
            if (this.message == null)
            {
                return(String.Empty);
            }



            HtmlRenderer html = new HtmlRenderer();

            html.Add("<tr><td align=\"center\" style=\"padding:8px;font-size:small;color:#909090;\" colspan=\"2\">");
            html.Text(this.message);
            html.Add("</td></tr>");

            if (this.paletteId > 0)
            {
                PaletteManager mgr = new PaletteManager(Utils.ConnectionString);
                PaletteItem    pi  = mgr.Load(this.paletteId);

                if (pi.Id == this.paletteId)
                {
                    html.Add("<tr><td align=\"center\" style=\"padding:2px;font-size:small;color:#909090; border:2px solid #909090;\" colspan=\"2\">");
                    html.Add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
                    search.RenderPaletteItem(html, pi, this.parameters["Key", String.Empty], false);
                    search.RenderPaletteItem(html, pi, this.parameters["Key", String.Empty], true);
                    html.Add("</table></td></tr>");
                }
            }

            return(html.ToString());
        }
示例#5
0
        public void PaintHexData(HexBox Box, Graphics graphics, long _startByte, long intern_endByte, Rectangle _recHex)
        {
            //if ( Box.BytesPerLine == 8 )
            {
                var oldClip = graphics.Clip;
                graphics.SetClip(_recHex);

                GR.Image.FastImage charImage = new GR.Image.FastImage(8, 8, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
                PaletteManager.ApplyPalette(charImage);

                for (int i = 0; i < intern_endByte - _startByte; ++i)
                {
                    byte character    = Box.ByteProvider.ReadByte(_startByte + i);
                    int  displayColor = 0;
                    int  bgColor      = 1;

                    if ((_startByte + i >= Box.SelectionStart) &&
                        (_startByte + i < Box.SelectionStart + Box.SelectionLength))
                    {
                        displayColor = 1;
                        bgColor      = 14;
                    }

                    switch (Mode)
                    {
                    case PETSCIIDisplay.UPPER_CASE:
                        CharacterDisplayer.DisplayHiResChar(ConstantData.UpperCaseCharsetC64.SubBuffer(character * 8, 8),
                                                            ConstantData.Palette,
                                                            bgColor, displayColor,
                                                            charImage, 0, 0);
                        break;

                    case PETSCIIDisplay.LOWER_CASE:
                        CharacterDisplayer.DisplayHiResChar(ConstantData.LowerCaseCharsetC64.SubBuffer(character * 8, 8),
                                                            ConstantData.Palette,
                                                            bgColor, displayColor,
                                                            charImage, 0, 0);
                        break;
                    }

                    charImage.DrawToHDC(graphics.GetHdc(),
                                        new Rectangle(_recHex.Left + (int)Box.CharSize.Width * (i % 8),
                                                      (int)(_recHex.Top + (i / 8) * (int)Box.CharSize.Height + (Box.CharSize.Height - Box.CharSize.Width) / 2),
                                                      (int)Box.CharSize.Width,
                                                      (int)Box.CharSize.Width));
                    graphics.ReleaseHdc();
                }
                charImage.Dispose();

                graphics.Clip = oldClip;
            }
        }
示例#6
0
        public static void OpenPaletteViewer()
        {
            PaletteManager pm = new PaletteManager();
            pm.StartPosition = FormStartPosition.CenterParent;
            pm.Owner = ReubenController.MainWindow;

            if (ActiveEditor != null)
            {
                if (ActiveEditor is LevelEditor)
                {
                    pm.ShowDialog(((LevelEditor)ActiveEditor).CurrentLevel.Palette);
                }
                else
                {
                    pm.ShowDialog(((WorldEditor)ActiveEditor).CurrentWorld.Palette);
                }
            }
            else
            {

                pm.ShowDialog();
            }
        }