Exemplo n.º 1
0
 public static FloatingElement CreateFloatingElement(string title, Point position, Size size, object modelInstance)
 {
   var fe = new FloatingElement
          {
            ModelInstance = modelInstance,
            OpacityDragging = 0.5,
            OpacityNormal = 1.0,
            CanMove = true,
            CanRotate = true,
            CanScale = true,
            StartOrientation = 0,
            AllowStream = true,
            Background = AppStateSettings.Instance.AccentBrush,
            MinSize = size,
            MaxSize = new Size(1500, 1500),
            StartPosition = position,
            StartSize = size,
            ShowsActivationEffects = false,
            RemoveOnEdge = true,
            Contained = true,
            Title = title,
            Foreground = Brushes.White,
            RotateWithFinger = AppStateSettings.Instance.Config.GetBool("Layout.Floating.RotateWithFinger", true),
            DockingStyle = DockingStyles.None,
          };
   return fe;
 }
Exemplo n.º 2
0
    public static FloatingElement CreateFloatingElement(string title, DockingStyles docking, object modelInstance, string icon, int priority)
    {
      var fe = new FloatingElement
             {
               ModelInstance = modelInstance,
               OpacityDragging = 0.5,
               OpacityNormal = 1.0,
               CanMove = true,
               CanRotate = true,
               CanScale = true,
               StartOrientation = 0,
               Large = true,
               Background = AppStateSettings.Instance.AccentBrush,
               MinSize = new Size(75, 75),
               MaxSize = new Size(1500, 1500),
               StartSize = new Size(75, 75),
               Width = 75,
               Height = 75,
               ShowsActivationEffects = false,
               RemoveOnEdge = true,
               Contained = true,
               Title = title,
               AllowStream = false,

               Foreground = Brushes.White,
               AnimationSpeed = new TimeSpan(0, 0, 0, 0, 200),
               SwitchWidth = 250,
               DockingStyle = docking,
               DragScaleFactor = 80,
               RotateWithFinger = AppStateSettings.Instance.Config.GetBool("Layout.Floating.RotateWithFinger", true),
               IconUri = icon
             };
      return fe;
    }
Exemplo n.º 3
0
        internal override DraggedTabInfo GetAutodockTarget(DragAbsoluteEventArgs args)
        {
            FloatingElement ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingElement>((Visual)(args.OriginalSource as DragUndockHeader));

            if (ancestor != null)
            {
                FloatSite floatSite = ancestor.DataContext as FloatSite;
                if (floatSite != null)
                {
                    ConstrainedView constrainedView = floatSite.Child as ConstrainedView;
                    if (constrainedView != null && !constrainedView.CanAutoDock())
                    {
                        return((DraggedTabInfo)null);
                    }
                }
            }
            return(base.GetAutodockTarget(args));
        }
Exemplo n.º 4
0
        private void InitScatterViewEvents() {
            _fe = (FloatingElement) DataContext;
            //if (_fe.Style == null) _fe.Style = this.FindResource("DefaultContainerStyle") as Style;
            _svi = (ScatterViewItem) Helpers.FindElementOfTypeUp(this, typeof (ScatterViewItem));

            if (_fe == null || _svi == null) return;
            _fe.PropertyChanged += FePropertyChanged;

            _floatingViewModel = IoC.Get<IFloating>();

            //TODO: get scatterview instead of window
            _sv = Application.Current.MainWindow;
            // (ScatterView)BaseWPFHelpers.Helpers.FindElementOfTypeUp(_svi, typeof(ScatterView));

            _fe.FlipEvent += FeFlipEvent;
            _fe.UnFlipEvent += FeUnFlipEvent;


            _svi.IsManipulationEnabled = !_fe.PromoteToMouse;

            _svi.ContainerManipulationCompleted += SviScatterManipulationCompleted;
            _svi.ContainerManipulationStarted += SviScatterManipulationStarted;
            _svi.ContainerManipulationDelta += SviScatterManipulationDelta;
            _svi.TouchDown += SviContactDown;
            //_svi.CanMove = false;

            _fe.DockingStyleChanged += _fe_DockingStyleChanged;

            SizeChanged += UcFloatingElementContainerSizeChanged;

            _svi.SetBinding(ScatterContentControlBase.CanMoveProperty,
                new Binding {Source = _fe, Path = new PropertyPath("CanMove")});
            _svi.SetBinding(ScatterContentControlBase.CanRotateProperty,
                new Binding {Source = _fe, Path = new PropertyPath("CanRotate")});
            _svi.SetBinding(ScatterContentControlBase.CanScaleProperty,
                new Binding {Source = _fe, Path = new PropertyPath("CanScale")});
            _svi.SetBinding(ScatterContentControlBase.ShowsActivationEffectsProperty,
                new Binding {Source = _fe, Path = new PropertyPath("ShowsActivationEffects")});

            if (_fe.DockingStyle != DockingStyles.None)
                _svi.SetBinding(VisibilityProperty,
                    new Binding {
                        Source = AppStateSettings.Instance,
                        Path = new PropertyPath("DockedFloatingElementsVisible"),
                        Converter = new BooleanToVisibilityConverter()
                    });


            //_svi.CanMove = false;
            //_svi.CanScale = false;
            //_svi.CanRotate = false;

            Loaded += FloatingContainerLoaded;

            Close += FloatingContainerClose;

            PreviewMouseDoubleClick += FloatingContainerPreviewMouseDoubleClick;
        }
