コード例 #1
0
        private void UpdateSelection()
        {
            if ((CursorViewer.Selection != null) && (CursorViewer.Selection.Variable == Variable))
            {
                RectangleSelection.Visibility = System.Windows.Visibility.Visible;
                double x1 = ScaleManager.GetOffset(CursorViewer.Selection.Start);
                double x2 = ScaleManager.GetOffset(CursorViewer.Selection.End);

                RectangleSelection.Width  = x2 - x1;
                RectangleSelection.Height = CanvasWaveform.ActualHeight;

                if (CanvasWaveform.Children.Contains(RectangleSelection) == false)
                {
                    CanvasWaveform.Children.Add(RectangleSelection);
                }

                Canvas.SetLeft(RectangleSelection, x1);
                Canvas.SetTop(RectangleSelection, 0);
            }
            else
            {
                RectangleSelection.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
コード例 #2
0
        /// <summary>
        /// Добавление заметки на долновую диаграмму
        /// </summary>
        /// <param name="bookMark"></param>
        private void AddBookmark(BookMark bookMark)
        {
            Uri bookmarkUri = new Uri("pack://application:,,,/Schematix.Waveform;component/icons/BookMark.jpg", UriKind.RelativeOrAbsolute);

            Image             img           = new Image();
            JpegBitmapDecoder iconDecoder   = new JpegBitmapDecoder(bookmarkUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            ImageSource       bitmapSource2 = iconDecoder.Frames[0];

            img.Source  = bitmapSource2;
            img.Stretch = Stretch.Fill;
            img.Margin  = new Thickness(0);
            img.Width   = 24;
            img.Height  = 24;

            img.Tag         = bookMark;
            img.ContextMenu = Resources["BookmarkMenu"] as ContextMenu;

            img.MouseEnter += new MouseEventHandler(img_MouseEnter);
            img.MouseLeave += new MouseEventHandler(img_MouseLeave);

            CanvasWaveform.Children.Add(img);
            Canvas.SetLeft(img, ScaleManager.GetOffset(bookMark.Time));
            Canvas.SetTop(img, 2);
        }