Esempio n. 1
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;
        }
Esempio n. 2
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);
        }
Esempio n. 3
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;
                }
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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
                             ));
            }
        }
Esempio n. 6
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;
        }
        private static void Control_Click(object sender, EventArgs e)
        {
            var control = sender as FrameworkElement;
            var command = GetCommand(control);

            if (control != null && command != null && command.CanExecute(null))
            {
                var page = VisualHelper.FindParent <Page>(control);
                command.Execute(page);
            }
        }
Esempio n. 8
0
        public virtual void UpdatePosition()
        {
            var canvas = VisualHelper.FindParent <Canvas>(this);

            if (canvas != null)
            {
                Center = this.TransformToAncestor(canvas).Transform(new Point(this.ActualWidth / 2, this.ActualHeight / 2));
            }
            else
            {
                Center = new Point(Double.NaN, Double.NaN);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// 当鼠标按下时操作
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         var item = this.DataContext as DiagramItem;
         var view = VisualHelper.FindParent <DiagramView>(item);
         if (item != null && view != null)
         {
             MouseDownPoint = e.GetPosition(view);
             view.DragTool.BeginDrag(MouseDownPoint.Value, item, this.Kind);
             e.Handled = true;
         }
     }
 }
Esempio n. 10
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            LayoutRoot.Background     = Background;
            TitleTextBlock.Foreground = Foreground;

            var page = VisualHelper.FindParent <Page>(this);

            if (page == null)
            {
                BackgroundGridPopup.Height = 1920;
                return;
            }

            BackgroundGridPopup.Height = page.ActualHeight;
        }
Esempio n. 11
0
 protected override void  OnPreviewMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
 {
     if (CanCreateLink)
     {
         var view = VisualHelper.FindParent <DiagramView>(this);
         if (view != null)
         {
             view.LinkTool.BeginDragNewLink(e.GetPosition(view), this);
             e.Handled = true;
         }
     }
     else
     {
         base.OnMouseLeftButtonDown(e);
     }
 }
Esempio n. 12
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);

                _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
                             ));
            }
        }
Esempio n. 13
0
        private void gridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var parent = VisualHelper.FindParent <Page>(sender as FrameworkElement);

            if (parent == null)
            {
                return;
            }

            if (AdvHelper.IsAdvItem(e.ClickedItem))
            {
                return;
            }

            parent.Frame.Navigate(typeof(DetailsPage), e.ClickedItem);
        }
Esempio n. 14
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ToggleButton btn     = sender as ToggleButton;
            StackPanel   s_panel = VisualHelper.FindParent <StackPanel>(btn);

            IFlowBalanceTI FlowBalanceTI_Frame = VisualHelper.FindParent <IFlowBalanceTI>(s_panel);

            ComboBox        cmbReturnProfile = (ComboBox)((UserControl)FlowBalanceTI_Frame).FindName("cmbReturnProfile");
            DataGridControl GridControl      = (DataGridControl)((UserControl)FlowBalanceTI_Frame).FindName("GridControl");

            TSection _SectionIntegralActs = FlowBalanceTI_Frame.GetSectionAct();

            if (s_panel != null)
            {
                ValuePair <string, TDatePeriod> title_pair = (ValuePair <string, TDatePeriod>)s_panel.DataContext;
                EnumDataSourceType?DataSourceType          = cmbReturnProfile.SelectedValue as EnumDataSourceType?;
                bool     isReadCalculatedValues            = true;
                DateTime dtStart = title_pair.Value.dtStart;

                FlowBalanceTI result = null;

                bool IsAdd = btn.IsChecked.Value;

                if (!IsAdd)
                {
                    result = new FlowBalanceTI()
                    {
                        NumbersValues = Extention.GetNumbersValuesInPeriod(enumTimeDiscreteType.DBHalfHours, dtStart, dtStart.AddMinutes(1410), Manager.Config.SelectedTimeZoneInfo)
                    };
                    ValuesToXceedGrid.UpdateFlowBalanceTIToGrid(GridControl, result, Proryv.AskueARM2.Client.Visual.Common.GlobalDictionary.TGlobalVisualDataRequestObjectsNames.GlobalVisualDataRequestObjectsNames, new ItemSelector(), title_pair, IsAdd);
                }
                else
                {
                    Manager.UI.RunAsync(delegate()
                    {
                        result = ARM_Service.SIA_GetFlowBalanceTI(_SectionIntegralActs.Section_ID, dtStart, dtStart.AddMinutes(1410),
                                                                  DataSourceType, enumTimeDiscreteType.DBHalfHours, EnumUnitDigit.None, isReadCalculatedValues, Manager.Config.TimeZone);
                    }, delegate()
                    {
                        if (result != null)
                        {
                            ValuesToXceedGrid.UpdateFlowBalanceTIToGrid(GridControl, result, Proryv.AskueARM2.Client.Visual.Common.GlobalDictionary.TGlobalVisualDataRequestObjectsNames.GlobalVisualDataRequestObjectsNames, new ItemSelector(), title_pair, IsAdd);
                        }
                    });
                }
            }
        }
