Exemplo n.º 1
0
        public static bool SetField <T>(this PropertyChangedBase obj
                                        , ref T field, T value
                                        , bool overrideChecks = false
                                        , [System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
        {
            if (obj == null)
            {
                return(false);
            }

            if (!overrideChecks)
            {
                if (EqualityComparer <T> .Default.Equals(field, value))
                {
                    return(false);
                }
            }

            field = value;

            if (obj.IsNotifying)
            {
                obj.NotifyOfPropertyChange(propertyName);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static bool SetFieldEnum <TEnum>(this PropertyChangedBase obj
                                                , ref TEnum field, TEnum value
                                                , bool overrideChecks = false
                                                , [System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
            where TEnum : struct, IComparable, IFormattable, IConvertible
        {
            if (obj == null)
            {
                return(false);
            }

            if (!overrideChecks)
            {
                if (field.ToInt64(null) == value.ToInt64(null))
                {
                    return(false);
                }
            }

            field = value;

            if (obj.IsNotifying)
            {
                obj.NotifyOfPropertyChange(propertyName);
            }

            return(true);
        }
Exemplo n.º 3
0
        void OpenLicenseVerify(string license)
        {
            WindowContent = new LicenseVerificationViewModel();

            LicenseVerify(license);
            DialogOpenIfNotOpenedYet();
        }
Exemplo n.º 4
0
        public SuppressNotificationScope(PropertyChangedBase model)
        {
            _wasNotifying = model.IsNotifying;

            _model             = model;
            _model.IsNotifying = false;
        }
Exemplo n.º 5
0
        public static bool SetFieldObj <T>(this PropertyChangedBase obj
                                           , ref T field, T value
                                           , bool overrideChecks = false
                                           , [System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
            where T : class, IEquatable <T>
        {
            if (obj == null)
            {
                return(false);
            }

            if (!overrideChecks)
            {
                if (field == null)
                {
                    if (value == null)
                    {
                        return(false);
                    }
                }
                else if (field.Equals(value))
                {
                    return(false);
                }
            }

            field = value;

            if (obj.IsNotifying)
            {
                obj.NotifyOfPropertyChange(propertyName);
            }

            return(true);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Opens the specified content.
 /// </summary>
 /// <param name="content">The content.</param>
 public void Open(PropertyChangedBase content)
 {
     this.ClearContent();
     this.SetPosition();
     this.SetContent(content);
     this._mouseLurker.MouseMove += this.MouseLurker_MouseMove;
 }
 public void Handle(TerminationMessages.Success message)
 {
     ActiveViewModel = _plannedAction == LaunchAction.Install
         ? (PropertyChangedBase)_screens.OfType <InstallSuccessViewModel>().First()
         : (PropertyChangedBase)_screens.OfType <UninstallSuccessViewModel>().First();
     NotifyStateChanged();
 }
        public void Handle(DirectorySearchMessages.DotaDirectoryFound message)
        {
            _dotaDirectoryKnown = true;
            _ba.Engine.StringVariables["DotaConfigDir"] = message.Path;

            ActiveViewModel = _screens.OfType <DotaDetectedViewModel>().First();
            NotifyStateChanged();
        }
Exemplo n.º 9
0
 public void Downloading()
 {
     if (SelectedView is DownloadingViewModel)
     {
         return;
     }
     SelectedView = new DownloadingViewModel(GlobalVariables.Instance.Songs);
 }
Exemplo n.º 10
0
 public void Settings()
 {
     if (SelectedView is SettingsViewModel)
     {
         return;
     }
     SelectedView = new SettingsViewModel();
 }
Exemplo n.º 11
0
 public void SongsList()
 {
     if (SelectedView is SongsListViewModel)
     {
         return;
     }
     SelectedView = new SongsListViewModel(GlobalVariables.Instance.Songs);
 }
Exemplo n.º 12
0
 public void AddLink()
 {
     if (SelectedView is AddLinkViewModel)
     {
         return;
     }
     SelectedView = new AddLinkViewModel(GlobalVariables.Instance.Songs);
 }
Exemplo n.º 13
0
        public static void QuietlyReload <T>(this PropertyChangedBase presenter, ref ICollectionView list, string propertyName)
        {
            var temp = list;

            list = new ListCollectionView(new List <T>());
            presenter.NotifyOfPropertyChange(propertyName);
            list = temp;
            presenter.NotifyOfPropertyChange(propertyName);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Backs this instance.
 /// </summary>
 public void Back()
 {
     if (ActiveChart is ColumnChartViewModel)
     {
         this._pieChart             = this.GetPieChart();
         this._pieChart.OnPieClick += this.PieChartViewModel_OnPieClick;
         this.ActiveChart           = this._pieChart;
     }
 }
Exemplo n.º 15
0
        public static void QuietlyReload <T>(this PropertyChangedBase presenter, ref IEnumerable <T> list, string propertyName)
        {
            var temp = list;

            list = null;
            presenter.NotifyOfPropertyChange(propertyName);
            list = temp;
            presenter.NotifyOfPropertyChange(propertyName);
        }
Exemplo n.º 16
0
        public static void QuietlyReload(this PropertyChangedBase presenter, ref IList list, string propertyName)
        {
            var temp = list;

            list = new List <IEnumerable>();
            presenter.NotifyOfPropertyChange(propertyName);
            list = temp;
            presenter.NotifyOfPropertyChange(propertyName);
        }
        public ToolbarViewModel(RiseSectionData riseSectionData, EditorManager editorManager)
        {
            mEditorManager = editorManager;
            mEditorManager.PropertyChanged += EditorManagerPropertyChanged;

            CreatePropertiesViewModels(riseSectionData);

            EditorViewModel     = new EditorViewModel(riseSectionData, editorManager);
            PropertiesViewModel = new NoSelectionPropertiesViewModel();
        }
 public static bool Set <T>(this PropertyChangedBase screen, ref T field, T value, [CallerMemberName] string propertyName = null)
 {
     if (EqualityComparer <T> .Default.Equals(field, value))
     {
         return(false);
     }
     field = value;
     screen.NotifyOfPropertyChange(propertyName);
     return(true);
 }
Exemplo n.º 19
0
 public static bool SetValue <T>(this PropertyChangedBase viewModel, ref T field, T newValue, Expression <Func <T> > propertyExpression)
 {
     if (EqualityComparer <T> .Default.Equals(field, newValue))
     {
         return(false);
     }
     field = newValue;
     viewModel.NotifyOfPropertyChange(propertyExpression);
     return(true);
 }
 private void SelectPropertiesViewModel()
 {
     if (mEditorManager.SelectedPlatform != null)
     {
         PropertiesViewModel = mPropertiesViewModels[typeof(PlatformEditorViewModel)];
     }
     else
     {
         PropertiesViewModel = mPropertiesViewModels[typeof(NoSelectionPropertiesViewModel)];
     }
 }
Exemplo n.º 21
0
        public static bool SetValue <T>(this PropertyChangedBase viewModel, ref T field, T newValue, [CallerMemberName] string propertyName = null)
        {
            if (EqualityComparer <T> .Default.Equals(field, newValue))
            {
                return(false);
            }

            field = newValue;
            viewModel.NotifyOfPropertyChange(propertyName);
            return(true);
        }
 private void SelectPropertiesViewModel()
 {
     if (mEditorManager.SelectedPlatform != null)
     {
         PropertiesViewModel = mPropertiesViewModels[typeof(PlatformEditorViewModel)];
     }
     else
     {
         PropertiesViewModel = mPropertiesViewModels[typeof(NoSelectionPropertiesViewModel)];
     }
 }
Exemplo n.º 23
0
        public static bool SetPropertyValue <T>(this PropertyChangedBase @base, ref T property, T value, [CallerMemberName] string propertyName = "")
        {
            if (Equals(property, value))
            {
                return(false);
            }

            property = value;
            @base.NotifyOfPropertyChange(propertyName);
            return(true);
        }
Exemplo n.º 24
0
        public static bool Set <T>(this PropertyChangedBase propertyChangedBase, ref T oldValue, T newValue, [CallerMemberName] string propertyName = null)
        {
            if (Equals(oldValue, newValue))
            {
                return(false);
            }

            oldValue = newValue;
            propertyChangedBase.NotifyOfPropertyChange(propertyName);

            return(true);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Pies the chart view model on pie click.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void PieChartViewModel_OnPieClick(object sender, LiveCharts.ChartPoint e)
 {
     if (Enum.TryParse <CurrencyType>(e.SeriesView.Title, true, out var value))
     {
         var trades = this._trades.Where(t => t.Price.CurrencyType == value);
         var chart  = new ColumnChartViewModel(trades.Select(t => t.ItemName).ToArray());
         chart.Add(e.SeriesView.Title, trades.Select(t => t.Price.NumberOfCurrencies));
         this._columnChart          = chart;
         this.ActiveChart           = this._columnChart;
         this._pieChart.OnPieClick -= this.PieChartViewModel_OnPieClick;
     }
 }
        public static void showVMDialog(PropertyChangedBase viewmodel, string windowHeader)
        {
            WindowManager windowManager = new WindowManager();
            dynamic       settings      = new ExpandoObject();

            settings.WindowStyle   = WindowStyle.None;
            settings.ShowInTaskbar = true;
            settings.Title         = windowHeader;
            settings.WindowState   = WindowState.Normal;
            settings.ResizeMode    = ResizeMode.CanMinimize;

            windowManager.ShowDialog(viewmodel, null, settings);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Called when activating.
        /// </summary>
        protected override async void OnActivate()
        {
            using (var service = new DatabaseService())
            {
                await service.CheckPledgeStatus();

                this._trades = service.Get().Where(t => !t.IsOutgoing).ToArray();
            }

            this._pieChart             = this.GetPieChart();
            this._pieChart.OnPieClick += this.PieChartViewModel_OnPieClick;
            this.ActiveChart           = this._pieChart;
            base.OnActivate();
        }
Exemplo n.º 28
0
 void OpenLicenseServerUnreachable(string license)
 {
     WindowContent = new LicenseServerUnreachableViewModel(
         context,
         () =>
     {
         if (ConfirmUseBasicFeatures())
         {
             LicenseSetBasicFeatures();
         }
     },
         () => LicenseVerify(license)
         );
     DialogOpenIfNotOpenedYet();
 }
Exemplo n.º 29
0
        public static bool SetPropertyChanged(this PropertyChangedBase obj
                                              , [System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj.IsNotifying)
            {
                obj.NotifyOfPropertyChange(propertyName);
            }

            return(true);
        }
Exemplo n.º 30
0
        /// <summary>
        ///     Show a pop-up window, can be a dialog, which once showed up does not allow interaction
        ///     with the background window. It also can be an independent window, which does allow
        ///     interaction with any other window of the application.
        /// </summary>
        /// <param name="viewModel">ViewModel to be shown in the pop-up window</param>
        /// <param name="windowHeader">Title of the window.</param>
        /// <param name="isDialog">Whether its a dialog or a window.</param>
        public static void ShowPopupWindow(PropertyChangedBase viewModel, string windowHeader, bool isDialog = true)
        {
            WindowManager windowManager = new WindowManager();
            var           settings      = SetupPopupWindow(windowHeader);

            settings.WindowState   = WindowState.Normal;
            settings.ResizeMode    = ResizeMode.CanResize;
            settings.SizeToContent = SizeToContent.Manual;

            if (isDialog)
            {
                windowManager.ShowDialog(viewModel, null, settings);
            }
            else
            {
                windowManager.ShowWindow(viewModel, null, settings);
            }
        }
Exemplo n.º 31
0
 public void ShowWorldSettings()
 {
     RightPanel = new SimulationSettingsViewModel(this, WorldSettings);
 }
Exemplo n.º 32
0
        public void AddMenu(ToggleButtonMenuViewModel panel)
        {
            //AppModel.EventAggregator.Publish(new SoundPlayMessage(SoundPlayType.MenuSlideOut));

            if (!Menus.Contains(panel))
            {
                if (panel.MenuParent == MainMenu)
                {
                    Menus.Apply(x => x.ControlIsVisible = false);
                    Menus.Clear();
                    Menus.Add(panel);
                }
                else
                {
                    BindableCollection<ToggleButtonMenuViewModel> newMenus = new BindableCollection<ToggleButtonMenuViewModel>(Menus);
                    bool foundParent = false;
                    foreach (ToggleButtonMenuViewModel menu in newMenus)
                    {
                        if ((foundParent |= menu == panel.MenuParent) && menu != panel.MenuParent)
                        {
                            menu.ControlIsVisible = false;
                            Menus.Remove(menu);
                        }
                    }

                    Menus.Add(panel);
                }

                panel.ControlIsVisible = true;

                foreach (OptionButtonViewModel button in panel.Buttons)
                {
                    button.IsOptionChecked = false;
                }

                Popup = null;
            }
        }