public void SetCurrent(UiEncodingWindowSource source, IList<int> mainIndices, IList<int> additionalIndices)
        {
            CurrentSource = source;
            CurrentMainIndices = mainIndices;
            CurrentAdditionalIndices = additionalIndices;

            for (int i = mainIndices.Count; i < _mainControls.Count; i++)
                _mainControls[i].Visibility = Visibility.Collapsed;
            for (int i = additionalIndices.Count; i < _additionalControls.Count; i++)
                _additionalControls[i].Visibility = Visibility.Collapsed;

            if (CurrentSource == null)
                return;

            for (int i = 0; i < mainIndices.Count; i++)
            {
                _mainControls[i].Load(source, mainIndices[i]);
                _mainControls[i].Visibility = Visibility.Visible;
            }

            for (int i = 0; i < additionalIndices.Count; i++)
            {
                _additionalControls[i].Load(source, additionalIndices[i]);
                _additionalControls[i].Visibility = Visibility.Visible;
            }

            _drawEvent.NullSafeSet();
        }
Beispiel #2
0
        public void Load(UiEncodingWindowSource source, int index)
        {
            _source = null;
            _index  = -1;

            _oldInputText = string.Empty;
            _littleIndex  = index % 256;

            int offsets = source.Info.Offsets[index];
            int sizes   = source.Info.Sizes[index];

            int oy = (offsets >> 16) & 0xFFFF;
            int ox = offsets & 0xFFFF;

            sbyte before = (sbyte)(sizes & 0x000000FF);
            sbyte width  = (sbyte)((sizes & 0x0000FF00) >> 8);
            sbyte after  = (sbyte)((sizes & 0x00FF0000) >> 16);

            _indexLabel.Text = "0x" + (index).ToString("X");
            _ox.Value        = ox;
            _oy.Value        = oy;
            _before.Value    = before;
            _width.Value     = width;
            _after.Value     = after;

            _output.Text = source.Chars[_littleIndex].ToString(CultureInfo.CurrentCulture);
            _input.Text  = _oldInputText = String.Join(string.Empty, source.Codes.SelectWhere(p => p.Value == _littleIndex, p => p.Key));

            _source = source;
            _index  = index;
        }
        public void Load(UiEncodingWindowSource source, int index)
        {
            _source = null;
            _index = -1;

            _oldInputText = string.Empty;
            _littleIndex = index % 256;

            int offsets = source.Info.Offsets[index];
            int sizes = source.Info.Sizes[index];

            int oy = (offsets >> 16) & 0xFFFF;
            int ox = offsets & 0xFFFF;

            sbyte before = (sbyte)(sizes & 0x000000FF);
            sbyte width = (sbyte)((sizes & 0x0000FF00) >> 8);
            sbyte after = (sbyte)((sizes & 0x00FF0000) >> 16);

            _indexLabel.Text = "0x" + (index).ToString("X");
            _ox.Value = ox;
            _oy.Value = oy;
            _before.Value = before;
            _width.Value = width;
            _after.Value = after;

            _output.Text = source.Chars[_littleIndex].ToString(CultureInfo.CurrentCulture);
            _input.Text = _oldInputText = String.Join(string.Empty, source.Codes.SelectWhere(p => p.Value == _littleIndex, p => p.Key));

            _source = source;
            _index = index;
        }
        public void SetCurrent(UiEncodingWindowSource source, IList <int> mainIndices, IList <int> additionalIndices)
        {
            CurrentSource            = source;
            CurrentMainIndices       = mainIndices;
            CurrentAdditionalIndices = additionalIndices;

            for (int i = mainIndices.Count; i < _mainControls.Count; i++)
            {
                _mainControls[i].Visibility = Visibility.Collapsed;
            }
            for (int i = additionalIndices.Count; i < _additionalControls.Count; i++)
            {
                _additionalControls[i].Visibility = Visibility.Collapsed;
            }

            if (CurrentSource == null)
            {
                return;
            }

            for (int i = 0; i < mainIndices.Count; i++)
            {
                _mainControls[i].Load(source, mainIndices[i]);
                _mainControls[i].Visibility = Visibility.Visible;
            }

            for (int i = 0; i < additionalIndices.Count; i++)
            {
                _additionalControls[i].Load(source, additionalIndices[i]);
                _additionalControls[i].Visibility = Visibility.Visible;
            }

            _drawEvent.NullSafeSet();
        }