Esempio n. 15
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var item = sender as FrameworkElement;

            if (item == null)
            {
                return;
            }

            var page = VisualHelper.FindParent <Page>(item);

            if (page == null)
            {
                return;
            }

            page.SizeChanged += OnPageSizeChanged;
            SetItemSize();
        }
Esempio n. 16
0
        private IEnumerable <Point> GetMiddlePoints(Point start, Point end)
        {
            var view = VisualHelper.FindParent <DiagramView>(this);

            if (view == null)
            {
                return(new Point[0]);
            }

            var points = new List <Point>();

            var p0 = GetFirstSegment(Source, start, view.GridCellSize);
            var p1 = GetFirstSegment(Target, end, view.GridCellSize);

            if (p0 == p1)
            {
                return(points);
            }


            var p2 = new Point(GetNearestCross(p0.X, p1.X), GetNearestCross(p0.Y, p1.Y));
            var p3 = new Point(GetNearestCross(p1.X, p0.X), GetNearestCross(p1.Y, p0.Y));

            if (p2 == p3)
            {
                points.Add(p0);
                points.Add(p2);
                points.Add(p1);
            }
            else
            {
                points.Add(p0);
                points.Add(p2);
                if (!GeometryHelper.AreEquals(p2.X, p3.X) && !GeometryHelper.AreEquals(p2.Y, p3.Y))
                {
                    points.Add(new Point(p2.X, p3.Y));
                }
                points.Add(p3);
                points.Add(p1);
            }
            DoScale(points, view.GridCellSize);
            return(points);
        }
        public static string BuildFileName(FrameworkElement grid, out bool isExportCollapsedDetail, out bool excludeGroupBySettings)
        {
            var    form = VisualHelper.FindParent <IFormingExportedFileName>(grid);
            string nameFromForm;

            isExportCollapsedDetail = false;

            if (form != null)
            {
                nameFromForm           = form.FormingExportedFileName(grid.Name, out isExportCollapsedDetail);
                excludeGroupBySettings = form.ExportExcludeGroupBySettings(grid.Name);
            }
            else
            {
                nameFromForm           = string.Empty;
                excludeGroupBySettings = false;
            }

            return(nameFromForm);
        }
Esempio n. 18
0
        private void gridViewHeader_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var parent = VisualHelper.FindParent <Page>(sender as FrameworkElement);

            if (parent == null)
            {
                return;
            }

            //todo пока только под events
            var element   = sender as FrameworkElement;
            var viewModel = element.DataContext as EventsViewModel;

            if (viewModel == null)
            {
                return;
            }

            parent.Frame.Navigate(typeof(DetailsPage), viewModel.EventOfTheDay);
        }
