/// <summary>
        /// Action when PrintObjectList change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPrintObjectListChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            _children.Clear();
            //_children.Add( CreateObjectDrawingVisual(Barcode_Base_List));
            int index = 0;

            foreach (PrintObject_Base b in PrintObject_List)
            {
                b._Index = index;
                index++;
                _children.Add(CreateObjectDrawingVisual(b));
            }
            if (_children.Contains(DashRect))
            {
                _children.Remove(DashRect);
            }
            if (e.OldItems != null)
            {
                foreach (INotifyPropertyChanged item in e.OldItems)
                {
                    item.PropertyChanged -= ItemList_PropertyChanged;
                }
            }
            if (e.NewItems != null)
            {
                foreach (INotifyPropertyChanged item in e.NewItems)
                {
                    item.PropertyChanged += ItemList_PropertyChanged;
                }
            }
        }
Exemple #2
0
 private void CheckLine()
 {
     if (_editor.SelectedItems != null && _editor.SelectedItems.Count == 1 && _editor.SelectedItems[0] is Helios.Controls.LineDecoration)
     {
         if (!_isline)
         {
             _children.Remove(_bottomLeft);
             _children.Remove(_bottomRight);
             _topRight.Cursor = Cursors.Cross;
             _topLeft.Cursor  = Cursors.Cross;
         }
         Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;
         _tempLine = new Helios.Controls.LineDecoration();
         _tempLine.Clone(line);
         _isline = true;
     }
     else
     {
         if (_isline)
         {
             _children.Add(_bottomLeft);
             _children.Add(_bottomRight);
             _topRight.Cursor = Cursors.SizeNESW;
             _topLeft.Cursor  = Cursors.SizeNWSE;
         }
         _tempLine = null;
         _isline   = false;
     }
 }
 private void RemoveVisuals()
 {
     foreach (var edv in _editableDrawingVisuals)
     {
         _children.Remove(edv);
     }
     _editableDrawingVisuals.Clear();
     _children.Remove(_visualCuttingForm);
 }
        /// <summary>
        /// Rotates the strokes to the same angle as outline.
        /// </summary>
        void rotateHandle_DragCompleted(object sender,
                                        DragCompletedEventArgs e)
        {
            if (rotation == null)
            {
                return;
            }

            visualChildren.Remove(rotatePreview);

            (linkStroke as LinkStroke).RotateStroke(rotation.Angle - lastAngle);

            DrawingService.UpdateLinks(new StrokeCollection {
                linkStroke
            });

            strokeBounds = linkStroke.GetBounds();
            center       = linkStroke.GetCenter();

            // Save the angle of the last rotation.
            lastAngle           = 0;
            linkStroke.rotation = 0;

            canvas.RefreshChildren();

            // Redraw rotateHandle.
            InvalidateArrange();
        }
