Ejemplo n.º 1
0
        private void InitializeComponent()
        {
            #region Initialization

            searchTextBox = new SearchBox
            {
                Size = new Size(268, -1)
            };

            #region Commands

            searchClearCommand = new Command {
                MenuText = "Clear", Image = ImageResources.Actions.Delete
            };

            cancelCommand = new Command {
                MenuText = "Cancel"
            };

            openCommand = new Command {
                MenuText = "Open", Image = ImageResources.Actions.Open
            };
            openWithCommand = new Command {
                MenuText = "Open with", Image = ImageResources.Actions.OpenWith
            };

            saveCommand = new Command {
                MenuText = "Save", Shortcut = SaveHotKey, Image = ImageResources.Actions.Save
            };
            saveAsCommand = new Command {
                MenuText = "Save As", Shortcut = SaveAsHotKey, Image = ImageResources.Actions.SaveAs
            };

            extractDirectoryCommand = new Command {
                MenuText = "Extract", Image = ImageResources.Actions.FolderExport
            };
            replaceDirectoryCommand = new Command {
                MenuText = "Replace", Image = ImageResources.Actions.FolderImport
            };
            renameDirectoryCommand = new Command {
                MenuText = "Rename", Image = ImageResources.Actions.Rename
            };
            deleteDirectoryCommand = new Command {
                MenuText = "Delete", Image = ImageResources.Actions.Delete
            };
            addDirectoryCommand = new Command {
                MenuText = "Add", Image = ImageResources.Actions.Add
            };

            extractFileCommand = new Command {
                MenuText = "Extract", Image = ImageResources.Actions.FileExport
            };
            replaceFileCommand = new Command {
                MenuText = "Replace", Image = ImageResources.Actions.FileImport
            };
            renameFileCommand = new Command {
                MenuText = "Rename", Image = ImageResources.Actions.Rename
            };
            deleteFileCommand = new Command {
                MenuText = "Delete", Image = ImageResources.Actions.Delete
            };

            #endregion

            #region Folders

            var folderContext = new ContextMenu
            {
                Items =
                {
                    extractDirectoryCommand,
                    replaceDirectoryCommand,
                    renameDirectoryCommand,
                    addDirectoryCommand,
                    deleteDirectoryCommand
                }
            };

            folders    = new TreeGridItemCollection();
            folderView = new TreeGridView
            {
                ContextMenu = folderContext,

                DataStore = folders,
                Columns   =
                {
                    new GridColumn
                    {
                        DataCell = new ImageTextCell(0, 1)
                    }
                },
                AllowColumnReordering = false
            };

            #endregion

            #region Files

            //NOTE Image has to be set explicitly, I think the Command is not used anymore as soon as sub-items are added
            openWithMenuItem = new ButtonMenuItem {
                Text = "Open with", Command = openWithCommand, Image = openWithCommand.Image
            };
            var fileContext = new ContextMenu
            {
                Items =
                {
                    openCommand,
                    openWithMenuItem,

                    new SeparatorMenuItem(),

                    extractFileCommand,
                    replaceFileCommand,
                    renameFileCommand,
                    deleteFileCommand
                }
            };

            files    = new ObservableCollection <FileElement>();
            fileView = new GridView <FileElement>
            {
                ShowHeader             = true,
                AllowMultipleSelection = true,
                BackgroundColor        = KnownColors.White,

                ContextMenu = fileContext,

                Columns =
                {
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Name)),
                        HeaderText = "Name",
                        Sortable   = true,
                        AutoSize   = true
                    },
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Size)),
                        HeaderText = "Size",
                        Sortable   = true,
                        AutoSize   = true
                    }
                },

                DataStore = files
            };

            #endregion

            #region Buttons

            searchClearButton = new Button
            {
                Image   = ImageResources.Actions.Clear,
                ToolTip = "Reset search",
                Command = searchClearCommand,
                Size    = new Size(22, -1)
            };

            cancelButton = new Button
            {
                Text    = "Cancel",
                Command = cancelCommand
            };

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

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

            extractButton = new ButtonToolStripItem
            {
                ToolTip = "Extract file(s)",
                Command = extractFileCommand,
            };

            replaceButton = new ButtonToolStripItem
            {
                ToolTip = "Replace file(s)",
                Command = replaceFileCommand,
            };

            renameButton = new ButtonToolStripItem
            {
                ToolTip = "Rename file",
                Command = renameFileCommand,
            };

            deleteButton = new ButtonToolStripItem
            {
                ToolTip = "Delete file",
                Command = deleteFileCommand,
            };

            #endregion

            #endregion

            #region Content

            var archiveToolStrip = new ToolStrip
            {
                Padding = 3,
                Items   =
                {
                    saveButton,
                    saveAsButton
                }
            };

            var mainContent = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    // Searchbar and file toolstrip
                    new TableRow
                    {
                        Cells =
                        {
                            // Searchbar
                            new StackLayout
                            {
                                Spacing     = 3,
                                Orientation = Orientation.Horizontal,
                                Items       =
                                {
                                    searchTextBox,
                                    searchClearButton
                                }
                            },

                            // file toolstrip
                            new ToolStrip
                            {
                                Items =
                                {
                                    extractButton,
                                    replaceButton,
                                    renameButton,
                                    deleteButton
                                }
                            },
                        }
                    },

                    // Folder and file view
                    new TableRow
                    {
                        Cells =
                        {
                            folderView,
                            fileView
                        }
                    }
                }
            };

            Content = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    new TableRow(archiveToolStrip),
                    new TableRow {
                        Cells = { new TableCell(mainContent)
                                  {
                                      ScaleWidth = true
                                  } },             ScaleHeight= true
                    }
                }
            };

            #endregion
        }
