示例#1
0
        private static void OnItemTap(object sender, GestureEventArgs e)
        {
            var border = e.OriginalSource as Border;
            if (border != null)
            {
                if (border.Name == "ToggleBorder")
                    return;
            }

            var control = sender as Control;
            var command = GetCommand(control);
            //var selected = GetCommandParameter(control);

            if (control != null && command != null && command.CanExecute(null))
            {
                var source = e.OriginalSource as FrameworkElement;
                if (source == null)
                    return;

                var viewModel = source.DataContext as NodeViewModelBase;
                if (viewModel == null)
                {
                    command.Execute(null);
                    return;
                }

                var page = VisualHelper.FindParent<Page>(control);
                var navObj = new NavigationObject(viewModel, page);
                command.Execute(navObj);
            }
        }
示例#2
0
 void CommunicationManager_StatusUpdated(object sender, StatusUpdatedEventArgs e)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
     {
         VisualHelper.BindTarget(TweetsListView, ListViewItem.OpacityProperty);
     }));
 }
示例#3
0
        private static ProgressBar SetProgressIndicator(FrameworkElement clickedButton, string indicatorText, int maxValue)
        {
            //Ищем прогресс бар
            var grid = VisualHelper.FindParent <Grid>(clickedButton);

            if (grid != null)
            {
                var spProgressLayout = grid.FindName("spProgressLayout") as FrameworkElement;
                if (spProgressLayout != null)
                {
                    spProgressLayout.Visibility = Visibility.Visible;
                    var progressBar = spProgressLayout.FindName("pbProgress") as ProgressBar;
                    if (progressBar != null)
                    {
                        progressBar.Maximum = maxValue / 100;
                    }

                    var tbProgress = spProgressLayout.FindName("tbProgress") as TextBlock;
                    if (tbProgress != null)
                    {
                        tbProgress.Text = indicatorText;
                    }

                    return(progressBar);
                }
            }

            return(null);
        }
示例#4
0
        private static void ClearProgressIndicator(FrameworkElement clickedButton)
        {
            if (clickedButton == null)
            {
                return;
            }

            //Ищем прогресс бар
            var grid = VisualHelper.FindParent <Grid>(clickedButton);

            if (grid != null)
            {
                var spProgressLayout = grid.FindName("spProgressLayout") as FrameworkElement;
                if (spProgressLayout != null)
                {
                    var progressBar = spProgressLayout.FindName("pbProgress") as ProgressBar;
                    if (progressBar != null)
                    {
                        progressBar.Value   = 0;
                        progressBar.Maximum = 0;
                    }

                    var tbProgress = spProgressLayout.FindName("tbProgress") as TextBlock;
                    if (tbProgress != null)
                    {
                        tbProgress.Text = string.Empty;
                    }

                    spProgressLayout.Visibility = Visibility.Collapsed;
                }
            }

            clickedButton.IsEnabled = true;
        }
示例#5
0
        static void element_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ItemsControl control = sender as ItemsControl;

            foreach (InputBinding b in control.InputBindings)
            {
                if (!(b is MouseBinding))
                {
                    continue;
                }

                if (b.Gesture != null &&
                    b.Gesture is MouseGesture &&
                    ((MouseGesture)b.Gesture).MouseAction == MouseAction.LeftDoubleClick &&
                    b.Command.CanExecute(null))
                {
                    if (control is ListBox)
                    {
                        var fe = e.OriginalSource as UIElement;
                        var li = VisualHelper.TryFindParent <ListBoxItem>(fe);
                        if (li != null)
                        {
                            (control as ListBox).SetValue(ListBox.SelectedValueProperty, li.DataContext);
                        }
                    }
                    b.Command.Execute(b.CommandParameter);
                    e.Handled = true;
                }
            }
        }
