예제 #1
0
		internal WebViewBackend (SWC.WebBrowser browser)
		{
			view = browser;
			view.Navigating += HandleNavigating;
			view.Navigated += HandleNavigated;
			view.LoadCompleted += HandleLoadCompleted;
			Widget = view;
		}
            public SelectionChangedInhibitor(WPFControls.TreeView treeView)
            {
                this.Target = treeView;

                OriginalIsSelectionChangeActiveValue = (bool)IsSelectionChangeActiveProperty.GetValue(Target, null);

                //# suppress selection change notification
                IsSelectionChangeActiveProperty.SetValue(Target, true, null);
            }
예제 #3
0
파일: ExComboBox.cs 프로젝트: akrisiun/xwt
 protected override void OnTemplateChanged(SWC.ControlTemplate oldTemplate, SWC.ControlTemplate newTemplate)
 {
     base.OnTemplateChanged(oldTemplate, newTemplate);
     UpdateTextBox();
 }
 private void OnSelectionChanged(object sender, selection.SelectionChangedEventArgs e)
 {
     var mainContainer = this.SelectedItem as MainContainerShapeBase;
     if (e.AddedItems.Count > 0 && this.manipulationAdorner != null && mainContainer != null)
     {
         this.manipulationAdorner.AdditionalHandlersVisibility = System.Windows.Visibility.Visible;
         this.UpdateHandlers(mainContainer);
     }
     else
     {
         this.manipulationAdorner.AdditionalHandlersVisibility = System.Windows.Visibility.Collapsed;
     }
 }
