Exemplo n.º 1
0
        private void addLayerToListIfNotNull(ref List <LayerInformation> list, Panel panel)
        {
            LayerSourceType?type = null;

            foreach (RadioButton button in panel.Children.OfType <RadioButton>())
            {
                if (button.IsChecked == true)
                {
                    type = (LayerSourceType)button.Tag;
                }
            }

            if (type.HasValue == true)
            {
                LayerInformation layerSourceInformation = new LayerInformation();
                layerSourceInformation.type = type.Value;

                if (layerSourceInformation.type == LayerSourceType.File)
                {
                    IEnumerable <Grid> grids = panel.Children.OfType <Grid>();
                    layerSourceInformation.filePath = grids.First <Grid>().Tag.ToString();
                }
                else
                {
                    IEnumerable <TextBox> textBoxes = panel.Children.OfType <TextBox>();
                    layerSourceInformation.text = textBoxes.First <TextBox>().Text;
                }

                list.Add(layerSourceInformation);
            }
        }
        private bool encodeLSBBMP()
        {
            bool result = false;

            BmpFileHeaders bmpFileHeaders = FileFormatHelpers.readBmpFileHeaders(this.fileBytes);

            LSBEncodeDialog lSBEncodeDialog = new LSBEncodeDialog();

            if (lSBEncodeDialog.ShowDialog() == true)
            {
                EncodeQueryResult encodeQueryResult = lSBEncodeDialog.getResult();

                byte[] sourceByteArray = FileFormatHelpers.convertLayerToByteArray(encodeQueryResult.layers[encodeQueryResult.layers.Count - 1]);

                for (int index = (encodeQueryResult.layers.Count - 1); index >= 0; index--)
                {
                    if (index == 0)
                    {
                        FileFormatHelpers.encodeDataIntoFileBytesBmp(
                            ref bmpFileHeaders,
                            ref sourceByteArray,
                            ref this.fileBytes
                            );
                    }
                    else
                    {
                        LayerInformation layerTargetInformation = encodeQueryResult.layers[index - 1];
                        sourceByteArray = FileFormatHelpers.encodeDataIntoLayersFileBytes(
                            ref sourceByteArray,
                            layerTargetInformation
                            );
                    }

                    encodeQueryResult.layers.RemoveAt(index);
                }

                result = true;
            }

            return(result);
        }