示例#6
0
        /// <summary>
        /// Updates the data displayed.
        /// </summary>
        private void UpdateDataDisplay()
        {
            if (DataResult != null && DataResult.Data != null)
            {
                View.Data = DataResult.Data.DefaultView;
                if (DataResult.Data.Rows.Count == 0)
                {
                    View.DataResultText = String.Format("{0} total records.", DataResult.Size);
                }
                else
                {
                    View.DataResultText = String.Format("Displaying records {0} through {1} of {2} total records.",
                                                        DataResult.Index + 1,
                                                        DataResult.Data.Rows.Count + DataResult.Index,
                                                        DataResult.Size);
                }

                if (String.IsNullOrWhiteSpace(DataResult.Data.TableName))
                {
                    Presenter.Header = VisualHelper.CreateIconHeader("SOQL", "Table.png");
                    Text             = "SOQL";
                }
                else
                {
                    Presenter.Header = VisualHelper.CreateIconHeader(DataResult.Data.TableName, "Table.png");
                    Text             = DataResult.Data.TableName;
                }
            }
            else
            {
                View.Data           = null;
                View.DataResultText = String.Empty;
            }
        }
        private static void OnCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var element = (FrameworkElement)d;

            if (element == null)
            {
                return;
            }

            element.MouseMove += (o, args) =>
            {
                var viewer = VisualHelper.GetScrollViewer(element);
                if (viewer == null)
                {
                    return;
                }

                var command = GetLoadMoreCommand(element);
                if (command == null)
                {
                    return;
                }

                var progress = viewer.VerticalOffset / viewer.ScrollableHeight;
                if (progress >= 0.6)
                {
                    command.Execute(null);
                }
            };
        }
示例#8
0
 private void CommandTextBox_Loaded(object sender, RoutedEventArgs e)
 {
     if (VisualHelper.GetAutoFocusMode(this) == AutoFocusMode.OnLoad)
     {
         AutoFocus();
     }
 }
示例#9
0
        /// <summary>
        /// Set the header based on the currently selected manifest.
        /// </summary>
        /// <param name="host">The type of host.</param>
        /// <param name="presenter">The presenter to use.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            bool canDelete = false;

            Manifest[] manifests = GetSelectedManifests();
            if (manifests.Length > 0)
            {
                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Delete.png");
                    presenter.ToolTip = (manifests.Length == 1) ?
                                        String.Format("Delete {0}", manifests[0].Name) :
                                        "Delete selected manifests";
                }
                else
                {
                    presenter.Header = (manifests.Length == 1) ?
                                       String.Format("Delete {0}", manifests[0].Name) :
                                       "Delete selected manifests";
                    presenter.Icon = VisualHelper.CreateIconHeader(null, "Delete.png");
                }

                canDelete = true;
            }

            IsVisible = canDelete;
        }
示例#10
0
        /// <summary>
        /// Set the headers.
        /// </summary>
        /// <param name="host">The type of host.</param>
        /// <param name="presenter">The presenter to use.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            ISourceFileEditorDocument document = CurrentDocument;

            if (document != null)
            {
                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Cut.png");
                    presenter.ToolTip = "Cut";
                }
                else
                {
                    presenter.Header           = "Cut";
                    presenter.Icon             = VisualHelper.CreateIconHeader(null, "Cut.png");
                    presenter.InputGestureText = "Ctrl+X";
                }

                IsVisible = true;
                IsEnabled = !document.IsReadOnly;
            }
            else
            {
                IsVisible = false;
            }
        }
示例#11
0
        private void imagePc_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MainWindow mainWindow = new MainWindow();
            string     txt;
            Image      img  = (Image)sender;
            var        obj  = img.Parent;
            Grid       grid = (Grid)obj;
            /////////////////////////
            string ip = "", text = "";//ip и имя второго пк

            /////////////////////////
            foreach (var label in VisualHelper.FindVisualChildren <Label>(grid))
            {
                if (label.Name == "label_text")
                {
                    text = label.Content.ToString();
                }
                if (label.Name == "label_ip")
                {
                    ip = label.Content.ToString();
                }
            }

            var    myIp = "127.0.0.1";
            string pass = "******";
            //*********************************
            var nextIp = ip;

            pass = "******";
            loadform(myIp, ip, "", ".");
        }
        /// <summary>
        /// Set the header based on the currently selected class.
        /// </summary>
        /// <param name="host">The type of host.</param>
        /// <param name="presenter">The presenter to use.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            bool canDelete = false;

            SourceFile file = GetSelectedSourceFile();

            if (file != null)
            {
                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Delete.png");
                    presenter.ToolTip = String.Format("Delete {0}", file.Name);
                }
                else
                {
                    presenter.Header = String.Format("Delete {0}", file.Name);
                    presenter.Icon   = VisualHelper.CreateIconHeader(null, "Delete.png");
                }

                canDelete = true;

                // make sure the file isn't locked
                Project project = App.Instance.SalesForceApp.CurrentProject;
                if (project != null && file.CheckedOutBy != null && !file.CheckedOutBy.Equals(project.Client.User))
                {
                    canDelete = false;
                }
            }

            IsVisible = canDelete;
        }
 private void ShowHideButton_PointerExited(object sender, PointerRoutedEventArgs e)
 {
     if (sender is UIElement s)
     {
         VisualHelper.SetScale(s, "1,1,1");
     }
 }
