private void InitializeComponent()
        {
            #region Controls

            imageView = new ImageViewEx {
                BackgroundColor = KnownColors.DarkGreen
            };

            widthText = new TextBox {
                Text = "1"
            };
            heightText = new TextBox {
                Text = "1"
            };
            offsetText = new TextBox {
                Text = "0"
            };
            palOffsetText = new TextBox {
                Text = "0"
            };
            encodings    = new ComboBox();
            palEncodings = new ComboBox();
            swizzles     = new ComboBox();

            encodingParameters = new GroupBox {
                Text = "Encoding Parameters"
            };
            palEncodingParameters = new GroupBox {
                Text = "Encoding Palette Parameters"
            };
            swizzleParameters = new GroupBox {
                Text = "Swizzle Parameters"
            };

            statusLabel = new Label {
                TextColor = KnownColors.DarkRed
            };

            #endregion

            #region Commands

            openFileCommand = new Command {
                MenuText = "Open"
            };
            closeFileCommand = new Command {
                MenuText = "Close", Enabled = false
            };
            extractImageCommand = new Command {
                MenuText = "Extract", Enabled = false
            };
            processCommand = new Command {
                Enabled = false
            };

            #endregion

            Title   = "Raw Image Viewer";
            Size    = new Size(500, 600);
            Padding = new Padding(4);

            Menu = new MenuBar
            {
                Items =
                {
                    new ButtonMenuItem {
                        Text = "File", Items ={ openFileCommand,         closeFileCommand, new SeparatorMenuItem(), extractImageCommand }
                    },
                }
            };

            #region Content

            var baseParameterLayout = new StackLayout
            {
                Orientation = Orientation.Vertical,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,

                Spacing = 3,

                Items =
                {
                    new TableLayout
                    {
                        Spacing = new Size(3, 3),
                        Rows    =
                        {
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Width:"
                                           }, widthText }
                            },
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Height:"
                                           }, heightText }
                            },
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Offset:"
                                           }, offsetText }
                            },
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Encoding:"
                                           }, encodings }
                            },
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Palette Offset:"
                                           }, palOffsetText }
                            },
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Palette Encoding:"
                                           }, palEncodings }
                            },
                            new TableRow {
                                Cells =  { new Label {
                                               Text = "Swizzles:"
                                           }, swizzles }
                            },
                        }
                    },
                    new Button           {
                        Text = "Process", Command = processCommand
                    }
                }
            };

            var encodingParameterLayout = new StackLayout
            {
                Orientation = Orientation.Vertical,

                Items =
                {
                    encodingParameters,
                    palEncodingParameters,
                    swizzleParameters
                }
            };

            Content = new TableLayout
            {
                Spacing = new Size(3, 3),

                Rows =
                {
                    new TableRow {
                        ScaleHeight = true, Cells ={ imageView                    }
                    },
                    new TableLayout
                    {
                        Rows =
                        {
                            new TableRow
                            {
                                Cells =
                                {
                                    baseParameterLayout,
                                    encodingParameterLayout
                                }
                            }
                        }
                    },
                    statusLabel
                }
            };

            #endregion
        }
示例#2
0
        private void InitializeComponent()
        {
            #region Commands

            saveCommand = new Command {
                Image = ImageResources.Actions.Save
            };
            saveAsCommand = new Command {
                Image = ImageResources.Actions.SaveAs
            };
            exportCommand = new Command {
                Image = ImageResources.Actions.ImageExport
            };
            importCommand = new Command {
                Image = ImageResources.Actions.ImageImport
            };

            #endregion

            #region Controls

            #region Buttons

            saveButton = new ButtonToolStripItem
            {
                ToolTip = "Save",
                Command = saveCommand,
            };

            saveAsButton = new ButtonToolStripItem
            {
                ToolTip = "Save As",
                Command = saveAsCommand,
            };

            exportButton = new ButtonToolStripItem
            {
                ToolTip = "Export image",
                Command = exportCommand,
            };

            importButton = new ButtonToolStripItem
            {
                ToolTip = "Import image data",
                Command = importCommand,
            };

            #endregion

            #region Default

            imageList = new ListBox
            {
                ItemImageBinding = Binding.Property <Image>(nameof(ImageElement.Thumbnail)),
                ItemTextBinding  = Binding.Property <string>(nameof(ImageElement.Text)),
            };

            imageView = new ImageViewEx {
                BackgroundColor = KnownColors.DarkGreen
            };
            imagePalette = new PaletteView {
                Size = new Size(200, -1),
            };

            var widthLabel = new Label {
                Text = "Width:"
            };
            var heightLabel = new Label {
                Text = "Height:"
            };
            var formatLabel = new Label {
                Text = "Format:"
            };
            var paletteLabel = new Label {
                Text = "Palette:"
            };

            width    = new Label();
            height   = new Label();
            formats  = new ComboBox();
            palettes = new ComboBox();

            #endregion

            #region Toolstrip

            var mainToolStrip = new ToolStrip
            {
                Padding = 3,
                Items   =
                {
                    saveButton,
                    saveAsButton,
                    new SplitterToolStripItem(),
                    exportButton,
                    importButton
                }
            };

            #endregion

            #region Layouts

            var imageLayout = new StackLayout
            {
                Spacing     = 3,
                Orientation = Orientation.Vertical,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem(imageView)
                    {
                        Expand = true, HorizontalAlignment = HorizontalAlignment.Stretch
                    },
                    new TableLayout
                    {
                        Spacing = new Size(3, 3),
                        Rows    =
                        {
                            new TableRow
                            {
                                Cells =
                                {
                                    widthLabel,
                                    width,
                                    heightLabel,
                                    height,
                                    new TableCell {
                                        ScaleWidth = true
                                    }
                                }
                            },
                            new TableRow
                            {
                                Cells =
                                {
                                    formatLabel,
                                    formats,
                                    paletteLabel,
                                    palettes,
                                    new TableCell {
                                        ScaleWidth = true
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var listLayout = new StackLayout
            {
                Spacing = 3,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                Orientation = Orientation.Vertical,
                Items       =
                {
                    new StackLayoutItem(imageList, true)
                    {
                        HorizontalAlignment = HorizontalAlignment.Stretch
                    },
                    new StackLayoutItem(imagePalette, true)
                }
            };

            var mainLayout = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    new TableRow
                    {
                        Cells =
                        {
                            new TableCell(imageLayout)
                            {
                                ScaleWidth = true
                            },
                            listLayout
                        }
                    }
                }
            };

            #endregion

            #endregion

            Content = new TableLayout
            {
                Rows =
                {
                    new TableRow(mainToolStrip),
                    mainLayout
                }
            };
        }