Exemplo n.º 1
0
        public void SnapPoint(ref Point p, out double snapAngle)
        {
            var cv = CanvasView.GetCanvasView(this);

            if (cv == null)
            {
                snapAngle = 0; return;
            }

            Point myPos = cv.ElementFromControl(this).GetPositionAttributes();

            Vector v = p - myPos;

            if (v.LengthSquared == 0)
            {
                p         = myPos + new Vector(Diameter / 2, 0);
                snapAngle = 0;
            }
            else
            {
                v.Normalize();

                p         = myPos + v * Diameter / 2;
                snapAngle = v.GetAngularCoordinate();
            }
        }
Exemplo n.º 2
0
        private void CheckValue(float valueToSet, float valueToCheck, string value)
        {
            if (valueToSet < valueToCheck && (Math.Abs(valueToSet - valueToCheck) > 0.3))
            {
                valueToSet = valueToCheck;
                var action = value == "Y" ? ActionType.Right : ActionType.Down;

                if (_level.PlayerTile.CanMakeAction(action, _level.Width, _level.Height))
                {
                    _level.PlayerTile.MakeAction(action);
                    _level.CheckPlayerTileCollision(action);
                }
                Console.WriteLine($"Accelerometer down/left {value}: Ok {valueToSet}:: {Math.Abs(valueToSet - valueToCheck)}");
            }

            if (valueToSet > valueToCheck && (Math.Abs(valueToSet - valueToCheck) > 0.3))
            {
                valueToSet = valueToCheck;
                var action = value == "Y" ? ActionType.Left : ActionType.Up;
                if (_level.PlayerTile.CanMakeAction(action, _level.Width, _level.Height))
                {
                    _level.PlayerTile.MakeAction(action);
                    _level.CheckPlayerTileCollision(action);
                }

                Console.WriteLine($"Accelerometer up/rigth {value}: Ok {valueToSet}:: {Math.Abs(valueToSet - valueToCheck)}");
            }
            CanvasView.InvalidateSurface();
        }
Exemplo n.º 3
0
 private void CanvasMouseLeftUp(object sender, MouseButtonEventArgs e)
 {
     if (mapImages.Count > 0)
     {
         CanvasView.ReleaseMouseCapture();
     }
 }
Exemplo n.º 4
0
 private void OnCanvasViewPan(object sender, PanUpdatedEventArgs e)
 {
     a.X = (float)e.TotalX;
     a.Y = (float)e.TotalY;
     CalcPointsXY();
     CanvasView.InvalidateSurface();
 }
        private void HookModel()
        {
            if (_model == null)
            {
                return;
            }
            _model.LoadCompleted             += (sender, e) => _loadProgressDialogDecorator.Hide();
            _model.EnumratePedestriansFailed += (sender, e) =>
            {
                using (Toast errorToast = Toast.MakeText(Application.BaseContext, Resources.GetString(Resource.String.FailedToEnumratePedestrians), ToastLength.Short))
                    errorToast.Show();
                _loadProgressDialogDecorator.Hide();
            };
            //LinearLayout mapLayout = FindViewById<LinearLayout>(Resource.Id.mapLayout);
            //((IAndroidMapService)_model.Map.MapService).VisualizeMap(this, mapLayout);
            View map = FindViewById <View>(Resource.Id.map);

            ((IAndroidMapService)_model.Map.MapService).HookMap(map);
            CanvasView           driverProfileView    = FindViewById <CanvasView>(Resource.Id.driverProfileView);
            DriverProfileAdapter driverProfileAdapter = new DriverProfileAdapter(this, _model);

            driverProfileView.LayoutChange += (sender, e) => driverProfileAdapter.UpdatePedestrianInfoPopups();
            driverProfileView.Adapter       = driverProfileAdapter;
            _loadProgressDialogDecorator.Show();
            _model.BeginLoad();
        }
