示例#1
0
        /// <summary>
        /// Cancel currently executed operation:
        /// add new object or group selection.
        ///
        /// Called when mouse capture is lost or Esc is pressed.
        /// </summary>
        void CancelCurrentOperation()
        {
            if (Tool == ToolType.Pointer)
            {
                if (graphicsList.Count > 0)
                {
                    if (graphicsList[graphicsList.Count - 1] is GraphicsSelectionRectangle)
                    {
                        // Delete selection rectangle if it exists
                        graphicsList.RemoveAt(graphicsList.Count - 1);
                    }
                    else
                    {
                        // Pointer tool moved or resized graphics object.
                        // Add this action to the history
                        toolPointer.AddChangeToHistory(this);
                    }
                }
            }
            else if (Tool > ToolType.Pointer && Tool < ToolType.Max)
            {
                // Delete last graphics object which is currently drawn
                if (graphicsList.Count > 0)
                {
                    graphicsList.RemoveAt(graphicsList.Count - 1);
                }
            }

            Tool = ToolType.Pointer;

            this.ReleaseMouseCapture();
            this.Cursor = HelperFunctions.DefaultCursor;
        }
示例#2
0
        private void Redraw()
        {
            try
            {
                Dispatcher.Invoke(() =>
                {
                    if (Constellation != null)
                    {
                        lock (_children)
                        {
                            _children.Add(DrawConstellation(Constellation));
                            if (_children.Count == 4)
                            {
                                _children.RemoveAt(1);
                            }

                            _children.Add(DrawTarget());
                            if (_children.Count == 4)
                            {
                                _children.RemoveAt(1);
                            }
                        }
                    }

                });
            }
            catch
            {
                // Can crash here if closing the app.

            }
        }
示例#3
0
        // ------------------------------------------------------------------
        // Syncs a floating element para list with a visual collection
        // ------------------------------------------------------------------
        internal static void UpdateFloatingElementVisuals(ContainerVisual visual, List <BaseParaClient> floatingElementList)
        {
            VisualCollection visualChildren = visual.Children;
            int visualIndex = 0;

            if (floatingElementList == null || floatingElementList.Count == 0)
            {
                visualChildren.Clear();
            }
            else
            {
                for (int index = 0; index < floatingElementList.Count; index++)
                {
                    Visual paraVisual = floatingElementList[index].Visual;

                    while (visualIndex < visualChildren.Count && visualChildren[visualIndex] != paraVisual)
                    {
                        visualChildren.RemoveAt(visualIndex);
                    }

                    if (visualIndex == visualChildren.Count)
                    {
                        visualChildren.Add(paraVisual);
                    }

                    visualIndex++;
                }


                if (visualChildren.Count > floatingElementList.Count)
                {
                    visualChildren.RemoveRange(floatingElementList.Count, visualChildren.Count - floatingElementList.Count);
                }
            }
        }
示例#4
0
        // Token: 0x0600692C RID: 26924 RVA: 0x001DC364 File Offset: 0x001DA564
        internal static void UpdateFloatingElementVisuals(ContainerVisual visual, List <BaseParaClient> floatingElementList)
        {
            VisualCollection children = visual.Children;
            int num = 0;

            if (floatingElementList == null || floatingElementList.Count == 0)
            {
                children.Clear();
                return;
            }
            for (int i = 0; i < floatingElementList.Count; i++)
            {
                Visual visual2 = floatingElementList[i].Visual;
                while (num < children.Count && children[num] != visual2)
                {
                    children.RemoveAt(num);
                }
                if (num == children.Count)
                {
                    children.Add(visual2);
                }
                num++;
            }
            if (children.Count > floatingElementList.Count)
            {
                children.RemoveRange(floatingElementList.Count, children.Count - floatingElementList.Count);
            }
        }