Exemple #5
0
        /// <summary>
        /// A generic method to update the visual children to match an ObservableCollection
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="creator"></param>
        /// <param name="layer"></param>
        private void ModelToVisual <T>(object sender, NotifyCollectionChangedEventArgs e, Func <T, DrawingVisual> creator,
                                       ref IList <DrawingVisual> layer)
        {
            var collection = sender as ObservableCollection <T>;

            if (collection == null)
            {
                return;
            }
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:

                var newVisuals = e.NewItems.Cast <T>().Select(creator);
                foreach (var dv in newVisuals)
                {
                    layer.Add(dv);
                    _children.Add(dv);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                var rm = layer[e.OldStartingIndex];
                layer.RemoveAt(e.OldStartingIndex);
                _children.Remove(rm);
                break;

            case NotifyCollectionChangedAction.Replace:
                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Reset:
                foreach (var dv in _outlines)
                {
                    _children.Remove(dv);
                }
                layer = new List <DrawingVisual>();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            this.InvalidateVisual();
        }
Exemple #6
0
 public void removeVisuals(IList items)
 {
     foreach (DrawingVisual visual in items)
     {
         children.Remove(visual);
     }
     InvalidateVisual();
 }
Exemple #7
0
            public void Init(MapColorModes mapColor = MapColorModes.Provs, List <Prov> list = null)
            {
                if (list == null)
                {
                    _children.Clear();
                    FindDict = new Dictionary <System.Windows.Media.DrawingVisual, Prov>();

                    ////////////////////
                    var vm = SimpleIoc.Default.GetInstance <MainViewModel>();

                    this.BeginInit();
                    foreach (var prov in vm.Provs)
                    {
                        var visual = CreateDrawingVisualProvince(prov, mapColor);


                        _children.Add(visual);
                        FindDict.Add(visual, prov);
                        prov.Visual = visual;
                    }
                    this.EndInit();
                    ///////////////////

                    var query =
                        vm.Provs.Select(
                            v =>
                            new SimpleProv
                    {
                        Name     = v.Name,
                        Color    = v.Color,
                        Contours = v.Contours
                    });
                    var str = JsonConvert.SerializeObject(query, Formatting.Indented);
                    System.IO.File.WriteAllText("points.json", str);
                }
                else
                {
                    var visuals = FindDict.Where(v => list.Contains(v.Value))
                                  .Where(v => !v.Value.IsLake && !v.Value.IsSea && !v.Value.IsWaste)
                                  .Select(v => v.Key);
                    visuals.ToList().ForEach(v =>
                    {
                        FindDict.Remove(v);
                        _children.Remove(v);
                    });

                    this.BeginInit();
                    foreach (var prov in list)
                    {
                        var visual = CreateDrawingVisualProvince(prov, mapColor);
                        _children.Add(visual);
                        FindDict.Add(visual, prov);
                        prov.Visual = visual;
                    }
                    this.EndInit();
                }
            }
Exemple #8
0
        public void ClearExclusivePointingIndicators()
        {
            foreach (var Indicator in ExclusivePointingIndicators)
            {
                Indicators.Remove(Indicator);
            }

            ExclusivePointingIndicators.Clear();
        }
        void HandleBottomRight(object sender, DragDeltaEventArgs args)
        {
            FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
            Thumb            hitThumb       = sender as Thumb;

            if (adornedElement == null || hitThumb == null)
            {
                return;
            }
            FrameworkElement parentElement = adornedElement.Parent as FrameworkElement;

            EnforceSize(adornedElement);

            adornedElement.Width  = Math.Max(adornedElement.Width + args.HorizontalChange, hitThumb.DesiredSize.Width);
            adornedElement.Height = Math.Max(args.VerticalChange + adornedElement.Height, hitThumb.DesiredSize.Height);

            visualChildren.Remove(dottedLine);
            isExist = true;
        }
        void Move_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            if (e.HorizontalChange == 0 && e.VerticalChange == 0)
            {
                visualChildren.Remove(resizePreview);
                InvalidateArrange();
                return;
            }

            visualChildren.Remove(resizePreview);

            canvas.MoveShape(NewRectangle.Rect.X - OldRectangle.Rect.X, NewRectangle.Rect.Y - OldRectangle.Rect.Y);

            canvas.RefreshLinks(false);
            canvas.RefreshChildren();

            InvalidateArrange();

            DrawingService.UpdateShapes(strokesSelected);
        }
Exemple #11
0
 /// <summary>
 /// Removes a Visual derived class from visualCollection will remove it from the visual tree of the CustomControl
 /// </summary>
 protected void RemoveChild(Visual child) {
   if (children!=null) {
     children.Remove(child);
   }
   //remove child from its parent
   RemoveLogicalChild(child); //equivalent to Child.Parent = null;
   //remove child from visual tree
   if (visualCollection!=null) {
     visualCollection.Remove(child);
   }
 }
Exemple #12
0
        public Boolean RemoveChild(IVisualElement element)
        {
            var changed = _children.Remove(element);

            if (changed)
            {
                InvalidateMeasure();
            }

            return(changed);
        }
 protected void UnregisterVisual_Callback(DrawingVisual vis)
 {
     try
     {
         Visuals.Remove(vis);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("=> [GFXContainer.UnregisterVisual_Callback]: " + ex.Message);
     }
 }
Exemple #14
0
        internal void RemoveCanvasChild(UIElement element)
        {
            var popupRoot = element as GamePopupRoot;

            if (popupRoot == null)
            {
                return;
            }

            _openPopupRoots.Remove(popupRoot);

            InvalidateMeasure();
        }
