Skip to content

Commit

Permalink
Merge pull request #18 from hnklp/debugging-verze
Browse files Browse the repository at this point in the history
Debugging verze
  • Loading branch information
hnklp authored Apr 25, 2024
2 parents 7569877 + 6dc94b7 commit 6786055
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 32 deletions.
24 changes: 24 additions & 0 deletions VerteMark/MainWindows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Windows.Media.Animation;
using System.Globalization;
using System.Windows.Controls.Primitives;
using System.Diagnostics;


namespace VerteMark {
Expand Down Expand Up @@ -59,6 +60,27 @@ public MainWindow() {
SetCanvasComponentsSize();
};
}
public MainWindow(bool debugging) {
InitializeComponent();
Debug.WriteLine($"Správný konstruktor zavolán.");
utility = new Utility();
utility.LoginUser("Debugger", true);
utility.DebugProjectStart();
CheckBoxes = new List<CheckBox>
{
CheckBox1, CheckBox2, CheckBox3, CheckBox4,
CheckBox5, CheckBox6, CheckBox7, CheckBox8
};
loggedInUser = utility.GetLoggedInUser();
InitializeCheckboxes();
UserIDStatus.Text = "ID: " + loggedInUser.UserID.ToString();
RoleStatus.Text = loggedInUser.Validator ? "v_status_str" : "a_status_str";
ImageHolder.Source = utility.GetOriginalPicture() ?? ImageHolder.Source; // Pokud og picture není null tak ho tam dosad
SwitchActiveAnot(0);
Loaded += delegate {
SetCanvasComponentsSize();
};
}

//dialog otevreni souboru s filtrem
//TODO odstranit moznost vsechny soubory??
Expand Down Expand Up @@ -355,5 +377,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
{
throw new NotImplementedException();
}


}
}
1 change: 1 addition & 0 deletions VerteMark/MainWindows/WelcomeWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</GridSplitter.Background>
</GridSplitter>
<Label x:Name ="UdajWarning" Content="" Foreground="Crimson" HorizontalAlignment="Left" Margin="612,0,0,0" VerticalAlignment="Center" FontSize="6"/>
<Button x:Name="debug_tlacitko" Content="&#x1f491;" HorizontalAlignment="Left" Margin="41,331,0,0" VerticalAlignment="Top" Height="27" Width="27" Click="DebugStart" IsEnabled="True" IsDefault="True" Cursor="Hand" FontFamily="Segoe UI Symbol"/>

</Grid>

Expand Down
14 changes: 14 additions & 0 deletions VerteMark/MainWindows/WelcomeWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,19 @@ private void SignInButton_Click(object sender, RoutedEventArgs e)

this.Close();
}

private void DebugStart(object sender, RoutedEventArgs e) {
// Check if the MainWindow is already open
var mainWindow = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();

if(mainWindow == null) {
// MainWindow is not open, so create and show it
mainWindow = new MainWindow(true);
mainWindow.Show();
}

// Close the MainWindow
this.Close();
}
}
}
41 changes: 39 additions & 2 deletions VerteMark/ObjectClasses/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
using VerteMark.ObjectClasses.FolderClasses;
using System.Diagnostics;
using System.Windows.Shell;
using System.Windows.Shapes;
using System.IO;
using FellowOakDicom.Imaging.Reconstruction;
using System.Reflection;

namespace VerteMark.ObjectClasses
{
Expand Down Expand Up @@ -42,6 +45,21 @@ public Project() {
jsonManip = new JsonManipulator();
}

public void DebugProjectStart() {
metadata = new Metadata();
CreateNewAnotaces();
// folderUtilityManager.CreateNewProject(path);
string assemblyDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string projectDirectory = Directory.GetParent(assemblyDirectory).Parent.Parent.FullName;
string relativeImagePath = System.IO.Path.Combine("Pictures", "CapyJedi.png");
string imagePath = System.IO.Path.Combine(projectDirectory, relativeImagePath);
if(File.Exists(imagePath)) {
// Load the image and set it as the source for your image control
BitmapImage bitmap = new BitmapImage(new Uri(imagePath));
originalPicture = bitmap;
}
}


// SLOUZI POUZE PRO ZIP FILE
// ZALOZENI SLOZKY TEMP V BEHOVEM PROSTREDI
Expand Down Expand Up @@ -213,7 +231,7 @@ public List<string> ChooseValidation()

public void Choose(string path, string projectType)
{
string newPath = Path.Combine(folderUtilityManager.tempPath, projectType, path);
string newPath = System.IO.Path.Combine(folderUtilityManager.tempPath, projectType, path);
if (projectType == "dicoms")
{
Debug.WriteLine(newPath);
Expand All @@ -226,5 +244,24 @@ public void Choose(string path, string projectType)

originalPicture = folderUtilityManager.GetImage();
}
BitmapImage DebugLoadBitmap(string imagePath) {
BitmapImage bitmap = new BitmapImage();
try {
// Create a FileStream to read the image file
using(FileStream stream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) {
// Set the bitmap image source to the FileStream
bitmap.BeginInit();
bitmap.CacheOption = BitmapCacheOption.OnLoad; // Load the image immediately
bitmap.StreamSource = stream;
bitmap.EndInit();
}
} catch(Exception ex) {
// Handle any exceptions that may occur during image loading
Debug.WriteLine($"Error loading image: {ex.Message}");
bitmap = null;
}
Debug.WriteLine("Image loaded as bitmap succesfuly");
return bitmap;
}
}
}
63 changes: 33 additions & 30 deletions VerteMark/ObjectClasses/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,43 @@ public void Choose(string path, string projectType)
project.Choose(path, projectType);
}

/*
public void SaveBitmapToFile(BitmapSource bitmap, SaveFileDialog saveFileDialog)
{
// Create a SaveFileDialog to prompt the user for file save location
// Show the dialog and get the result
if (saveFileDialog.ShowDialog() == true)
public void DebugProjectStart() {
project.DebugProjectStart();
}
/*
public void SaveBitmapToFile(BitmapSource bitmap, SaveFileDialog saveFileDialog)
{
// Create a BitmapEncoder based on the selected file format
BitmapEncoder encoder = null;
switch (System.IO.Path.GetExtension(saveFileDialog.FileName).ToUpper())
// Create a SaveFileDialog to prompt the user for file save location
// Show the dialog and get the result
if (saveFileDialog.ShowDialog() == true)
{
case ".PNG":
encoder = new PngBitmapEncoder();
break;
case ".JPG":
encoder = new JpegBitmapEncoder();
break;
case ".BMP":
encoder = new BmpBitmapEncoder();
break;
default:
// Unsupported file format
return;
}
// Create a BitmapEncoder based on the selected file format
BitmapEncoder encoder = null;
switch (System.IO.Path.GetExtension(saveFileDialog.FileName).ToUpper())
{
case ".PNG":
encoder = new PngBitmapEncoder();
break;
case ".JPG":
encoder = new JpegBitmapEncoder();
break;
case ".BMP":
encoder = new BmpBitmapEncoder();
break;
default:
// Unsupported file format
return;
}
// Encode and save the bitmap to the selected file path
encoder.Frames.Add(BitmapFrame.Create(bitmap));
using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create))
{
encoder.Save(stream);
// Encode and save the bitmap to the selected file path
encoder.Frames.Add(BitmapFrame.Create(bitmap));
using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create))
{
encoder.Save(stream);
}
}
}
}*/
}*/


}
}
}
Binary file added VerteMark/Pictures/CapyJedi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6786055

Please sign in to comment.