示例#14
0
        public void UpdateLink(LinkInfo initialState, Aga.Diagrams.Controls.ILink link)
        {
            using (BeginUpdate())
            {
                var sourcePort = link.Source as PortBase;
                var source     = VisualHelper.FindParent <Node>(sourcePort);
                var targetPort = link.Target as PortBase;
                var target     = VisualHelper.FindParent <Node>(targetPort);
                var oldLink    = (link as LinkBase).ModelElement as Link;
                var message    = "";
                var action     = "";
                if (null != oldLink)
                {
                    message = ((link as LinkBase).ModelElement as Link).Message;
                    action  = ((link as LinkBase).ModelElement as Link).Action;
                }

                _model.Links.Remove((link as LinkBase).ModelElement as Link);
                _model.Links.Add(
                    new Link((FlowNode)source.ModelElement, (PortKinds)sourcePort.Tag,
                             (FlowNode)target.ModelElement, (PortKinds)targetPort.Tag,
                             link.ControlPoint1, link.ControlPoint2, message, action
                             ));
            }
        }
示例#15
0
        /// <summary>
        /// Show context menu.
        /// </summary>
        /// <param name="sender">Object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        private void dataGridResults_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                _rightClickedCell             = VisualHelper.GetAncestor <DataGridCell>(e.OriginalSource as DependencyObject);
                _menuItemCopyValue.Visibility = (_rightClickedCell != null && _rightClickedCell.Content is TextBlock) ?
                                                System.Windows.Visibility.Visible :
                                                System.Windows.Visibility.Collapsed;

                DataGridRow item = VisualHelper.GetAncestor <DataGridRow>(e.OriginalSource as DependencyObject);
                if (item != null)
                {
                    dataGridResults.SelectedIndex = item.GetIndex();
                    if (dataGridResults.SelectedIndex < dataGridResults.Items.Count - 1)
                    {
                        _contextMenu.PlacementTarget = item;
                        _contextMenu.Placement       = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
                        _contextMenu.IsOpen          = true;
                    }
                }
            }
            catch (Exception err)
            {
                App.HandleException(err);
            }
        }
    private static void OnIsDisabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        if (d is UIElement element)
        {
            if ((bool)e.NewValue)
            {
                element.PreviewMouseWheel += ScrollViewerPreviewMouseWheel;
            }
            else
            {
                element.PreviewMouseWheel -= ScrollViewerPreviewMouseWheel;
            }
        }

        void ScrollViewerPreviewMouseWheel(object sender, MouseWheelEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }

            args.Handled = true;

            if (VisualHelper.GetParent <System.Windows.Controls.ScrollViewer>((UIElement)sender) is { } scrollViewer)
            {
                scrollViewer.RaiseEvent(new MouseWheelEventArgs(args.MouseDevice, args.Timestamp, args.Delta)
                {
                    RoutedEvent = UIElement.MouseWheelEvent,
                    Source      = sender
                });
            }
        }
    }
示例#17
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var page = VisualHelper.FindParent <Page>(this);

            if (page == null)
            {
                return;
            }

            page.MouseLeftButtonDown += Page_MouseLeftButtonDown;
            DropDownList.ItemsSource  = ItemsSource;

            if (DropDownList.Items.Count == 0)
            {
                return;
            }

            //var firstItem = DropDownList.Items.FirstOrDefault();
            //if (firstItem == null)
            //    return;

            //if (DropDownList.SelectedItem == null)
            //{
            //    DropDownList.SelectedItem = firstItem.ToString();
            //    SelectedValueTextBlock.Text = firstItem.ToString();
            //    return;
            //}
            if (SelectedItem == null)
            {
                return;
            }

            SelectedValueTextBlock.Text = SelectedItem.ToString();
            DropDownList.SelectedItem   = SelectedItem;
        }
示例#18
0
 private void CommandTextBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (IsVisible && VisualHelper.GetAutoFocusMode(this) == AutoFocusMode.OnVisible)
     {
         AutoFocus();
     }
 }