Exemplo n.º 6
0
 private void DispatcherTimer_Tick(object sender, object e)
 {
     //CanvasView.PaintSurface += CanvasView_PaintSurface;
     CanvasView.Invalidate();
     //CanvasView.PaintSurface += CanvasView_PaintSurface;
     //System.Diagnostics.Debug.WriteLine("TICK");
 }
        public void OnChangeRenderer(CanvasView canvasView, Renderer newRenderer)
        {
            if (defaultMaterials != null)
            {
                ResetMaterialsToDefault(renderer);
            }

            renderer     = newRenderer;
            previousMesh = null;

            if (newRenderer != null)
            {
                if (!(newRenderer is SkinnedMeshRenderer ||
                      newRenderer is MeshRenderer))
                {
                    EditorUtility.DisplayDialog(
                        string.Empty,
                        $"Support {nameof(SkinnedMeshRenderer)}, {nameof(MeshRenderer)}.",
                        "OK");
                    renderer = null;
                    return;
                }

                Initialize(canvasView);
            }
            else
            {
                canvasView.InitializeDrawArea();
            }
        }
Exemplo n.º 8
0
 private void CanvasView_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     KeyboardNavigation.SetControlTabNavigation(this, KeyboardNavigationMode.None);
     CanvasView.Focusable = true;
     CanvasView.Focus();
     Keyboard.Focus(CanvasView);
 }
Exemplo n.º 9
0
    void Awake()
    {
        DontDestroyOnLoad(this.gameObject);
        _instance   = this;
        CanvasRoot  = transform;
        graphic     = CanvasRoot.GetComponent <GraphicRaycaster>();
        canvas      = CanvasRoot.GetComponent <Canvas>();
        uicamera    = CanvasRoot.Find("Camera").GetComponent <Camera>();
        canvasRect  = CanvasRoot.GetComponent <RectTransform>();
        loading     = CanvasRoot.Find("Loading").gameObject;
        loading_cur = loading.transform.Find("loading_cur").GetComponent <Image>();
        loading_txt = loading.transform.Find("loading_txt").GetComponent <Text>();

        notice     = this.transform.Find("Notice").gameObject;
        notice_pop = notice.GetComponent <PopTextMgr>();
        //JsonMgr.GetSingleton();

#if UNITY_EDITOR
        if (EnableDebugUILine)
        {
            this.gameObject.AddComponent <DebugUILine>();
        }
#endif

        //调整分辨率
        float designAspect = designWidth / designHeight;
        float aspect       = Screen.width / Screen.height;
        this.GetComponent <CanvasScaler>().matchWidthOrHeight = (aspect > designAspect ? 1 : 0);
    }
Exemplo n.º 10
0
        public void load_bitmap(string url, int key)
        {
            Uri        uri     = new Uri(url);
            WebRequest request = WebRequest.Create(uri);

            request.BeginGetResponse((IAsyncResult arg) =>
            {
                try
                {
                    using (Stream stream = request.EndGetResponse(arg).GetResponseStream())
                        using (MemoryStream memStream = new MemoryStream())
                        {
                            stream.CopyTo(memStream);
                            memStream.Seek(0, SeekOrigin.Begin);

                            using (SKManagedStream skStream = new SKManagedStream(memStream))
                            {
                                hours_weatherstatusthumb.AddOrUpdate(key, SKBitmap.Decode(skStream), (k, v) => v);
                                Device.BeginInvokeOnMainThread(() => CanvasView.InvalidateSurface());
                            }
                        }
                }
                catch
                {
                }
            }, null);
        }
