PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/NerdSharp.Net_Studio/NerdSharp_UberNet/Science/Comp_Sci/StudioComponents/SideComponents/Desktop.xaml.cs

https://bitbucket.org/pastageek/scide-cad-scilife
C# | 108 lines | 88 code | 11 blank | 9 comment | 3 complexity | 8cf5263b23e8326baca2bcb26110c5e4 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using O = System.Windows.Forms.OpenFileDialog;
  15. using Stm = System.IO.Stream;
  16. using System.IO;
  17. using NerdSharp.Net_Studio.NerdSharp_UberNet.Science.Math.TypeLibrary.Graphs_ChartsWidgets;
  18. namespace NerdSharp.Net_Studio.NerdSharp_UberNet.Science.Comp_Sci.StudioComponents.SideComponents
  19. {
  20. /// <summary>
  21. /// Interaction logic for Desktop.xaml
  22. /// </summary>
  23. public partial class Desktop : UserControl
  24. {
  25. public Desktop()
  26. {
  27. InitializeComponent();
  28. }
  29. private void changeImageMenuItemLable_MouseDown(object sender, MouseButtonEventArgs e)
  30. {
  31. O openImgFile = new O();
  32. if (openImgFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  33. {
  34. try
  35. {
  36. bgImg.Source = new BitmapImage(new Uri(@openImgFile.FileName));
  37. }
  38. catch (IOException ex)
  39. {
  40. MessageBox.Show("Unable to obtain picture.");
  41. }
  42. catch (Exception ex)
  43. {
  44. MessageBox.Show(ex.ToString());
  45. }
  46. }
  47. }
  48. private void floorPolygon_Loaded(object sender, RoutedEventArgs e)
  49. {
  50. RenderRoom();
  51. }
  52. private void AddPoints()
  53. {
  54. floorPolygon.Points.Clear();
  55. for (int i = 0; i < 4; i++)
  56. {
  57. floorPolygon.Points.Add(new Point(0, 0));
  58. leftWallPolyGon.Points.Add(new Point(0, 0));
  59. }
  60. }
  61. private void RenderRoom()
  62. {
  63. AddPoints();
  64. //lower left corner
  65. floorPolygon.Points[0] = new Point(0, this.ActualHeight);
  66. //upper lett corner
  67. floorPolygon.Points[1] = new Point(this.ActualWidth / 3.5, this.ActualHeight / 3.5);
  68. //upper right corner
  69. floorPolygon.Points[2] = new Point(this.ActualWidth / 1.5, this.ActualHeight / 3.5);
  70. //lower right corner
  71. floorPolygon.Points[3] = new Point(this.ActualWidth, this.ActualHeight);
  72. //TwoDGraph graphTest = new TwoDGraph();
  73. leftWallPolyGon.Points[1] = new Point(this.ActualWidth / 3.5, this.ActualHeight / 5);
  74. leftWallPolyGon.Points[2] = floorPolygon.Points[2];
  75. leftWallPolyGon.Points[3] = floorPolygon.Points[3];
  76. leftWallPolyGon.Stroke = floorPolygon.Stroke;
  77. leftWallPolyGon.StrokeThickness = floorPolygon.StrokeThickness;
  78. //desktopGrid.Children.Add(graphTest);
  79. }
  80. private void desktopGrid_SizeChanged(object sender, SizeChangedEventArgs e)
  81. {
  82. RenderRoom();
  83. }
  84. private void browser_Click(object sender, RoutedEventArgs e)
  85. {
  86. desktopGrid.Children.Add(new VirtualWindow());
  87. }
  88. private void tilePictureCmBxItem_Selected(object sender, RoutedEventArgs e)
  89. {
  90. floorBgVisBrush.TileMode = TileMode.Tile;
  91. }
  92. private void tileTextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  93. {
  94. floorBgVisBrush.TileMode = TileMode.Tile;
  95. }
  96. }
  97. }