示例#19
0
        /// <summary>
        /// Когда кнопка экспорта загружена
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExportOnLoaded(object sender, RoutedEventArgs e)
        {
            var fe = sender as FrameworkElement;

            var obj = VisualHelper.FindParent <XamGrid>(fe);

            if (obj != null)
            {
                var p = obj.GetValue(VisualHelper.IsExportToExcelEnabledProperty);
                if (p != null)
                {
                    if ((bool)p)
                    {
                        fe.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        fe.Visibility = Visibility.Collapsed;
                    }
                }
                else
                {
                    fe.Visibility = Visibility.Visible;
                }
            }
        }
示例#20
0
        private static void AddItem(TokenContainerControl userControl)
        {
            var tb   = VisualHelper.FindChild <TextBox>(userControl, "MainTextBox");
            var item = tb.Text;

            if (string.IsNullOrEmpty(item))
            {
                return;
            }

            // Add token
            var currentItems = userControl.SelectedItemsCSV != null?userControl.SelectedItemsCSV.Split(',') : new string[]
            {
            };

            if (!currentItems.Contains(item))
            {
                userControl.SelectedItemsCSV = string.Join(",", currentItems.Where(x => !string.IsNullOrEmpty(x)).Union(new List <string> {
                    item
                }));
            }

            System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() =>
            {
                userControl.TextBoxText = string.Empty;
            }));
        }
示例#21
0
        /// <summary>
        /// Set the visibility of the header.
        /// </summary>
        /// <param name="host">The type of host for this function.</param>
        /// <param name="presenter">The presenter to use when updating the view.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            bool canSave = false;
            bool isDirty = false;

            if (CurrentDocument != null)
            {
                Manifest manifest = CurrentDocument.Manifest;
                isDirty = CurrentDocument.IsDirty;

                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Save.png");
                    presenter.ToolTip = String.Format("Save {0}", manifest.Name);
                }
                else
                {
                    presenter.Header           = String.Format("Save {0}", manifest.Name);
                    presenter.Icon             = VisualHelper.CreateIconHeader(null, "Save.png");
                    presenter.InputGestureText = "Ctrl+S";
                }

                canSave = true;
            }

            IsVisible = canSave;
            IsEnabled = isDirty;
        }
示例#22
0
        private static MessageBox CreateMessageBox(
            System.Windows.Window owner,
            string messageBoxText,
            string caption,
            MessageBoxButton button,
            MessageBoxImage icon,
            MessageBoxResult defaultResult)
        {
            if (!IsValidMessageBoxButton(button))
            {
                throw new InvalidEnumArgumentException(nameof(button), (int)button, typeof(MessageBoxButton));
            }
            if (!IsValidMessageBoxImage(icon))
            {
                throw new InvalidEnumArgumentException(nameof(icon), (int)icon, typeof(MessageBoxImage));
            }
            if (!IsValidMessageBoxResult(defaultResult))
            {
                throw new InvalidEnumArgumentException(nameof(defaultResult), (int)defaultResult, typeof(MessageBoxResult));
            }

            var ownerWindow = owner ?? VisualHelper.GetActiveWindow();
            var ownerIsNull = ownerWindow is null;

            return(new MessageBox
            {
                _message = messageBoxText,
                Owner = ownerWindow,
                WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner,
                ShowTitle = true,
                Title = caption ?? string.Empty,
                Topmost = ownerIsNull,
                _messageBoxResult = defaultResult
            });
        }
示例#23
0
        public static Dialog Show(object content)
        {
            var dialog = new Dialog
            {
                Content = content
            };

            var window = VisualHelper.GetActiveWindow();

            if (window != null)
            {
                var decorator = VisualHelper.GetChild <AdornerDecorator>(window);
                if (decorator != null)
                {
                    if (decorator.Child != null)
                    {
                        decorator.Child.IsEnabled = false;
                    }
                    var layer = decorator.AdornerLayer;
                    if (layer != null)
                    {
                        var container = new AdornerContainer(layer)
                        {
                            Child = dialog
                        };
                        dialog._container = container;
                        layer.Add(container);
                    }
                }
            }

            return(dialog);
        }