Esempio n. 19
0
        /// <summary>
        /// Отмена экспорта
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void progress_Cancel(object sender, EventArgs e)
        {
            var fe = sender as FrameworkElement;

            if (fe == null)
            {
                return;
            }

            //Пытаемся найти кнопку с экспортом, в ней в Tag помещен BackgroundWorker
            var grid = VisualHelper.FindParent <Grid>(fe);

            if (grid == null)
            {
                return;
            }

            var expButton = grid.FindName("Export") as Button;

            if (expButton == null)
            {
                return;
            }

            var worker = expButton.Tag as BackgroundWorker;

            if (worker != null)
            {
                //Отменяем экспорт
                try
                {
                    ClearProgressIndicator(expButton);
                    worker.CancelAsync();
                }
                catch
                {
                }
            }

            Manager.UI.ShowMessage("Экспорт отменен!");
        }
Esempio n. 20
0
        public void Detach()
        {
            FrameworkElement fe = AssociatedObject as FrameworkElement;

            if (fe == null)
            {
                return;
            }

            var page = VisualHelper.FindParent <Page>(fe);

            if (page == null)
            {
                return;
            }

            page.SizeChanged -= OnPageSizeChanged;
            //fe.RemoveHandler(UIElement.PointerPressedEvent, new PointerEventHandler(OnPointerPressed));
            fe.Loaded       -= OnLoaded;
            AssociatedObject = null;
        }
Esempio n. 21
0
        private void DataGridCell_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            DataGridCell cell = sender as DataGridCell;

            Console.WriteLine($"Clicked Cell : {cell}, Name : {cell.Name}");
            ComboBox groupComboBox = VisualHelper.FindChild <ComboBox>(cell);

            if (groupComboBox != null)
            {
                return;
            }

            if (cell != null && !cell.IsEditing)
            {
                DataGridRow row = VisualHelper.FindParent <DataGridRow>(cell);
                if (row != null)
                {
                    CheckBox checkBox = VisualHelper.FindChild <CheckBox>(cell);

                    if (checkBox != null)
                    {
                        HitTestResult result = VisualTreeHelper.HitTest(checkBox, e.GetPosition(cell));

                        if (result != null)
                        {
                            // execute button and do not select / deselect row
                            checkBox.Command.Execute(row.DataContext);
                            e.Handled = true;
                            return;
                        }
                    }

                    row.IsSelected = !row.IsSelected;
                    e.Handled      = true;
                }
            }
        }
Esempio n. 22
0
 private void Connector_Loaded(object sender, RoutedEventArgs e)
 {
     _documentView = VisualHelper.FindParent <DocumentView>(this);
 }
Esempio n. 23
0
 /// <summary>
 /// 附加CustomDockLayoutManager
 /// </summary>
 private void AttachDockLayoutManager()
 {
     DockManager = VisualHelper.FindParent <CustomDockLayoutManager>(this);
 }
Esempio n. 24
0
 private void DragableUserControl_Loaded(object sender, RoutedEventArgs e)
 {
     _parentPanel = VisualHelper.FindParent <Grid>(this);
     MouseMove   += DragableUserControl_MouseMove;
 }
Esempio n. 25
0
        private Point TransformPoint(Point currentPoint)
        {
            Zoombox zoombox = VisualHelper.FindParent <Zoombox>(this);

            return(new Point(zoombox.ZoomPercentage * currentPoint.X, zoombox.ZoomPercentage * currentPoint.Y));
        }
