Inheritance: INotifyPropertyChanged
        public void ApplyTo(ViewModelBase viewModel)
        {
            var dynamicObject = new DynamicObject(viewModel);

            var commands = dynamicObject.GetProperties().Where(p => p.PropertyType == typeof (DelegateCommand));

            foreach (var c in commands)
            {
                var command = c;
                var executeMethodName = string.Format("On{0}", command.Name);
                var canExecuteMethodName = string.Format("Can{0}", command.Name);

                var delegateCommand = command.GetValue(viewModel, null) as DelegateCommand;

                if (delegateCommand != null)
                {
                    if (dynamicObject.MethodExist(executeMethodName))
                    {
                        delegateCommand.ExecuteDelegate = () =>
                        {
                            dynamicObject.InvokeMethod(executeMethodName);
                        };
                    }

                    if (dynamicObject.MethodExist(canExecuteMethodName))
                    {
                        delegateCommand.CanExecuteDelegate = () =>
                        {
                            return (bool)dynamicObject.InvokeMethod(canExecuteMethodName);
                        };
                    }
                }
            }
        }
Esempio n. 2
0
        public bool ShowViewModel(string title, ViewModelBase viewModel)
        {
            var win = new DialogWindow(viewModel) {Title = title};
            win.ShowDialog();

            return win.CloseResult;
        }
Esempio n. 3
0
        /// <summary>
        /// Executes business logic to determine if an instance of the application should prompt the user to solicit user ratings.
        /// If it determines it should, the dialog to solicit ratings will be displayed.
        /// </summary>
        /// <returns>Awaitable task is returned.</returns>
        public async Task CheckForRatingsPromptAsync(ViewModelBase vm)
        {
            bool showPrompt = false;

            // PLACE YOUR CUSTOM RATE PROMPT LOGIC HERE!
            this.LastPromptedForRating = Platform.Current.Storage.LoadSetting<DateTime>(LAST_PROMPTED_FOR_RATING);

            // If trial, not expired, and less than 2 days away from expiring, set as TRUE
            bool preTrialExpiredBasedPrompt = 
                Platform.Current.AppInfo.IsTrial 
                && !Platform.Current.AppInfo.IsTrialExpired 
                && DateTime.Now.AddDays(2) > Platform.Current.AppInfo.TrialExpirationDate;

            if (preTrialExpiredBasedPrompt && this.LastPromptedForRating == DateTime.MinValue)
            {
                showPrompt = true;
            }
            else if (this.LastPromptedForRating != DateTime.MinValue && this.LastPromptedForRating.AddDays(21) < DateTime.Now)
            {
                // Every X days after the last prompt, set as TRUE
                showPrompt = true;
            }
            else if(this.LastPromptedForRating == DateTime.MinValue && Windows.ApplicationModel.Package.Current.InstalledDate.DateTime.AddDays(3) < DateTime.Now)
            {
                // First time prompt X days after initial install
                showPrompt = true;
            }

            if(showPrompt)
                await this.PromptForRatingAsync(vm);
        }
 public MvvmableContentPage(ViewModelBase viewModel)
 {
     _viewModel = viewModel;
     BindingContext = viewModel;
     Title = "SharedSquawk";
     BackgroundColor = Styling.BackgroundColor;
 }
Esempio n. 5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="UtilityChannelView" /> class.
        /// </summary>
        /// <param name="vm">
        ///     The vm.
        /// </param>
        public HomeChannelView(HomeChannelViewModel vm)
        {
            InitializeComponent();
            this.vm = vm;

            DataContext = this.vm;
        }
 public void PushViewModelContext(ViewModelBase viewModel)
 {
     lock (this)
     {
         _contextStack.Push(viewModel);
     }
 }