예제 #5
0
 internal WebViewBackend(SWC.WebBrowser browser)
 {
     Widget = browser;
 }
 public static void SetCancelNextVerticalScrollEvent(WPFControls.TreeView element, bool value)
 {
     element.SetValue(CancelNextVerticalScrollEventProperty, value);
 }
 public static void SetPreventAutomaticVerticalScrolling(WPFControls.TreeView element, bool value)
 {
     element.SetValue(PreventAutomaticVerticalScrollingProperty, value);
 }
        static void UpdatePreventAutomaticVerticalScrollingSate(WPFControls.TreeView tv, bool isEnabled)
        {
            if (isEnabled)
            {
                var scrollViewer = tv.FindVisualDescendant<WPFControls.ScrollViewer>();

                if (scrollViewer == null)
                    return;

                scrollViewer.ScrollChanged += scrollViewer_VerticalScrollChanged;
                tv.RequestBringIntoView += tv_VerticalRequestBringIntoView;
            }
            else
            {
                var scrollViewer = tv.FindVisualDescendant<WPFControls.ScrollViewer>();

                if (scrollViewer == null)
                    return;

                scrollViewer.ScrollChanged -= scrollViewer_VerticalScrollChanged;
                tv.RequestBringIntoView -= tv_VerticalRequestBringIntoView;
            }
        }
 public static void SetSelectedItems(WPFControls.TreeView element, List<WPFControls.TreeViewItem> value)
 {
     element.SetValue(SelectedItemsProperty, value);
 }
        private static bool TryGetNewBlockSelectionDetails(
            WPFControls.TreeView treeView,
            IEnumerable<WPFControls.TreeViewItem> alreadySelectedItems,
            WPFControls.TreeViewItem newlySelectedItem,
            out int blockSelectionStartIndex,
            out int blockSelectionEndIndex,
            out WPFControls.TreeViewItem parentTreeViewItem)
        {
            blockSelectionStartIndex = -1;
            blockSelectionEndIndex = -1;

            var parentTvi = newlySelectedItem.FindVisualParent<TreeViewItem>();

            parentTreeViewItem = parentTvi;

            if (parentTvi == null)
                return false;

            var hasSelectedItemsFromDifferentParent =
                (from i in alreadySelectedItems
                    where i.FindVisualParent<TreeViewItem>() != parentTvi
                    select i).Any();

            if (!hasSelectedItemsFromDifferentParent)
            {
                var initiallySelectedItem = GetInitiallySelectedItem(treeView);

                // shift pressed but this is a first item selected, so there's no initally selected item yet
                if (initiallySelectedItem == null)
                {
                    return false;
                }

                var initiallySelectedIndex =
                    parentTvi.ItemContainerGenerator.IndexFromContainer(initiallySelectedItem);

                var newSelectedIndex = parentTvi.ItemContainerGenerator.IndexFromContainer(newlySelectedItem);

                if (initiallySelectedIndex == -1 || newSelectedIndex == -1)
                    return false;

                blockSelectionStartIndex = Math.Min(initiallySelectedIndex, newSelectedIndex);
                blockSelectionEndIndex = Math.Max(initiallySelectedIndex, newSelectedIndex);

                return true;
            }

            return false;
        }
 public static bool GetAllowMultiSelection(WPFControls.TreeView element)
 {
     return (bool)element.GetValue(AllowMultiSelectionProperty);
 }
 public static void SetAllowMultiSelection(WPFControls.TreeView element, bool value)
 {
     element.SetValue(AllowMultiSelectionProperty, value);
 }
        static void HandlePreviewSelectionEvent(WPFControls.TreeView tv, TreeViewItem tvi, out bool isEventHandled)
        {
            isEventHandled = false;

            if (tvi.IsSelected)
            {
                //# Item has been previously selected (we're in preview event and it is already selected)

                var allowMultiSelection = GetAllowMultiSelection(tv);

                var selectedItems = GetSelectedItems(tv);

                if (allowMultiSelection)
                {
                    if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                    {
                        //# Ctrl pressed and item has been previously selected (IsSelected == true) => Unselect this item

                        selectedItems.Remove(tvi);

                        tvi.IsSelected = false;

                        isEventHandled = true;

                        return;
                    }
                    if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                    {
                        //# Shift pressed - block selection
                        //# Item has been previously selected (IsSelected == true) => update selection range

                        int blockSelectionStartIndex = -1;
                        int blockSelectionEndIndex = -1;
                        WPFControls.TreeViewItem parentTvi = null;

                        if (!TryGetNewBlockSelectionDetails(tv, selectedItems, tvi, out blockSelectionStartIndex, out blockSelectionEndIndex, out parentTvi))
                        {
                            //# this is not a valid block selection, clear previous selection data
                            selectedItems.Clear();
                            selectedItems.Add(tvi);

                            isEventHandled = false;
                            return;
                        }

                        using (new SelectionChangedInhibitor(tv))
                        {
                            var removedItems =
                                (from si in selectedItems
                                 let index = parentTvi.ItemContainerGenerator.IndexFromContainer(si)
                                 where index < blockSelectionStartIndex || index > blockSelectionEndIndex
                                 select si)
                                 .ToArray();

                            foreach (var i in removedItems)
                            {
                                i.IsSelected = false;
                                selectedItems.Remove(i);
                            }

                            for (var i = blockSelectionStartIndex; i <= blockSelectionEndIndex; i++)
                            {
                                //# mark all selected items as selected
                                var tvi2 = (parentTvi.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewItem);
                                tvi2.IsSelected = true;

                                selectedItems.Add(tvi2);
                            }
                        }

                        isEventHandled = true;
                        return;
                    }
                }

                if (!allowMultiSelection || !isEventHandled)
                {
                    if (selectedItems.Count > 0)
                    {
                        // make new selected item the only selection

                        using (new SelectionChangedInhibitor(tv))
                        {
                            foreach (var i in selectedItems)
                                i.IsSelected = false;
                        }

                        selectedItems.Clear();

                        selectedItems.Add(tvi);

                        SetInitiallySelectedItem(tv, tvi);

                        tvi.IsSelected = true;
                    }
                }
            }
            else
            {
                // noting to do here for now
            }
        }