示例#5
0
        // ------------------------------------------------------------------
        // Update visuals for list of paragraphs.
        // ------------------------------------------------------------------
        internal static void UpdateParaListVisuals(
            PtsContext ptsContext,
            VisualCollection visualCollection,
            PTS.FSKUPDATE fskupdInherited,
            PTS.FSPARADESCRIPTION [] arrayParaDesc)
        {
            // For each paragraph, do following:
            // (1) Retrieve ParaClient object
            // (3) Update visual, if necessary
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                // (2) Update visual, if necessary
                PTS.FSKUPDATE fskupd = arrayParaDesc[index].fsupdinf.fskupd;
                if (fskupd == PTS.FSKUPDATE.fskupdInherited)
                {
                    fskupd = fskupdInherited;
                }
                if (fskupd == PTS.FSKUPDATE.fskupdNew)
                {
                    // Disconnect visual from its old parent, if necessary.
                    Visual currentParent = VisualTreeHelper.GetParent(paraClient.Visual) as Visual;
                    if (currentParent != null)
                    {
                        ContainerVisual parent = currentParent as ContainerVisual;
                        Invariant.Assert(parent != null, "parent should always derives from ContainerVisual");
                        parent.Children.Remove(paraClient.Visual);
                    }

                    // New paragraph - insert new visual node
                    visualCollection.Insert(index, paraClient.Visual);

                    paraClient.ValidateVisual(fskupd);
                }
                else
                {
                    // Remove visuals for non-existing paragraphs
                    while (visualCollection[index] != paraClient.Visual)
                    {
                        visualCollection.RemoveAt(index);
                        Invariant.Assert(index < visualCollection.Count);
                    }

                    if (fskupd == PTS.FSKUPDATE.fskupdChangeInside || fskupd == PTS.FSKUPDATE.fskupdShifted)
                    {
                        paraClient.ValidateVisual(fskupd);
                    }
                }
            }
            // Remove obsolete visuals
            if (arrayParaDesc.Length < visualCollection.Count)
            {
                visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
            }
        }
        private void AddCross(Point point)
        {
            if (Points.Count >= MAX_POINTS_COUNT)
            {
                //There are already 4 points, so this call adds a 5th one. This is why the first point will be removed.
                Points.RemoveAt(0);
                _children.RemoveAt(2);
            }
            Points.Add(point);
            CreateCross(point.X, point.Y);

            if (Points.Count == MAX_POINTS_COUNT)
            {
                //When we have 4 points, it is possible to draw and create the quadrilateral.
                ConnectCrosses();
                CreateQuadrilateral();
            }
        }
        public override void RemoveAt(int index)
        {
            UIElement element = visualChildren[index] as UIElement;

            visualChildren.RemoveAt(index);
            if (element != null)
            {
                ClearLogicalParent(element);
            }
        }
示例#8
0
        /// <summary>
        /// Replace a DrawingVisual in VisualsPanel at the specified index.
        /// </summary>
        public void Replace(int index, DrawingVisual visual)
        {
            handleOffset(visual);
            if (hasBackgroundVisual)
            {
                index++;
            }

            visuals.RemoveAt(index);
            visuals.Insert(index, visual);
        }
示例#9
0
            public void TransmitBytes()
            {
                foreach (var ch in TextToTransmit)
                {
                    NavigateToChar(ch);
                    CharReceived(ch);
                    PauseBetweenPointing();
                }

                NavigateToChar('-');



                Dispatcher.BeginInvoke(new Action(delegate
                {
                    TransmitButton.IsEnabled = true;

                    Childrens.RemoveAt(Childrens.Count - 1);

                    InitializePointingLine();
                }));
            }
        /// <summary>Removes the <see cref="T:System.Windows.UIElement" /> at the specified index. </summary>
        /// <param name="index">The index of the <see cref="T:System.Windows.UIElement" /> that you want to remove.</param>
        // Token: 0x0600594E RID: 22862 RVA: 0x0018AB50 File Offset: 0x00188D50
        public virtual void RemoveAt(int index)
        {
            this.VerifyWriteAccess();
            VisualCollection visualChildren = this._visualChildren;
            UIElement        uielement      = visualChildren[index] as UIElement;

            visualChildren.RemoveAt(index);
            if (uielement != null)
            {
                this.ClearLogicalParent(uielement);
            }
            this._visualParent.InvalidateMeasure();
        }
示例#11
0
        private void UpdateSplitters()
        {
            var desiredCount = Children.Count - 1;

            while (splitters.Count > desiredCount)
            {
                splitters.RemoveAt(splitters.Count - 1);
            }

            while (splitters.Count < desiredCount)
            {
                splitters.Add(new SplitPanelSplitter(this, splitters.Count));
            }
        }
示例#12
0
        public virtual void RemoveAt(int index)
        {
            VisualCollection vc = _visualChildren;

            //disconnect from logical tree
            UIElement e = vc[index] as UIElement;

            vc.RemoveAt(index);

            if (e != null)
            {
                ClearLogicalParent(e);
            }

            //_visualParent.InvalidateMeasure();
        }
        // Token: 0x06006856 RID: 26710 RVA: 0x001D68F8 File Offset: 0x001D4AF8
        private void DestroyVisualLinks(ContainerVisual visual)
        {
            VisualCollection children = visual.Children;

            if (children != null)
            {
                for (int i = 0; i < children.Count; i++)
                {
                    if (children[i] is UIElementIsland)
                    {
                        children.RemoveAt(i);
                    }
                    else
                    {
                        Invariant.Assert(children[i] is ContainerVisual, "The children should always derive from ContainerVisual");
                        this.DestroyVisualLinks((ContainerVisual)children[i]);
                    }
                }
            }
        }
示例#14
0
        internal void MoveArm2(System.Drawing.PointF ptAxisNew, System.Drawing.PointF ptNewDispense)
        {
            _children.RemoveAt(1);
            var drawingVisual = CreateSecondArm(ptArm2Axis,new Vector(ptAxisNew.X - ptArm2Axis.X,ptAxisNew.Y - ptArm2Axis.Y));

            Vector vecNew = new Vector(ptNewDispense.X - ptAxisNew.X, ptNewDispense.Y - ptAxisNew.Y);//use the new axis
            Vector vecOrg = new Vector(ptDispense.X - ptArm2Axis.X, ptDispense.Y - ptArm2Axis.Y);//this vector is fixed, never change
            float angle = (float)Vector.AngleBetween(vecNew, vecOrg);
            if (ptNewDispense.X < ptDispense.X + ptAxisNew.X - ptArm2Axis.X) //rotate ccw
            {
                angle = -angle;
            }
         
            
            MotorController.Instance.Rotate2ABSAngle(2,angle);
            var rotateTransform = new RotateTransform(angle, ptAxisNew.X, ptAxisNew.Y);
            drawingVisual.Transform = rotateTransform;
            _children.Add(drawingVisual);

        }