Beispiel #5
0
        public void Load(UiEncodingWindowSource source, int index)
        {
            _source     = null;
            _index      = -1;
            _largeIndex = index + 256;

            _oldInputText = string.Empty;
            short value = source.Info.AdditionalTable[index];

            _indexLabel.Text = "0x" + (0x8140 + index).ToString("X");
            _rowNumber.Value = (value >> 8);
            _colNumber.Value = (value & 0xFF);

            _output.Text = source.Chars[_largeIndex].ToString(CultureInfo.CurrentCulture);
            _input.Text  = String.Join(string.Empty, source.Codes.SelectWhere(p => p.Value == _largeIndex, p => p.Key));

            _source = source;
            _index  = index;
        }
Beispiel #6
0
        private void OnEditViewportDrawSprites(Device device, SpriteBatch spriteBatch, Rectangle cliprectangle)
        {
            UiEncodingWindowSource current = _currentSource;

            if (current == null)
            {
                return;
            }

            try
            {
                spriteBatch.Begin();
                current.Texture.Draw(device, spriteBatch, Vector2.Zero, new Rectangle(0, 0, current.Texture.Descriptor2D.Width, current.Texture.Descriptor2D.Height), 0, cliprectangle);
                spriteBatch.End();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
 private void OnComboBoxItemChanged(object sender, EventArgs e)
 {
     _currentSource = (UiEncodingWindowSource)_comboBox.SelectedItem;
     _charactersControl.SetCurrent(_currentSource, new int[0], new int[0]);
     _editViewport.SetDesiredSize(_currentSource.Texture.Descriptor2D.Width, _currentSource.Texture.Descriptor2D.Height);
 }
 public void Add(UiEncodingWindowSource source)
 {
     _comboBox.Items.Add(source);
 }
Beispiel #9
0
 private void OnComboBoxItemChanged(object sender, EventArgs e)
 {
     _currentSource = (UiEncodingWindowSource)_comboBox.SelectedItem;
     _charactersControl.SetCurrent(_currentSource, new int[0], new int[0]);
     //_glEditControl.SetViewportDesiredSize(_currentSource.Texture.Width, _currentSource.Texture.Height);
     //_glPreviewControl.SetViewportDesiredSize(_currentSource.Texture.Width * 4, (_currentSource.Info.Header.LineHeight + _currentSource.Info.Header.LineSpacing) * 8 * 4);
     GLService.SetViewportDesiredSize(_currentSource.Texture.Width, _currentSource.Texture.Height);
 }
Beispiel #10
0
        private void DrawPreview(UiEncodingWindowSource source, string text)
        {
            GL.Color3(Color.Transparent);

            float x = 0;
            float y = source.Info.Header.LineSpacing; // + source.Texture.Height
            int squareSize = source.Info.Header.SquareSize;
            int lineSpacing = source.Info.Header.LineHeight + source.Info.Header.LineSpacing;

            foreach (char ch in text)
            {
                if (ch == '\r')
                    continue;

                if (ch == '\n')
                {
                    x = 0;
                    y += lineSpacing;
                    continue;
                }

                short index;
                if (source.Codes.TryGetValue(ch, out index))
                {
                    int ox, oy;
                    float h, w;
                    if (index < 256)
                    {
                        byte before, width, after;
                        source.Info.GetSizes(index, out before, out width, out after);
                        w = width;
                        h = source.Info.Header.LineHeight;

                        if (before > 0x7F)
                            x = Math.Max(x - (0xFF - before), 0);
                        else
                            x += before;

                        source.Info.GetOffsets(index, out ox, out oy);
                        source.Texture.Draw(x, y, 0, ox, oy, w, h);

                        if (after > 0x7F)
                            x = Math.Max(x - (0xFF - after), 0);
                        else
                            x += after;
                    }
                    else
                    {
                        index -= 256;
                        w = h = squareSize;
                        int value = source.Info.AdditionalTable[index];
                        ox = (value & 0xFF) * squareSize;
                        oy = (value >> 8) * squareSize;
                        source.Texture.Draw(x, y, 0, ox, oy, w, h);
                    }

                    x += w;
                }
            }
        }
Beispiel #11
0
        private void DrawCharacters(UiEncodingWindowSource source)
        {
            WflContent info = source.Info;
            if (info.Header.TableType != WflHeader.LargeTable)
                return;

            GLRectangle rectangle = new GLRectangle {Height = info.Header.LineHeight};

            for (int i = 0; i < 256 * 2; i++)
            {
                if (i % 256 < 0x20)
                    continue;

                int x, y;
                info.GetOffsets(i, out x, out y);

                byte before, width, after;
                info.GetSizes(i, out before, out width, out after);

                rectangle.X = x;
                rectangle.Y = y;
                rectangle.Width = width & 0x7F;

                if (_charactersControl.CurrentMainIndices.Contains(i))
                {
                    rectangle.DrawSolid(SelectedColor);

                    if (before > 0x7F)
                    {
                        rectangle.Width = (0xFF - before) + 1;
                        rectangle.X = x;
                    }
                    else
                    {
                        rectangle.Width = before;
                        rectangle.X = x - before;
                    }
                    rectangle.DrawSolid(SpacingColor);

                    if (after > 0x7F)
                    {
                        rectangle.Width = (0xFF - after) + 1;
                        rectangle.X = x + (width & 0x7F) - rectangle.Width;
                    }
                    else
                    {
                        rectangle.Width = after;
                        rectangle.X = x + width & 0x7F;
                    }
                    rectangle.DrawSolid(SpacingColor);
                }
                else if (source.Chars[i % 256] == 0x00)
                {
                    rectangle.DrawSolid(NotMappedColor);
                }
                else
                {
                    rectangle.DrawBorder(GridColor);
                }
            }

            int squareSize = info.Header.LineSpacing + info.Header.SquareDiff;
            rectangle.Height = squareSize;
            rectangle.Width = squareSize;
            for (int i = 0; i < info.AdditionalTable.Length; i++)
            {
                int value = info.AdditionalTable[i];
                if (value == 0)
                    continue;

                rectangle.Y = (value >> 8) * squareSize;
                rectangle.X = (value & 0xFF) * squareSize;

                if (_charactersControl.CurrentAdditionalIndices.Contains(i))
                    rectangle.DrawSolid(SelectedColor);
                else if (source.Chars[i + 256] == 0x00)
                    rectangle.DrawSolid(NotMappedColor);
                else
                    rectangle.DrawBorder(GridColor);
            }
        }
        public void Load(UiEncodingWindowSource source, int index)
        {
            _source = null;
            _index = -1;
            _largeIndex = index + 256;

            _oldInputText = string.Empty;
            short value = source.Info.AdditionalTable[index];

            _indexLabel.Text = "0x" + (0x8140 + index).ToString("X");
            _rowNumber.Value = (value >> 8);
            _colNumber.Value = (value & 0xFF);

            _output.Text = source.Chars[_largeIndex].ToString(CultureInfo.CurrentCulture);
            _input.Text = String.Join(string.Empty, source.Codes.SelectWhere(p => p.Value == _largeIndex, p => p.Key));

            _source = source;
            _index = index;
        }
Beispiel #13
0
        private void OnPreviewViewportDraw(Device device, SpriteBatch spriteBatch, Rectangle cliprectangle)
        {
            UiEncodingWindowSource source = _currentSource;

            if (source == null)
            {
                return;
            }

            spriteBatch.Begin(SpriteSortMode.Deferred, null, _previewViewport.DxControl.RenderContainer.GraphicsDevice.SamplerStates.PointClamp, null, null, null, SharpDX.Matrix.Scaling(_scale));

            float x = 0, maxX = 0;
            float y           = source.Info.Header.LineSpacing;
            int   squareSize  = source.Info.Header.SquareSize;
            int   lineSpacing = source.Info.Header.LineHeight + source.Info.Header.LineSpacing;

            foreach (char ch in _previewText)
            {
                if (ch == '\r')
                {
                    continue;
                }

                if (ch == '\n')
                {
                    x  = 0;
                    y += lineSpacing;
                    continue;
                }

                short index;
                if (source.Codes.TryGetValue(ch, out index))
                {
                    int ox, oy;
                    int h, w;
                    if (index < 256)
                    {
                        byte before, width, after;
                        source.Info.GetSizes(index, out before, out width, out after);
                        w = width;
                        h = source.Info.Header.LineHeight;

                        if (before > 0x7F)
                        {
                            x = Math.Max(x - (0xFF - before), 0);
                        }
                        else
                        {
                            x += before;
                        }

                        source.Info.GetOffsets(index, out ox, out oy);
                        source.Texture.Draw(device, spriteBatch, new Vector2(x, y), new Rectangle(ox, oy, w, h), 0, cliprectangle);

                        if (after > 0x7F)
                        {
                            x = Math.Max(x - (0xFF - after), 0);
                        }
                        else
                        {
                            x += after;
                        }
                    }
                    else
                    {
                        index -= 256;
                        w      = h = squareSize;
                        int value = source.Info.AdditionalTable[index];
                        ox = (value & 0xFF) * squareSize;
                        oy = (value >> 8) * squareSize;
                        source.Texture.Draw(device, spriteBatch, new Vector2(x, y), new Rectangle(ox, oy, w, h), 0, cliprectangle);
                    }

                    x   += w;
                    maxX = Math.Max(x, maxX);
                }
            }

            spriteBatch.End();

            double desiredWidth, desiredHeight;

            _previewViewport.GetDesiredSize(out desiredWidth, out desiredHeight);

            double newDesiredWidth  = x * _scale;
            double newDesiredHeight = (y + lineSpacing) * _scale;

            if (Math.Abs(newDesiredWidth - desiredWidth) > 1 || Math.Abs(newDesiredHeight - newDesiredHeight) > 1)
            {
                _previewViewport.SetDesiredSize(newDesiredWidth, newDesiredHeight);
            }
        }
Beispiel #14
0
        private void OnEditViewportDrawPrimitives(Device device, RenderTarget target2D, Rectangle cliprectangle)
        {
            UiEncodingWindowSource source = _currentSource;

            WflContent info = source?.Info;

            if (info?.Header.TableType != WflHeader.LargeTable)
            {
                return;
            }

            int viewportX = _editViewport.X;
            int viewportY = _editViewport.Y;

            RectangleF rectangle = new RectangleF {
                Height = info.Header.LineHeight
            };

            target2D.BeginDraw();

            for (int i = 0; i < 256 * 2; i++)
            {
                if (i % 256 < 0x20)
                {
                    continue;
                }

                int x, y;
                info.GetOffsets(i, out x, out y);
                x -= viewportX;
                y -= viewportY;

                byte before, width, after;
                info.GetSizes(i, out before, out width, out after);

                rectangle.X     = x;
                rectangle.Y     = y;
                rectangle.Width = width & 0x7F;

                if (_charactersControl.CurrentMainIndices.Contains(i))
                {
                    target2D.FillRectangle(rectangle, _selectedColorBrush);

                    if (before > 0x7F)
                    {
                        rectangle.Width = (0xFF - before) + 1;
                        rectangle.X     = x;
                    }
                    else
                    {
                        rectangle.Width = before;
                        rectangle.X     = x - before;
                    }
                    target2D.FillRectangle(rectangle, _spacingColorBrush);

                    if (after > 0x7F)
                    {
                        rectangle.Width = (0xFF - after) + 1;
                        rectangle.X     = x + (width & 0x7F) - rectangle.Width;
                    }
                    else
                    {
                        rectangle.Width = after;
                        rectangle.X     = x + width & 0x7F;
                    }

                    target2D.FillRectangle(rectangle, _spacingColorBrush);
                }
                else if (source.Chars[i % 256] == 0x00)
                {
                    target2D.FillRectangle(rectangle, _notMappedColorBrush);
                }
                else
                {
                    target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f);
                }
            }

            int squareSize = info.Header.LineSpacing + info.Header.SquareDiff;

            rectangle.Height = squareSize;
            rectangle.Width  = squareSize;
            for (int i = 0; i < info.AdditionalTable.Length; i++)
            {
                int value = info.AdditionalTable[i];
                if (value == 0)
                {
                    continue;
                }

                rectangle.Y = (value >> 8) * squareSize - viewportY;
                rectangle.X = (value & 0xFF) * squareSize - viewportX;

                if (_charactersControl.CurrentAdditionalIndices.Contains(i))
                {
                    target2D.FillRectangle(rectangle, _selectedColorBrush);
                }
                else if (source.Chars[i + 256] == 0x00)
                {
                    target2D.FillRectangle(rectangle, _notMappedColorBrush);
                }
                else
                {
                    target2D.DrawRectangle(rectangle, _gridColorBrush, 1.0f);
                }
            }

            target2D.EndDraw();
        }
Beispiel #15
0
 private void OnComboBoxItemChanged(object sender, EventArgs e)
 {
     _currentSource = (UiEncodingWindowSource)_comboBox.SelectedItem;
     _charactersControl.SetCurrent(_currentSource, new int[0], new int[0]);
     _editViewport.SetDesiredSize(_currentSource.Texture.Descriptor2D.Width, _currentSource.Texture.Descriptor2D.Height);
 }
Beispiel #16
0
 public void Add(UiEncodingWindowSource source)
 {
     _comboBox.Items.Add(source);
 }