Exemplo n.º 1
0
        public CanvasWindowGestureView(GestureParser gestureParser)
        {
            _gestureParser = gestureParser;
            RegisterEventHandlers();

            //提前申请一次内存,避免开始画手势时延迟
            //_bitmap = new DiBitmap(_screenBounds.Size);
            //_bitmap = null;

            new Thread(() =>
            {
                _canvasWindow = new CanvasWindow()
                {
                    //最初的时候放在屏幕以外
                    Visible     = false,
                    IgnoreInput = true,
                    NoActivate  = true,
                    TopMost     = true
                };
                _canvasWindow.ShowDialog();
            })
            {
                Name = "CanvasWindow线程"
            }.Start();

            Thread.Sleep(50);

            InitDefaultProperties();

            _fadeOuTimer.Elapsed += OnFadeOutTimerElapsed;

            SystemEvents.DisplaySettingsChanged += SystemDisplaySettingsChanged;
        }
Exemplo n.º 2
0
        public void Execute(object parameter)
        {
            var canvasWindow = new CanvasWindow(new Dyysh.Image.CaptureGDI());

            canvasWindow.Show();
            canvasWindow.Activate();
        }
        public CanvasWindowGestureView(GestureParser gestureParser)
        {
            _gestureParser = gestureParser;
            RegisterEventHandlers();
            var waitCanvasWindow = new AutoResetEvent(false);

            new Thread(() =>
            {
                _canvasWindow = new CanvasWindow()
                {
                    //最初的时候放在屏幕以外
                    Visible     = false,
                    IgnoreInput = true,
                    NoActivate  = true,
                    TopMost     = true
                };
                waitCanvasWindow.Set();
                _canvasWindow.ShowDialog();
            })
            {
                Name = "CanvasWindow"
            }.Start();

            waitCanvasWindow.WaitOne();

            InitDefaultProperties();
            _fadeOuTimer.Elapsed += OnFadeOutTimerElapsed;
            SystemEvents.DisplaySettingsChanged += SystemDisplaySettingsChanged;
        }
Exemplo n.º 4
0
        public Runtime(CanvasWindow window, Canvas canvas, int noiseSeed)
        {
            this.window = window;
            this.canvas = canvas;

            perlinNoise = new PerlinNoise(noiseSeed);
            rng         = new SecureRandom();
        }
Exemplo n.º 5
0
        public REPL(Canvas canvas, CanvasWindow window)
        {
            this.canvas = canvas;
            this.window = window;
            runtime     = new Runtime(window, canvas, 99);
            vm          = new VirtualMachine();

            Run();
        }
Exemplo n.º 6
0
        public REPL(int width, int height, string title)
        {
            canvas  = new Canvas(width, height);
            window  = new CanvasWindow(canvas, title);
            runtime = new Runtime(window, canvas, 99);
            vm      = new VirtualMachine();

            Run();
        }