示例#15
0
 // Token: 0x06006930 RID: 26928 RVA: 0x001DC5E0 File Offset: 0x001DA7E0
 internal static void UpdateParaListVisuals(PtsContext ptsContext, VisualCollection visualCollection, PTS.FSKUPDATE fskupdInherited, PTS.FSPARADESCRIPTION[] arrayParaDesc)
 {
     for (int i = 0; i < arrayParaDesc.Length; i++)
     {
         BaseParaClient baseParaClient = ptsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient;
         PTS.ValidateHandle(baseParaClient);
         PTS.FSKUPDATE fskupdate = arrayParaDesc[i].fsupdinf.fskupd;
         if (fskupdate == PTS.FSKUPDATE.fskupdInherited)
         {
             fskupdate = fskupdInherited;
         }
         if (fskupdate == PTS.FSKUPDATE.fskupdNew)
         {
             Visual visual = VisualTreeHelper.GetParent(baseParaClient.Visual) as Visual;
             if (visual != null)
             {
                 ContainerVisual containerVisual = visual as ContainerVisual;
                 Invariant.Assert(containerVisual != null, "parent should always derives from ContainerVisual");
                 containerVisual.Children.Remove(baseParaClient.Visual);
             }
             visualCollection.Insert(i, baseParaClient.Visual);
             baseParaClient.ValidateVisual(fskupdate);
         }
         else
         {
             while (visualCollection[i] != baseParaClient.Visual)
             {
                 visualCollection.RemoveAt(i);
                 Invariant.Assert(i < visualCollection.Count);
             }
             if (fskupdate == PTS.FSKUPDATE.fskupdChangeInside || fskupdate == PTS.FSKUPDATE.fskupdShifted)
             {
                 baseParaClient.ValidateVisual(fskupdate);
             }
         }
     }
     if (arrayParaDesc.Length < visualCollection.Count)
     {
         visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
     }
 }
示例#16
0
 public void Draw()
 {
     try
     {
         Dispatcher.Invoke(
             () =>
         {
             if (Data != null)
             {
                 _children.Add(DrawSignal(Data));
                 if (_children.Count == 2)
                 {
                     _children.RemoveAt(0);
                 }
             }
         });
     }
     catch
     {
         // Can crash here if closing the app.
     }
 }
        public void AddCursorPosition(double x, double y, bool drawTrack)
        {
            Point newPoint = new Point(x, y);

            if (drawTrack)
            {
                DrawingVisual line = new DrawingVisual();
                _children.Add(line);
                DrawTrack(line, newPoint);
            }

            DrawingVisual circle = new DrawingVisual();

            _children.Add(circle);
            DrawCursor(circle, newPoint);
            _lastPoint = newPoint;

            while (_children.Count > MaxTrackCount)
            {
                _children.RemoveAt(0);
            }
        }
示例#18
0
        // Replace objects in graphicsList with objects from clone list
        private static void ReplaceObjects(VisualCollection graphicsList, List <PropertiesGraphicsBase> list)
        {
            for (int i = 0; i < graphicsList.Count; i++)
            {
                PropertiesGraphicsBase replacement = null;

                foreach (PropertiesGraphicsBase o in list)
                {
                    if (o.ID == ((GraphicsBase)graphicsList[i]).Id)
                    {
                        replacement = o;
                        break;
                    }
                }

                if (replacement != null)
                {
                    // Replace object with its clone
                    graphicsList.RemoveAt(i);
                    graphicsList.Insert(i, replacement.CreateGraphics());
                }
            }
        }
示例#19
0
        private void Draw()
        {
            try
            {
                Dispatcher.Invoke(
                    () =>
                {
                    if (Signal != null)
                    {
                        // Explanation::
                        // The SpecLines are drawn initially at index 0 (loaded).
                        // On each call,
                        // - We start with a list that contains: 0-Spec
                        // - The signal is drawn at index 1 and the speclines at index 2
                        // - Since the list exceeds 2 elements, we remove the first element, keeping the latest signal and speclines.
                        //
                        // We want to draw the speclines before removing the old ones to avoid flickering
                        // Also, if the window is resized, the speclines get drawn at the proper location
                        //

                        _children.Add(DrawSignal(Signal));
                        _children.Add(DrawSpecLines());

                        // Only keep the latest signal and speclines.
                        while (_children.Count > 2)
                        {
                            _children.RemoveAt(0);
                        }
                    }
                });
            }
            catch
            {
                // Can crash here if closing the app.
            }
        }
示例#20
0
文件: VisualHost.cs 项目: Finthan/C-
 public void RemoveLastChild()
 {
     _children.RemoveAt(VisualChildrenCount - 1);
 }