fork download
  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.  
  15. namespace WpfApplication1
  16. {
  17. /// <summary>
  18. /// MainWindow.xaml の相互作用ロジック
  19. /// </summary>
  20. public partial class MainWindow : Window
  21. {
  22. bool _leftIsDragging;
  23. bool _rightIsDragging;
  24. bool _middleIsDragging;
  25. Point _leftDragOffset;
  26. Point _rightDragOffset;
  27. Point _middleDragOffset;
  28.  
  29. TranslateTransform _pan;
  30. ScaleTransform _zoom;
  31. RotateTransform _turn;
  32.  
  33. public MainWindow()
  34. {
  35. InitializeComponent();
  36.  
  37. _pan = new TranslateTransform();
  38. _zoom = new ScaleTransform();
  39. _turn = new RotateTransform();
  40.  
  41. TransformGroup tGroup = new TransformGroup();
  42. tGroup.Children.Add(_zoom);
  43. tGroup.Children.Add(_turn);
  44. tGroup.Children.Add(_pan);
  45. controlTarget.RenderTransform = tGroup;
  46.  
  47. controlTarget.MouseDown += new MouseButtonEventHandler(controlTarget_MouseDown);
  48. controlTarget.MouseMove += new MouseEventHandler(controlTarget_MouseMove);
  49. controlTarget.MouseUp += new MouseButtonEventHandler(controlTarget_MouseUp);
  50.  
  51. this.KeyDown += new KeyEventHandler(MainWindow_KeyDown);
  52. }
  53.  
  54. void MainWindow_KeyDown(object sender, KeyEventArgs e)
  55. {
  56. if (e.Key == Key.Escape)
  57. {
  58. _pan.X = 0;
  59. _pan.Y = 0;
  60. _zoom.ScaleX = 1;
  61. _zoom.ScaleY = 1;
  62. _zoom.CenterX = 0;
  63. _zoom.CenterY = 0;
  64. }
  65. }
  66.  
  67. void controlTarget_MouseDown(object sender, MouseButtonEventArgs e)
  68. {
  69. if (e.ChangedButton == MouseButton.Left)
  70. {
  71. var s = sender as UIElement;
  72. s.CaptureMouse();
  73. _leftDragOffset = e.GetPosition(this);
  74. _leftIsDragging = true;
  75. }
  76. if (e.ChangedButton == MouseButton.Right)
  77. {
  78. var s = sender as UIElement;
  79. s.CaptureMouse();
  80. _rightDragOffset = e.GetPosition(this);
  81. _rightIsDragging = true;
  82. Point center = e.GetPosition(s);
  83. _zoom.CenterX = center.X;
  84. _zoom.CenterY = center.Y;
  85. }
  86. }
  87.  
  88. void controlTarget_MouseMove(object sender, MouseEventArgs e)
  89. {
  90. if (_leftIsDragging)
  91. {
  92. var s = sender as UIElement;
  93. Point p = e.GetPosition(this);
  94. _pan.X += p.X - _leftDragOffset.X;
  95. _pan.Y += p.Y - _leftDragOffset.Y;
  96. _leftDragOffset = p;
  97. }
  98. if (_rightIsDragging)
  99. {
  100. var s = sender as UIElement;
  101. Point p = e.GetPosition(this);
  102. double delta = (_rightDragOffset.Y - p.Y) * 0.01;
  103. _zoom.ScaleX += delta;
  104. _zoom.ScaleY += delta;
  105. _rightDragOffset = p;
  106. }
  107. }
  108.  
  109. void controlTarget_MouseUp(object sender, MouseButtonEventArgs e)
  110. {
  111. if (e.ChangedButton == MouseButton.Left)
  112. {
  113. var s = sender as UIElement;
  114. s.ReleaseMouseCapture();
  115. _leftIsDragging = false;
  116. }
  117. if (e.ChangedButton == MouseButton.Right)
  118. {
  119. var s = sender as UIElement;
  120. s.ReleaseMouseCapture();
  121. _rightIsDragging = false;
  122. }
  123. }
  124. }
  125. }
  126.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1: error: expected nested-name-specifier before ‘System’
prog.cpp:1: error: ‘System’ has not been declared
prog.cpp:2: error: expected nested-name-specifier before ‘System’
prog.cpp:2: error: ‘System’ has not been declared
prog.cpp:2: error: expected `;' before ‘.’ token
prog.cpp:2: error: expected unqualified-id before ‘.’ token
prog.cpp:3: error: expected nested-name-specifier before ‘System’
prog.cpp:3: error: ‘System’ has not been declared
prog.cpp:3: error: expected `;' before ‘.’ token
prog.cpp:3: error: expected unqualified-id before ‘.’ token
prog.cpp:4: error: expected nested-name-specifier before ‘System’
prog.cpp:4: error: ‘System’ has not been declared
prog.cpp:4: error: expected `;' before ‘.’ token
prog.cpp:4: error: expected unqualified-id before ‘.’ token
prog.cpp:5: error: expected nested-name-specifier before ‘System’
prog.cpp:5: error: ‘System’ has not been declared
prog.cpp:5: error: expected `;' before ‘.’ token
prog.cpp:5: error: expected unqualified-id before ‘.’ token
prog.cpp:6: error: expected nested-name-specifier before ‘System’
prog.cpp:6: error: ‘System’ has not been declared
prog.cpp:6: error: expected `;' before ‘.’ token
prog.cpp:6: error: expected unqualified-id before ‘.’ token
prog.cpp:7: error: expected nested-name-specifier before ‘System’
prog.cpp:7: error: ‘System’ has not been declared
prog.cpp:7: error: expected `;' before ‘.’ token
prog.cpp:7: error: expected unqualified-id before ‘.’ token
prog.cpp:8: error: expected nested-name-specifier before ‘System’
prog.cpp:8: error: ‘System’ has not been declared
prog.cpp:8: error: expected `;' before ‘.’ token
prog.cpp:8: error: expected unqualified-id before ‘.’ token
prog.cpp:9: error: expected nested-name-specifier before ‘System’
prog.cpp:9: error: ‘System’ has not been declared
prog.cpp:9: error: expected `;' before ‘.’ token
prog.cpp:9: error: expected unqualified-id before ‘.’ token
prog.cpp:10: error: expected nested-name-specifier before ‘System’
prog.cpp:10: error: ‘System’ has not been declared
prog.cpp:10: error: expected `;' before ‘.’ token
prog.cpp:10: error: expected unqualified-id before ‘.’ token
prog.cpp:11: error: expected nested-name-specifier before ‘System’
prog.cpp:11: error: ‘System’ has not been declared
prog.cpp:11: error: expected `;' before ‘.’ token
prog.cpp:11: error: expected unqualified-id before ‘.’ token
prog.cpp:12: error: expected nested-name-specifier before ‘System’
prog.cpp:12: error: ‘System’ has not been declared
prog.cpp:12: error: expected `;' before ‘.’ token
prog.cpp:12: error: expected unqualified-id before ‘.’ token
prog.cpp:13: error: expected nested-name-specifier before ‘System’
prog.cpp:13: error: ‘System’ has not been declared
prog.cpp:13: error: expected `;' before ‘.’ token
prog.cpp:13: error: expected unqualified-id before ‘.’ token
prog.cpp:20: error: expected unqualified-id before ‘public’
prog.cpp:125: error: expected `}' at end of input
stdout
Standard output is empty