Exemplo n.º 11
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            CanvasView.PaintSurface += CanvasView_PaintSurface;
            var pan  = new NSPanGestureRecognizer(MapPanned);
            var zoom = new NSMagnificationGestureRecognizer(MapZoomed);

            _screenScale = (float)NSScreen.MainScreen.BackingScaleFactor;
            _canvasSize  = new SKSize(20000, 2000);

            CanvasView.AddGestureRecognizer(zoom);
            CanvasView.AddGestureRecognizer(pan);

            //load images
            for (int i = 1; i < 16; i++)
            {
                var img = await ImageService.Instance.LoadFileFromApplicationBundle("img/img" + i + ".jpg").AsNSImageAsync();

                var sizeRandom = rand.NextDouble() * (1.2 - 0.2) + 0.2;
                var size       = new SKSize((float)(img.Size.Width * sizeRandom), (float)(img.Size.Height * sizeRandom));
                var rect       = SKRect.Empty;
                rect.Size = size;
                var pointRandomW = rand.NextDouble() * (_canvasSize.Width - 0) + 0;
                var pointRandomH = rand.NextDouble() * (_canvasSize.Height - 0) + 0;

                rect.Location = new SKPoint((float)pointRandomW, (float)pointRandomH);
                rects.Add(rect);
                imgs.Add(img.ToSKImage());
            }
        }
Exemplo n.º 12
0
        private object convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string shape = value as string;

            // Convert invalid shapeID into invalid snap target
            if (shape == null || shape == string.Empty || this.ReferenceControl == null)
            {
                return(null);
            }

            // Find canvas view through reference on this converter
            CanvasView cv = CanvasView.GetCanvasView(this.ReferenceControl);

            // No canvas view found
            if (cv == null)
            {
                return(null);
            }

            // Get references element from viewmodel
            ShapeViewModelBase e = cv.CanvasViewModel.DocumentViewModel.dm_DocumentDataModel.GetShapeById(shape);

            // Use CanvasView to find canvas object in vicinity
            return(cv.ControlFromElement(e));
        }
Exemplo n.º 13
0
        public void Reset()
        {
            _rotatedDegrees = 0;

            Matrix = SKMatrix.CreateIdentity();

            CanvasView?.InvalidateSurface();
        }
 private void OnEnable()
 {
     canvasView    = CreateInstance <CanvasView>();
     toolView      = CreateInstance <ToolView>();
     model         = new MeshDeleterWithTextureModel();
     localizedText = new LocalizedText();
     ChangeLanguage(localizedText.SelectedLanguage);
 }
Exemplo n.º 15
0
        private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            SKPoint point = new SKPoint((float)(CanvasView.CanvasSize.Width * args.Location.X / CanvasView.Width),
                                        (float)(CanvasView.CanvasSize.Height * args.Location.Y / CanvasView.Height));

            CanvasView.InvalidateSurface();
            WasTouched(this, false); //Might need to change boolean in the future
        }
Exemplo n.º 16
0
 public MapPage(int lvl = 0)
 {
     InitializeComponent();
     LvlNumber = lvl;
     SetupSensor();
     CanvasView.PaintSurface += CanvasViewLoadMap_OnPaintSurface;
     CanvasView.InvalidateSurface();
 }
Exemplo n.º 17
0
 public PhaseDisplayAdapter NewPhaseAdapter(CanvasView view, HorizontalAxisView horizontalAxisView,
                                            VerticalAxisView verticalAxisView, TextBox tbX, TextBox tbDelta)
 {
     return(new PhaseDisplayAdapter(view, horizontalAxisView, verticalAxisView, tbX, tbDelta,
                                    GeneralConfigurations.Get().DispPoints,
                                    SamplingConfigurations.Get().SamplingRate, 0,
                                    (int)Math.Round(SamplingConfigurations.Get().SamplingRateInMHz / 2)));
 }
Exemplo n.º 18
0
 public SpectrumDisplayAdapter NewSpectrumAdapter(CanvasView view, HorizontalAxisView horizontalAxisView,
                                                  VerticalAxisView verticalAxisView, TextBox tbX, TextBox tbDelta, double?dipLockFreq, double lockDipScanRadius)
 {
     return(new SpectrumDisplayAdapter(view, horizontalAxisView, verticalAxisView, tbX, tbDelta,
                                       GeneralConfigurations.Get().DispPoints,
                                       SamplingConfigurations.Get().SamplingRate, 0,
                                       (int)Math.Round(SamplingConfigurations.Get().SamplingRateInMHz / 2), dipLockFreq, lockDipScanRadius));
 }
