Ejemplo n.º 1
0
        private TileCanvas GetCanvas(BitmapImage imageSource, int targetWidth, int targetHeight)
        {
            int width  = imageSource.PixelWidth;
            int height = imageSource.PixelHeight;

            var canvas = new TileCanvas {
                Width = targetWidth, Height = targetHeight
            };

            for (int x = 0; x < targetWidth; x += width)
            {
                for (int y = 0; y < targetHeight; y += height)
                {
                    var image = new Image {
                        Source = imageSource
                    };
                    Canvas.SetLeft(image, x);
                    Canvas.SetTop(image, y);
                    canvas.Children.Add(image);
                }
            }
            canvas.Clip = new RectangleGeometry {
                Rect = new Rect(0, 0, targetWidth, targetHeight)
            };
            return(canvas);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Conect to a datastore and a canvas view
        /// </summary>
        public void SetConnections([NotNull] TileCanvas view, [NotNull] IStorageContainer storage)
        {
            _view    = view;
            _storage = storage;

            // Load pins (adding the default centre view)
            ThreadPool.QueueUserWorkItem(x => { ReloadPins(); });
        }
Ejemplo n.º 3
0
        //Initialise les modes de rendus des canvas
        private void Form1_Load(object sender, EventArgs e)
        {
            mapG  = MapCanvas.CreateGraphics();
            tileG = TileCanvas.CreateGraphics();
            mapG.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            mapG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            tileG.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            tileG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
        }
Ejemplo n.º 4
0
        private void UpdateServerClientRectangle()
        {
            var left = (double)TileCanvas.GetValue(Canvas.LeftProperty);
            var top  = (double)TileCanvas.GetValue(Canvas.TopProperty);

            _eventMediator.DispatchMessage(new UpdatePropertyMessage
            {
                TargetId     = ServerEntity.Identifier,
                PropertyName = "ClientRectangle",
                Value        = new Rectangle
                {
                    Left   = (int)left,
                    Top    = (int)top,
                    Width  = (int)(left + TileCanvas.ActualWidth),
                    Height = (int)(top + TileCanvas.ActualHeight)
                }
            });
        }
Ejemplo n.º 5
0
 public void SetCanvasTarget(TileCanvas canvas)
 {
     _canvas = canvas;
 }
Ejemplo n.º 6
0
 private void TileCanvas_MouseEnter(object sender, EventArgs e)
 {
     IsHovered = true;
     TileCanvas.Invalidate();
 }
Ejemplo n.º 7
0
 private void TileCanvas_MouseLeave(object sender, EventArgs e)
 {
     IsHovered = false;
     TileCanvas.Invalidate();
 }
Ejemplo n.º 8
0
        private Gtk.Widget CreateContents()
        {
            Gtk.HBox entryLine = new HBox(false, 4);

            Gtk.Label words = new Gtk.Label(Catalog.GetString("Search terms:"));
            entryLine.PackStart(words, false, false, 3);

            history = new Gtk.ListStore(new Type[] { typeof(string) });

            Gtk.EntryCompletion comp = new Gtk.EntryCompletion();
            comp.Model      = history;
            comp.TextColumn = 0;

            entry            = new Gtk.Entry("");
            entry.Activated += new EventHandler(this.DoSearch);
            entry.Completion = comp;
            entryLine.PackStart(entry, true, true, 3);

            words = new Gtk.Label("");
            entryLine.PackStart(words, false, false, 3);

            Gtk.ComboBox combo = FilterComboBox();
            combo.Changed += new EventHandler(this.ChangeType);
            entryLine.PackStart(combo, false, false, 3);

            Gtk.HBox   buttonContents = new HBox(false, 0);
            Gtk.Widget buttonImg      = Beagle.Images.GetWidget("icon-search.png");
            buttonContents.PackStart(buttonImg, false, false, 1);
            Gtk.Label buttonLabel = new Gtk.Label(Catalog.GetString("Find"));
            buttonContents.PackStart(buttonLabel, false, false, 1);

            Gtk.Button button = new Gtk.Button();
            button.Add(buttonContents);
            button.Clicked += new EventHandler(this.DoSearch);
            entryLine.PackStart(button, false, false, 3);

            Gtk.Button clearButton = new Gtk.Button();
            clearButton.Label    = "Clear";
            clearButton.Clicked += new EventHandler(this.ClearSearch);
            entryLine.PackStart(clearButton, false, false, 4);

            canvas = new TileCanvas();
            canvas.Show();

            HBox pager = new HBox();

            page_label = new Label();
            page_label.Show();
            pager.PackStart(page_label, false, false, 3);

            forward_button = StockButton("gtk-go-forward",
                                         Catalog.GetString("Show More Results"));
            forward_button.Show();
            forward_button.Clicked += new EventHandler(PageForwardHandler);
            pager.PackEnd(forward_button, false, false, 3);

            back_button = StockButton("gtk-go-back",
                                      Catalog.GetString("Show Previous Results"));
            back_button.Show();

            back_button.Clicked += new EventHandler(PageBackHandler);
            pager.PackEnd(back_button, false, false, 3);

            pager.Show();

            VBox contents = new VBox(false, 3);

            contents.PackStart(entryLine, false, true, 3);
            contents.PackStart(canvas, true, true, 3);
            contents.PackStart(pager, false, false, 3);

            entryLine.ShowAll();
            canvas.ShowAll();

            return(contents);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Start the canvas up with the default document
        /// </summary>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            // Set up pen/mouse/touch input
            var ip = baseInkCanvas?.InkPresenter;


            if (ip == null)
            {
                throw new Exception("Base ink presenter is missing");
            }
            if (paletteView == null)
            {
                throw new Exception("Palette object is missing");
            }
            if (pinsView == null)
            {
                throw new Exception("Palette object is missing");
            }

            ip.ActivateCustomDrying();

            if (ip.UnprocessedInput == null || ip.InputProcessingConfiguration == null || ip.InputConfiguration == null)
            {
                throw new Exception("Ink Presenter is malformed");
            }

            // These to get all the drawing and input directly
            ip.UnprocessedInput.PointerMoved    += UnprocessedInput_PointerMoved;
            ip.UnprocessedInput.PointerPressed  += UnprocessedInput_PointerPressed;
            ip.UnprocessedInput.PointerReleased += UnprocessedInput_PointerReleased;

            ip.InputProcessingConfiguration.Mode            = InkInputProcessingMode.None;
            ip.InputProcessingConfiguration.RightDragAction = InkInputRightDragAction.AllowProcessing;

            ip.InputConfiguration.IsEraserInputEnabled = true;
            ip.InputConfiguration.IsPrimaryBarrelButtonInputEnabled = true;

            ip.InputDeviceTypes = CoreInputDeviceTypes.Mouse /*| CoreInputDeviceTypes.Touch*/ | CoreInputDeviceTypes.Pen;
            ip.IsInputEnabled   = true;

            paletteView.Opacity = 0.0; // 1.0 is 100%, 0.0 is 0%
            pinsView.Opacity    = 0.0; // 1.0 is 100%, 0.0 is 0%

            var defaultFile = Path.Combine(ApplicationData.Current?.RoamingFolder?.Path, "default.slick");

            if (defaultFile == null)
            {
                throw new Exception("Failed to pick an initial page path");
            }
            _tileStore = Sync.Run(() => LoadTileStore(defaultFile));
            if (_tileStore == null)
            {
                throw new Exception("Failed to load initial page");
            }
            if (renderLayer == null)
            {
                throw new Exception("Invalid page structure (1)");
            }

            _tileCanvas = new TileCanvas(renderLayer, _tileStore);
            pinsView?.SetConnections(_tileCanvas, _tileStore);
            ImageImportFloater?.SetCanvasTarget(_tileCanvas);
            TextFloater?.SetCanvasTarget(_tileCanvas);

            _wetInk = new WetInkCanvas(wetInkCanvas ?? throw new Exception("Invalid page structure (2)"));

            _tileCanvas?.Invalidate();

            SetTitleBarString(Path.GetFileNameWithoutExtension(defaultFile));
        }
Ejemplo n.º 10
0
 private void OnDestroy()
 {
     _canvas = null;
 }
Ejemplo n.º 11
0
 private void OnEnable()
 {
     _canvas = this;
 }