Esempio n. 7
0
        public EquipmentRightViewModel(ViewModelBase parent)
        {
            Parent = parent;

            Label11 = "Asset ID:";
            Label21 = "Fed Form:";
            Label12 = "Equipment Type:";
            Label22 = "Rated Voltage:";
            Label13 = "Location:";
            Label23 = "Problem?:";

            Equipment equipment = ((EquipmentViewModel)Parent).SelectedEquipment;

            TextBox11 = equipment.Asset_ID;
            //TextBox21 = equipment.f;
            TextBox12 = equipment.EquipmentTypeID.ToString();
            //TextBox22 = equipment;
            TextBox13 = equipment.LocationID.ToString();
            //TextBox23 = equipment;

            SetTab1Page();
            SetTab2Page();
            SetTab3Page();
            SetTab4Page();
            SetTab5Page();
            SetTab6Page();
            SetTab7Page();
            SetTab8Page();
        }
Esempio n. 8
0
        public EquipmentViewModel(ViewModelBase parent, Equipment selectedEquipment)// : base()
        {
            Parent = parent;
 
            SelectedEquipment = selectedEquipment;
            SetLeftPanel();
        }
Esempio n. 9
0
        public static async Task<ViewModelBase> Next(LinkViewModel parentLink, ViewModelBase currentActual)
        {
            if (parentLink != null)
            {
                var viewModelContextService = ServiceLocator.Current.GetInstance<IViewModelContextService>();
                var firstRedditViewModel = viewModelContextService.ContextStack.FirstOrDefault(context => context is RedditViewModel) as RedditViewModel;
                if (firstRedditViewModel != null)
                {
                    RepositionContextScroll(parentLink);

                    var imagesService = ServiceLocator.Current.GetInstance<IImagesService>();
                    var offlineService = ServiceLocator.Current.GetInstance<IOfflineService>();
                    var settingsService = ServiceLocator.Current.GetInstance<ISettingsService>();
                    ViewModelBase stackNext = null;
                    if (settingsService.OnlyFlipViewUnread && (stackNext = LinkHistory.Forward()) != null)
                    {
                        return stackNext;
                    }
                    else
                    {
                        var currentLinkPos = firstRedditViewModel.Links.IndexOf(parentLink);
                        var linksEnumerator = new NeverEndingRedditView(firstRedditViewModel, currentLinkPos, true);
                        var result = await MakeContextedTuple(imagesService, offlineService, settingsService, linksEnumerator);
                        LinkHistory.Push(currentActual);
                        return result;
                    }
                }
            }
            return null;
        }
Esempio n. 10
0
        public static async Task<ViewModelBase> Previous(LinkViewModel parentLink, ViewModelBase currentActual)
        {
            if (parentLink != null)
            {
                var viewModelContextService = ServiceLocator.Current.GetInstance<IViewModelContextService>();
                var firstRedditViewModel = viewModelContextService.ContextStack.FirstOrDefault(context => context is RedditViewModel) as RedditViewModel;
                if (firstRedditViewModel != null)
                {
                    RepositionContextScroll(parentLink);

                    var imagesService = ServiceLocator.Current.GetInstance<IImagesService>();
                    var offlineService = ServiceLocator.Current.GetInstance<IOfflineService>();
                    var settingsService = ServiceLocator.Current.GetInstance<ISettingsService>();
                    //need to go backwards in time, not paying attention to the unread rules
                    ViewModelBase stackPrevious = null;
                    var emptyForward = LinkHistory.EmptyForward;
                    if (settingsService.OnlyFlipViewUnread && (stackPrevious = LinkHistory.Backward()) != null)
                    {
                        if (emptyForward)
                            LinkHistory.Push(currentActual);

                        return stackPrevious;
                    }
                    else
                    {
                        var currentLinkPos = firstRedditViewModel.Links.IndexOf(parentLink);
                        var linksEnumerator = new NeverEndingRedditView(firstRedditViewModel, currentLinkPos, false);
                        return await MakeContextedTuple(imagesService, offlineService, settingsService, linksEnumerator);
                    }

                }
            }
            return null;
        }
Esempio n. 11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            _vm = (ViewModelBase)this.DataContext;
            _vm.OnNavigatedTo(e);
        }
