Exemplo n.º 1
0
        protected static LightBoxAdorner GetAdorner(UIElement element)
        {
            // Window系のクラスだったら、Contentプロパティを利用。それ以外の場合はそのまま利用。
            var win    = element as Window;
            var target = win?.Content as UIElement ?? element;

            if (target == null)
            {
                return(null);
            }
            var layer = AdornerLayer.GetAdornerLayer(target);

            if (layer == null)
            {
                return(null);
            }

            var current = layer.GetAdorners(target)
                          ?.OfType <LightBoxAdorner>()
                          ?.SingleOrDefault();

            return(current);
        }
Exemplo n.º 2
0
        private void lvUsersColumnHeader_Click(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader column = (sender as GridViewColumnHeader);
            string sortBy = column.Tag.ToString();

            if (listViewSortCol != null)
            {
                AdornerLayer.GetAdornerLayer(listViewSortCol).Remove(listViewSortAdorner);
                lvUsers.Items.SortDescriptions.Clear();
            }

            ListSortDirection newDir = ListSortDirection.Ascending;

            if (listViewSortCol == column && listViewSortAdorner.Direction == newDir)
            {
                newDir = ListSortDirection.Descending;
            }

            listViewSortCol     = column;
            listViewSortAdorner = new SortAdorner(listViewSortCol, newDir);
            AdornerLayer.GetAdornerLayer(listViewSortCol).Add(listViewSortAdorner);
            lvUsers.Items.SortDescriptions.Add(new SortDescription(sortBy, newDir));
        }
        /// <summary>
        /// Remove the watermark from the specified element
        /// </summary>
        /// <param name="control">Element to remove the watermark from</param>
        private static void RemoveWatermark(UIElement control)
        {
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(control);

            // layer could be null if control is no longer in the visual tree
            if (layer != null)
            {
                Adorner[] adorners = layer.GetAdorners(control);
                if (adorners == null)
                {
                    return;
                }

                foreach (Adorner adorner in adorners)
                {
                    if (adorner is WatermarkAdorner)
                    {
                        adorner.Visibility = Visibility.Hidden;
                        layer.Remove(adorner);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void ShowAdorner()
        {
            if (this.adorner != null)
            {
                this.adorner.Visibility = Visibility.Visible;
            }
            else
            {
                var adornerLayer = AdornerLayer.GetAdornerLayer(this);

                if (adornerLayer != null)
                {
                    var parent = this.Parent as Panel;
                    this.adorner         = new BusyAdorner(parent);
                    this.adorner.Cancel += (s1, e1) => { if (Cancel != null)
                                                         {
                                                             Cancel(s1, e1);
                                                         }
                    };
                    adornerLayer.Add(this.adorner);
                }
            }
        }
        /// <summary>
        /// The associated object_ drag enter.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void AssociatedObject_DragEnter(object sender, DragEventArgs e)
        {
            if (this.dataType == null)
            {
                // if the DataContext implements IDropable, record the data type that can be dropped
                if (this.AssociatedObject.DataContext != null)
                {
                    if (this.AssociatedObject.DataContext as IDropable != null)
                    {
                        this.dataType = ((IDropable)this.AssociatedObject.DataContext).DataType;
                    }
                }
            }

            // initialize adorner manager with the adorner layer of the itemsControl
            if (this.insertAdornerManager == null)
            {
                this.insertAdornerManager =
                    new ListBoxAdornerManager(AdornerLayer.GetAdornerLayer(sender as ItemsControl));
            }

            e.Handled = true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Sorts the grid view column
        /// </summary>
        /// <param name="column"></param>
        private void SetSort(GridViewColumnHeader column)
        {
            try
            {
                if (column != null)
                {
                    String field = column.Tag as String;

                    // Clear the previous data.
                    if (currentSortCol != null)
                    {
                        AdornerLayer.GetAdornerLayer(currentSortCol).Remove(currentAdorner);
                        ReminderList.Items.SortDescriptions.Clear();
                    }

                    ListSortDirection newDir = ListSortDirection.Ascending;
                    if (currentSortCol == column && currentAdorner.Direction == newDir)
                    {
                        newDir = ListSortDirection.Descending;
                    }

                    currentSortCol = column;
                    currentAdorner = new SortAdorner(currentSortCol, newDir);
                    ReminderList.Items.SortDescriptions.Add(new SortDescription(field, newDir));

                    // Check to see if the adorner
                    var Layer = AdornerLayer.GetAdornerLayer(currentSortCol);
                    if (Layer != null)
                    {
                        Layer.Add(currentAdorner);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 7
0
        private void SetupDrag(MouseEventArgs e)
        {
            // Get the dragged ListViewItem
            ListView     listView     = this.ListWebsites; //use to be sender
            ListViewItem listViewItem = FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource);

            if (listViewItem == null)
            {
                return;
            }

            Websites dest = (Websites)listView.ItemContainerGenerator.ItemFromContainer(listViewItem);

            //setup the drag adorner.
            InitialiseAdorner(listViewItem);

            //add handles to update the adorner.
            listView.PreviewDragOver += ListViewDragOver;
            listView.DragLeave       += ListViewDragLeave;
            listView.DragEnter       += ListViewDragEnter;

            //Console.WriteLine("original source" + e.OriginalSource.ToString());
            // Initialize the drag & drop operation
            DataObject      dragData = new DataObject("myFormat", dest);
            DragDropEffects derp     = DragDrop.DoDragDrop(listView, dragData, DragDropEffects.Move);

            //cleanup
            listView.PreviewDragOver -= ListViewDragOver;
            listView.DragLeave       -= ListViewDragLeave;
            listView.DragEnter       -= ListViewDragEnter;

            if (_adorner != null)
            {
                AdornerLayer.GetAdornerLayer(listView).Remove(_adorner);
                _adorner = null;
            }
        }
Exemplo n.º 8
0
        private async void PageShelf_Loaded(object sender, RoutedEventArgs e)
        {
            FingerprintManager.SetError += FingerprintManager_SetError;
            FingerprintManager.Touched  += FingerprintManager_Touched;

            App.CurrentApp.TagChanged += CurrentApp_TagChanged;

            RfidManager.ClearCache();
            // 注:将来也许可以通过(RFID 以外的)其他方式输入图书号码
            if (string.IsNullOrEmpty(RfidManager.Url))
            {
                this.SetGlobalError("rfid", "尚未配置 RFID 中心 URL");
            }

            _layer   = AdornerLayer.GetAdornerLayer(this.mainGrid);
            _adorner = new LayoutAdorner(this);

            {
                List <string> style = new List <string>();
                if (string.IsNullOrEmpty(App.RfidUrl) == false)
                {
                    style.Add("rfid");
                }
                if (string.IsNullOrEmpty(App.FingerprintUrl) == false)
                {
                    style.Add("fingerprint");
                }
                if (string.IsNullOrEmpty(App.FaceUrl) == false)
                {
                    style.Add("face");
                }
                this.patronControl.SetStartMessage(StringUtil.MakePathList(style));
            }


            await Fill(new CancellationToken());
        }
            private void OnListViewLoaded()
            {
                if (!_firstLoad)
                {
                    return;
                }

                var gridView = _listView.View as GridView;

                if (gridView == null)
                {
                    return;
                }

                foreach (var column in gridView.Columns)
                {
                    var header = column.Header as GridViewColumnHeader;
                    if (header != null)
                    {
                        // The "Loaded" event is called multiple times for UI elements inside
                        // a tab control. The first "Loaded" event is called when the control
                        // is not visible yet, meaning there are no adornment layers for the column
                        // headers of the listview. The next "Loaded" events are called when
                        // the containing TabItem is activated. We use the trick below
                        // to figure out when it is safe to add the "Sorter" adornment, but
                        // we must do it only once.
                        if (AdornerLayer.GetAdornerLayer(header) != null)
                        {
                            _firstLoad = false;
                            if (Wpf.ListViewSorter.GetInitialSortColumn(header))
                            {
                                HeaderClick(header);
                            }
                        }
                    }
                }
            }
Exemplo n.º 10
0
        /// <summary>
        /// Kliknięcie kolumny headera - sortowanie
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridViewColumnSort(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader column = (sender as GridViewColumnHeader);
            string sortBy = column.Tag.ToString();

            if (listViewSortCol != null)
            {
                AdornerLayer.GetAdornerLayer(listViewSortCol).Remove(listViewSortAdorner);
                NormalGameModeList.Items.SortDescriptions.Clear();
            }

            ListSortDirection newDir = ListSortDirection.Ascending;

            if (listViewSortCol == column && listViewSortAdorner.Direction == newDir)
            {
                newDir = ListSortDirection.Descending;
            }

            listViewSortCol     = column;
            listViewSortAdorner = new SortAdorner(listViewSortCol, newDir);
            AdornerLayer.GetAdornerLayer(listViewSortCol).Add(listViewSortAdorner);

            var item = ((FrameworkElement)e.OriginalSource).DataContext;

            switch (LobbyTab.SelectedIndex)
            {
            case 0:
                NormalGameModeList.Items.SortDescriptions.Clear();
                NormalGameModeList.Items.SortDescriptions.Add(new SortDescription(sortBy, newDir));
                break;

            case 1:
                TournamentGameModeList.Items.SortDescriptions.Clear();
                TournamentGameModeList.Items.SortDescriptions.Add(new SortDescription(sortBy, newDir));
                break;
            }
        }
Exemplo n.º 11
0
        private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                imageViewXY.ViewingPlaneIndex = Xvue.MSOT.Services.Imaging.ImagingConstants.BufferIndexXY;
                imageViewXZ.ViewingPlaneIndex = Xvue.MSOT.Services.Imaging.ImagingConstants.BufferIndexXZ;
                imageViewYZ.ViewingPlaneIndex = Xvue.MSOT.Services.Imaging.ImagingConstants.BufferIndexYZ;

                imageViewXY.GridPercentageWidthStepSize = "GridStepSizePercentageXY";
                imageViewXZ.GridPercentageWidthStepSize = "GridStepSizePercentageXY";
                imageViewYZ.GridPercentageWidthStepSize = "GridStepSizePercentageZ";

                //Set different colors to Image borders that do not change.
                _3DRenderingControl.text3DControl.BorderXYColor = Colors.Blue;
                _3DRenderingControl.text3DControl.BorderYZColor = Colors.Green;
                _3DRenderingControl.text3DControl.BorderXZColor = Colors.Yellow;

                imageViewXY.zpImageBorder.BorderBrush = imageViewXY.imageCanvasBorder.BorderBrush = new SolidColorBrush(_3DRenderingControl.text3DControl.BorderXYColor);
                imageViewYZ.zpImageBorder.BorderBrush = imageViewYZ.imageCanvasBorder.BorderBrush = new SolidColorBrush(_3DRenderingControl.text3DControl.BorderYZColor);
                imageViewXZ.zpImageBorder.BorderBrush = imageViewXZ.imageCanvasBorder.BorderBrush = new SolidColorBrush(_3DRenderingControl.text3DControl.BorderXZColor);

                refreshCrossHairPARTColors();

                imageAdornerLayer = AdornerLayer.GetAdornerLayer(imageViewXY.backgroundImage);
                //AdornerLayer imageYZAdornerLayer = AdornerLayer.GetAdornerLayer(imageViewYZ.backgroundImage);
                //AdornerLayer imageXZAdornerLayer = AdornerLayer.GetAdornerLayer(imageViewXZ.backgroundImage);


                //imageAdornerLayer.Add(_roiAdorner);
                model3DPane = (base.DataContext as ViewModel3DPane);

                initUpdateCropLimitDetailsAdorner();
            }
            catch
            {
            }
        }
Exemplo n.º 12
0
        private void BeginDrag(MouseEventArgs e)
        {
            ListView     listView     = this.FileNameListView;
            ListViewItem listViewItem =
                FindAncestor <ListViewItem>((DependencyObject)e.OriginalSource);

            if (listViewItem == null)
            {
                return;
            }

            // get the data for the ListViewItem
            //object name = listView.ItemContainerGenerator.ItemFromContainer(listViewItem);
            int index = listView.ItemContainerGenerator.IndexFromContainer(listViewItem);

            //setup the drag adorner.
            InitialiseAdorner(listViewItem);

            //add handles to update the adorner.
            listView.PreviewDragOver += FileNameListView_DragOver;
            listView.DragLeave       += FileNameListView_DragLeave;
            listView.DragEnter       += FileNameListView_DragEnter;

            DataObject      data = new DataObject("myFormat", index);
            DragDropEffects de   = DragDrop.DoDragDrop(this.FileNameListView, data, DragDropEffects.Move);

            //cleanup
            listView.PreviewDragOver -= FileNameListView_DragOver;
            listView.DragLeave       -= FileNameListView_DragLeave;
            listView.DragEnter       -= FileNameListView_DragEnter;

            if (_adorner != null)
            {
                AdornerLayer.GetAdornerLayer(listView).Remove(_adorner);
                _adorner = null;
            }
        }
        // Quand une nouvelle nouvelle stroke a ete ajoute
        private void surfaceDessin_OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            if ((DataContext as VueModele)?.OutilSelectionne == "crayon" && surfaceDessin.SelectedStrokes.Count > 0)
            {
                CustomStroke newStroke = (DataContext as VueModele).AddStrokeFromView(
                    (CustomStroke)surfaceDessin.SelectedStrokes[0]
                    );
                surfaceDessin.Select(new StrokeCollection {
                    newStroke
                });
                if (newStroke.GetType() != typeof(LinkStroke))
                {
                    Path path = new Path();
                    path.Data = new RectangleGeometry(newStroke.GetBounds());
                    surfaceDessin.Children.Add(path);
                    AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(path);
                    myAdornerLayer.Add(new RotateAdorner(path, newStroke, surfaceDessin));
                    myAdornerLayer.Add(new AnchorPointAdorner(path, newStroke, surfaceDessin));
                    Adorner[] ad = myAdornerLayer.GetAdorners(path);
                    myAdornerLayer.Add(new EditionAdorner(path, newStroke, surfaceDessin));
                }
            }
            else
            {
                foreach (CustomStroke stroke in surfaceDessin.GetSelectedStrokes())
                {
                    if (stroke is LinkStroke)
                    {
                        surfaceDessin.modifyLinkStrokePath(stroke as LinkStroke, e.GetPosition(surfaceDessin));
                    }
                }
            }


            // Pour que les boutons soient de la bonne couleur
            (DataContext as VueModele)?.ChoisirOutil.Execute("lasso");
        }
Exemplo n.º 14
0
        private static void OnIsInEditModePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            var textBlock = obj as TextBlock;

            if (textBlock == null)
            {
                throw new ArgumentException("IsInEditMode property can only be set on TextBlock");
            }

            //Get the adorner layer of the uielement (here TextBlock)
            var layer = AdornerLayer.GetAdornerLayer(textBlock);

            //If the IsInEditMode set to true means the user has enabled the edit mode then
            //add the adorner to the adorner layer of the TextBlock.
            if (layer != null)
            {
                if ((bool)e.NewValue)
                {
                    layer.Add(new EditableTextBlockAdorner(textBlock));
                }
                else if ((bool)e.OldValue)
                {
                    var adorner = GetAdorner(textBlock);
                    if (adorner != null)
                    {
                        layer.Remove(adorner);
                    }

                    // Update the textblock's text binding.
                    var expression = textBlock.GetBindingExpression(TextBlock.TextProperty);
                    if (null != expression)
                    {
                        expression.UpdateTarget();
                    }
                }
            }
        }
Exemplo n.º 15
0
        public override void Activate()
        {
            _poly = AdornedElement as Polyline;
            if (_poly == null)
            {
                throw new ArgumentException();
            }

            foreach (var p in _poly.Points)
            {
                var pd = new PointDragThumb(_view, AdornedElement as FrameworkElement);
                pd.DragStarted += PointDragStarted;
                pd.DragDelta   += PointDragDelta;
                pd.PreviewMouseLeftButtonUp += OnPreviewMouseLeftButtonUp;
                visualChildren.Add(pd);
            }

            for (int i = 0; i < _poly.Points.Count; i++)
            {
                var m = _poly.GeometryTransform.Value;

                var p = m.Transform(_poly.Points[i]);
                p = _poly.TranslatePoint(p, _view.MainPanel);
                _poly.Points[i] = p;
            }
            _poly.Stretch = Stretch.None;
            EditorHelper.SetDependencyProperty(_poly, Canvas.LeftProperty, DependencyProperty.UnsetValue);
            EditorHelper.SetDependencyProperty(_poly, Canvas.TopProperty, DependencyProperty.UnsetValue);
            EditorHelper.SetDependencyProperty(_poly, FrameworkElement.WidthProperty, DependencyProperty.UnsetValue);
            EditorHelper.SetDependencyProperty(_poly, FrameworkElement.HeightProperty, DependencyProperty.UnsetValue);

            _poly.RenderTransform = null;
            AdornerLayer.GetAdornerLayer(AdornedElement).PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(PolylineEditManipulantor_PreviewMouseLeftButtonDown);

            _poly.UpdateLayout();
            base.Activate();
        }
Exemplo n.º 16
0
        private void UpdateResizeAdorner()
        {
            if (IsDrawing)
            {
                return;
            }

            if (_dragging && !_isSelecting)
            {
                return;
            }

            if (SelectedModels.Count > 1)
            {
                Rect?bounds = GetSelectedContentBounds();

                if (bounds.HasValue && bounds != Rect.Empty)
                {
                    AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(_drawingCanvas);

                    if (adornerLayer != null)
                    {
                        if (_resizingAdorner == null)
                        {
                            _resizingAdorner = new ResizeAdorner(_drawingCanvas, this, bounds.Value);
                            adornerLayer.Add(_resizingAdorner);
                            //_resizingAdorner.Bounds = bounds.Value;
                        }
                        adornerLayer.Update();
                    }
                }
            }
            else
            {
                RemoveResizeAdorner();
            }
        }
        private static void OnListViewHeaderClick(object sender, RoutedEventArgs e)
        {
            ListView             listView = e.Source as ListView;
            GridViewColumnHeader header   = e.OriginalSource as GridViewColumnHeader;
            SortInfo             sortInfo = listView.GetValue(SortInfoProperty.DependencyProperty) as SortInfo;

            if (sortInfo != null)
            {
                AdornerLayer.GetAdornerLayer(sortInfo.LastSortColumn).Remove(sortInfo.CurrentAdorner);
                listView.Items.SortDescriptions.Clear();
            }
            else
            {
                sortInfo = new SortInfo();
            }

            if (sortInfo.LastSortColumn == header)
            {
                (sortInfo.CurrentAdorner.Child as ListSortDecorator).SortDirection = (sortInfo.CurrentAdorner.Child as ListSortDecorator).SortDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending;
            }
            else
            {
                sortInfo.CurrentAdorner = new UIElementAdorner(header, new ListSortDecorator());
            }

            sortInfo.LastSortColumn = header;
            listView.SetValue(SortInfoProperty, sortInfo);

            AdornerLayer.GetAdornerLayer(header).Add(sortInfo.CurrentAdorner);
            SortDescription sortDescriptioin = new SortDescription()
            {
                Direction    = (sortInfo.CurrentAdorner.Child as ListSortDecorator).SortDirection,
                PropertyName = header.Column.GetValue(SortFieldProperty) as string ?? header.Column.Header as string
            };

            listView.Items.SortDescriptions.Add(sortDescriptioin);
        }
Exemplo n.º 18
0
        public static void sortColumn(object sender, ListView listViewControl)
        {
            try
            {
                GridViewColumnHeader column = (sender as GridViewColumnHeader);
                string sortBy = column.Tag.ToString();
                if (listViewSortCol != null)
                {
                    AdornerLayer.GetAdornerLayer(listViewSortCol).Remove(listViewSortAdorner);
                    listViewControl.Items.SortDescriptions.Clear();
                }

                ListSortDirection newDir = ListSortDirection.Ascending;
                if (listViewSortCol == column && listViewSortAdorner.Direction == newDir)
                {
                    newDir = ListSortDirection.Descending;
                }

                listViewSortCol     = column;
                listViewSortAdorner = new SortAdorner(listViewSortCol, newDir);
                AdornerLayer.GetAdornerLayer(listViewSortCol).Add(listViewSortAdorner);
                listViewControl.Items.SortDescriptions.Add(new SortDescription(sortBy, newDir));
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }
Exemplo n.º 19
0
        private void AddCropToElement(FrameworkElement fel)
        {
            if (_felCur != null)
            {
                return;
            }
            var rcInterior = new Rect(
                0,
                0,
                fel.ActualWidth,
                fel.ActualHeight);
            var adornerLayer = AdornerLayer.GetAdornerLayer(fel);
            _clp = new CroppingAdorner(fel, rcInterior);
            _felCur = fel;
            var color = Colors.Black;
            color.A = 180;
            _clp.Fill = new SolidColorBrush(color);
            adornerLayer.Add(_clp);
            adornerLayer.UpdateLayout();

            var dx = 1d / _clp.ClippingRectangle.Width * _imageWidth;
            var dy = 1d / _clp.ClippingRectangle.Height * _imageHeight;
            _clp.SetClippingRectangle(new Rect(
                Configuration.Configuration.Instance.Settings.ClippingRectangle.X / dx,
                Configuration.Configuration.Instance.Settings.ClippingRectangle.Y / dy,
                Configuration.Configuration.Instance.Settings.ClippingRectangle.Width / dx,
                Configuration.Configuration.Instance.Settings.ClippingRectangle.Height / dy
                ));

            UpdateClippingRectangle();
            _clp.CropChanged += (sender, args) =>
            {
                UpdateClippingRectangle();
            };
            Image.SizeChanged += ImageSizeChanged;
        }
Exemplo n.º 20
0
        void RemoveBorderAdorner(UIElement adornedElement)
        {
            if (adornedElement != null)
            {
                AdornerLayer layr = AdornerLayer.GetAdornerLayer(adornedElement);
                if (layr != null)
                {
                    Adorner[] adorners = layr.GetAdorners(adornedElement);
                    if (adorners != null)
                    {
                        foreach (Adorner adr in adorners)
                        {
                            BorderAdorner badr = adr as BorderAdorner;

                            if (badr != null)
                            {
                                layr.Remove(badr);
                                badr.DisposeDragging();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        private static void InitializeSortDirection(ListView listView)
        {
            #region Guards
            var dataSource = listView.ItemsSource;
            if (dataSource == null)
            {
                return;
            }

            var dataview = CollectionViewSource.GetDefaultView(dataSource);
            if (dataview == null || dataview.SortDescriptions.Count == 0)
            {
                return;
            }

            SortInfo sortInfo = listView.GetValue(SortInfoProperty.DependencyProperty) as SortInfo;
            if (sortInfo != null)
            {
                return;
            }
            #endregion

            foreach (var columnHeader in listView.FindChildren <GridViewColumnHeader>(h => h.Role != GridViewColumnHeaderRole.Padding))
            {
                if (columnHeader.Column != null && dataview.SortDescriptions.Count > 0 &&
                    dataview.SortDescriptions[0].PropertyName.Equals(GetSortField(columnHeader.Column)))
                {
                    sortInfo = new SortInfo();
                    sortInfo.LastSortColumn = columnHeader;
                    sortInfo.CurrentAdorner = new VisualAdorner(columnHeader, new ListSortDecorator());
                    AdornerLayer.GetAdornerLayer(columnHeader).Add(sortInfo.CurrentAdorner);
                    listView.SetValue(SortInfoProperty, sortInfo);
                    break;
                }
            }
        }
Exemplo n.º 22
0
        private void CreateAndAttachBackstageAdorner()
        {
            if (this.adorner != null)
            {
                return;
            }

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                // TODO: in design mode it is required to use design time adorner
                var topLevelElement = (FrameworkElement)VisualTreeHelper.GetParent(this);
                var topOffset       = this.TranslatePoint(new Point(0, this.ActualHeight), topLevelElement).Y;
                this.adorner = new BackstageAdorner(topLevelElement, this.Content, topOffset);
            }
            else
            {
                var mainWindow = Window.GetWindow(this);
                if (mainWindow == null)
                {
                    return;
                }

                var topLevelElement = (FrameworkElement)mainWindow.Content;
                if (topLevelElement == null)
                {
                    return;
                }

                var topOffset = this.TranslatePoint(new Point(0, this.ActualHeight), topLevelElement).Y;
                this.adorner = new BackstageAdorner(topLevelElement, this.Content, topOffset);
            }

            var layer = AdornerLayer.GetAdornerLayer(this);

            layer.Add(this.adorner);
        }
Exemplo n.º 23
0
        private static void OnShowContextPanelChanged(DependencyObject d,
                                                      DependencyPropertyChangedEventArgs args)
        {
            ItemSkimmingPanel skimmingPanel = d as ItemSkimmingPanel;

            if ((bool)args.NewValue)
            {
                AdornerLayer layer = AdornerLayer.GetAdornerLayer(skimmingPanel);
                skimmingPanel._contextAdorner = new SkimmingContextAdorner(skimmingPanel);

                layer.Add(skimmingPanel._contextAdorner);
                skimmingPanel._contextAdorner.SelectItem(skimmingPanel._selectedIndex,
                                                         skimmingPanel._previousIndex);
            }
            else
            {
                AdornerLayer layer = AdornerLayer.GetAdornerLayer(skimmingPanel);
                if (skimmingPanel._contextAdorner != null)
                {
                    layer.Remove(skimmingPanel._contextAdorner);
                }
                skimmingPanel._contextAdorner = null;
            }
        }
Exemplo n.º 24
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            TextBlock textBlock = GetTemplateChild("PART_DisplayTextBlockPart") as TextBlock;

            Debug.Assert(textBlock != null, "No TextBlock!");
            this.Focusable = false;
            _adorner       = new EditBoxAdorner(this, textBlock);

            RoutedEventHandler attachedHandler = null;

            attachedHandler = delegate
            {
                textBlock.Loaded -= attachedHandler;
                AdornerLayer layer = AdornerLayer.GetAdornerLayer(textBlock);
                if (layer != null)
                {
                    layer.Add(_adorner);
                }
            };


            textBlock.Loaded += attachedHandler;
        }
Exemplo n.º 25
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (e.LeftButton != MouseButtonState.Pressed)
            {
                dragStartPoint = null;
            }

            if (dragStartPoint.HasValue)
            {
                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
                if (adornerLayer != null)
                {
                    RubberbandAdorner adorner = new RubberbandAdorner(this, dragStartPoint);
                    if (adorner != null)
                    {
                        adornerLayer.Add(adorner);
                    }
                }

                e.Handled = true;
            }
        }
        private void ConstructGhostAdornerWithHandlers(Point initialPoint, FrameworkElement adornedElement, TouchEventArgs e)
        {
            AdornerLayer  adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
            GalaxyAdorner adorner      = new GalaxyAdorner(adornedElement, initialPoint);

            if (adornerLayer != null && adorner != null)
            {
                adornerLayer.Add(adorner);
            }
            else
            {
                return;
            }

            EventHandler <TouchEventArgs> moveHandler        = new EventHandler <TouchEventArgs>((s, evt) => DragDropContainer_TouchMove(s, e, adorner));
            EventHandler <TouchEventArgs> upHandler          = new EventHandler <TouchEventArgs>((s, evt) => DragDropContainer_TouchUp(s, evt, adorner, adornedElement));
            EventHandler <TouchEventArgs> unsubscribeHandler = new EventHandler <TouchEventArgs>((s, evt) => DragDropContainer_Unsubscribe(s, e, moveHandler, upHandler, adorner));

            adorner.UnsubscribeEvent = unsubscribeHandler;

            DragOverlay.TouchMove += moveHandler;
            DragOverlay.TouchUp   += upHandler;
            DragOverlay.TouchUp   += unsubscribeHandler;
        }
Exemplo n.º 27
0
        private void WindowLoaded(object sender, EventArgs e)
        {
            if (ExecutionMode.IsRunningWithIdentity())
            {
                this.Title = "PhotoStore";
                this.TitleSpan.Foreground = Brushes.Blue;
            }
            else
            {
                this.Title = "Desktop App";
                this.TitleSpan.Foreground = Brushes.Navy;
            }

            var layer = AdornerLayer.GetAdornerLayer(CurrentPhoto);

            _cropSelector = new RubberbandAdorner(CurrentPhoto)
            {
                Window = this
            };
            layer.Add(_cropSelector);
#if VISUALCHILD
            CropSelector.Rubberband.Visibility = Visibility.Hidden;
#endif
#if NoVISUALCHILD
            CropSelector.ShowRect = false;
#endif

            Photos = (PhotoList)(this.Resources["Photos"] as ObjectDataProvider)?.Data;
            Photos.Init(PhotosFolder.Current);
            ShoppingCart = (PrintList)(this.Resources["ShoppingCart"] as ObjectDataProvider)?.Data;

            // listen for files being created via Share UX
            FileSystemWatcher watcher = new FileSystemWatcher(PhotosFolder.Current);
            watcher.EnableRaisingEvents = true;
            watcher.Created            += Watcher_Created;
        }
Exemplo n.º 28
0
        /// <summary>Is called when a control template is applied.</summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
            myAdornerLabel = new AdornerLabel(this, Note, NoteStyle);
            UpdateAdorner(this);

            DependencyPropertyDescriptor focusProp = DependencyPropertyDescriptor.FromProperty(
                IsFocusedProperty, typeof(FrameworkElement));

            if (focusProp != null)
            {
                focusProp.AddValueChanged(this, delegate { UpdateAdorner(this); });
            }

            DependencyPropertyDescriptor containsTextProp = DependencyPropertyDescriptor.FromProperty(
                HasTextProperty, typeof(InfoTextBox));

            if (containsTextProp != null)
            {
                containsTextProp.AddValueChanged(this, delegate { UpdateAdorner(this); });
            }
        }
        private void listBoxItem_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            var lbi = sender as ListBoxItem;

            if (e.LeftButton == MouseButtonState.Pressed && dragGhost == null && dragItem == lbi)
            {
                var nowPos = e.GetPosition(lbi);
                if (Math.Abs(nowPos.X - dragStartPos.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(nowPos.Y - dragStartPos.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    ItemList.AllowDrop = true;

                    var layer = AdornerLayer.GetAdornerLayer(ItemList);
                    dragGhost = new DragAdorner(ItemList, lbi, 0.5, dragStartPos);
                    layer.Add(dragGhost);
                    DragDrop.DoDragDrop(lbi, lbi, DragDropEffects.Move);
                    layer.Remove(dragGhost);
                    dragGhost = null;
                    dragItem  = null;

                    ItemList.AllowDrop = false;
                }
            }
        }
Exemplo n.º 30
0
 private void RenameCurrentModelSystem()
 {
     if (Display.SelectedItem is ModelSystem modelSystem)
     {
         var selectedModuleControl = GetCurrentlySelectedControl();
         var layer = AdornerLayer.GetAdornerLayer(selectedModuleControl);
         Renaming = true;
         var adorn = new TextboxAdorner("Rename", result =>
         {
             string error = null;
             if (!Runtime.ModelSystemController.Rename(modelSystem, result, ref error))
             {
                 MessageBox.Show(GetWindow(), error, "Unable to Rename Model System", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
             }
             else
             {
                 RefreshModelSystems();
             }
         }, selectedModuleControl, modelSystem.Name);
         adorn.Unloaded += Adorn_Unloaded;
         layer.Add(adorn);
         adorn.Focus();
     }
 }