예제 #14
0
파일: ExComboBox.cs 프로젝트: m13253/xwt
		protected override void OnSelectionChanged (SWC.SelectionChangedEventArgs e)
		{
			base.OnSelectionChanged (e);
			OnTextChanged (EventArgs.Empty);
		}
 public static void SetOriginalVerticalOffset(WPFControls.TreeView element, double value)
 {
     element.SetValue(OriginalVerticalOffsetProperty, value);
 }
 public static double GetOriginalVerticalOffset(WPFControls.TreeView element)
 {
     return (double)element.GetValue(OriginalVerticalOffsetProperty);
 }
 public static List<WPFControls.TreeViewItem> GetSelectedItems(WPFControls.TreeView element)
 {
     return (List<WPFControls.TreeViewItem>)element.GetValue(SelectedItemsProperty);
 }
        static void scrollViewer_VerticalScrollChanged(object sender, WPFControls.ScrollChangedEventArgs e)
        {
            var sv = sender as WPFControls.ScrollViewer;
            var tv = sv.FindVisualParent<WPFControls.TreeView>();
            if (tv == null)
                return;

            if (!GetCancelNextVerticalScrollEvent(tv))
            {
                SetCancelNextVerticalScrollEvent(tv, false);
                return;
            }

            var originalVerticalOffset = GetOriginalVerticalOffset(tv);
            if (originalVerticalOffset != sv.VerticalOffset)
            {
                sv.ScrollToVerticalOffset(GetOriginalVerticalOffset(tv));
            }            

            SetCancelNextVerticalScrollEvent(tv, false);
        }
 public static void SetInitiallySelectedItem(WPFControls.TreeView element, WPFControls.TreeViewItem value)
 {
     element.SetValue(InitiallySelectedItem, value);
 }
 public static bool GetPreventAutomaticVerticalScrolling(WPFControls.TreeView element)
 {
     return (bool)element.GetValue(PreventAutomaticVerticalScrollingProperty);
 }
 public static WPFControls.TreeViewItem GetInitiallySelectedItem(WPFControls.TreeView element)
 {
     return (WPFControls.TreeViewItem) element.GetValue(InitiallySelectedItem);
 }
 public static bool GetCancelNextVerticalScrollEvent(WPFControls.TreeView element)
 {
     return (bool)element.GetValue(CancelNextVerticalScrollEventProperty);
 }
        /// <summary>
        /// Creates image from canvas with map background.
        /// </summary>
        /// <param name="mapImage">Map image.</param>
        /// <param name="canvas">Canvas to draw.</param>
        /// <returns>Created image.</returns>
        private Image _CreateImage(MapImage mapImage, SysControls.Canvas canvas)
        {
            Debug.Assert(null != mapImage);
            Debug.Assert(null != canvas);

            Image imageWithData = null;

            RenderTargetBitmap bmp = null;
            SysControls.Canvas outer = null;

            Image sourceImage = null;
            using (MemoryStream sourceStream = new MemoryStream((byte[])mapImage.ImageData))
                sourceImage = Image.FromStream(sourceStream);

            try
            {

                var bitmap = sourceImage as Bitmap;
                Debug.Assert(null != bitmap);
                ImageBrush imageBrush = _CreateImageBrush(bitmap);

                outer = new SysControls.Canvas();

                outer.Width = mapImage.ImageWidth;
                outer.Height = mapImage.ImageHeight;
                outer.Children.Add(canvas);
                outer.Background = (ImageBrush)imageBrush.GetCurrentValueAsFrozen();
                outer.Arrange(new Rect(0, 0, outer.Width, outer.Height));

                bmp = new RenderTargetBitmap((int)outer.Width,
                                             (int)outer.Height,
                                             mapImage.ImageDPI,
                                             mapImage.ImageDPI,
                                             PixelFormats.Pbgra32);
                bmp.Render(outer);

                var encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bmp));

                using (MemoryStream stream = new MemoryStream())
                {
                    encoder.Save(stream);
                    imageWithData = Image.FromStream(stream);
                }
            }
            finally
            {   // Clear and dispose all used stuff
                if (outer != null)
                {
                    outer.UpdateLayout();
                    outer.Children.Clear();
                }

                canvas.UpdateLayout();
                foreach (object child in canvas.Children)
                {
                    var symbolControl = child as SymbolControl;
                    if (symbolControl != null)
                        symbolControl.Template = null;
                }
                canvas.Children.Clear();

                if (bmp != null)
                    bmp.Clear();

                if (sourceImage != null)
                    sourceImage.Dispose();
            }

            return imageWithData;
        }
 private void SelectItemFromGenerator(C.ItemContainerGenerator rootItemItemContainerGenerator)
 {
     RadTreeMapItem russiaContainer = rootItemItemContainerGenerator.ContainerFromIndex(0) as RadTreeMapItem;
     russiaContainer.IsSelected = true;
 }
 void cmb_PopupContentSelectionChanged(object sender, WinControls.SelectionChangedEventArgs e)
 {
     // При удалении будет RemovedItems содержать элементы.
     item = e.AddedItems.Count > 0 ? e.AddedItems[0].ToString() : null;
 }