예제 #1
0
        /// <summary>
        /// Gets a view instance for a view model.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <returns>An instance of the associated view.</returns>
        private object GetViewForViewModel(object viewModel)
        {
            //  Get the type of the view, given the broker hint.
            var viewType = ApexBroker.GetViewForViewModel(viewModel.GetType(), BrokerHint);

            //  If we don't have a type, we must throw an exception, unless we allow this.
            if (viewType == null && AllowUnknownViewModels)
            {
                return(null);
            }
            else if (viewType == null)
            {
                throw new InvalidOperationException("Cannot broker a view for the view model type " + viewModel.GetType().Name);
            }

            //  We have the view type, now we must create an instance of it.
            //  TODO: This is where we must take the re-use options into account.
            object viewInstance = Activator.CreateInstance(viewType);

            //  It must be a dependency object and framework element.
            if (viewInstance is FrameworkElement == false)
            {
                throw new InvalidOperationException("A View must be a FrameworkElement");
            }

            //  Set the data context.
            ((FrameworkElement)viewInstance).DataContext = viewModel;

            //  Return the view instance.
            return(viewInstance);
        }
예제 #2
0
        private void ShowPopupCommandOnExecuting(object sender, CancelCommandEventArgs args)
        {
            var shell = ApexBroker.GetShell();

            ViewModel.PopupResult =
                shell.ShowPopup(new SimplePopup());
        }
예제 #3
0
        /// <summary>
        /// Performs the RefreshAssemblies command.
        /// </summary>
        /// <param name="parameter">The RefreshAssemblies command parameter.</param>
        private void DoRefreshAssembliesCommand(object parameter)
        {
            //  Clear the assemblies.
            Assemblies.Clear();

            //  Set the status text.
            RefreshAssembliesCommand.ReportProgress(
                () =>
            {
                StatusInfo = Resources.Msg_RefreshAssemblies_Progress;
            });

            //  Start the enumeration.
            var timeTaken = ApexBroker.GetModel <IGACManagerModel>().EnumerateAssemblies(
                assemblyDetails =>
            {
                //  Create an assembly view model from the detials.
                var viewModel = new GACAssemblyViewModel();
                viewModel.FromModel(assemblyDetails);

                //  Add it to the collection.
                Assemblies.Add(viewModel);
            });

            //  Set the resulting status info.
            RefreshAssembliesCommand.ReportProgress(
                () =>
            {
                AssembliesCollectionView = new ListCollectionView(Assemblies.ToList());

                AssembliesCollectionView.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending));
                AssembliesCollectionView.Filter += Filter;
                StatusInfo = string.Format(Resources.Msg_RefreshAssemblies_Success, Assemblies.Count, timeTaken.TotalMilliseconds);
            });
        }
예제 #4
0
 private void detector7_Click(object sender, RoutedEventArgs e)
 {
     TscData t = Utils.Utils.GetTscDataByApplicationCurrentProperties();
     //pevent(this, 1);
     Utils.Utils.SetSelectedDetector(7);
     ApexBroker.GetShell().ClosePopup(this, true);
 }
예제 #5
0
        protected override void OnExit(ExitEventArgs e)
        {
            //  Save the last run time.
            ApexBroker.GetModel <IAppModel>().SaveLastRunTime(DateTime.Now);

            base.OnExit(e);
        }
예제 #6
0
        private void ShowFadePopupCommandOnExecuting(object sender, CancelCommandEventArgs args)
        {
            var shell = ApexBroker.GetShell();

            shell.PopupAnimationHelper = new FadeInOutPopupAnimationHelper();
            shell.ShowPopup(new CustomisedPopup());
        }
        public ViewBrokerSampleView()
        {
            //  Register mappings with the broker.
            ApexBroker.RegisterViewForViewModel(typeof(FolderViewModel), typeof(FolderView));
            ApexBroker.RegisterViewForViewModel(typeof(FileViewModel), typeof(FileView));

            InitializeComponent();
        }
예제 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TheModelViewModel"/> class.
        /// </summary>
        public TheModelViewModel()
        {
            Title = "The Model";

            //  Get the Zune Model.
            var zuneModel = ApexBroker.GetModel <IZuneModel>();

            //  Get the albums.
            var albums = zuneModel.GetAlbums();
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        public MainViewModel()
        {
            //  Wire up commands.
            CloseCommand = new Command(DoCloseCommand);

            //  Get the last run time from the model - as long as we're not in the designer.
            if (Apex.Design.DesignTime.IsDesignTime)
            {
                Title += " (Design Time)";
            }
            else
            {
                LastRunTime = ApexBroker.GetModel <IAppModel>().LoadLastRunTime();
            }
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MusicViewModel"/> class.
        /// </summary>
        public MusicViewModel()
        {
            Title = "Music";

            if (ApexBroker.CurrentExecutionContext == ExecutionContext.Design)
            {
                //  Add some design-time data.
                artists.Add("The Beatles");
                artists.Add("Pink Floyd");
            }
            else
            {
                //  Get the artists from the model.
                var zuneModel = ApexBroker.GetModel <ItscuiModel>();
                foreach (var artist in zuneModel.GetArtists())
                {
                    artists.Add(artist);
                }
            }
        }
예제 #11
0
파일: Shell.cs 프로젝트: yatagarasu25/apex
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            //  Call the base.
            base.OnApplyTemplate();

            //  Register the shell.
            ApexBroker.RegisterShell(this);

            //  Wire up the close event handler.
            PopupClosed += OnPopupClosed;

            //  Get the template parts.
            try
            {
                applicationHost = (Grid)GetTemplateChild("PART_ApplicationHost");
                // dragAndDropHost = (DragAndDropHost)GetTemplateChild("PART_DragAndDropHost");
                popupHost = (Grid)GetTemplateChild("PART_PopupHost");
            }
            catch
            {
                throw new Exception("Unable to access the internal elements of the Application host.");
            }
        }
예제 #12
0
 private void button_Cancel_Click(object sender, RoutedEventArgs e)
 {
     ApexBroker.GetShell().ClosePopup(this, false);
 }
예제 #13
0
 private void Close_Click(object sender, RoutedEventArgs e)
 {
     ApexBroker.GetShell().ClosePopup(this, null);
 }
예제 #14
0
 /// <summary>
 /// Handles the Executed event of the ShowPopupCommand.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="args">The <see cref="Apex.MVVM.CommandEventArgs"/> instance containing the event data.</param>
 void ShowPopupCommand_Executed(object sender, CommandEventArgs args)
 {
     //  Get the shell and show the example popup.
     ApexBroker.GetShell().ShowPopup(new ExamplePopup(), (result) => { });
 }
예제 #15
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var appHost = ApexBroker.GetShell();

            appHost.ShowPopup(new SimplePopupView(), o => {});
        }