示例#24
0
        /// <summary>
        /// Set the header.
        /// </summary>
        /// <param name="host">The type of host.</param>
        /// <param name="presenter">The presenter to use.</param>
        public override void Init(FunctionHost host, IFunctionPresenter presenter)
        {
            // setup image
            Image image = new Image();

            image.Height = 16;
            image.Width  = 16;

            if (Browser.Image == null)
            {
                image.Source = VisualHelper.LoadBitmap("WebBrowser.png");
            }
            else
            {
                image.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                    Browser.Image.Handle,
                    System.Windows.Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
            }

            // setup presenter
            if (host == FunctionHost.Toolbar)
            {
                presenter.Header  = image;
                presenter.ToolTip = String.Format("Open {0}", Browser.Name);
            }
            else
            {
                presenter.Header = String.Format("Open {0}", Browser.Name);
                presenter.Icon   = image;
            }
        }
示例#25
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (KeysDataGrid.SelectedIndex == -1)
            {
                return;
            }

            var row = (DataGridRow)KeysDataGrid.ItemContainerGenerator.ContainerFromItem(KeysDataGrid.SelectedItem);

            if (row == null)
            {
                return;
            }

            //Getting the ContentPresenter of the row details
            var presenter = VisualHelper.GetVisualChild <DataGridDetailsPresenter>(row);

            if (presenter == null)
            {
                return;
            }

            //Finding Remove button from the DataTemplate that is set on that ContentPresenter
            var template = presenter.ContentTemplate;
            var box      = (KeyBox)template.FindName("AddKeyBox", presenter);

            if (!box.MainKey.HasValue)
            {
                return;
            }

            InternalList[KeysDataGrid.SelectedIndex].KeyList.Add(new SimpleKeyGesture(box.MainKey.Value, box.ModifierKeys, true));
            KeysDataGrid.Items.Refresh();
        }
示例#26
0
        private void PlaceVisual(VisualHelper visual, Point pointLocation, double radius)
        {
            visual.HoverShape.Width  = radius * 2;
            visual.HoverShape.Height = radius * 2;
            Canvas.SetLeft(visual.PointShape, pointLocation.X - visual.PointShape.Width * .5);
            Canvas.SetTop(visual.PointShape, pointLocation.Y - visual.PointShape.Height * .5);
            Canvas.SetLeft(visual.HoverShape, pointLocation.X - visual.HoverShape.Width * .5);
            Canvas.SetTop(visual.HoverShape, pointLocation.Y - visual.HoverShape.Height * .5);

            visual.PointShape.BeginAnimation(OpacityProperty,
                                             new DoubleAnimation(0, 0, TimeSpan.FromMilliseconds(1)));

            if (!Chart.DisableAnimation)
            {
                var pt = new DispatcherTimer {
                    Interval = AnimSpeed
                };
                pt.Tick += (sender, args) =>
                {
                    visual.PointShape.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, AnimSpeed));
                    pt.Stop();
                };
                pt.Start();
            }
            else
            {
                visual.PointShape.BeginAnimation(OpacityProperty,
                                                 new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(1)));
            }
        }
示例#27
0
        /// <summary>
        /// Set the header based on the currently selected snippet.
        /// </summary>
        /// <param name="host">The type of host.</param>
        /// <param name="presenter">The presenter to use.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            bool canDelete = false;

            string[] snippets = GetSelectedSnippets();
            if (snippets.Length > 0)
            {
                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Delete.png");
                    presenter.ToolTip = (snippets.Length == 1) ?
                                        String.Format("Delete {0}", System.IO.Path.GetFileNameWithoutExtension(snippets[0])) :
                                        "Delete selected snippets";
                }
                else
                {
                    presenter.Header = (snippets.Length == 1) ?
                                       String.Format("Delete {0}", System.IO.Path.GetFileNameWithoutExtension(snippets[0])) :
                                       "Delete selected snippets";
                    presenter.Icon = VisualHelper.CreateIconHeader(null, "Delete.png");
                }

                canDelete = true;
            }

            IsVisible = canDelete;
        }
        private void UIElement_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (_dlg == null)
            {
                var chartKey = false;
                if (DoubleChart.MainChartGroup.IsMouseOver || DoubleChart.SmallerChartGroup.IsMouseOver)
                {
                    var chartGroup = DoubleChart.MainChartGroup.IsMouseOver
                        ? DoubleChart.MainChartGroup
                        : DoubleChart.SmallerChartGroup;
                    var stockChart = VisualHelper.GetChildOfType <SciStockChart>(chartGroup);

                    if (stockChart != null)
                    {
                        var xCalc       = stockChart.XAxis.GetCurrentCoordinateCalculator();
                        var yCalc       = stockChart.YAxis.GetCurrentCoordinateCalculator();
                        var mousePoint  = Mouse.GetPosition((UIElement)stockChart.ModifierSurface);
                        var candleIndex = (int)xCalc.GetDataValue(mousePoint.X);
                        var price       = (decimal)yCalc.GetDataValue(mousePoint.Y);

                        ((MainWindowViewModel)DataContext).KeyDown(e.Key, candleIndex, price);
                        chartKey = true;
                    }
                }

                if (!chartKey)
                {
                    ((MainWindowViewModel)DataContext).KeyDown(e.Key, null, null);
                }
            }
        }
