Пример #1
0
        public void SwitchController(MainViewType newViewType, bool visible = true)
        {
            if (CurrentViewType == newViewType)
            {
                return;
            }

            Log.InfoFormat("**** BEGIN SwitchController(): switch from {0} to {1} **** ", CurrentViewType, newViewType);

            using (new WaitCursor())
            {
                Items.Clear();
                if (visible)
                {
                    MainGridView.Columns.Clear();

                    LastSortOrder.Clear();

                    if (CurrentViewType != MainViewType.Invalid)
                    {
                        KnownViews[CurrentViewType].Button.Background = UnselectedBackgroundColor;
                        KnownViews[CurrentViewType].Button.Foreground = UnselectedForegroundColor;
                    }
                }


                // cleanup
                CurrentController = KnownViews[newViewType].Controller;

                // create columns
                DateTime startTime = DateTime.Now;
                try
                {
                    CurrentController.Refresh(Items);
                }
                catch (Exception e)
                {
                    Log.Error(string.Format("Exception caught while refreshing {0}", CurrentController), e);
                }
                Log.InfoFormat("Total time for CurrentController.Refresh: {0}", DateTime.Now - startTime);
                Log.InfoFormat("Total items count: {0}", Items.Count);

                FindThisText.Text = "";
                if (visible)
                {
                    MainListView.ItemsSource = Items;   //your query result
                    foreach (DataObjectColumn oc in CurrentController.Columns)
                    {
                        GridViewColumn column = new GridViewColumn();
                        column.Header = oc.DisplayName;
                        column.DisplayMemberBinding = new Binding(oc.BindingName);
                        column.Width = System.Double.NaN;
                        MainGridView.Columns.Add(column);
                    }
                    CurrentController.MainListView   = MainListView;
                    MainListView.ContextMenu         = CurrentController.ContextMenu;
                    MainListView.ContextMenuOpening += MainListView_ContextMenuOpening;

                    UpdateDefaultStatusBar();

                    TbControlStart.Text    = CurrentController.ControlStartDescription;
                    TbControlStop.Text     = CurrentController.ControlStopDescription;
                    TbControlRestart.Text  = CurrentController.ControlRestartDescription;
                    TbControlPause.Text    = CurrentController.ControlPauseDescription;
                    TbControlContinue.Text = CurrentController.ControlContinueDescription;

                    UpdateTitle();

                    CreateInitialSort();
                    KnownViews[newViewType].Button.Background = SelectedBackgroundColor;
                    KnownViews[newViewType].Button.Foreground = SelectedForegroundColor;

                    if (FirstDisplay)
                    {
                        FindThisText.Text = App.Settings.LastSearchText;


                        FirstDisplay = false;
                    }
                }
                CurrentViewType = newViewType;

                App.Settings.LastViewType = CurrentViewType.ToString();

                if ((InitialSSR != null) && (InitialServiceNames != null))
                {
                    if (newViewType == MainViewType.Services)
                    {
                        services.ServicesDataController sdc = CurrentController as services.ServicesDataController;
                        sdc.PerformExplicitRequest(InitialSSR, InitialServiceNames,
                                                   pserv4.Properties.Resources.IDS_PERFORMING_ACTION);
                        Close();
                    }
                    else
                    {
                        InitialSSR          = null;
                        InitialServiceNames = null;
                    }
                }
            }

            Log.Info("**** END SwitchController() ****");
        }
Пример #2
0
 public DataView(DataController controller, Button button)
 {
     Controller = controller;
     Button     = button;
 }
Пример #3
0
 public ApplyTemplate(DataController controller, List<ActionTemplateInfo> requests)
 {
     DC = controller;
     Requests = requests;
 }