Esempio n. 12
0
        Window CreateWindow(ViewModelBase viewModel)
        {
            Type windowType;
            lock (_viewMap)
            {
                if (!_viewMap.ContainsKey(viewModel.GetType()))
                    throw new ArgumentException("viewModel not registered");
                windowType = _viewMap[viewModel.GetType()];
            }

            var window = (Window)Activator.CreateInstance(windowType);
            window.DataContext = viewModel;
            window.Closed += OnClosed;

            lock (_openedWindows)
            {
                // Last window opened is considered the 'owner' of the window.
                // May not be 100% correct in some situations but it is more
                // then good enough for handling dialog windows
                if (_openedWindows.Count > 0)
                {
                    Window lastOpened = _openedWindows[_openedWindows.Count - 1];

                    if (window != lastOpened)
                        window.Owner = lastOpened;
                }

                _openedWindows.Add(window);
            }

            // Listen for the close event
            Messenger.Default.Register<RequestCloseMessage>(window, viewModel, OnRequestClose);

            return window;
        }
Esempio n. 13
0
 public LinkViewModel(ViewModelBase context, Link link)
 {
     Context = context;
     Link = link;
     Comments = new CommentsViewModel(this, link);
     _content = new Lazy<ContentViewModel>(() => SnooStream.ViewModel.Content.ContentViewModel.MakeContentViewModel(link.Url, link.Title, this, link.Thumbnail));
 }
 public PropertyViewModel(ViewModelBase parent, PropertyFinderPersistentState state, Property property)
 {
     _state = state;
       _property = property;
       _isFavourited = state.IsPropertyFavourited(property);
       Parent = parent;
 }
