Exemple #1
0
        //////////////////////////////////////////////////////////////////////////////////////
        //
        // scale + offset dragging
        //
        //////////////////////////////////////////////////////////////////////////////////////

        private void ItemsControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!this.dragwatcherinstalled &&
                ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != 0 &&
                 (e.MiddleButton == MouseButtonState.Pressed || e.LeftButton == MouseButtonState.Pressed)))
            {
                ItemsControl ic = (ItemsControl)sender;
                Mouse.Capture(ic);

                this.dragpoint = e.GetPosition(ic);                             // position relativ zum itemscontrol!!

                // die listbox aus der datatemplate-instanz muss erst noch ermittelt werden
                Grid    grid    = (Grid)LogicalTreeHelper.GetParent(ic);
                ListBox listbox = (ListBox)grid.FindName("listbox");

                if (listbox.SelectedItem == null)
                {
                    listbox.SelectedIndex = 0;
                }

                /*
                 * dragselectedrenderslice = (RenderSlice) listbox.SelectedItem;
                 *
                 * dragscale = dragselectedrenderslice.Scale;
                 * dragoffset = dragselectedrenderslice.Offset;
                 */

                // die folgende liste NICHT mit linq zusammenbauen!!
                // das ist dann saulahm!! ich glaub er re-evaluiert die abfrage, sobald offset/scale
                // verändert wird => changed-event (INotifyPropertyChanged in RenderSlice)
                this.dragselectedrenderslices = new List <DragScaleOffsetInfo>();
                foreach (RenderSlice rs in listbox.SelectedItems)
                {
                    this.dragselectedrenderslices.Add(new DragScaleOffsetInfo(rs));
                }

                this.dragInvolvedRenderers = RendererManager.GetInvolvedRenderers(from RenderSlice rs in listbox.SelectedItems select rs);

                // Keyboard.Modifiers == None ist für das time-scroll&stretch in signalviewercontrol
                if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) != 0)
                {
                    ic.PreviewMouseMove      += this.ItemsControl_PreviewMouseMove_ScaleAndOffset;
                    this.dragwatcherinstalled = true;
                }

                e.Handled = true;
            }
        }
Exemple #2
0
        private void MenuItem_Click_Invert(object sender, RoutedEventArgs e)
        {
            MenuItem mi = (MenuItem)sender;
            ObservableCollection <RenderSlice> rslist     = (ObservableCollection <RenderSlice>)mi.DataContext;
            IEnumerable <RenderSlice>          selectedrs = this.GetSelectedRenderSlices(rslist);

            foreach (RenderSlice rs in selectedrs)
            {
                // Inverst the scaling factor and calculate new range
                rs.Scale = -rs.Scale;
                float min = -rs.Offset;
                float max = (float)rs.Range - rs.Offset;

                // Update range and offset.
                rs.Zoominfo.PhysicalMax = max > min ? max : min;
                rs.Zoominfo.PhysicalMin = max > min ? min : max;
                rs.Offset = -max;
            }

            // Draw inversted signal
            RendererManager.UpdateRenderers(RendererManager.GetInvolvedRenderers(selectedrs));
        }