Esempio n. 26
0
        public void ButtonExportExcel_Click(object sender, RoutedEventArgs e)
        {
            var fe      = sender as FrameworkElement;
            var xamGrid = VisualHelper.FindParent <XamGrid>(fe);

            if (xamGrid == null || xamGrid.ItemsSource == null)
            {
                return;
            }

            bool isExportCollapsedDetail;
            bool excludeGroupBySettings;

            var fileName = ExportHelper.BuildFileName(xamGrid, out isExportCollapsedDetail, out excludeGroupBySettings);

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


            //progress.Value = 0;
            //progress.Maximum = requesterHh.PartitionsCount + requsterIntegral.PartitionsCount;

            //if (_worker != null)
            //{
            //    _worker.DoWork -= worker_DoWork;
            //    _worker.RunWorkerCompleted -= worker_RunWorkerCompleted;
            //}

            var worker = new BackgroundWorker
            {
                WorkerSupportsCancellation = true,
                WorkerReportsProgress      = true
            };

            fe.Tag = worker;

            var dataView = xamGrid.ItemsSource as DataView;

            if (dataView == null)
            {
                Manager.UI.ShowMessage("Пока работаем только с DataView");
                return;
            }

            var progressBar = SetProgressIndicator(fe, fileName, dataView.Count);

            var columnInfos   = new List <XamGridColumnInfo>();
            int currentColumn = 0;
            var measure       = VisualHelper.FindParent <IMeasure>(xamGrid);

            CollectColumnInfos(xamGrid.Columns, ref currentColumn, columnInfos, measure);

            worker.DoWork             += worker_DoWork;
            worker.RunWorkerCompleted += worker_RunWorkerCompleted;
            worker.RunWorkerAsync(new XamExporterResult
            {
                ClickedButton = fe,
                FileName      = fileName,
                SheetName     = xamGrid.Name,
                ColumnInfos   = columnInfos,
                DataView      = dataView,
                ProgressBar   = progressBar,
                Measure       = measure,
            });

            //if (exporter.Measured == null)
            //{
            //    var p = VisualHelper.FindParent<Popup>(grid);
            //    if (p != null && p.PlacementTarget != null)
            //    {
            //        exporter.Measured = VisualHelper.FindParent<IMeasure>(p.PlacementTarget as FrameworkElement);
            //    }
            //}

            fe.IsEnabled = false;
        }
Esempio n. 27
0
 private void ConnectionView_Loaded(object sender, RoutedEventArgs e)
 {
     _parentPanel = VisualHelper.FindParent <Grid>(this);
 }
Esempio n. 28
0
        internal void ButtonExportExcel_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var grid   = VisualHelper.FindParent <DataPresenterBase>(button);

            if (grid == null)
            {
                return;
            }

            bool isExportCollapsedDetail;
            bool excludeGroupBySettings;

            _fileName = VisualHelper.prepareFile("xlsx", ExportHelper.BuildFileName(grid, out isExportCollapsedDetail, out excludeGroupBySettings), Manager.UI.ShowMessage);

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


            try
            {
                var exportOptions = new ExportOptions
                {
                    ChildRecordCollectionSpacing   = ChildRecordCollectionSpacing.None, // ???
                    ExcludeExpandedState           = false,                             //
                    ExcludeFieldLayoutSettings     = true,                              //
                    ExcludeFieldSettings           = false,                             // исключить настройки колонок
                    ExcludeGroupBySettings         = excludeGroupBySettings,            // исключить группировку
                    ExcludeRecordFilters           = false,                             // исключить фильтрацию
                    ExcludeRecordVisibility        = false,                             // исключить видимость строк
                    ExcludeSortOrder               = false,                             // исключить сортировку
                    ExcludeSummaries               = true,                              // исключить строки с суммами
                    ExcludeCrossFieldRecordFilters = true,
                    FileLimitBehaviour             = FileLimitBehaviour.TruncateData,   // при превышении лимита урезать данные
                };

                var exporter = new ProryvDataPresenterExcelExporter
                {
                    Measured = VisualHelper.FindParent <IMeasure>(grid)
                };

                if (exporter.Measured == null)
                {
                    var p = VisualHelper.FindParent <Popup>(grid);
                    if (p != null && p.PlacementTarget != null)
                    {
                        exporter.Measured = VisualHelper.FindParent <IMeasure>(p.PlacementTarget as FrameworkElement);
                    }
                }


                exporter.HeaderLabelExporting += OnLabelExporting;
                exporter.CellExported         += OnCellExported;
                //exporter.CellExporting += Exporter_CellExporting;
                exporter.ExportEnded += OnExportEnden;

                //exporter.Export(grid, _fileName, WorkbookFormat.Excel2007, exportOptions);
                exporter.ExportAsync(grid, _fileName, WorkbookFormat.Excel2007, exportOptions);
            }
            catch (Exception ex)
            {
                Manager.UI.ShowMessage("Ошибка при экспорте в Excel! " + ex.Message);
            }
        }