Esempio n. 15
0
        public PublicRoomsPage(ViewModelBase viewModel)
            : base(viewModel)
        {
            var listView = new BindableListView
                {
                    ItemTemplate = new DataTemplate(() =>
                        {
                        var textCell = new TextCell();
                            textCell.SetBinding(TextCell.TextProperty, new Binding("Name"));
                            textCell.TextColor = Styling.BlackText;
                            //textCell.SetBinding(TextCell.DetailProperty, new Binding("Description"));
                            return textCell;
                        }),
                    SeparatorVisibility = SeparatorVisibility.None
                };

            listView.SetBinding(ListView.ItemsSourceProperty, new Binding("PublicRooms"));
            listView.SetBinding(BindableListView.ItemClickedCommandProperty, new Binding("SelectRoomCommand"));

            var loadingIndicator = new ActivityIndicator ();
            loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy"));
            loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            Content = new StackLayout
            {
                Children =
                        {
                            loadingIndicator,
                            listView
                        }
            };
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ChannelTextBoxEntryView" /> class.
        /// </summary>
        public ChannelTextBoxEntryView()
        {
            InitializeComponent();

            Entry.FocusableChanged += (s, e) =>
                {
                    if ((bool) e.NewValue)
                        Entry.Focus();
                };

            Entry.Language = XmlLanguage.GetLanguage(ApplicationSettings.Langauge);
            vm = DataContext as ViewModelBase;

            if (vm != null)
                vm.PropertyChanged += PropertyChanged;

            DataContextChanged += (sender, args) =>
                {
                    if (vm != null)
                        vm.PropertyChanged -= PropertyChanged;

                    vm = DataContext as ViewModelBase;

                    if (vm != null)
                        vm.PropertyChanged += PropertyChanged;
                };
        }
Esempio n. 17
0
        private void ReceiveViewMessage(String requestedUpdateViewModel)
        {
            if (requestedUpdateViewModel == "ViewHuntViewModel")
            {
                CurrentViewModel = MainViewModel.viewHuntViewModel;
            }
            else if (requestedUpdateViewModel == "SearchHuntViewModel")
            {
                CurrentViewModel = MainViewModel.searchHuntViewModel;
            }
            else if (requestedUpdateViewModel == "PrintViewModel")
            {
                CurrentViewModel = MainViewModel.printViewModel;
            }
            else if (requestedUpdateViewModel == "CreateHuntViewModel")
            {
                CurrentViewModel = MainViewModel.createHuntViewModel;
            }
            else if (requestedUpdateViewModel == "LoginViewModel")
            {
                CurrentViewModel = MainViewModel.loginViewModel;
            }
            else if (requestedUpdateViewModel == "RegisterViewModel")
            {
                CurrentViewModel = MainViewModel.registerViewModel;
            }
            else if (requestedUpdateViewModel == "LeaderboardViewModel")
            {
                CurrentViewModel = MainViewModel.leaderboardViewModel;
            }

        }
Esempio n. 18
0
		public void FocusWindow(ViewModelBase viewModel)
		{
			if (this.openWindows.ContainsKey(viewModel))
			{
				this.openWindows[viewModel].Focus();
			}
		}
        public void GotoReplyToPost(ViewModelBase currentContext, CommentsViewModel source)
        {

			source.CurrentlyFocused = source.AddReplyComment(null);
			Messenger.Default.Send<FocusChangedMessage>(new FocusChangedMessage(source));
			
        }
 public void PopViewModelContext(ViewModelBase viewModel)
 {
     lock (this)
     {
         _contextStack = new Stack<ViewModelBase>(_contextStack.Where(vm => vm != viewModel));
     }
 }
Esempio n. 21
0
        public SiteViewModel(ViewModelBase parent, Site selectedSite) //: base()
        {
            Parent = parent;
 
            SelectedSite = selectedSite;
            SetLeftPanel();
        }
Esempio n. 22
0
 public PageNavigationMessage(ViewModelBase bindingViewModel, NavigationKind kind)
 {
     this.BindingViewModel = bindingViewModel;
     if (kind == NavigationKind.Navigate)
         throw new ArgumentException("Navigate は Pageを含むコンストラクタが必要です。");
     this.Kind = kind;
 }
        PivotItem MapViewModel(ViewModelBase viewModel)
        {
            var rvm = viewModel as RedditViewModel;

            var plainHeader = rvm.Heading == "The front page of this device" ? "front page" : rvm.Heading.ToLower();
            return new PivotItem { DataContext = viewModel, Header = rvm.IsTemporary ? "*" + plainHeader : plainHeader };
        }
Esempio n. 24
0
        public WebViewBridge(IWebView webView, ViewModelBase viewModel)
        {
            _webView = webView;
            _bridge = new Bridge(viewModel, this);

            _webView.NativeViewInitialized += (sender, args) => _webView.DocumentReady += (sender2, args2) => Initialize();
        }
Esempio n. 25
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="UtilityChannelView" /> class.
        /// </summary>
        /// <param name="vm">
        ///     The vm.
        /// </param>
        public UtilityChannelView(UtilityChannelViewModel vm)
        {
            InitializeComponent();
            this.vm = vm;

            DataContext = this.vm;
        }
Esempio n. 26
0
        public static void ProvideView(ViewModelBase vm, ViewModelBase parentVm = null)
        {
            IViewMap map = Maps.SingleOrDefault(x => x.ViewModelType == vm.GetType());

            if (map == null)
                return;

            var viewInstance = Activator.CreateInstance(map.ViewType) as Window;

            if (viewInstance == null)
                throw new InvalidOperationException(string.Format("Can not create an instance of {0}", map.ViewType));

            if (parentVm != null)
            {
                ViewInstance parent = RegisteredViews.SingleOrDefault(x => x.ViewModel == parentVm);

                if (parent != null)
                {
                    Window parentView = parent.View;

                    if (Application.Current.Windows.OfType<Window>().Any(x => Equals(x, parentView)))
                        viewInstance.Owner = parentView;
                }
            }

            viewInstance.DataContext = vm;

            RegisteredViews.Add(new ViewInstance(viewInstance, vm));

            viewInstance.Show();
        }
Esempio n. 27
0
		/// <summary>
		/// Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called. 
		/// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. 
		/// </summary>
		/// <param name="viewModel">The view model. </param>
		/// <param name="view">The view. </param>
		public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view)
		{
			viewModel.Initialize();

			view.Loaded += (sender, args) => viewModel.CallOnLoaded();
			view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();
		}