Exemplo n.º 5
0
        private void _svi_ScatterManipulationDelta(object sender, ContainerManipulationDeltaEventArgs e) {
            if (!_fe.CanDrag) return;
            hitResultsList = new List<FloatingElement>();
            // Set up a callback to receive the hit test result enumeration,
            // but no hit test filter enumeration.
            VisualTreeHelper.HitTest(Application.Current.MainWindow,
                null, // No hit test filtering.
                MyHitTestResult,
                new PointHitTestParameters(_svi.Center));

            if (hitResultsList != null && hitResultsList.Count > 0) {
                var fe = hitResultsList[0];
                if (_lastDragElement == null) {
                    fe.ForceDragEnter(this, _fe);
                }
                else {
                    if (fe != _lastDragElement) {
                        _lastDragElement.ForceDragLeave(this, _fe);
                        fe.ForceDragEnter(this, fe);
                    }
                }

                _lastDragElement = fe;
            }
            else {
                if (_lastDragElement != null) {
                    _lastDragElement.ForceDragLeave(this, _fe);
                }
                _lastDragElement = null;
            }
        }
Exemplo n.º 6
0
    public static FloatingElement CreateFloatingElement(Document e)
    {
      var fe = new FloatingElement
      {
        Document = e,
        OpacityDragging = 0.5,
        OpacityNormal = 1.0,
        CanMove = true,
        CanRotate = true,
        CanDrag = true,
        CanScale = true,
        StartOrientation = 0,
        Background = AppStateSettings.Instance.AccentBrush,
        MinSize = new Size(50, 50),
        MaxSize = new Size(1500, 1500),
        StartPosition = new Point(300, 300),
        ShowsActivationEffects = false,
        StartSize = new Size(300, 300),
        Width = 300,
        Height = 300,
        AllowStream = true,
        RemoveOnEdge = true,
        Contained = true,
        Foreground = Brushes.White,
        RotateWithFinger = AppStateSettings.Instance.Config.GetBool("Layout.Floating.RotateWithFinger", true),
        DockingStyle = DockingStyles.None
      };
      if (e.ShareUrl != null) fe.Contracts.Add("link", e.ShareUrl.Replace("^", string.Empty).Replace(" ", "%20"));
        if (e.OriginalUrl != null) fe.Contracts.Add("document", e.OriginalUrl.Replace("^", string.Empty));

      return fe;
    }
Exemplo n.º 7
0
    /// <summary>
    /// Creates a floating element with a QR code on the backside
    /// </summary>
    /// <param name="e"></param>
    /// <param name="uri"> </param>
    /// <returns></returns>
    public static FloatingElement CreateFloatingElementWithQrBackside(Document e, string uri)
    {
      var qrCode = AppStateSettings.Instance.Container.GetExportedValue<IQrCode>();
      qrCode.Text = new Uri(uri, UriKind.RelativeOrAbsolute).AbsoluteUri;

      var fe = new FloatingElement
      {
        Document               = e,
        OpacityDragging        = 0.5,
        OpacityNormal          = 1.0,
        CanMove                = true,
        CanRotate              = true,
        CanDrag                = true,
        CanScale               = true,
        StartOrientation       = 0,
        Background             = AppStateSettings.Instance.AccentBrush,
        MinSize                = new Size(50, 50),
        MaxSize                = new Size(1500, 1500),
        StartPosition          = new Point(300, 300),
        ShowsActivationEffects = false,
        StartSize              = new Size(300, 300),
        Width                  = 300,
        Height                 = 300,
        RemoveOnEdge           = true,
        Contained              = true,
        Foreground             = Brushes.White,
        RotateWithFinger       = AppStateSettings.Instance.Config.GetBool("Layout.Floating.RotateWithFinger", true),
        DockingStyle           = DockingStyles.None,
        CanFlip                = true,
        IsBacksideQrCode       = true,
        ModelInstanceBack      = qrCode
      };
      return fe;
    }