Ejemplo n.º 1
0
        public ImageEditorTabPage(IEnumerable <FirmwareDefinition> definitions, ResourcePacksStorage resourcePackStorage)
        {
            m_definitions         = definitions;
            m_resourcePackStorage = resourcePackStorage;

            InitializeComponent();
            InitializeControls();
        }
        public CreateResourcePackWindow
        (
            [NotNull] ResourcePacksStorage resourcePackStorage,
            [NotNull] IEnumerable <FirmwareDefinition> definitions,
            [NotNull] string definition,
            [NotNull] List <ExportedImage> exportedImages,
            [CanBeNull] ResourcePackFile existedResourcePack
        ) : this()
        {
            if (resourcePackStorage == null)
            {
                throw new ArgumentNullException("resourcePackStorage");
            }
            if (definitions == null)
            {
                throw new ArgumentNullException("definitions");
            }
            if (string.IsNullOrEmpty(definition))
            {
                throw new ArgumentNullException("definition");
            }
            if (exportedImages == null)
            {
                throw new ArgumentNullException("exportedImages");
            }

            m_resourcePackStorage = resourcePackStorage;
            m_exportedImages      = exportedImages.ToList();

            definitions.ForEach(x => DefinitionComboBox.Items.Add(x));
            if (existedResourcePack == null)
            {
                DefinitionComboBox.Text = definition;
                AuthorTextBox.Text      = Environment.UserName;
            }
            else
            {
                NameTextBox.Text        = existedResourcePack.Name;
                VersionTextBox.Text     = existedResourcePack.Version;
                AuthorTextBox.Text      = existedResourcePack.Author;
                DefinitionComboBox.Text = existedResourcePack.Definition;
                DescriptionTextBox.Text = existedResourcePack.Description;
            }
            flowLayoutPanel1.SuspendLayout();
            foreach (var exportedImage in exportedImages.Select(x => x.Data))
            {
                flowLayoutPanel1.Controls.Add(CreateGrid(exportedImage));
            }
            flowLayoutPanel1.ResumeLayout();
        }
Ejemplo n.º 3
0
        public ResourcePacksTabPage([NotNull] ResourcePacksStorage resourcePackStorage)
        {
            if (resourcePackStorage == null)
            {
                throw new ArgumentNullException("resourcePackStorage");
            }

            m_resourcePackStorage = resourcePackStorage;
            InitializeComponent();

            ResourcePackListView.Resize += (s, e) =>
            {
                NameColumnHeader.Width = ResourcePackListView.ClientRectangle.Width - FileNameColumnHeader.Width - VersionColumnHeader.Width - 1;
            };
            ResourcePackListView.SelectedIndexChanged += ResourcePackListView_SelectedIndexChanged;
            ResourcePackListView.ItemActivate         += ResourcePackListView_ItemActivate;
            ResourcePackListView.ColumnClick          += ListViewItemComparer.ListViewColumnClick;
            PreviewResourcePackButton.Click           += PreviewResourcePackButton_Click;
            ImportResourcePackButton.Click            += ImportResourcePackButton_Click;
            ReloadResourcePacksButton.Click           += ReloadResourcePacksButton_Click;
        }
Ejemplo n.º 4
0
        public void SetData([NotNull] List <bool[, ]> images)
        {
            if (images == null)
            {
                throw new ArgumentNullException("images");
            }

            var data = new List <ExportedImage>();

            foreach (var image in images)
            {
                var size = FirmwareImageProcessor.GetImageSize(image);
                data.Add(new ExportedImage(0, size, image)
                {
                    DataString = ResourcePacksStorage.WriteImageToAsciiString(size.Width, size.Height, image)
                });
            }
            var buffer = Serializer.Write(data);

            Clipboard.SetText(buffer);
        }
Ejemplo n.º 5
0
        public List <bool[, ]> GetData()
        {
            var images = new List <bool[, ]>();

            try
            {
                var buffer = Clipboard.GetText();
                var data   = Serializer.Read <List <ExportedImage> >(buffer);
                if (data == null)
                {
                    return(images);
                }

                foreach (var exportedImage in data)
                {
                    images.Add(ResourcePacksStorage.ReadImageFromAsciiString(exportedImage.Width, exportedImage.Height, exportedImage.DataString));
                }
                return(images);
            }
            catch
            {
                return(images);
            }
        }