Esempio n. 28
0
        public bool Show(ViewModelBase viewModel, int windowHeight = 600, int windowWidth = 860)
        {
            if(_window == null)
                _window = new WindowView();

            var refreashable = viewModel as IRefreashable;
            if (refreashable != null)
                refreashable.Refreash();

            if (_window.DataContext != null && _window.DataContext.Equals(viewModel))
            {
                return false;
            }

            if(_window.IsVisible)
            {
                _window.Focus();
                return false;
            }

            _window.Height = windowHeight;
            _window.Width = windowWidth;
            _window.Title = viewModel.ToString();
            _window.DataContext = viewModel;

            var result = _window.ShowDialog();

            _window = null;

            return result == true;
        }
        public void SetTaskPaneViewModel(ViewModelBase vm)
        {
            if (TaskPane == null)
            {
                TaskPaneControl = new TreemapView((TreemapViewModel)vm);
                ElementHost host = new ElementHost { Child = TaskPaneControl };
                host.Dock = DockStyle.Fill;
                UserControl userControl = new UserControl();
                userControl.BackColor = Color.White;
                userControl.Controls.Add(host);
                TaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(userControl, "Treemap");
                TaskPane.VisibleChanged += (sender, e) =>
                {
                    if (!TaskPane.Visible)
                    {
                        TreemapViewModel tvm = (TreemapViewModel)TaskPaneControl.DataContext;
                        tvm.IsDead = true;
                    }
                };
            }
            else
            {
                TaskPaneControl.DataContext = vm;
            }

            TaskPane.Width = 400;
            TaskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionRight;
            TaskPane.Visible = true;
        }
Esempio n. 30
0
        public cTabSiteViewModel(ViewModelBase parent)
        {
            Parent = parent;

            Customer customer = ((CustomerViewModel)Parent.Parent).SelectedCustomer;

            ItemList = new ObservableCollection<Site>(customer.Sites);
        }
Esempio n. 31
0
 internal DefiniteWorkStatusManagerControl(StatusManager manager, string statusText, ViewModelBase callingViewModel) : base(manager, statusText, callingViewModel)
 {
     if (manager.currentPlatform == Core.Platform.Mobile)
     {
         manager.UpdateStatusText(statusText);
         manager.UpdateProgress(0);
     }
 }
Esempio n. 32
0
        public UserPage()
        {
            ViewModel = new ViewModelBase();

            InitializeComponent();
        }
Esempio n. 33
0
 public void setViewModel(ViewModelBase viewModel)
 {
     this.viewModel = viewModel;
 }
Esempio n. 34
0
 public ViewModelConfig(ViewModelBase self)
 {
     _self = self as MainWindowViewModel;
 }
Esempio n. 35
0
        public IActionResult Pic()
        {
            var model = ViewModelBase.Default();

            return(View(model));
        }
 public virtual void RemoveFromUi(ViewModelBase viewModel)
 {
     ApplicationController.DoOnMainThread(() => UiItems.Remove(viewModel));
 }
Esempio n. 37
0
 private void OnItemReadyToBeRemoved(ViewModelBase viewModel)
 {
     _presentedItemsSource.Remove((TViewModel)viewModel);
 }
Esempio n. 38
0
 /// <summary>
 /// Sets the data context.
 /// </summary>
 /// <param name="dataContext">The data context.</param>
 public void SetDataContext(ViewModelBase dataContext)
 {
     this.DataContext = dataContext;
 }
Esempio n. 39
0
 public ShellViewModel(FalconViewModel viewModel)
 {
     CurrentViewModel = viewModel;
 }
Esempio n. 40
0
        public IActionResult Progress()
        {
            var model = ViewModelBase.Default("REMOTE TASK");

            return(View(model));
        }
Esempio n. 41
0
        public IActionResult Clock()
        {
            var model = ViewModelBase.Default("SMART CLOCK");

            return(View(model));
        }
Esempio n. 42
0
 public void ShowView(ViewModelBase viewModelBase)
 {
     Window.DataContext = viewModelBase;
     Window.ShowDialog();
 }
Esempio n. 43
0
 public override void SetViewModel(ViewModelBase viewModel)
 {
     VM = (GameCoreViewModel)viewModel;
 }
