Exemplo n.º 1
0
        /// <summary>
        /// Adds or updates status for selected page.
        /// </summary>
        /// <param name="sourcePage">Source page to status updating.</param>
        /// <param name="statusContent">Status content (can be null).</param>
        private void _SetStatus(AppPages.Page sourcePage, object statusContent)
        {
            Debug.Assert(null != sourcePage);

            if (statusContent == null)
            {
                // create empty status
                StatusContentControl.Content = _CreateStatusLabel(string.Empty);
            }
            else
            {   // update status in source page
                if (_statusesHash.Contains(sourcePage))
                {
                    // only if real changed
                    if (!_statusesHash[sourcePage].Equals(statusContent))
                    {
                        _statusesHash[sourcePage] = statusContent;
                    }
                }
                else
                {
                    // add status to page
                    _statusesHash.Add(sourcePage, statusContent);
                }

                // force update status for current page
                if (App.Current.MainWindow.CurrentPage.Equals(sourcePage))
                {
                    StatusContentControl.Content = statusContent;
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        public override void Initialize(Page page)
        {
            base.Initialize(page);

            App.Current.ApplicationInitialized += new EventHandler(App_ApplicationInitialized);
            this.Loaded += new RoutedEventHandler(TasksWidget_Loaded);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Starts import process.
        /// </summary>
        /// <param name="parentPage">Page requirest importing.</param>
        /// <param name="profile">Import profile.</param>
        /// <param name="defaultDate">Default date for default initialize imported objects.</param>
        /// <param name="dataProvider">Data provider.</param>
        private void _StartImportProcess(AppPages.Page parentPage,
                                         ImportProfile profile,
                                         DateTime defaultDate,
                                         IDataProvider dataProvider)
        {
            Debug.Assert(null != parentPage);   // created
            Debug.Assert(null != profile);      // created
            Debug.Assert(null != dataProvider); // creatde

            // reset state
            _importer = null;
            _geocoder = null;

            // subscribe to events
            App currentApp = App.Current;

            currentApp.MainWindow.Closed += new EventHandler(_MainWindow_Closed);

            // create background worker
            Debug.Assert(null == _worker); // only once
            SuspendBackgroundWorker worker = _CreateBackgroundWorker();

            // create internal objects
            var tracker       = new ImportCancelTracker(worker);
            var cancelTracker = new CancellationTracker(tracker);

            _informer = new ProgressInformer(parentPage, profile.Type, tracker);
            _informer.SetStatus("ImportLabelImporting");

            var infoTracker = new ProgressInfoTracker(worker,
                                                      _informer.ParentPage,
                                                      _informer.ObjectName,
                                                      _informer.ObjectsName);

            _importer = new Importer(infoTracker);

            if (PropertyHelpers.IsGeocodeSupported(profile.Type))
            {
                _geocoder = new Geocoder(infoTracker);
            }

            // set precondition
            string message = currentApp.GetString("ImportProcessStarted", _informer.ObjectName);

            currentApp.Messenger.AddInfo(message);

            // lock GUI
            currentApp.UIManager.Lock(true);

            // run worker
            var parameters = new ProcessParams(profile,
                                               defaultDate,
                                               dataProvider,
                                               cancelTracker,
                                               infoTracker);

            worker.RunWorkerAsync(parameters);
            _worker = worker;
        }
Exemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Method sets status bar content.
        /// </summary>
        /// <param name="sourcePage">Status source page.</param>
        /// <param name="statusContent">Status content (must be simple string or control,
        /// or null for clearing).</param>
        public void SetStatus(AppPages.Page sourcePage, object statusContent)
        {
            Debug.Assert(null != sourcePage);

            if (statusContent is string)
            {
                statusContent = _CreateStatusLabel(statusContent.ToString());
            }

            _SetStatus(sourcePage, statusContent);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates and initializes a new instance of the <c>ProgressTracker</c> class.
        /// </summary>
        /// <param name="parentPage">Parent page for status panel.</param>
        /// <param name="type">Import objects type.</param>
        /// <param name="canceler">Operation canceler interface (can be NULL).</param>
        public ProgressInformer(AppPages.Page parentPage, ImportType type, ICanceler canceler)
        {
            Debug.Assert(null != parentPage); // created

            // store context
            _parentPage = parentPage;
            _canceler   = canceler;

            // initialize state
            _InitStrings(type);
            _InitStatusStack();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates and initializes a new instance of the <c>ProgressInfoTracker</c> class.
        /// </summary>
        /// <param name="worker">Background worker.</param>
        /// <param name="parentPage">Parent page for status panel.</param>
        /// <param name="objectName">Object name to progress message generation.</param>
        /// <param name="objectsName">Objects name to status message generation.</param>
        public ProgressInfoTracker(BackgroundWorker worker,
                                   AppPages.Page parentPage,
                                   string objectName,
                                   string objectsName)
        {
            Debug.Assert(!string.IsNullOrEmpty(objectsName)); // not empty
            Debug.Assert(!string.IsNullOrEmpty(objectName)); // not empty
            Debug.Assert(null != parentPage); // created
            Debug.Assert(null != worker); // created

            _parentPage = parentPage;
            _objectName = objectName;
            _objectsName = objectsName;
            _worker = worker;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates and initializes a new instance of the <c>ProgressInfoTracker</c> class.
        /// </summary>
        /// <param name="worker">Background worker.</param>
        /// <param name="parentPage">Parent page for status panel.</param>
        /// <param name="objectName">Object name to progress message generation.</param>
        /// <param name="objectsName">Objects name to status message generation.</param>
        public ProgressInfoTracker(BackgroundWorker worker,
                                   AppPages.Page parentPage,
                                   string objectName,
                                   string objectsName)
        {
            Debug.Assert(!string.IsNullOrEmpty(objectsName)); // not empty
            Debug.Assert(!string.IsNullOrEmpty(objectName));  // not empty
            Debug.Assert(null != parentPage);                 // created
            Debug.Assert(null != worker);                     // created

            _parentPage  = parentPage;
            _objectName  = objectName;
            _objectsName = objectsName;
            _worker      = worker;
        }
Exemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Starts asynchronous import process.
        /// </summary>
        /// <param name="parentPage">Page requirest importing.</param>
        /// <param name="profile">Import profile to importing.</param>
        /// <param name="defaultDate">Default date for default initialize imported objects.</param>
        public void ImportAsync(AppPages.Page parentPage,
                                ImportProfile profile,
                                DateTime defaultDate)
        {
            Debug.Assert(null != parentPage); // created
            Debug.Assert(null != profile);    // created

            IDataProvider dataProvider = _InitDataSourceProvider(profile);

            if (null != dataProvider)
            {     // provider must present
                if (0 == dataProvider.RecordsCount)
                { // empty file detected
                    App    currentApp = App.Current;
                    string message    = currentApp.FindString("ImportStatusFileIsEmpty");
                    currentApp.Messenger.AddWarning(message);
                }
                else
                {   // provider in valid state - start process
                    _StartImportProcess(parentPage, profile, defaultDate, dataProvider);
                }
            }
        }
        /// <summary>
        /// Called when main window is loaded.
        /// </summary>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // load layout
                _LoadLayout();

                foreach (PageItem pageItem in _navigationTree.NaviationTreeRoot.Children[0].Children)
                {
                    if (pageItem.Page == null)
                    {
                        AppPages.Page newPage = (AppPages.Page)Activator.CreateInstance(pageItem.PageType);
                        newPage.Initialize(App.Current);
                        pageItem.Page = newPage;
                    }
                }
                _currentPage = ((PageItem)_navigationTree.NaviationTreeRoot.Children[0].Children[0]).Page;
                _NavigateHome();
            }
            catch (Exception ex)
            {
                // unable to load window layout
                App.Current.Messenger.AddError(ex.Message);
                // close the application
                Application.Current.Shutdown();
            }

            NavigationPaneContainer.Width = new GridLength((double)App.Current.FindResource("DefaultNavigationPaneWidth"));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Navigates to the specified page.
        /// </summary>
        /// <param name="item"></param>
        private void _Navigate(PageItem item)
        {
            // If this page cannot be left - do not navigate from current page.
            if ((_currentPage != item.Page) && !_currentPage.CanBeLeft)
                item = _currentPageItem;

            _NotifyNavigationCalled();

            this.RemoveHandler(NavigationPane.ChangeSelectionEvent, (RoutedEventHandler)OnCurrentPageChanged);

            CategoryItem currentCategory = (CategoryItem)item.Parent;

            if (item.Page.IsAllowed &&
                ((null == currentCategory.PageCategory) || // NOTE: category can be not belong to categories ("Preferences")
                ((null != currentCategory.PageCategory) && currentCategory.PageCategory.IsEnabled)))
            {
                PageFrame.Navigate(item.Page);

                _ChangeCurrentCategory(item.Parent as INavigationItem);
                _UpdateCurrentCategoryButton();

                // Add widgets panel to hash table
                if (!_widgetsHash.Contains(item.PageType.FullName))
                {
                    StackPanel widgetsStack = _CreateWidgetsPanel(item.Page);
                    _widgetsHash.Add(item.PageType.FullName, widgetsStack);
                }

                foreach (NavigationPanePage panePage in navigationPane.Pages)
                {
                    if (panePage.Tag == item)
                    {   // set navigation pane content
                        panePage.PageContent = (StackPanel)_widgetsHash[item.PageType.FullName];
                        navigationPane.SelectPage(panePage);
                        break;
                    }
                }
                _taskPanelContentBuilder.UpdateTaskPanelWidgetsState((StackPanel)_widgetsHash[item.PageType.FullName]);
                _currentPageItem = item;
                _currentPage = item.Page;
            }

            this.AddHandler(NavigationPane.ChangeSelectionEvent, new RoutedEventHandler(OnCurrentPageChanged));
        }
Exemplo n.º 11
0
 public override void Initialize(Page page)
 {
     Debug.Assert(page != null);
     _page = page;
 }
 public override void Initialize(ESRI.ArcLogistics.App.Pages.Page page)
 {
     base.Initialize(page);
     _InitQuickHelpText();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Method makes status like: N objects selected
        /// and set it to status container.
        /// </summary>
        /// <param name="collectionSize"></param>
        /// <param name="statusObjectTypeName"></param>
        /// <param name="xceedControl"></param>
        /// <param name="statusContainer"></param>
        public void FillSelectionStatusWithoutCollectionSize(int collectionSize, string statusObjectTypeName, int selectionSize, ESRI.ArcLogistics.App.Pages.Page page)
        {
            string status = "";

            if (!string.IsNullOrEmpty(statusObjectTypeName))
            {
                status = (selectionSize > 0)?
                         string.Format((string)App.Current.FindResource("SelectedGridWithoutCollectionSizeStatusPattern"), selectionSize, statusObjectTypeName) :
                         string.Format((string)App.Current.FindResource("DefauGridStatusPattern"), collectionSize, statusObjectTypeName);
            }

            App.Current.MainWindow.StatusBar.SetStatus(page, status);
        }
Exemplo n.º 14
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes widget.
        /// </summary>
        /// <param name="page">Parent widget's page.</param>
        public override void Initialize(ESRI.ArcLogistics.App.Pages.Page page)
        {
            base.Initialize(page);
        }
Exemplo n.º 15
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates and initializes a new instance of the <c>ProgressTracker</c> class.
        /// </summary>
        /// <param name="parentPage">Parent page for status panel.</param>
        /// <param name="type">Import objects type.</param>
        /// <param name="canceler">Operation canceler interface (can be NULL).</param>
        public ProgressInformer(AppPages.Page parentPage, ImportType type, ICanceler canceler)
        {
            Debug.Assert(null != parentPage); // created

            // store context
            _parentPage = parentPage;
            _canceler = canceler;

            // initialize state
            _InitStrings(type);
            _InitStatusStack();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Finds collection of commands to be executed for when the specified
        /// key event occured on the specified page.
        /// </summary>
        /// <param name="currentPage">Current application page.</param>
        /// <param name="e">Key down event args.</param>
        private IEnumerable<ICommand> _FindCommandsForKey(Page currentPage, KeyEventArgs e)
        {
            List<ICommand> commands = new List<ICommand>();

            ICollection<string> categories = _categories.Keys;
            foreach (string category in categories)
            {
                if (!_pageByGroupDictionary.ContainsKey(category))
                    continue; // NOTE: skip category

                string pageType = _pageByGroupDictionary[category];
                if (!currentPage.GetType().FullName.Equals(pageType))
                    continue; // NOTE: category not for current page - skip

                foreach (ICommand command in _categories[category])
                {
                    try
                    {
                        // WORKARROUND: safely adding
                        //  KeyGesture in plugin throw exception
                        KeyGesture gesture = command.KeyGesture;
                        if ((gesture != null) &&
                            (gesture.Key == e.Key) &&
                            (gesture.Modifiers == Keyboard.Modifiers) &&
                            command.IsEnabled &&
                            !commands.Contains(command))
                        {
                            commands.Add(command);
                        }
                    }
                    catch
                    { }
                }
            }

            return commands;
        }
Exemplo n.º 17
0
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Try to execute command.
 /// </summary>
 /// <param name="currentPage">Current application page.</param>
 /// <param name="e">Key down event args.</param>
 internal void ExecuteCommand(Page currentPage, KeyEventArgs e)
 {
     foreach (var command in _FindCommandsForKey(currentPage, e))
         command.Execute();
 }
Exemplo n.º 18
0
        /// <summary>
        /// Sets status like : New object being created
        /// </summary>
        /// <param name="objectType"></param>
        /// <param name="page"></param>
        public void FillCreatingStatus(string objectType, ESRI.ArcLogistics.App.Pages.Page page)
        {
            string status = string.Format((string)App.Current.FindResource("CreatingObject"), objectType, objectType);

            App.Current.MainWindow.StatusBar.SetStatus(page, status);
        }
Exemplo n.º 19
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates a new instance of the <c>ReportProcessor</c> class.
        /// </summary>
        /// <param name="parentPage">Paren page for status update.</param>
        public ReportProcessor(Page parentPage)
        {
            Debug.Assert(null != parentPage);

            _exportDialogFilter = ReportsHelpers.AssemblyDialogFilter();
            _parentPage = parentPage;
        }