Exemplo n.º 7
0
        public PlainViewer(Canvas canvas, CanvasWindow window)
        {
            this.canvas = canvas;
            this.window = window;
            runtime     = new Runtime(window, canvas, 99);
            vm          = new VirtualMachine();

            window.Load += OnLoad;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Draw an image
        /// </summary>
        /// <param name="c"></param>
        /// <param name="user"></param>
        /// <param name="b"></param>
        public static void DrawImage(CanvasWindow c, CanvasWindow user, String b)
        {
            BitmapImage newImage = new BitmapImage();

            newImage.BeginInit();
            newImage.UriSource = new Uri(b);
            newImage.EndInit();
            c.Background    = System.Windows.Media.Brushes.White;
            user.Background = System.Windows.Media.Brushes.White;

            double W, H;

            if (newImage.Width <= c.canvas.Width && newImage.Height <= c.canvas.Height)
            {
                W = newImage.Width;
                H = newImage.Height;
            }
            else if (newImage.Width > c.canvas.Width && newImage.Height <= c.canvas.Height)
            {
                H = (newImage.Height * c.canvas.Width) / newImage.Width;
                W = c.canvas.Width;
            }
            else if (newImage.Width <= c.canvas.Width && newImage.Height > c.canvas.Height)
            {
                W = (newImage.Width * c.canvas.Height) / newImage.Height;
                H = c.canvas.Height;
            }
            else
            {
                double widthR  = (double)c.canvas.Width / (double)newImage.Width;
                double heightR = (double)c.canvas.Height / (double)newImage.Height;

                if (widthR < heightR)
                {
                    H = (newImage.Height * c.canvas.Width) / newImage.Width;
                    W = c.canvas.Width;
                }
                else
                {
                    W = (newImage.Width * c.canvas.Height) / newImage.Height;
                    H = c.canvas.Height;
                }
            }

            c.image.Source = newImage;
            //c.image.StretchDirection = StretchDirection.DownOnly;
            c.image.Width  = W;
            c.image.Height = H;

            double ratio = user.canvas.Height / c.canvas.Height;

            user.image.Source = newImage;
            //user.image.StretchDirection = StretchDirection.DownOnly;
            user.image.Width  = W * ratio;
            user.image.Height = H * ratio;
        }
Exemplo n.º 9
0
 /// <summary>
 /// opens a new canvas screen
 /// </summary>
 private void showCanvas()
 {
     if (canvas == null)
     {
         canvas = new CanvasWindow();
         subscribeToCanvasHandler();
     }
     canvas.Show();
     alignScreens();
 }
Exemplo n.º 10
0
 /// <summary>
 /// closes current canvas screen
 /// </summary>
 private void closeCanvas()
 {
     if (canvas != null)
     {
         canvas.Hide();
         unsubscribeToCanvasHandler();
         canvas.Close();
         canvas = null;
     }
 }
Exemplo n.º 11
0
		public PintaCanvas (CanvasWindow window, Document document)
		{
            CanvasWindow = window;
            this.document = document;

			cr = new CanvasRenderer (true);
			
			// Keep the widget the same size as the canvas
            document.Workspace.CanvasSizeChanged += delegate (object sender, EventArgs e) {
                SetRequisition (document.Workspace.CanvasSize);
			};

			// Update the canvas when the image changes
            document.Workspace.CanvasInvalidated += delegate (object sender, CanvasInvalidatedEventArgs e) {
                // If GTK+ hasn't created the canvas window yet, no need to invalidate it
                if (GdkWindow == null)
                    return;

				if (e.EntireSurface)
					GdkWindow.Invalidate ();
				else
					GdkWindow.InvalidateRect (e.Rectangle, false);
			};

			// Give mouse press events to the current tool
			ButtonPressEvent += delegate (object sender, ButtonPressEventArgs e) {
                // The canvas gets the button press before the tab system, so
                // if this click is on a canvas that isn't currently the ActiveDocument yet, 
                // we need to go ahead and make it the active document for the tools
                // to use it, even though right after this the tab system would have switched it
                if (PintaCore.Workspace.ActiveDocument != document)
                    PintaCore.Workspace.SetActiveDocument (document);

                PintaCore.Tools.CurrentTool.DoMouseDown (this, e, document.Workspace.WindowPointToCanvas (e.Event.X, e.Event.Y));
			};

			// Give mouse release events to the current tool
			ButtonReleaseEvent += delegate (object sender, ButtonReleaseEventArgs e) {
                PintaCore.Tools.CurrentTool.DoMouseUp (this, e, document.Workspace.WindowPointToCanvas (e.Event.X, e.Event.Y));
			};

			// Give mouse move events to the current tool
			MotionNotifyEvent += delegate (object sender, MotionNotifyEventArgs e) {
                var point = document.Workspace.WindowPointToCanvas (e.Event.X, e.Event.Y);

                if (document.Workspace.PointInCanvas (point))
					PintaCore.Chrome.LastCanvasCursorPoint = point.ToGdkPoint ();

				if (PintaCore.Tools.CurrentTool != null)
					PintaCore.Tools.CurrentTool.DoMouseMove ((DrawingArea)sender, e, point);
			};
		}
Exemplo n.º 12
0
        public static void Main(string[] args)
        {
            //SplashScreen splashScreen = new SplashScreen("safe_image.gif");
            //splashScreen.Show(false);

            //Program app = new Program();
            //app.MainWind  ow = new DockPanelWindow();
            //app.MainWindow.ShowDialog();

            // 和上面结果一样
            var app     = new Application();
            var windows = new CanvasWindow();

            app.Run(windows);
        }
Exemplo n.º 13
0
        public ObjManager()
        {
            Globals.PassWindow = AddWindow;
            offset             = Vector2.Zero;

            Window canvasWindow = new CanvasWindow(new Vector2(50, 50), new Vector2(400, 400));

            Globals.canvas = new Canvas(canvasWindow, new Vector2(20, 35), new Vector2(200, 200));
            //add windows
            Globals.PassWindow(new TimelineWindow(new Vector2(500, 350), new Vector2(400, 200)));
            Globals.PassWindow(new PlaybackWindow(new Vector2(50, 500), new Vector2(300, 200)));
            Globals.PassWindow(new ColorPickerWindow(new Vector2(500, 50), new Vector2(400, 280)));
            Globals.PassWindow(new ToolsWindow(new Vector2(500, 500), new Vector2(200, 200)));
            //Globals.PassWindow(new TestWindow(new Vector2(50, 50), new Vector2(300, 200)));
            Globals.PassWindow(canvasWindow);
            menu = new Menu(Vector2.Zero, new Vector2(1000, 24));
        }
Exemplo n.º 14
0
        public UIController(Boolean demoMode, String GBTISAASADDRESS, String AUTHKEY)
        {
            this.AUTHKEY       = AUTHKEY;
            client.BaseAddress = new Uri(GBTISAASADDRESS);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            names = new List <string>();
            namesInit();
            //How GBTIS operates
            this.demoMode = demoMode;
            canWave       = false;

            //TESTING PURPOSES
            names = new List <String>();

            //Making the kinect Controller
            kinect = Kinect.getInstance();
            kinectHandler();

            //Starting and showing the admin window
            admin = new AdminWindow();
            //Starting and showing the admin window only if its normal mode
            if (!demoMode)
            {
                adminHandler();
                admin.Show();
            }
            else
            {
                //Demomode will close in 3 min due to inactivity
                timeoutTimerInit();
                kinect.ModeEnd += resetTimeoutTimer;
            }

            //Starting the standby window
            showStandby();

            //Starting the canvas screen
            canvas = null;
        }
Exemplo n.º 15
0
 private void StartCanvasWindow()
 {
     CanvasWindow canvas = new CanvasWindow();
     if (Screen.AllScreens.Length > 1) {
         int mainScreen = Screen.AllScreens.Length == 2 ? 1 : 0;
         Screen s2 = Screen.AllScreens[mainScreen];
         System.Drawing.Rectangle r2 = s2.Bounds;
         canvas.Top = r2.Top;
         canvas.Left = r2.Left;
         canvas.Show();
         canvas.WindowStyle = WindowStyle.None;
         canvas.WindowState = WindowState.Maximized;
         canvas.Topmost = true;
     }
     else {
         Screen s1 = Screen.AllScreens[0];
         System.Drawing.Rectangle r1 = s1.WorkingArea;
         canvas.Top = r1.Top;
         canvas.Left = r1.Left;
         canvas.Show();
     }
 }
Exemplo n.º 16
0
        public PlainViewer(string sourceFile, string title)
        {
            canvas  = new Canvas(512, 512);
            window  = new CanvasWindow(canvas, title);
            runtime = new Runtime(window, canvas, 99);
            vm      = new VirtualMachine();

            if (File.Exists(sourceFile))
            {
                source = File.ReadAllText(sourceFile);
            }
            else
            {
                Program.MessageBox(IntPtr.Zero, "The given source code file(" + sourceFile + " could not be found.", "Error!", 0);
                return;
            }

            window.Load += OnLoad;
            window.Run(1 / 60.0);

            window.Dispose();
            canvas.Dispose();
            runtime.Dispose();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Draw an image
        /// </summary>
        /// <param name="c"></param>
        /// <param name="user"></param>
        /// <param name="b"></param>
        public static void DrawImage(CanvasWindow c, CanvasWindow user, String b)
        {
            BitmapImage newImage = new BitmapImage();
            newImage.BeginInit();
            newImage.UriSource = new Uri(b);
            newImage.EndInit();
            c.Background = System.Windows.Media.Brushes.White;
            user.Background = System.Windows.Media.Brushes.White;

            double W, H;

            if (newImage.Width <= c.canvas.Width && newImage.Height <= c.canvas.Height)
            {
                W = newImage.Width;
                H = newImage.Height;
            }
            else if (newImage.Width > c.canvas.Width && newImage.Height <= c.canvas.Height)
            {
                H = (newImage.Height * c.canvas.Width) / newImage.Width;
                W = c.canvas.Width;
            }
            else if (newImage.Width <= c.canvas.Width && newImage.Height > c.canvas.Height)
            {
                W = (newImage.Width * c.canvas.Height) / newImage.Height;
                H = c.canvas.Height;
            }
            else
            {
                double widthR = (double)c.canvas.Width / (double)newImage.Width;
                double heightR = (double)c.canvas.Height / (double)newImage.Height;

                if (widthR < heightR)
                {
                    H = (newImage.Height * c.canvas.Width) / newImage.Width;
                    W = c.canvas.Width;
                }
                else
                {
                    W = (newImage.Width * c.canvas.Height) / newImage.Height;
                    H = c.canvas.Height;
                }
            }

            c.image.Source = newImage;
            //c.image.StretchDirection = StretchDirection.DownOnly;
            c.image.Width = W;
            c.image.Height = H;

            double ratio = user.canvas.Height / c.canvas.Height;

            user.image.Source = newImage;
            //user.image.StretchDirection = StretchDirection.DownOnly;
            user.image.Width = W * ratio;
            user.image.Height = H * ratio;
        }
Exemplo n.º 18
0
        public PintaCanvas(CanvasWindow window, Document document)
        {
            CanvasWindow  = window;
            this.document = document;

            cr = new CanvasRenderer(true);

            // Keep the widget the same size as the canvas
            document.Workspace.CanvasSizeChanged += delegate(object?sender, EventArgs e) {
                SetRequisition(document.Workspace.CanvasSize);
            };

            // Update the canvas when the image changes
            document.Workspace.CanvasInvalidated += delegate(object?sender, CanvasInvalidatedEventArgs e) {
                // If GTK+ hasn't created the canvas window yet, no need to invalidate it
                if (Window == null)
                {
                    return;
                }

                if (e.EntireSurface)
                {
                    Window.Invalidate();
                }
                else
                {
                    Window.InvalidateRect(e.Rectangle, false);
                }
            };

            // Give mouse press events to the current tool
            ButtonPressEvent += delegate(object sender, ButtonPressEventArgs e) {
                // The canvas gets the button press before the tab system, so
                // if this click is on a canvas that isn't currently the ActiveDocument yet,
                // we need to go ahead and make it the active document for the tools
                // to use it, even though right after this the tab system would have switched it
                if (PintaCore.Workspace.ActiveDocument != document)
                {
                    PintaCore.Workspace.SetActiveDocument(document);
                }

                PintaCore.Tools.DoMouseDown(document, e);
            };

            // Give mouse release events to the current tool
            ButtonReleaseEvent += delegate(object sender, ButtonReleaseEventArgs e) {
                PintaCore.Tools.DoMouseUp(document, e);
            };

            // Give mouse move events to the current tool
            MotionNotifyEvent += delegate(object sender, MotionNotifyEventArgs e) {
                var point = document.Workspace.WindowPointToCanvas(e.Event.X, e.Event.Y);

                if (document.Workspace.PointInCanvas(point))
                {
                    PintaCore.Chrome.LastCanvasCursorPoint = point.ToGdkPoint();
                }

                if (PintaCore.Tools.CurrentTool != null)
                {
                    PintaCore.Tools.DoMouseMove(document, e);
                }
            };
        }
Exemplo n.º 19
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            #region unregistor events
            _gestureParser.IntentRecognized     -= HandleIntentRecognized;
            _gestureParser.IntentInvalid        -= HandleIntentInvalid;
            _gestureParser.IntentOrPathCanceled -= HandleIntentOrPathCanceled;

            _gestureParser.PathTracker.PathStart          -= HandlePathStart;
            _gestureParser.PathTracker.PathGrow           -= HandlePathGrow;
            _gestureParser.PathTracker.PathTimeout        -= HandlePathTimeout;
            _gestureParser.IntentReadyToExecute           -= HandleIntentReadyToExecute;
            _gestureParser.IntentReadyToExecuteOnModifier -= HandleIntentReadyToExecuteOnModifier;

            _gestureParser.GestureCaptured     -= HandleGestureRecorded;
            _gestureParser.CommandReportStatus -= HandleCommandReportStatus;

            #endregion

            #region dispose pens
            _mainPen.Dispose();
            _middleBtnPen.Dispose();
            _borderPen.Dispose();
            _alternativePen.Dispose();

            foreach (var p in _shadowPens)
            {
                p.Dispose();
            }
            _shadowPens = null;


            _dirtyMarkerPen.Dispose();
            #endregion

            if (_canvasBuf != null)
            {
                _canvasBuf.Dispose();
                _canvasBuf = null;
            }
            if (_canvasWindow != null)
            {
                _canvasWindow.Dispose();
                _canvasWindow = null;
            }
            if (_gPath != null)
            {
                _gPath.Dispose();
                _gPath = null;
            }
            if (_gPathDirty != null)
            {
                _gPathDirty.Dispose();
                _gPathDirty = null;
            }

            if (_labelPath != null)
            {
                _labelPath.Dispose();
                _labelPath = null;
            }
            if (_labelFont != null)
            {
                _labelFont.Dispose();
                _labelFont = null;
            }

            if (_fadeOuTimer != null)
            {
                _fadeOuTimer.Elapsed -= OnFadeOutTimerElapsed;
                _fadeOuTimer.Dispose();
                _fadeOuTimer = null;
            }

            SystemEvents.DisplaySettingsChanged -= SystemDisplaySettingsChanged;


            Debug.WriteLine("Dispose");
            IsDisposed = true;
        }
Exemplo n.º 20
0
 public static void SetCanvasWindow(CanvasWindow window)
 {
     canvasWindow = window;
 }
Exemplo n.º 21
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            #region unregistor events
            _gestureParser.IntentRecognized     -= WhenIntentRecognized;
            _gestureParser.IntentInvalid        -= WhenIntentInvalid;
            _gestureParser.IntentExecuted       -= WhenIntentExecuted;
            _gestureParser.IntentOrPathCanceled -= WhenIntentOrPathCanceled;

            _gestureParser.PathTracker.PathStart          -= WhenPathStart;
            _gestureParser.PathTracker.PathGrow           -= WhenPathGrow;
            _gestureParser.PathTracker.PathTimeout        -= WhenPathTimeout;
            _gestureParser.IntentReadyToExecute           -= WhenIntentReadyToExecute;
            _gestureParser.IntentReadyToExecuteOnModifier -= WhenIntentReadyToExecuteOnModifier;



            _gestureParser.GestureCaptured -= WhenGestureCaptured;
            #endregion

            #region dispose pens
            _mainPen.Dispose();
            _middleBtnPen.Dispose();
            _borderPen.Dispose();
            _alternativePen.Dispose();
            _shadowPen.Dispose();
            #endregion

            if (_bitmap != null)
            {
                _bitmap.Dispose();
                _bitmap = null;
            }
            if (_canvasWindow != null)
            {
                _canvasWindow.Dispose();
                _canvasWindow = null;
            }
            if (_gPath != null)
            {
                _gPath.Dispose();
                _gPath = null;
            }
            if (_pathDirtyRegion != null)
            {
                _pathDirtyRegion.Dispose();
                _pathDirtyRegion = null;
            }

            if (_labelPath != null)
            {
                _labelPath.Dispose();
                _labelPath = null;
            }
            if (_labelFont != null)
            {
                _labelFont.Dispose();
                _labelFont = null;
            }

            if (_fadeOuTimer != null)
            {
                _fadeOuTimer.Elapsed -= OnFadeOutTimerElapsed;
                _fadeOuTimer.Dispose();
                _fadeOuTimer = null;
            }

            SystemEvents.DisplaySettingsChanged -= SystemDisplaySettingsChanged;


            Debug.WriteLine("Dispose");
            IsDisposed = true;
        }