Ejemplo n.º 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
                }
            };
        }
Ejemplo n.º 3
0
        private void InitializeComponent()
        {
            #region Initialization

            searchTextBox = new TextBox
            {
                Size = new Size(268, -1)
            };

            #region Commands

            searchClearCommand = new Command {
                MenuText = "Clear"
            };

            cancelCommand = new Command {
                MenuText = "Cancel"
            };

            openCommand = new Command {
                MenuText = "Open"
            };
            openWithCommand = new Command {
                MenuText = "Open with"
            };

            saveCommand = new Command {
                MenuText = "Save", Shortcut = SaveHotKey
            };
            saveAsCommand = new Command {
                MenuText = "Save As", Shortcut = SaveAsHotKey
            };

            extractDirectoryCommand = new Command {
                MenuText = "Extract", Image = MenuExportResource
            };
            replaceDirectoryCommand = new Command {
                MenuText = "Replace", Image = MenuImportResource
            };
            renameDirectoryCommand = new Command {
                MenuText = "Rename", Image = MenuEditResource
            };
            deleteDirectoryCommand = new Command {
                MenuText = "Delete", Image = MenuDeleteResource
            };
            addDirectoryCommand = new Command {
                MenuText = "Add", Image = MenuAddResource
            };

            extractFileCommand = new Command {
                MenuText = "Extract", Image = MenuExportResource
            };
            replaceFileCommand = new Command {
                MenuText = "Replace", Image = MenuImportResource
            };
            renameFileCommand = new Command {
                MenuText = "Rename", Image = MenuEditResource
            };
            deleteFileCommand = new Command {
                MenuText = "Delete", Image = MenuDeleteResource
            };

            #endregion

            #region Folders

            var folderContext = new ContextMenu
            {
                Items =
                {
                    extractDirectoryCommand,
                    replaceDirectoryCommand,
                    renameDirectoryCommand,
                    addDirectoryCommand,
                    deleteDirectoryCommand
                }
            };

            folders    = new TreeGridItemCollection();
            folderView = new TreeGridView
            {
                ContextMenu = folderContext,

                DataStore = folders,
                Columns   =
                {
                    new GridColumn
                    {
                        DataCell = new ImageTextCell(0, 1)
                    }
                },
                AllowColumnReordering = false
            };

            #endregion

            #region Files

            openWithMenuItem = new ButtonMenuItem {
                Text = "Open with", Command = openWithCommand
            };
            var fileContext = new ContextMenu
            {
                Items =
                {
                    openCommand,
                    openWithMenuItem,

                    new SeparatorMenuItem(),

                    extractFileCommand,
                    replaceFileCommand,
                    renameFileCommand,
                    deleteFileCommand
                }
            };

            files    = new ObservableCollection <FileElement>();
            fileView = new GridView <FileElement>
            {
                ShowHeader             = true,
                AllowMultipleSelection = true,
                BackgroundColor        = KnownColors.White,

                ContextMenu = fileContext,

                Columns =
                {
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Name)),
                        HeaderText = "Name",
                        Sortable   = true,
                        AutoSize   = true
                    },
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Size)),
                        HeaderText = "Size",
                        Sortable   = true,
                        AutoSize   = true
                    }
                },

                DataStore = files
            };

            #endregion

            #region Buttons

            searchClearButton = new Button
            {
                Text    = "X",
                Size    = new Size(22, -1),
                Command = searchClearCommand
            };

            cancelButton = new Button
            {
                Text    = "Cancel",
                Command = cancelCommand
            };

            saveButton = new ButtonToolStripItem
            {
                Command = saveCommand,
                Image   = MenuSaveResource
            };

            saveAsButton = new ButtonToolStripItem
            {
                Command = saveAsCommand,
                Image   = MenuSaveAsResource
            };

            extractButton = new ButtonToolStripItem
            {
                Command = extractFileCommand,
                Image   = MenuExportResource
            };

            replaceButton = new ButtonToolStripItem
            {
                Command = replaceFileCommand,
                Image   = MenuImportResource
            };

            renameButton = new ButtonToolStripItem
            {
                Command = renameFileCommand,
                Image   = MenuExportResource
            };

            deleteButton = new ButtonToolStripItem
            {
                Command = deleteFileCommand,
                Image   = MenuDeleteResource
            };

            #endregion

            #endregion

            #region Content

            var archiveToolStrip = new ToolStrip
            {
                BackgroundColor = KnownColors.White,
                Items           =
                {
                    saveButton,
                    saveAsButton
                }
            };

            var mainContent = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    // Searchbar and file toolstrip
                    new TableRow
                    {
                        Cells =
                        {
                            // Searchbar
                            new StackLayout
                            {
                                Spacing     = 3,
                                Orientation = Orientation.Horizontal,
                                Items       =
                                {
                                    searchTextBox,
                                    searchClearButton
                                }
                            },

                            // file toolstrip
                            new ToolStrip
                            {
                                Size            = new SizeF(-1, ToolStripItem.Height + 6),
                                BackgroundColor = KnownColors.White,
                                Items           =
                                {
                                    extractButton,
                                    replaceButton,
                                    renameButton,
                                    deleteButton
                                }
                            },
                        }
                    },

                    // Folder and file view
                    new TableRow
                    {
                        Cells =
                        {
                            folderView,
                            fileView
                        }
                    }
                }
            };

            Content = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    new TableRow(new Panel {
                        Content = archiveToolStrip, Size = new Size(-1, (int)ToolStripItem.Height + 6)
                    }),
                    new TableRow           {
                        Cells =            { new TableCell(mainContent)
                                             {
                                                 ScaleWidth = true
                                             } }, ScaleHeight = true
                    }
                }
            };

            #endregion
        }