Esempio n. 44
0
 public IActionResult Media()
 {
     return(View(ViewModelBase.Default("MEDIA")));
 }
        private void NavigateBase(Type viewModelType, Type view, object parameter)
        {
            if (view == null)
            {
                throw new Exception("View not found!");
            }

            ViewModelBase viewModel = null;

            bool useDataContext = NavigationManager.GetViewModelInfo(viewModelType).UseDataContextInsteadOfCreating; //(bool)view.GetTypeInfo().GetCustomAttribute<NavigationViewModelAttribute>()?.UseDataContextInsteadOfCreating;

            if (!useDataContext)
            {
                bool viewModelCachingEnabled = Crystal3.CrystalApplication.GetCurrentAsCrystalApplication().Options.EnableViewModelCaching;
                if (viewModelCachingEnabled)
                {
                    viewModel = Crystal3.CrystalApplication.GetCurrentAsCrystalApplication().ResolveCachedViewModel(viewModelType);
                }
            }

            NavigatingCancelEventHandler navigatingHandler = null;

            navigatingHandler = new NavigatingCancelEventHandler((object sender, Windows.UI.Xaml.Navigation.NavigatingCancelEventArgs e) =>
            {
                NavigationFrame.Navigating -= navigatingHandler;

                if (!useDataContext) //we can't access the data context in this event so don't even bother
                {
                    if (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh)
                    {
                        if (viewModel == null)
                        {
                            viewModel = CreateViewModelFromType(viewModelType) as ViewModelBase;
                        }

                        viewModel.NavigationService = this;

                        if (lastViewModel != null)
                        {
                            e.Cancel = lastViewModel.OnNavigatingFrom(sender, new CrystalNavigationEventArgs(e)
                            {
                                Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                            });
                        }

                        viewModel.OnNavigatingTo(sender, new CrystalNavigationEventArgs(e)
                        {
                            Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                        });
                    }
                    //else if (e.NavigationMode == NavigationMode.Back)
                    //{
                    //    e.Cancel = viewModel.OnNavigatingFrom(sender, e);
                    //}
                }
            });

            NavigatedEventHandler navigatedHandler = null;

            navigatedHandler = new NavigatedEventHandler((object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) =>
            {
                NavigationFrame.Navigated -= navigatedHandler;

                InvokePreNavigatedEvent(new NavigationServicePreNavigatedSignaledEventArgs(viewModel, new CrystalNavigationEventArgs(e)));

                if (e.NavigationMode == NavigationMode.New)
                {
                    if (lastViewModel != null)
                    {
                        lastViewModel.OnNavigatedFrom(sender, new CrystalNavigationEventArgs(e)
                        {
                            Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                        });

                        viewModelBackStack.Push(lastViewModel);
                    }

                    Page page = e.Content as Page;

                    //page.NavigationCacheMode = NavigationCacheMode.Enabled;

                    if (!useDataContext)
                    {
                        page.DataContext = viewModel;
                    }
                    else
                    {
                        viewModel = page.DataContext as ViewModelBase;
                    }

                    if (viewModel == null)
                    {
                        throw new Exception();
                    }

                    if (viewModel is UIViewModelBase)
                    {
                        ((UIViewModelBase)viewModel).UI.SetUIElement(page);
                    }

                    //page.SetValue(FrameworkElement.DataContextProperty, viewModel);

                    viewModel.OnNavigatedTo(sender, new CrystalNavigationEventArgs(e)
                    {
                        Direction = ConvertToCrystalNavDirections(e.NavigationMode)
                    });

                    lastViewModel = viewModel;
                }
                //else if (e.NavigationMode == NavigationMode.Back)
                //{
                //    viewModel.OnNavigatedFrom(sender, e);
                //}

                InvokeNavigatedEvent(new CrystalNavigationEventArgs(e)
                {
                    Direction = ConvertToCrystalNavDirections(e.NavigationMode), Parameter = e.Parameter
                });

                navigationLock.Set();
            });

            navigationLock.Reset();

            NavigationFrame.Navigated  += navigatedHandler;
            NavigationFrame.Navigating += navigatingHandler;

            NavigationFrame.Navigate(view, parameter);
        }
 public ScintificsPanelViewModel(ViewModelBase parentVM) : base(parentVM.Controller)
 {
     ParentVM = parentVM;
 }
 public DiagTypePanelViewModel(ViewModelBase parentVM) : base(parentVM.Controller)
 {
     ParentVM = parentVM;
 }
 public void Navigate(ViewModelBase _viewModel)
 {
     SelectedViewModel = _viewModel;
 }
 public virtual void LoadToUi(ViewModelBase viewModel)
 {
     ApplicationController.DoOnMainThread(() => UiItems.Add(viewModel));
 }
