</ItemGroup>\r
<ItemGroup>\r
<Compile Include="Properties\AssemblyInfo.cs" />\r
- <Compile Include="psychlops\core\app\Class1.cs" />\r
+ <Compile Include="psychlops\core\app\misc.cs" />\r
<Compile Include="psychlops\core\device\hid.cs" />\r
<Compile Include="psychlops\core\graphic\canvas.cs" />\r
<Compile Include="psychlops\core\graphic\font.cs" />\r
+++ /dev/null
-\r
-\r
-namespace Psychlops\r
-{\r
-\r
-\r
- public static class Main\r
- {\r
- public delegate void func();\r
- public static Drawable drawable;\r
- }\r
-\r
-\r
-}\r
--- /dev/null
+namespace Psychlops\r
+{\r
+\r
+ public static class Main\r
+ {\r
+ public static Drawable drawable;\r
+ }\r
+}\r
\r
public class Canvas : Drawable\r
{\r
- public static System.Windows.Controls.Image default_buffer_frame;\r
+ //public static System.Windows.Controls.Image default_buffer_frame;\r
public static System.Windows.Controls.UserControl default_panel;\r
public static System.Windows.Controls.Canvas default_api_canvas;\r
public static WriteableBitmap default_buffer;\r
- System.Windows.Controls.Image instance;\r
+ //WriteableBitmap buffer;\r
+ //System.Windows.Controls.Image instance;\r
System.Windows.Controls.Canvas api_canvas;\r
System.Windows.Controls.UserControl panel;\r
- WriteableBitmap buffer;\r
System.Windows.Shapes.Rectangle back_panel;\r
System.Windows.Media.SolidColorBrush back_panel_color;\r
\r
{\r
panel = default_panel;\r
api_canvas = default_api_canvas;\r
- instance = default_buffer_frame;\r
+ //instance = default_buffer_frame;\r
initialize(wid, hei);\r
}\r
- public Canvas(int wid, int hei, System.Windows.Controls.Image target, System.Windows.Controls.Canvas apicnvs, System.Windows.Controls.UserControl system)\r
+ public Canvas(int wid, int hei, System.Windows.Controls.Canvas apicnvs, System.Windows.Controls.UserControl system)\r
{\r
panel = system;\r
api_canvas = apicnvs;\r
- instance = target;\r
+ //instance = target;\r
initialize(wid, hei);\r
}\r
protected void initialize(int wid, int hei)\r
{\r
- instance.Width = wid;\r
- instance.Height = hei;\r
- instance.Source = buffer;\r
+ //instance.Width = wid;\r
+ //instance.Height = hei;\r
+ //instance.Source = buffer;\r
+ //buffer = new WriteableBitmap((int)instance.Width, (int)instance.Height);\r
+ //default_buffer = buffer;\r
api_canvas.Width = wid;\r
api_canvas.Height = hei;\r
- buffer = new WriteableBitmap((int)instance.Width, (int)instance.Height);\r
api_canvas.MouseMove += Mouse.Canvas_MousePos;\r
api_canvas.MouseLeftButtonDown += Mouse.Canvas_LDown;\r
api_canvas.MouseLeftButtonUp += Mouse.Canvas_LUp;\r
panel.KeyUp += Keyboard.Canvas_KeyUp;\r
Mouse._prime = api_canvas;\r
Main.drawable = this;\r
- default_buffer = buffer;\r
\r
back_panel = new System.Windows.Shapes.Rectangle();\r
back_panel.Width = wid;\r
}\r
public Point getCenter()\r
{\r
- return new Point(instance.Width/2.0, instance.Height/2.0, 0);\r
+ return new Point(api_canvas.Width / 2.0, api_canvas.Height / 2.0, 0);\r
}\r
\r
public void clear()\r
{\r
- buffer.Clear(Color.black);\r
+ //buffer.Clear(Color.black);\r
+ clear(Color.black);\r
}\r
public void clear(Color col)\r
{\r
\r
public void pix(int x, int y, Color col)\r
{\r
- buffer.SetPixel(x, y, col);\r
+ //buffer.SetPixel(x, y, col);\r
}\r
\r
+ #region static initializer\r
+ /*\r
static System.Windows.Shapes.Line api_line;\r
static System.Windows.Shapes.Path api_curve;\r
static System.Windows.Shapes.Rectangle api_rect;\r
static System.Windows.Media.SolidColorBrush api_fill;\r
static System.Windows.Media.SolidColorBrush api_stroke;\r
static System.Windows.Media.TranslateTransform api_translation;\r
+ */\r
protected static System.Collections.Generic.Dictionary<int, System.Windows.FontWeight> FONT_WEIGHT_BRIDGE;\r
protected static System.Collections.Generic.Dictionary<Font.Style, System.Windows.FontStyle> FONT_STYLE_BRIDGE;\r
protected static System.Collections.Generic.Dictionary<Letters.HorizontalAlign, TextAlignment> LETTERS_H_ALIGN_BRIDGE;\r
LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.TEXT_ALIGN_RIGHT, TextAlignment.Right);\r
LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.NOT_SPECIFIED, TextAlignment.Left);\r
\r
+ /*\r
api_line = new System.Windows.Shapes.Line();\r
api_curve = new System.Windows.Shapes.Path();\r
api_rect = new System.Windows.Shapes.Rectangle();\r
api_fill = new System.Windows.Media.SolidColorBrush();\r
api_stroke = new System.Windows.Media.SolidColorBrush();\r
api_translation = new System.Windows.Media.TranslateTransform();\r
+ */\r
}\r
+ #endregion\r
\r
public void line(Line drawee, Color col)\r
{\r
public void var<Type>(Type val, double x, double y, Color col) { msg(val.ToString(), x, y, col); }\r
\r
\r
- public int frame;\r
public void flip()\r
{\r
- buffer.Invalidate();\r
- frame++;\r
+ //buffer.Invalidate();\r
}\r
\r
public double width { get { return api_canvas.Width; } }\r
public double height { get { return api_canvas.Height; } }\r
- }\r
\r
+ }\r
\r
}
\ No newline at end of file
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" \r
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" \r
- mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" x:Name="LayoutMain">\r
- <Canvas x:Name="LayoutRoot">\r
- <Image x:Name="main_buffer" Width="640" Height="480"/>\r
- </Canvas>\r
+ mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">\r
+ <StackPanel x:Name="TotalRoot" HorizontalAlignment="Center" VerticalAlignment="Center">\r
+ <Canvas x:Name="LayoutRoot"></Canvas>\r
+ <!--<Image x:Name="main_buffer" Width="640" Height="480"/>-->\r
+ </StackPanel>\r
</UserControl>\r
{\r
public partial class MainPage : System.Windows.Controls.UserControl\r
{\r
- public System.ComponentModel.BackgroundWorker main_routine;\r
+ System.Collections.Generic.IEnumerator<int> main_routine;\r
public System.Windows.Controls.Image master;\r
public PsychlopsMain main;\r
+#if DEBUG\r
+ public System.Windows.Controls.TextBlock DebugConsole;\r
+#endif\r
public MainPage()\r
{\r
InitializeComponent();\r
// Show fps counter\r
- Canvas.default_buffer_frame = main_buffer;\r
+ //Canvas.default_buffer_frame = main_buffer;\r
Canvas.default_api_canvas = LayoutRoot;\r
Canvas.default_panel = this;\r
this.IsTabStop = true;\r
//main_routine.DoWork += new System.ComponentModel.DoWorkEventHandler(psychlops_main);\r
//main_routine.RunWorkerAsync();\r
\r
- \r
main = new PsychlopsMain();\r
- main.initialize();\r
+ //main.initialize();\r
+ //main_routine = new System.Threading.Thread(ThreadTest2);\r
+ //main_routine.Start();\r
+ main_routine = main.psychlops_main();\r
+#if DEBUG\r
+ DebugConsole = new System.Windows.Controls.TextBlock();\r
+ TotalRoot.Children.Add(DebugConsole);\r
+#endif\r
}\r
- protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e)\r
- {\r
+ protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) {\r
this.Focus();\r
}\r
- int background;\r
- private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs args)\r
- {\r
- while (true)\r
- {\r
- System.Threading.Thread.Sleep(10);\r
- background++;\r
- }\r
- }\r
\r
- int frame;\r
+ int nextIntervalFrame = 1;\r
private void CompositionTarget_Rendering(object sender, System.EventArgs e)\r
{\r
- frame++;\r
- //Canvas.default_buffer.Invalidate();\r
- main.each_frames();\r
+ nextIntervalFrame--;\r
+ if (nextIntervalFrame<=0)\r
+ {\r
+ main_routine.MoveNext();\r
+ nextIntervalFrame = main_routine.Current;\r
+ }\r
}\r
\r
- /*\r
- Canvas cnvs;\r
- Rectangle[] rects;\r
- double tfreq = 1;\r
-\r
- public void initialize()\r
- {\r
- cnvs = new Canvas(500, 500, image, this);\r
- rects = new Rectangle[100];\r
- for (int i = 0; i < rects.Length; i++) { rects[i] = new Rectangle(10,10); }\r
- cnvs.clear(Color.gray);\r
- }\r
- public void trial()\r
- {\r
- cnvs.clear(new Color(Mouse.left.pressed() ? 1.0 : 0.5));\r
- foreach (Rectangle rect in rects) { rect.centering().shift(background,0).draw(); }\r
- cnvs.flip();\r
- }\r
- */\r
}\r
}\r
\r
Color col;\r
int isize = 100;\r
double tfreq = 1;\r
+ int frames;\r
\r
- public void initialize()\r
+ public System.Collections.Generic.IEnumerator<int> psychlops_main()\r
{\r
cnvs = new Canvas(500, 500);\r
img = new Image(isize * 2, isize * 2);\r
var poly = new Letters("日本語");\r
shape = poly;\r
cnvs.clear(Color.gray);\r
- }\r
\r
- public void each_frames()\r
- {\r
- cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.25));\r
- col.set(Math.random(1.0));\r
+ while(true) {\r
+ frames++;\r
+ \r
+ cnvs.clear(new Color(Mouse.left.pressed() ? 0.75 : 0.25));\r
+ col.set(Math.random(1.0));\r
\r
- fixation.centering();\r
- fixation.draw(Color.red);\r
+ fixation.centering();\r
+ fixation.draw(Color.red);\r
\r
- Figures.drawGabor(ref img, 20, 10, 1, 0, cnvs.frame * 2.0 * Math.PI / tfreq / 60);\r
- //Figures.drawGaussian(ref img, 20, 1);\r
- //Figures.drawGrating(10, 1, 2, cnvs.frame * 2.0 * Math.PI / tfreq / 60);\r
- img.centering(Mouse.position);\r
- img.draw();\r
+ Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
+ //Figures.drawGaussian(ref img, 20, 1);\r
+ //Figures.drawGrating(10, 1, 2, cnvs.frame * 2.0 * Math.PI / tfreq / 60);\r
+ img.centering(Mouse.position);\r
+ img.draw();\r
\r
- shape.centering(Mouse.position);\r
- shape.draw(Color.red);\r
- if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
+ shape.centering(Mouse.position);\r
+ shape.draw(Color.red);\r
+ if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
\r
- cnvs.flip();\r
+ cnvs.var(frames, 10, 20);\r
+\r
+ yield return 3;\r
+ }\r
}\r
}\r
+\r
}\r