예제 #1
0
        private void repositoryItemButtonEditSource_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            var dataSource =
                DataSources.ElementAt(GridViewDataSources.FocusedRowHandle).DataSource as IPropertiesProvider;

            if (dataSource != null)
            {
                var form = new PropertiesForm();

                var validationRules = dataSource.GetValidationRules();
                form.SetValidationRules(validationRules);
                var propertyEditors = dataSource.GetPropertyEditors();
                form.SetPropertyEditors(propertyEditors);
                var simpleProperties = dataSource.GetSimpleProperties();
                form.SetSimpleProperties(simpleProperties);
                var collectionProperties = dataSource.GetCollections();
                form.SetCollectionProperties(collectionProperties);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    dataSource.ApplySimpleProperties();
                    dataSource.ApplyCollections();
                    GridViewDataSources.HideEditor();
                    GridViewDataSources.RefreshData();
                }
                else
                {
                    form.RevertChanges();
                }
            }
        }
예제 #2
0
        public override void PlotToParentStandalone(Point point, EventMessage @event)
        {
            if (!VisualData.TryTransformVisualData <ContextData>(out var visual_data))
            {
                return;
            }

            if (!IsCrossShow)
            {
                X.Visibility = Visibility.Collapsed;
                Y.Visibility = Visibility.Collapsed;
                return;
            }

            var coms = DataSources.ElementAt(0).Value as ChartDataSource;

            var axisxs   = coms.AxisXCollection;
            var axisys   = coms.AxisYCollection;
            var series   = coms.SeriesCollection;
            var plotArea = coms.ConnectVisual.PlotArea;

            if (LastPlotArea != plotArea)
            {
                X.X1 = Y.X1 = 0;
                X.Y1 = Y.X1 = 0;
                X.X2 = plotArea.Width;
                X.Y2 = 0;
                Y.X2 = 0;
                Y.Y2 = plotArea.Height;

                Canvas.SetLeft(X, plotArea.Location.X);
                Canvas.SetTop(X, plotArea.Location.Y);
                Canvas.SetTop(Y, plotArea.Location.Y);
                Canvas.SetLeft(Y, plotArea.Location.X);
            }

            if (!visual_data.Current.Items.ContainsKey(ContextDataItem.HitPointer))
            {
                return;
            }
            var hitPointer = (Point)visual_data.Current.Items[ContextDataItem.HitPointer];
            //优化
            bool isXInvariant = false;
            bool isYInvariant = false;

            if (hitPointer.X == LastPoint.X)
            {
                isXInvariant = true;
            }
            if (hitPointer.Y == LastPoint.Y)
            {
                isYInvariant = true;
            }
            LastPoint = hitPointer;
            if (plotArea.Contains(point))
            {
                if (IsLabelShow)
                {
                    var nearestX = point.X;
                    var nearestY = point.Y;
                    //var nearestY = point.Y;
                    //找最小距离
                    var axisLabelList = new List <ElementPosition>();

                    if (!isXInvariant)
                    {
                        foreach (DiscreteAxis axis in axisxs)
                        {
                            var value = axis.GetValue(axis.OffsetPostion(point.X));
                            if (!value.IsBad() && axis.IsAxisLabelShow)
                            {
                                if (!CurrentAll.ContainsKey(axis.Id))
                                {
                                    ParentCanvas.AddElement(axis.AxisLabel);
                                    CurrentAll[axis.Id] = axis;
                                }

                                axis.AxisLabel.Text = axis.GetStringValue(value);
                                var labelData = axis.GetAxisLabelData(value);
                                if (labelData.IsBad)
                                {
                                    continue;
                                }
                                axisLabelList.Add(new ElementPosition(axis.AxisLabel, true, labelData.Left, labelData.Top, axis.AxisLabel.ZIndex));
                            }
                            else
                            {
                                axisLabelList.Add(new ElementPosition(axis.AxisLabel));
                            }
                        }
                    }

                    if (!isYInvariant)
                    {
                        foreach (ContinuousAxis axis in axisys)
                        {
                            var value = axis.GetValue(axis.OffsetPostion(nearestY));
                            if (axis.IsAxisLabelShow)
                            {
                                if (!CurrentAll.ContainsKey(axis.Id))
                                {
                                    ParentCanvas.Children.Add(axis.AxisLabel);
                                    CurrentAll[axis.Id] = axis;
                                }

                                axis.AxisLabel.Text = $"{axis.GetStringValue(value)}{axis.Unit}";
                                var labelData = axis.GetAxisLabelData(value);

                                axisLabelList.Add(new ElementPosition(axis.AxisLabel, true, labelData.Left, labelData.Top));
                            }
                            else
                            {
                                axisLabelList.Add(new ElementPosition(axis.AxisLabel));
                            }
                        }
                    }

                    foreach (var item in axisLabelList)
                    {
                        item.Render();
                    }
                }

                LastPlotArea = plotArea;

                if (!isYInvariant)
                {
                    if (IsXShow)
                    {
                        X.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        X.Visibility = Visibility.Collapsed;
                    }
                    Canvas.SetTop(X, hitPointer.Y);
                }
                if (!isXInvariant)
                {
                    if (IsYShow)
                    {
                        Y.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        Y.Visibility = Visibility.Collapsed;
                    }
                    Canvas.SetLeft(Y, hitPointer.X);
                }
            }
            else
            {
                foreach (var item in CurrentAll)
                {
                    item.Value.AxisLabel.Visibility = Visibility.Collapsed;
                }

                X.Visibility = Visibility.Collapsed;
                Y.Visibility = Visibility.Collapsed;
            }
        }