Esempio n. 50
0
 public EditStorePage(ViewModelBase viewModelBase) : base(GetViewModel(viewModelBase))
 {
     InitializeComponent();
 }
Esempio n. 51
0
        public void Show(ViewModelBase viewModel)
        {
            var displayRootRegistry = (Application.Current as App).displayRootRegistry;

            displayRootRegistry.ShowModalPresentation(viewModel);
        }
Esempio n. 52
0
 public void LoadBasePreferences(ViewModelBase vmBase)
 {
     vmBase.ProcessContactEmail        = GetPreferenceValue(Constants.ContactEmail);
     vmBase.ProccessContactMailSubject = GetPreferenceValue(Constants.ContactSubject);
     vmBase.ProcessContactName         = GetPreferenceValue(Constants.ContactName);
 }
 public void NavigateTo(ViewModelBase target)
 {
     _navigationHandlerConfiguration.NavigationRequestedCallbacks.ForEach(f => f.Invoke(target));
 }
Esempio n. 54
0
        protected async override void OnResume()
        {
            await UserTokenSettings.Current.RefreshUserTokenAsync();

            if (registered)
            {
                return;
            }
            registered = true;
            Connectivity.ConnectivityChanged += ConnectivityChanged;

            MessagingService.Current.Subscribe(MessageKeys.NavigateLogin, async m =>
            {
                Page page = new NavigationPage(new AuthorizePage());

                var nav = Xamarin.Forms.Application.Current?.MainPage?.Navigation;
                if (nav == null)
                {
                    return;
                }

                await NavigationService.PushModalAsync(nav, page);
            });
            MessagingService.Current.Subscribe <string>(MessageKeys.NavigateToken, async(m, q) =>
            {
                var result = await TokenHttpClient.Current.PostTokenAsync(q);
                if (result.Success)
                {
                    var token         = JsonConvert.DeserializeObject <Token>(result.Message.ToString());
                    token.RefreshTime = DateTime.Now;
                    UserTokenSettings.Current.UpdateUserToken(token);

                    var userResult = await UserHttpClient.Current.GetAsyn(Apis.Users);
                    if (userResult.Success)
                    {
                        var user = JsonConvert.DeserializeObject <User>(userResult.Message.ToString());

                        UserSettings.Current.UpdateUser(user);

                        var nav = Xamarin.Forms.Application.Current?.MainPage?.Navigation;
                        if (nav == null)
                        {
                            return;
                        }
                        await nav.PopModalAsync();
                    }
                }
            });
            MessagingService.Current.Subscribe(MessageKeys.NavigateAccount, async m =>
            {
                Page page = new NavigationPage(new AccountPage());

                var nav = Xamarin.Forms.Application.Current?.MainPage?.Navigation;
                if (nav == null)
                {
                    return;
                }

                await NavigationService.PushModalAsync(nav, page);
            });
            MessagingService.Current.Subscribe <string>(MessageKeys.NavigateNotification, async(m, message) =>
            {
                DependencyService.Get <IToast>().SendToast(message);
                var nav = Xamarin.Forms.Application.Current?.MainPage?.Navigation;
                if (nav == null)
                {
                    return;
                }
                Page page        = null;
                var notification = JsonConvert.DeserializeObject <Notification>(message);
                if (notification != null)
                {
                    switch (notification.Type)
                    {
                    case "articles":
                        page = new NavigationPage(new ArticlesDetailsPage(new Articles()
                        {
                            Title = notification.Title, Id = notification.ID
                        }));
                        break;

                    case "news":
                        page = new NavigationPage(new NewsDetailsPage(new News()
                        {
                            Title = notification.Title, Id = notification.ID
                        }));
                        break;

                    case "kbarticles":
                        page = new NavigationPage(new KbArticlesDetailsPage(new KbArticles()
                        {
                            Title = notification.Title, Id = notification.ID
                        }));
                        break;

                    case "questions":
                        page = new NavigationPage(new QuestionsDetailsPage(new Questions()
                        {
                            Title = notification.Title, Qid = notification.ID
                        }));
                        break;

                    case "update":
                        if (notification.ID > int.Parse(VersionTracking.CurrentBuild))
                        {
                            if (await Xamarin.Forms.Application.Current?.MainPage.DisplayAlert("New tip", notification.Title, "DownLoad Now", "cancel"))
                            {
                                await ViewModelBase.ExecuteLaunchBrowserAsync(notification.Url);
                            }
                        }
                        return;

                    default:
                        return;
                    }
                }
                await NavigationService.PushAsync(nav, page);
            });
        }
