private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     PlotCanvas.ReleaseMouseCapture();
     _isMouseCaptured = false;
     Cursor           = Cursors.Arrow;
     _mousePosition   = e.GetPosition(PlotCanvas);
 }
Example #2
0
        public PlotSample()
        {
            plotCanvas = new PlotCanvas ();

            // Set defaults for the sample plotCanvas
            plotCanvas.AutoScaleAutoGeneratedAxes = false;
            plotCanvas.AutoScaleTitle = false;
            plotCanvas.Legend = null;
            plotCanvas.Canvas.Name = "plotCanvas";
            plotCanvas.Title = "";
            plotCanvas.TitleFont = Font.SystemSansSerifFont.WithSize (14);
        }
Example #3
0
        public PlotSample()
        {
            plotCanvas = new PlotCanvas ();

            // Set defaults for the sample plotCanvas
            plotCanvas.AutoScaleAutoGeneratedAxes = false;
            plotCanvas.AutoScaleTitle = false;
            plotCanvas.Legend = null;
            plotCanvas.Canvas.Name = "plotCanvas";
            plotCanvas.Title = "";
            plotCanvas.TitleFont = Font.FromName ("Ubuntu 14");
        }
Example #4
0
        public PlotSample()
        {
            plotCanvas = new PlotCanvas();

            // Set defaults for the sample plotCanvas
            plotCanvas.AutoScaleAutoGeneratedAxes = false;
            plotCanvas.AutoScaleTitle             = false;
            plotCanvas.Legend      = null;
            plotCanvas.Canvas.Name = "plotCanvas";
            plotCanvas.Title       = "";
            plotCanvas.TitleFont   = Font.SystemSansSerifFont.WithSize(14);
        }
Example #5
0
        void HandleSamplesTreeSelectionChanged(object sender, EventArgs e)
        {
            if (samplesTree.SelectedRow != null)
            {
                // Remove currentInteraction if there is one
                if (currentInteraction != null)
                {
                    // must already have a valid plot sample with the interaction added to it
                    PlotSample ps = (PlotSample)currentWidget;
                    PlotCanvas pc = ps.PlotCanvas;
                    // Remove current interaction from PlotCanvas
                    pc.RemoveInteraction(currentInteraction);
                    currentInteraction = null;
                }

                // get newSample from selected row
                TreePosition  viewRow   = samplesTree.SelectedRow;
                TreeNavigator storeRow  = store.GetNavigatorAt(viewRow);
                Sample        newSample = storeRow.GetValue(sampleCol);

                TreePosition newCategory = newSample.Category;
                if (newCategory == interactionCategory)
                {
                    // only allow interaction if there is already a plotSample
                    if (currentCategory == plotCategory)
                    {
                        PlotSample ps = (PlotSample)currentWidget;
                        PlotCanvas pc = ps.PlotCanvas;
                        // Add new interaction to existing PlotCanvas
                        currentInteraction = newSample.Interaction;
                        pc.AddInteraction(currentInteraction);
                    }
                }
                else
                {
                    // plotCategory or testCategory
                    currentCategory = newCategory;
                    if (currentWidget != null)
                    {
                        sampleBox.Remove(currentWidget);
                    }
                    if (newSample.Type != null)
                    {
                        currentWidget = (Widget)Activator.CreateInstance(newSample.Type);
                        sampleBox.PackStart(currentWidget, true);
                        Dump(currentWidget, 0);
                    }
                }
            }
        }
        private void VisualizeItemsSource()
        {
            //we may change the size of the plot depending on number of elements we have to draw.
            //Dont want to fire the size-changed event and redraw stuff, so unhook event handler
            PlotCanvas.SizeChanged -= Canvas_SizeChanged;
            String[] currHighlight = null;
            if (PlotCanvas.Children.Count > 0)
            {
                currHighlight = (from tl in PlotCanvas.Children
                                 where
                                 tl is TimeLine && ((TimeLine)tl).ItemsSource.IsHighlighted
                                 select((TimeLine)tl).ItemsSource.Label).ToArray();
            }

            //remove all existing stuff on the plot canvas
            PlotCanvas.Children.Clear();
            //if the elements can be more than the minimum specified height and still fit into the
            //viewport of scrollviewer, do that. Else grow the plotcanvas height to (elementCount * minimumHeight)
            PlotCanvas.Height = PlotScrollViewer.ActualHeight;
            double totalHeight = PlotCanvas.Height;
            double tlHeight    = 0;

            if (_itemsSource != null)
            {
                tlHeight = totalHeight / _itemsSource.Count();
            }
            if (tlHeight < MINIMUM_TIMELINE_HEIGHT)
            {
                tlHeight          = MINIMUM_TIMELINE_HEIGHT;
                PlotCanvas.Height = _itemsSource == null?0: MINIMUM_TIMELINE_HEIGHT *_itemsSource.Count();
            }
            //Draw Axis and the background shading inside plotcanvas for axis-related stuff (weekends, etc.)
            DrawAxis();

            //Create a TimeLine for each item in source, and position it on the plot canvas one below the other.
            double i = 0;

            if (_itemsSource != null)
            {
                foreach (TimeLineData d in _itemsSource)
                {
                    if (currHighlight != null && currHighlight.Contains(d.Label))
                    {
                        d.IsHighlighted = true;
                    }
                    var tl = new TimeLine
                    {
                        TimeLineStart = _startDate,
                        TimeLineEnd   = _endDate,
                        Height        = tlHeight,
                        Width         = PlotCanvas.ActualWidth,
                        ItemsSource   = d
                    };
                    tl.DetailRequested += TlDetailRequested;
                    if (IsSingleSelect)
                    {
                        tl.Selected += TlSelected;
                    }
                    tl.GlobalDeselectRequested += TlGlobalDeselectRequested;
                    Canvas.SetLeft(tl, 0);
                    //Position the TimeLine below the last one.
                    Canvas.SetTop(tl, i * tlHeight);
                    PlotCanvas.Children.Add(tl);
                    i++;
                }
            }
            PlotCanvas.UpdateLayout();
            //We are done. Let the event handler play again.
            PlotCanvas.SizeChanged += Canvas_SizeChanged;
        }
 private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     _isMouseCaptured = true;
     PlotCanvas.CaptureMouse();
     Cursor = Cursors.Hand;
 }