pub fn content_info(
    ui: &mut egui::Ui,
    dfu_file: &Option<dfufile::DfuFile>,
    device_info: Option<&dfudev::DeviceInfo>,
) {
    ui.group(|ui| {
        ui.set_width(ui.available_width());
        ui.set_height(ui.available_height());

        match dfu_file {
            Some(dfu_file) => match &dfu_file.content {
                dfufile::Content::Plain => {
                    ui.centered_and_justified(|ui| {
                        ui.label("Plain file. No details available.");
                    });
                }
                dfufile::Content::DfuSe(content) => {
                    ui.vertical(|ui| {
                        ui.heading("Images");
                        ui.add_space(5.0);
                        egui::Grid::new("file_content_info").show(ui, |ui| {
                            ui.label("ID");
                            ui.label("Name");
                            ui.label("Size");
                            ui.label("El.");
                            if device_info.is_some() {
                                ui.label("Target");
                            }
                            ui.end_row();

                            for image in &content.images {
                                ui.label(format!("{}", image.target_prefix.bAlternateSetting));
                                ui.label(match image.target_prefix.bTargetNamed {
                                    0 => "(unnamed)".to_string(),
                                    _ => image.target_prefix.szTargetName.to_string(),
                                });
                                ui.label(format!("{}", image.target_prefix.dwTargetSize));
                                ui.label(format!("{}", image.target_prefix.dwNbElements));
                                if let Some(device_info) = device_info {
                                    let target = device_info.alt_settings.iter().find(|&alt| {
                                        alt.0 == image.target_prefix.bAlternateSetting
                                    });
                                    if let Some(target) = target {
                                        ui.add(egui::Label::new(
                                            egui::RichText::new(&target.1)
                                                .color(egui::Color32::GREEN),
                                        ));
                                    } else {
                                        ui.add(egui::Label::new(
                                            egui::RichText::new("Not found")
                                                .color(egui::Color32::RED),
                                        ));
                                    }
                                }
                                ui.end_row();
                            }
                        });
                    });
                }
            },
            None => {
                ui.centered_and_justified(|ui| {
                    ui.label("No file selected");
                });
            }
        }
    });
}
/// Show box with file content information
Show box with file content information
Show box with file content information
pub fn content_info(
    ui: &mut egui::Ui,
    dfu_file: &Option<dfufile::DfuFile>,
    device_info: Option<&dfudev::DeviceInfo>,
) {
    ui.group(|ui| {
        ui.set_width(ui.available_width());
        ui.set_height(ui.available_height());
        match dfu_file {
            Some(dfu_file) => match &dfu_file.content {
                dfufile::Content::Plain => {
                    ui.centered_and_justified(|ui| {
                        ui.label("Plain file. No details available.");
                    });
                }
                dfufile::Content::DfuSe(content) => {
                    ui.vertical(|ui| {
                        ui.heading("Images");
                        ui.add_space(5.0);
                        egui::Grid::new("file_content_info").show(ui, |ui| {
                            ui.label("ID");
                            ui.label("Name");
                            ui.label("Size");
                            ui.label("El.");
                            if device_info.is_some() {
                                ui.label("Target");
                            }
                            ui.end_row();
                            for image in &content.images {
                                ui.label(format!("{}", image.target_prefix.bAlternateSetting));
                                ui.label(match image.target_prefix.bTargetNamed {
                                    0 => "(unnamed)".to_string(),
                                    _ => image.target_prefix.szTargetName.to_string(),
                                });
                                ui.label(format!("{}", image.target_prefix.dwTargetSize));
                                ui.label(format!("{}", image.target_prefix.dwNbElements));
                                if let Some(device_info) = device_info {
                                    let target = device_info.alt_settings.iter().find(|&alt| {
                                        alt.0 == image.target_prefix.bAlternateSetting
                                    });
                                    if let Some(target) = target {
                                        ui.add(egui::Label::new(
                                            egui::RichText::new(&target.1)
                                                .color(egui::Color32::GREEN),
                                        ));
                                    } else {
                                        ui.add(egui::Label::new(
                                            egui::RichText::new("Not found")
                                                .color(egui::Color32::RED),
                                        ));
                                    }
                                }
                                ui.end_row();
                            }
                        });
                    });
                }
            },
            None => {
                ui.centered_and_justified(|ui| {
                    ui.label("No file selected");
                });
            }
        }
    });
}
pub fn content_info ( ui : & mut egui :: Ui , dfu_file : & Option < dfufile :: DfuFile > , device_info : Option < & dfudev :: DeviceInfo > , ) { ui . group ( | ui | { ui . set_width ( ui . available_width ( ) ) ; ui . set_height ( ui . available_height ( ) ) ; match dfu_file { Some ( dfu_file ) => match & dfu_file . content { dfufile :: Content :: Plain => { ui . centered_and_justified ( | ui | { ui . label ( " " ) ; } ) ; } dfufile :: Content :: DfuSe ( content ) => { ui . vertical ( | ui | { ui . heading ( " " ) ; ui . add_space ( 5.0 ) ; egui :: Grid :: new ( " " ) . show ( ui , | ui | { ui . label ( " " ) ; ui . label ( " " ) ; ui . label ( " " ) ; ui . label ( " " ) ; if device_info . is_some ( ) { ui . label ( " " ) ; } ui . end_row ( ) ; for image in & content . images { ui . label ( format ! ( " " image target_prefix bAlternateSetting ) ) ; ui . label ( match image . target_prefix . bTargetNamed { 0 => " " . to_string ( ) , _ => image . target_prefix . szTargetName . to_string ( ) , } ) ; ui . label ( format ! ( " " image target_prefix dwTargetSize ) ) ; ui . label ( format ! ( " " image target_prefix dwNbElements ) ) ; if let Some ( device_info ) = device_info { let target = device_info . alt_settings . iter ( ) . find ( | & alt | { alt . 0 == image . target_prefix . bAlternateSetting } ) ; if let Some ( target ) = target { ui . add ( egui :: Label :: new ( egui :: RichText :: new ( & target . 1 ) . color ( egui :: Color32 :: GREEN ) , ) ) ; } else { ui . add ( egui :: Label :: new ( egui :: RichText :: new ( " " ) . color ( egui :: Color32 :: RED ) , ) ) ; } } ui . end_row ( ) ; } } ) ; } ) ; } } , None => { ui . centered_and_justified ( | ui | { ui . label ( " " ) ; } ) ; } } } ) ; }
Show box with file content information
Show box with file content information
ui
&mut egui::Ui
dfu_file
&Option<dfufile::DfuFile>
device_info
Option<&dfudev::DeviceInfo>