Exemplo n.º 19
0
        private void GraphGUI_Load(object sender, EventArgs e)
        {
            var canvas = new CanvasModel(10);

            _canvasController = new CanvasController(canvas);
            _canvasView       = new CanvasView(drawPanel.CreateGraphics(), canvas, drawPanel.BackColor, debugOutput);
            _canvasView.Render();
        }
 public void OnChangeMaterial(CanvasView canvasView)
 {
     if (defaultMaterials != null)
     {
         ResetMaterialsToDefault(renderer);
         canvasView.InitializeDrawArea(matInfos[materialInfoIndex], renderer);
     }
 }
Exemplo n.º 21
0
        private void CoerceLater()
        {
            CanvasView cv = CanvasView.GetCanvasView(this);

            if (cv != null)
            {
                cv.NotifyOnLayoutUpdated(this.CoerceCoordinates);
            }
        }
        public void OnDeleteMeshButtonClicked(CanvasView canvasView)
        {
            ResetMaterialsToDefault(renderer);

            var deletePos         = canvasView.GetDeleteData();
            var hadDeletedSubMesh = DeleteMesh(renderer, deletePos, matInfos[materialInfoIndex]);

            Initialize(canvasView, hadDeletedSubMesh);
        }
Exemplo n.º 23
0
        private void OnPointerWheelChanged(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            const float zoomFactor        = 1.1f;
            var         wheelDelta        = e.GetCurrentPoint(CanvasView).Properties.MouseWheelDelta;
            float       currentZoomFactor = wheelDelta > 0 ? zoomFactor : 1 / zoomFactor;

            _scene.ZoomByScaleFactor(_scene.GetCenter(), currentZoomFactor);
            CanvasView.Invalidate();
        }
Exemplo n.º 24
0
        public override void Load()
        {
            Engine.Canvas.StretchMode = CanvasStretchMode.LetterBox;

            left_view  = Engine.Canvas.CreateView();
            right_view = Engine.Canvas.CreateView();

            left_view.Viewport  = RectF.FromBox(0f, 0f, 0.495f, 1f);
            right_view.Viewport = RectF.FromBox(0.5f, 0f, 0.5f, 1f);

            left_view.SizeFactor  = new Vec2(0.5f, 1.0f);
            right_view.SizeFactor = new Vec2(0.5f, 1.0f);

            texture = Engine.Content.Get <Texture2D>("party");
            bg_tile = Engine.Content.Get <Texture2D>("purple_tile");

            bg_tile.Tiled = true;

            int canvas_w = Engine.Canvas.Width;
            int canvas_h = Engine.Canvas.Height;

            quad = new Quad(texture);

            quad.V0.X = canvas_w / 2 - texture.Width / 2;
            quad.V0.Y = canvas_h / 2 - texture.Height / 2;
            quad.V1.X = quad.V0.X + texture.Width;
            quad.V1.Y = quad.V0.Y;
            quad.V2.X = quad.V1.X;
            quad.V2.Y = quad.V0.Y + texture.Height;
            quad.V3.X = quad.V0.X;
            quad.V3.Y = quad.V2.Y;

            bg_quad = new Quad();

            bg_quad.V0.X   = 0;
            bg_quad.V0.Y   = 0;
            bg_quad.V0.Col = 0xFFFFFFFF;
            bg_quad.V1.X   = canvas_w;
            bg_quad.V1.Y   = 0;
            bg_quad.V1.Col = 0xFFFFFFFF;
            bg_quad.V2.X   = canvas_w;
            bg_quad.V2.Y   = canvas_h;
            bg_quad.V2.Col = 0xFFFFFFFF;
            bg_quad.V3.X   = 0;
            bg_quad.V3.Y   = canvas_h;
            bg_quad.V3.Col = 0xFFFFFFFF;

            bg_quad.V0.Tx = 0;
            bg_quad.V0.Ty = 0;
            bg_quad.V1.Tx = canvas_w / 64f;
            bg_quad.V1.Ty = 0;
            bg_quad.V2.Tx = canvas_w / 64f;
            bg_quad.V2.Ty = canvas_h / 64f;
            bg_quad.V3.Tx = 0;
            bg_quad.V3.Ty = canvas_h / 64f;
        }