Esempio n. 55
0
 private void Init()
 {
     CustomersViewModel = ContainerHelper.Container.Resolve <CustomersViewModel>();
     CurrentViewModel   = CustomersViewModel;
 }
 private void SetupView(string viewName, FrameworkElement view, ViewModelBase viewModel)
 {
     view.DataContext = viewModel;
     views.Add(viewName, view);
 }
Esempio n. 57
0
        protected override void Configure()
        {
            App.AppPath = AppDomain.CurrentDomain.BaseDirectory;
            Directory.SetCurrentDirectory(App.AppPath);

            var args = Environment.GetCommandLineArgs();

            try
            {
                var configurationSettings = new CustomConfigurationSettings();
                BpHelperConfigParser.PopulateConfigurationSettings(configurationSettings);
                UserDataConfigParser.PopulateUserDataSettings();
                App.CustomConfigurationSettings = configurationSettings;
                App.NextConfigurationSettings   = configurationSettings;
            }
            catch (Exception)
            {
                //Ignored
            }

            if (args.Any(arg => arg.ToLower() == "/log"))
            {
                LogUtil.NoLog   = false;
                OcrEngine.Debug = true;
            }

            if (args.Any(arg => arg.ToLower() == "/devtool"))
            {
                App.DevTool = true;
            }

            if (args.Any(arg => arg.ToLower() == "/debugv2"))
            {
                LogUtil.NoLog   = false;
                OcrEngine.Debug = true;
                App.Debug       = true;
            }

            if (args.Any(arg => arg.ToLower() == "/debugv2"))
            {
                LogUtil.NoLog   = false;
                OcrEngine.Debug = true;
                App.Debug       = true;
            }

            if (args.Any(arg => arg.ToLower() == "/forceupdate"))
            {
                App.ForceUpdate = true;
            }

            try
            {
                if (args.Any(arg => arg.ToLower().StartsWith("/upload")))
                {
                    var dateString = args.First(arg => arg.ToLower().StartsWith("/upload")).Substring(7);
                    App.UploadMinimumAcceptableTime = DateTime.Parse(dateString).ToUniversalTime();
                }
                else
                {
                    App.UploadMinimumAcceptableTime = Const.HotsweekAcceptTime;
                }
            }
            catch
            {
                App.UploadMinimumAcceptableTime = DateTime.Now;
            }

            if (args.Any(arg => arg.ToLower() == "/errortest"))
            {
                ErrorView _errorView = new ErrorView(ViewModelBase.L("NoMatchResolution"),
                                                     ViewModelBase.L("MSG_NoMatchResolution"), "https://www.bphots.com/articles/errors/test");
                _errorView.ShowDialog();
            }
        }
Esempio n. 58
0
 public LoadingPage(ViewModelBase vm)
 {
     BindingContext = vm;
 }
Esempio n. 59
0
 public SurveyPage(ViewModelBase vm)
 {
     BindingContext = vm;
     NavigationPage.SetBackButtonTitle(this, "");
     InitializeComponent();
 }
Esempio n. 60
0
 public override void Initialize(ViewModelBase viewModel)
 {
     base.Initialize(viewModel);
 }