Exemple #15
0
        void All_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            Point actualPos = Mouse.GetPosition(this);

            if (e.HorizontalChange == 0 && e.VerticalChange == 0)
            {
                visualChildren.Remove(resizePreview);
                InvalidateArrange();
                return;
            }

            visualChildren.Remove(resizePreview);

            canvas.ResizeShape(customStroke, NewRectangle, OldRectangle);

            canvas.RefreshLinks(false);
            canvas.RefreshChildren();

            InvalidateArrange();

            DrawingService.UpdateShapes(new StrokeCollection {
                customStroke
            });
        }
        /// <summary>
        /// Rotates the strokes to the same angle as outline.
        /// </summary>
        void rotateHandle_DragCompleted(object sender,
                                        DragCompletedEventArgs e)
        {
            if (rotation == null)
            {
                return;
            }

            visualChildren.Remove(rotatePreview);

            canvas.RotateStrokesWithAngle(rotation.Angle - (stroke as ShapeStroke).shapeStyle.rotation);

            // Save the angle of the last rotation.
            lastAngle = rotation.Angle;

            // Redraw rotateHandle.
            InvalidateArrange();
        }
 public void Highlight(List <ClassObject> list)
 {
     HighlightedObjects.ForEach(v => children.Remove(v));
     HighlightedObjects.Clear();
     if (list != null)
     {
         list.ForEach(o =>
         {
             DrawingVisual visual   = new DrawingVisual();
             DrawingContext context = visual.RenderOpen();
             Color fill             = FromClass(o.C);
             fill.A = 200;
             context.DrawRectangle(new SolidColorBrush(FromClass(o.C)), new Pen(new SolidColorBrush(fill), 3),
                                   new Rect(o.X - 3, o.Y - 3, 6, 6));
             context.Close();
             this.children.Add(visual);
             this.HighlightedObjects.Add(visual);
         });
     }
 }
Exemple #18
0
        /// <summary>
        /// Detaches a visual from the tree, also removes highligher parents if empty
        /// when true is passed
        /// </summary>
        private void DetachVisual(Visual visual)
        {
            ContainerVisual parent = (ContainerVisual)(VisualTreeHelper.GetParent(visual));

            if (parent != null)
            {
                VisualCollection children = parent.Children;
                children.Remove(visual);

                // If the parent is a childless highlighter, detach it too.
                HighlighterContainerVisual hcVisual = parent as HighlighterContainerVisual;
                if (hcVisual != null &&
                    hcVisual.Children.Count == 0 &&
                    _highlighters != null &&
                    _highlighters.ContainsValue(hcVisual))
                {
                    DetachVisual(hcVisual);
                    _highlighters.Remove(hcVisual.Color);
                }
            }
        }
        private void CreateLayers()
        {
            if (_backgroundVisual != null)
            {
                _children.Remove(_backgroundVisual);
                _backgroundVisual = null;
            }

            _backgroundVisual = CreateVisual();
            _children.Add(_backgroundVisual);

            /*if (_mainVisual != null)
             * {
             *  _children.Remove(_mainVisual);
             *  _mainVisual = null;
             * }
             *
             * _mainVisual = CreateVisual();
             * _children.Add(_mainVisual);*/
            var renderRect = _collectionRect;
            var borderRect = GetChartBorderRect();
            var whileRect  = new Rect(0, 0, ActualWidth, ActualHeight);

            _backgroundVisual.Clip = new RectangleGeometry(whileRect);
            //_mainVisual.Clip = new RectangleGeometry(borderRect);

            if (_customGraphicListVisual != null)
            {
                _children.Remove(_customGraphicListVisual);
                _customGraphicListVisual = null;
            }

            if (_customGraphicsList != null)
            {
                _customGraphicListVisual = CreateVisual();
                _children.Add(_customGraphicListVisual);
            }
        }
        private void UpdateMonitors()
        {
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);

            foreach (MonitorRectangle monitorRect in _monitorRectangles)
            {
                if (layer != null)
                {
                    layer.Remove(monitorRect.Adorner);
                }
                _children.Remove(monitorRect.View);
            }

            _monitorRectangles.Clear();

            if (Profile != null)
            {
                _setAdorners = true;

                int i = 1;
                foreach (Monitor monitor in Profile.Monitors)
                {
                    HeliosVisualView monitorView = new HeliosVisualView();
                    monitorView.Visual     = monitor;
                    monitorView.Visibility = ShowPanels ? Visibility.Visible : Visibility.Hidden;
                    _children.Add(monitorView);

                    MonitorAdorner adorner = new MonitorAdorner(monitorView, i++.ToString(), monitor);

                    MonitorRectangle monitorRect = new MonitorRectangle();
                    monitorRect.Monitor = monitor;
                    monitorRect.View    = monitorView;
                    monitorRect.Adorner = adorner;
                    _monitorRectangles.Add(monitorRect);
                }
            }
            InvalidateMeasure();
            InvalidateArrange();
            InvalidateVisual();
        }