Exemplo n.º 22
0
        public void subItemClick(string type)
        {
            Vector2 defaultSize = new Vector2(300, 250);
            Vector2 defaultPos  = new Vector2(Globals.screenWidth / 2, Globals.screenHeight / 2) - new Vector2(defaultSize.X / 2, defaultSize.Y / 2);

            if (subItemNames[1].Contains(type) && ObjManager.Windows.Find(x => x.GetType().Name == type + "Window") != null)    //the window already exists
            {
                Window tempWindow = ObjManager.Windows.Find(x => x.GetType().Name == type + "Window");
                if (tempWindow.docked)
                {
                    return;
                }
                tempWindow.pos = defaultPos;
                tempWindow.dim = defaultSize;
                return;
            }

            switch (type)   //the window doesn't already exist / a different submenu item was clicked
            {
            case "Save":
                ObjManager.createGif();
                break;

            case "Canvas":
                CanvasWindow cw = new CanvasWindow(defaultPos, defaultSize);
                Globals.canvas.window = cw;
                Globals.PassWindow(cw);
                break;

            case "Tools":
                Globals.PassWindow(new ToolsWindow(defaultPos, defaultSize));
                break;

            case "Timeline":
                Globals.PassWindow(new TimelineWindow(defaultPos, defaultSize));
                break;

            case "ColorPicker":
                Globals.PassWindow(new ColorPickerWindow(defaultPos, defaultSize));
                break;

            case "Playback":
                Globals.PassWindow(new PlaybackWindow(defaultPos, defaultSize));
                break;

            case "New":
                Globals.PassWindow(new NewWindow());
                break;

            case "GitHub":
                var psi = new ProcessStartInfo
                {
                    FileName        = "https://github.com/RustingRobot/Kolibri",
                    UseShellExecute = true
                };
                Process.Start(psi);
                break;

            default:
                break;
            }
        }