Exemplo n.º 25
0
        public void Rotate90(bool left)
        {
            float degree = left ? -90 : 90;

            _rotatedDegrees += degree;

            Matrix = Matrix.PostConcat(SKMatrix.CreateRotationDegrees(degree));

            CanvasView?.InvalidateSurface();
        }
Exemplo n.º 26
0
 private void CanvasMouseLeftDown(object sender, MouseButtonEventArgs e)
 {
     if (mapImages.Count > 0)
     {
         var tt = TranslateTransform;
         start  = e.GetPosition(CanvasView);
         origin = new Point(tt.X, tt.Y);
         CanvasView.CaptureMouse();
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// Adds a layout handler call to the list of layout update handlers
        /// to MoveTo the Left, Top position when a layout update occurs.
        /// </summary>
        private void CoerceLater()
        {
            CanvasView cv = CanvasView.GetCanvasView(this);

            // Coearce coordinates when the associated layout changes
            if (cv != null)
            {
                cv.NotifyOnLayoutUpdated(this.CoerceCoordinates);
            }
        }
        private void InitAnimation()
        {
            pageIsActive = true;

            Device.StartTimer(TimeSpan.FromSeconds(1.0 / 30), () => {
                CanvasView.InvalidateSurface();

                return(pageIsActive);
            });
        }
Exemplo n.º 29
0
        public void ReRender()
        {
            if (horoscopeCanvas.Subviews.Count() > 0)
            {
                horoscopeCanvas.Subviews[0].RemoveFromSuperview();
            }
            CanvasView sk = new CanvasView(new CGRect(0, 0, 580, 580));

            sk.PaintSurface += CanvasPaint;
            horoscopeCanvas.AddSubview(sk);
        }
        public void RevertMeshToPreviously(CanvasView canvasView)
        {
            ResetMaterialsToDefault(renderer);

            RendererUtility.SetMesh(renderer, previousMesh);
            previousMesh             = null;
            renderer.sharedMaterials = previousMaterials;
            previousMaterials        = null;

            Initialize(canvasView, false);
        }
Exemplo n.º 31
0
    public Sample()
    {
        XML gui = new XML (null, "gui.glade", "main", null);
        gui.Autoconnect (this);

        canvas = new Dia.Canvas();
        canvas.AllowUndo = true;
        view = new CanvasView (canvas, true);
        scrolledwindow.Add (view);

        SetupTools();
        CreateItemsProgramatically();
        main.ShowAll();
    }
Exemplo n.º 32
0
 void MoveItem(CanvasView view, Gdk.EventButton evnt, CanvasItem item)
 {
     double wx, wy;
     view.WindowToWorld (evnt.X, evnt.Y, out wx, out wy);
     item.Move (wx, wy);
 }
Exemplo n.º 33
0
        void GrabHandle(CanvasView view, Gdk.EventButton evnt, CanvasItem item)
        {
            if (item is CanvasLine) {
                /*
                  wx, wy = view.window_to_world(event.x, event.y)
                  dist, glue, glue_to = view.canvas.glue_handle (first, wx, wy)
                  if glue_to and (dist <= view.handle_layer.glue_distance):
                  glue_to.connect_handle(first)
                  view.handle_layer.grab_handle(last)
                */

                Handle first = null;
                Handle last = null;
                bool started = true;
                foreach (Handle handle in item.Handles) {
                    if (started)
                        first = handle;
                    else
                        last = handle;

                    started = false;
                }
                view.HandleLayer.GrabHandle (first);

            } else if (item is CanvasElement) {
                Handle handle_se = null;

                int counter = 0;
                foreach (Handle handle in item.Handles) {
                    if (counter++ != (int)CanvasElementHandle.Se) {
                        continue;
                    }
                    handle_se = handle;
                }

                view.HandleLayer.GrabHandle (handle_se);
            }
        }