Exemple #21
0
        // Set selection order in graphicsList according to list of IDs
        private static void ChangeOrder(VisualCollection graphicsList, List <int> indexList)
        {
            List <GraphicsBase> tmpList = new List <GraphicsBase>();

            // Read indexList, find every element in graphicsList by ID
            // and move it to tmpList.

            foreach (int id in indexList)
            {
                GraphicsBase objectToMove = null;

                foreach (GraphicsBase g in graphicsList)
                {
                    if (g.Id == id)
                    {
                        objectToMove = g;
                        break;
                    }
                }

                if (objectToMove != null)
                {
                    // Move
                    tmpList.Add(objectToMove);
                    graphicsList.Remove(objectToMove);
                }
            }

            // Now tmpList contains objects in correct order.
            // Read tmpList and add all its elements back to graphicsList.

            foreach (GraphicsBase g in tmpList)
            {
                graphicsList.Add(g);
            }
        }
Exemple #22
0
        private void ChartHost_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var curPos    = e.GetPosition(this);
            var chartRect = GetChartRect();

            if (!IsPointInChart(curPos))
            {
                return;
            }
            if (startPoint != null && startPoint.Value.X == curPos.X && startPoint.Value.Y == curPos.Y)
            {
                startPoint = null;
            }
            else if (mouseAction == MouseAction.Select)
            {
                if (startPoint != null)
                {
                    ShowRegion(startPoint.Value, curPos);
                    ShowRegion4ConnectionList(startPoint.Value, curPos);

                    startPoint = null;
                }

                if (midPoint != null)
                {
                    _children.Remove(_cursorVisual);
                    _cursorVisual = null;
                }
            }
            else if (mouseAction == MouseAction.Measure)
            {
                startPoint = null;
                _children.Remove(_cursorVisual);
                _cursorVisual = null;
            }

            mouseAction = MouseAction.None;
        }
        // Set selection order in graphicsList according to list of IDs
        private static void ChangeOrder(VisualCollection graphicsList, List<int> indexList)
        {
            List<GraphicsBase> tmpList = new List<GraphicsBase>();

            // Read indexList, find every element in graphicsList by ID
            // and move it to tmpList.

            foreach(int id in indexList)
            {
                GraphicsBase objectToMove = null;

                foreach(GraphicsBase g in graphicsList)
                {
                    if ( g.Id == id)
                    {
                        objectToMove = g;
                        break;
                    }
                }

                if ( objectToMove != null )
                {
                    // Move
                    tmpList.Add(objectToMove);
                    graphicsList.Remove(objectToMove);
                }
            }

            // Now tmpList contains objects in correct order.
            // Read tmpList and add all its elements back to graphicsList.

            foreach(GraphicsBase g in tmpList)
            {
                graphicsList.Add(g);
            }
        }