示例#29
0
        /// <summary>
        /// Select nearby conenctions
        /// </summary>
        /// <param name="e"></param>
        private bool SelectNearLine(MouseButtonEventArgs e)
        {
            var paths = VisualHelper.FindVisualChildren <Path>(this);
            var mouseNeighbourhood = Helper.CreateCenteredRect(e.GetPosition(CanvasItemContainer), new Size(10, 10));

            foreach (Path path in paths)
            {
                if (path.Name == "ConnectionPath")
                {
                    ElementsConnectionViewModel viewModel = path.DataContext as ElementsConnectionViewModel;
                    if (viewModel != null)
                    {
                        List <Rect> rects = Helper.GetPathRects(viewModel);
                        foreach (Rect rect in rects)
                        {
                            if (mouseNeighbourhood.IntersectsWith(rect))
                            {
                                if (e.ChangedButton == MouseButton.Left)
                                {
                                    viewModel.Select();
                                }
                                else if (e.ChangedButton == MouseButton.Right)
                                {
                                    viewModel.IsContextMenuOpened = true;
                                }
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
示例#30
0
        /// <summary>
        /// Set the visibility of the header.
        /// </summary>
        /// <param name="host">The type of host for this function.</param>
        /// <param name="presenter">The presenter to use when updating the view.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            bool canCreate = false;
            bool isDirty   = false;

            if (CurrentDocument != null)
            {
                Manifest manifest = CurrentDocument.Manifest;
                isDirty = CurrentDocument.IsDirty;

                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "NewPackage.png");
                    presenter.ToolTip = "New package";
                }
                else
                {
                    presenter.Header = "New package";
                    presenter.Icon   = VisualHelper.CreateIconHeader(null, "NewPackage.png");
                }

                canCreate = true;
            }

            IsVisible = canCreate;
            IsEnabled = !isDirty;
        }
示例#31
0
 private void AddToCanvas(VisualHelper visual, ChartPoint point)
 {
     Chart.ShapesMapper.Add(new ShapeMap
     {
         Series = this,
         HoverShape = visual.HoverShape,
         Shape = visual.PointShape,
         ChartPoint = point
     });
     Chart.DrawMargin.Children.Add(visual.PointShape);
     Chart.DrawMargin.Children.Add(visual.HoverShape);
     Shapes.Add(visual.PointShape);
     Shapes.Add(visual.HoverShape);
     Panel.SetZIndex(visual.HoverShape, int.MaxValue);
     Panel.SetZIndex(visual.PointShape, int.MaxValue - 2);
     visual.HoverShape.MouseDown += Chart.DataMouseDown;
     visual.HoverShape.MouseEnter += Chart.DataMouseEnter;
     visual.HoverShape.MouseLeave += Chart.DataMouseLeave;
 }
示例#32
0
        private void PlaceVisual(VisualHelper visual, Point pointLocation, double radius)
        {
            visual.HoverShape.Width = radius * 2;
            visual.HoverShape.Height = radius * 2;
            Canvas.SetLeft(visual.PointShape, pointLocation.X - visual.PointShape.Width * .5);
            Canvas.SetTop(visual.PointShape, pointLocation.Y - visual.PointShape.Height * .5);
            Canvas.SetLeft(visual.HoverShape, pointLocation.X - visual.HoverShape.Width * .5);
            Canvas.SetTop(visual.HoverShape, pointLocation.Y - visual.HoverShape.Height * .5);

            visual.PointShape.BeginAnimation(OpacityProperty,
                new DoubleAnimation(0, 0, TimeSpan.FromMilliseconds(1)));

            if (!Chart.DisableAnimation)
            {
                var pt = new DispatcherTimer { Interval = AnimSpeed };
                pt.Tick += (sender, args) =>
                {
                    visual.PointShape.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, AnimSpeed));
                    pt.Stop();
                };
                pt.Start();
            }
            else
            {
                visual.PointShape.BeginAnimation(OpacityProperty,
                    new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(1)));
            }
        }