Beispiel #1
0
        private unsafe void Dropped(DragEventArgs e, RenderSlice rs)
        {
            ObservableCollection <RenderSlice> l = this.GetRenderSliceListFromDropPoint(e);
            Renderer r         = rs.Renderer;
            double   maxbreite = rs.ImageSource.Height;
            int      imageWidth;

            if (l.Count > 0)
            {
                imageWidth = (int)l[0].ImageSource.Width;
            }
            else
            {
                imageWidth = 128;
            }

            RendererManager.Renderer_Update(rs, imageWidth, maxbreite);
            RendererManager.RenderSlice_Update(rs, imageWidth, maxbreite);

            rs.Scale = (float)(imageWidth / rs.Range);
            this.MoveRenderSlice(rs, l);
            XElement channel = rs.UnisensNode;

            RendererManager.Render(rs.Renderer, channel);
        }
Beispiel #2
0
        /// <summary>
        /// new Render in X-direchtion
        /// </summary>
        /// <param name="stackercontrol"></param>
        /// <param name="imageHeight">New image height in pixels (height is the time or x axis</param>
        public static void Drag(StackerControl stackercontrol, double imageHeight)
        {
            if (imageHeight < 20)
            {
                imageHeight = 20;
            }
            MaxBreite = imageHeight;
            for (int i = 0; i < stackercontrol.renderSliceLists.Count; i++)
            {
                RenderSlice rs = null;

                // modify all RenderSlice of the Renderers
                for (int j = 0; j < stackercontrol.renderSliceLists[i].Count; j++)
                {
                    // at adding a new RenderSlice in the rslist,
                    // the current RenderSlice is moved forward.
                    rs = stackercontrol.renderSliceLists[i][0];
                    int imageWidth = ((RasterRenderSlice)rs).ImageWidth;

                    Renderer_Update(rs, imageWidth, imageHeight);
                    RenderSlice_Update(rs, imageWidth, imageHeight);

                    // old RenderSlice replaced by new
                    Renderer r       = rs.Renderer;
                    XElement channel = rs.UnisensNode;
                    stackercontrol.MoveRenderSlice(rs, stackercontrol.renderSliceLists[i]);

                    // paint signal again
                    RendererManager.Render(r, channel);
                }
            }
        }
        private IEnumerable <XElement> ExecutePlugin(IDspPlugin1 p, IEnumerable <XElement> selectedsignals, double time_cursor, string parameter)
        {
            IEnumerable <XElement> retsigs = null;

            foreach (XElement xe in selectedsignals)
            {
                RendererManager.CloseRenderer(xe);
            }

            try
            {
                string path = Environment.CurrentDirectory + "\\" + "unisens.xml";
                retsigs = p.Main(UnisensXmlFileManager.CurrentUnisensInstance.Xdocument, selectedsignals, path, time_cursor, signalviewercontrol.SelectionStart, signalviewercontrol.SelectionEnd, parameter);
            }
            catch (Exception ex)
            {
                retsigs = null;
                MessageBox.Show("Exception im Plugin: " + ex.Message);
            }

            foreach (XElement xe in selectedsignals)
            {
                try
                {
                    RendererManager.ReOpenRenderer(xe);
                }
                catch
                {
                    RendererManager.KillRenderer(xe);
                }
            }

            if (retsigs != null)
            {
                foreach (XElement xe in retsigs)
                {
                    if (StackerControl.IsSignalEventValueEntry(xe))
                    {
                        signalviewercontrol.stackercontrol.DropSignalEventValueEntry(xe, null);
                    }
                }
            }

            signalviewercontrol.Deselect();
            if (RendererManager.TimeMax < RendererManager.Time)
            {
                RendererManager.Scroll(0.0);
            }
            else
            {
                RendererManager.Render();
            }

            // Save Unisens file after Plugin execution
            Executed_Save(null, null);

            return(retsigs);
        }
        private void Execute_setMarker(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                double timeCursor;
                ObservableCollection <RenderSlice> selectedRsList;
                string markerSymbol = "M";
                if (e.Parameter != null && e.Parameter.Equals("ContextMenu"))
                {
                    // Informationen vom Contextmenu
                    timeCursor     = this.signalviewercontrol.stackercontrol.PluginContextMenuTimeCursor;
                    selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                }
                else
                {
                    // Informationen von der aktuellen Mausposition
                    HoverStackEventArgs currentHoverStackEventArgs = hoverStackEventArgs;
                    if (currentHoverStackEventArgs == null)
                    {
                        return;
                    }

                    Point point = Mouse.GetPosition(currentHoverStackEventArgs.ItemsControl);
                    timeCursor     = RendererManager.Time + (RendererManager.TimeStretch * point.X / currentHoverStackEventArgs.ItemsControl.ActualWidth);
                    markerSymbol   = (e.Parameter == null || e.Parameter.Equals(string.Empty)) ? "M" : e.Parameter.ToString();
                    selectedRsList = currentHoverStackEventArgs.Stack;
                }

                IEnumerable <XElement> retsigs = Marker.setMarker(RendererManager.GetSevEntries(selectedRsList), timeCursor, markerSymbol);

                // Neues signal hinzufuegen
                if (retsigs != null)
                {
                    foreach (XElement xe in retsigs)
                    {
                        if (StackerControl.IsSignalEventValueEntry(xe))
                        {
                            signalviewercontrol.stackercontrol.DropSignalEventValueEntry(xe, selectedRsList);
                        }
                    }
                }

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
Beispiel #5
0
        public unsafe void ItemsControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            int imageWidth = (int)itemscontrol_RenderSliceImages.ActualHeight;
            ObservableCollection <RenderSlice> rslist = (ObservableCollection <RenderSlice>)itemscontrol_RenderSliceImages.DataContext;
            RenderSlice rs            = null;
            bool        width_changed = false;

            if (imageWidth < 10)
            {
                imageWidth = 10;
            }


            if (rslist != null)
            {
                // check if the width is changed or a slice is closed, when the mouse is released.
                if (imageWidth != ((RasterRenderSlice)rslist[0]).ImageWidth)
                {
                    width_changed = true;
                }
            }
            if (width_changed)
            {
                int i = 0;
                while (i < rslist.Count)
                {
                    // at adding a new RenderSlice in the rslist,
                    // the current RenderSlice is moved forward.
                    rs = rslist[0];
                    int deltaWidth = (int)(imageWidth - rs.ImageSource.Width);

                    int maxbreite = ((RasterRenderSlice)rs).ImageHeight;
                    // modify all RenderSlice of the Renderers
                    RendererManager.Renderer_Update(rs, imageWidth, maxbreite);
                    RendererManager.RenderSlice_Update(rs, imageWidth, maxbreite);

                    // Update Scale
                    rs.Scale = (float)(imageWidth / rs.Range);
                    //rs.ZoomInto(rs.Zoominfo.PhysicalMin, rs.Zoominfo.PhysicalMax);

                    Renderer r       = rs.Renderer;
                    XElement channel = rs.UnisensNode;

                    // old RenderSlice replaced by new
                    this.MoveRenderSlice(rs, rslist);

                    // paint all signals again
                    RendererManager.Render(r, channel);
                    i++;
                }
            }
        }