Exemple #24
0
        /// <summary>
        /// Hide in-place editing textbox.
        /// Called from TextTool, when user pressed Enter or Esc,
        /// or from this class, when user clicks on the canvas.
        ///
        /// graphicsText passed to this function can be new text added by
        /// ToolText, or existing text opened for editing.
        /// If ToolText.OldText is empty, this is new object.
        /// If not, this is existing object.
        /// </summary>
        internal void HideTextbox(GraphicsText graphicsText)
        {
            if (toolText.TextBox == null)
            {
                return;
            }

            graphicsText.IsSelected = true;   // restore selection which was removed for better textbox appearance


            if (toolText.TextBox.Text.Trim().Length == 0)
            {
                // Textbox is empty: remove text object.

                if (!String.IsNullOrEmpty(toolText.OldText))     // existing text was edited
                {
                    // Since text object is removed now,
                    // Add Delete command to the history
                    undoManager.AddCommandToHistory(new CommandDelete(this));
                }

                // Remove empty text object
                graphicsList.Remove(graphicsText);
            }
            else
            {
                if (!String.IsNullOrEmpty(toolText.OldText))              // existing text was edited
                {
                    if (toolText.TextBox.Text.Trim() != toolText.OldText) // text was really changed
                    {
                        // Create command
                        CommandChangeState command = new CommandChangeState(this);

                        // Make change in the text object
                        graphicsText.Text = toolText.TextBox.Text.Trim();
                        graphicsText.UpdateRectangle();

                        // Keep state after change and add command to the history
                        command.NewState(this);
                        undoManager.AddCommandToHistory(command);
                    }
                }
                else                                          // new text was added
                {
                    // Make change in the text object
                    graphicsText.Text = toolText.TextBox.Text.Trim();
                    graphicsText.UpdateRectangle();

                    // Add command to the history
                    undoManager.AddCommandToHistory(new CommandAdd(graphicsText));
                }
            }

            // Remove textbox and set it to null.
            this.Children.Remove(toolText.TextBox);
            toolText.TextBox = null;

            // This enables back all ApplicationCommands,
            // which are disabled while textbox is active.
            this.Focus();
        }
Exemple #25
0
 public void DeleteVisual(Visual visual)
 {
     visuals.Remove(visual);
 }
 /// <summary>Удаляет визуальный элемент с карты</summary>
 /// <param name="v"></param>
 protected void DeleteVisual(MapVisual v)
 {
     _visuals.Remove(v);
 }
 public void RemoveLayer(DrawingVisual annotationVisual)
 {
     _children.Remove(annotationVisual);
 }
Exemple #28
0
 /// <summary>Удаляет визуальный элемент с карты</summary>
 /// <param name="v"></param>
 protected void DeleteVisual(GraphVisual v)
 {
     _visuals.Remove(v);
 }
Exemple #29
0
        public void PutChar(char ch)
        {
            if (ch == '\n')
            {
                cursorY++;
                cursorX = 0;
            }
            else
            {
                // First, see if we've already inserted something at this position. If so, delete the old visuals.
                var cursorPos = new CursorPos(cursorX, cursorY);
                if (visualPairs.ContainsKey(cursorPos))
                {
                    var pair = visualPairs[cursorPos];
                    visuals.Remove(pair.Background);
                    visuals.Remove(pair.Character);
                    visualPairs.Remove(cursorPos);
                }

                var backgroundVisual  = new DrawingVisual();
                var backgroundContext = backgroundVisual.RenderOpen();

                var x = fontCharSize.Width * cursorX;
                var y = fontCharSize.Height * cursorY;

                Brush fg, bg;
                if (reverse)
                {
                    fg = FontsAndColorsService.Background;
                    bg = FontsAndColorsService.Foreground;
                }
                else
                {
                    fg = FontsAndColorsService.Foreground;
                    bg = FontsAndColorsService.Background;
                }

                var backgroundRect = new Rect(
                    Math.Floor(x),
                    Math.Floor(y),
                    Math.Ceiling(fontCharSize.Width + .5),
                    Math.Ceiling(fontCharSize.Height));

                backgroundContext.DrawRectangle(bg, null, backgroundRect);

                backgroundContext.Close();

                visuals.Insert(0, backgroundVisual);

                var textVisual  = new DrawingVisual();
                var textContext = textVisual.RenderOpen();

                textContext.DrawText(
                    new FormattedText(
                        ch.ToString(),
                        CultureInfo.CurrentUICulture,
                        FlowDirection.LeftToRight,
                        GetTypeface(),
                        FontsAndColorsService.FontSize,
                        fg,
                        new NumberSubstitution(NumberCultureSource.User, CultureInfo.CurrentUICulture, NumberSubstitutionMethod.AsCulture),
                        TextFormattingMode.Display),
                    new Point(x, y));

                textContext.Close();

                visuals.Add(textVisual);

                var newPair = new VisualPair(backgroundVisual, textVisual);
                visualPairs.Add(cursorPos, newPair);

                cursorX++;
            }
        }
 internal void InternalRemove(UIElement element)
 {
     _internalChildren.Remove(element);
     ClearLogicalParent(element);
 }
 public override void Remove(UIElement element)
 {
     visualChildren.Remove(element);
     ClearLogicalParent(element);
 }