Beispiel #6
0
        private void ItemsControl_PreviewMouseMove_ScaleAndOffset(object sender, MouseEventArgs e)
        {
            ItemsControl ic = (ItemsControl)sender;

            Point  p      = e.GetPosition(ic);
            double deltax = p.X - this.dragpoint.X;
            double deltay = p.Y - this.dragpoint.Y;

            if (e.MiddleButton == MouseButtonState.Pressed || e.LeftButton == MouseButtonState.Pressed)
            {
                if ((Keyboard.Modifiers & ModifierKeys.Control) != 0)
                {
                    foreach (DragScaleOffsetInfo dsoi in this.dragselectedrenderslices)
                    {
                        //dsoi.Renderslice.Offset = dsoi.Dragoffset + ((float)(deltay / (ic.ActualHeight * dsoi.Dragscale)) * 128.0f);
                        dsoi.Renderslice.Offset = dsoi.Dragoffset + ((float)(deltay / (ic.ActualHeight * dsoi.Dragscale)) * (float)(dsoi.Renderslice.ImageSource.Width));
                    }

                    foreach (Renderer r in this.dragInvolvedRenderers)
                    {
                        RendererManager.Render(r, null);
                    }
                }

                if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0)
                {
                    float scale = 0;
                    foreach (DragScaleOffsetInfo dsoi in this.dragselectedrenderslices)
                    {
                        scale = dsoi.Dragscale + (float)(deltax * 0.005 * dsoi.Dragscale);
                        if (scale > 0)
                        {
                            dsoi.Renderslice.Scale = scale;            //disable inversion (scaling < 0)
                        }
                    }

                    foreach (Renderer r in this.dragInvolvedRenderers)
                    {
                        RendererManager.Render(r, null);
                    }
                }
            }
            else
            {
                // nix mehr gedrückt, handler deinstallieren
                ic.PreviewMouseMove      -= this.ItemsControl_PreviewMouseMove_ScaleAndOffset;
                this.dragwatcherinstalled = false;
                Mouse.Capture(null);
            }

            e.Handled = true;
        }
        private void Execute_truncateMarker(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                double timeCursor;
                ObservableCollection <RenderSlice> selectedRsList;
                if (e.Parameter != null && e.Parameter.Equals("ContextMenu"))
                {
                    // Informationen vom Contextmenu
                    timeCursor     = this.signalviewercontrol.stackercontrol.PluginContextMenuTimeCursor;
                    selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                }
                else
                {
                    // Informationen von der aktuellen Mausposition
                    HoverStackEventArgs currentHoverStackEventArgs = hoverStackEventArgs;
                    if (currentHoverStackEventArgs == null)
                    {
                        return;
                    }

                    Point point = Mouse.GetPosition(currentHoverStackEventArgs.ItemsControl);
                    timeCursor     = RendererManager.Time + (RendererManager.TimeStretch * point.X / currentHoverStackEventArgs.ItemsControl.ActualWidth);
                    selectedRsList = currentHoverStackEventArgs.Stack;
                }

                Marker.truncateMarker(RendererManager.GetSevEntries(selectedRsList), timeCursor);

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
        private void Execute_setArtifacts(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                //ObservableCollection<RenderSlice> selectedRsList;
                string artifactSymbol_Start = "(artifact";
                string artifactSymbol_End   = "artifact)";

                IEnumerable <XElement> retsigs = Artifacts.setArtifact(signalviewercontrol.SelectionStart, signalviewercontrol.SelectionEnd, artifactSymbol_Start, artifactSymbol_End);

                // Neues signal hinzufuegen
                if (retsigs != null)
                {
                    ObservableCollection <RenderSlice> selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                    foreach (XElement xe in retsigs)
                    {
                        if (StackerControl.IsSignalEventValueEntry(xe))
                        {
                            signalviewercontrol.stackercontrol.DropSignalEventValueEntry(xe, selectedRsList);
                        }
                    }
                }

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
        private void Execute_deleteMarker(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                ObservableCollection <RenderSlice> selectedRsList;
                if (e.Parameter != null && e.Parameter.Equals("ContextMenu"))
                {
                    // Informationen vom Contextmenu
                    selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                }
                else
                {
                    // Informationen von der aktuellen Mausposition
                    HoverStackEventArgs currentHoverStackEventArgs = hoverStackEventArgs;
                    if (currentHoverStackEventArgs == null)
                    {
                        return;
                    }

                    selectedRsList = currentHoverStackEventArgs.Stack;
                }
                Marker.deleteMarker(RendererManager.GetSevEntries(selectedRsList), signalviewercontrol.SelectionStart, signalviewercontrol.SelectionEnd);

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
        private void Execute_CropSelection(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                if (Crop.CropSelection(signalviewercontrol.SelectionStart, signalviewercontrol.SelectionEnd))
                {
                    // Deselect all and Render again
                    signalviewercontrol.Deselect();

                    if (RendererManager.TimeMax < RendererManager.Time)
                    {
                        RendererManager.Scroll(0.0);
                    }
                    else
                    {
                        RendererManager.Render();
                    }

                    // Save Unisens file after Plugin execution
                    Executed_Save(null, null);
                }
            }
        }
        private void Execute_setMarkerList(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                string path = Environment.CurrentDirectory + "\\" + "unisens.xml";
                IEnumerable <XElement> retsigs = MarkerList.setMarkerList(path);

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }