Esempio n. 1
0
        public MainWindowViewModel()
        {
            ScallParam = new ObservableCollection <string>();
            ScallParam.Add("1:1");
            ScallParam.Add("1:100");
            ScallParam.Add("1:500");
            ScallParam.Add("1:1000");
            ScallParam.Add("1:2000");
            ScallParam.Add("1:5000");
            ScallParam.Add("1:10000");
            ScallParam.Add("1:25000");
            ScallParam.Add("1:50000");
            ScallParam.Add("1:100000");
            ScallParam.Add("1:200000");
            ScallParam.Add("1:300000");
            ScallParam.Add("1:500000");
            ScallParam.Add("1:1000000");

            this.Translate   = new Translate();
            ScaleCanvasParam = new ScaleCanvasParam();
            Scale            = new Scale();
            GetUIElement     = new RelayCommands <UIElementCollection>((obj) => CanvasChildren = obj, (obj) => true);
            OpenFile         = new RelayCommands(ParseXmlFile);
            enlargeCommands  = new RelayCommands <Object>((obj) => Scale.Enlarge(1.3), (obj) => true);
            decreaseCommands = new RelayCommands <Object>((obj) => Scale.Decrease(1.3), (obj) => true);
        }
Esempio n. 2
0
        public MainViewModel(IDialogService dialogService, XmlComputerReader sourceReader, XmlComputerWriter sourceWriter)
        {
            _dialogService     = dialogService;
            _xmlComputerReader = sourceReader;
            _xmlComputerWriter = sourceWriter;

            Computers = new ObservableCollection <Computer>();
            if (File.Exists(@"serwis.xml"))
            {
                var fileName = @"serwis.xml"; // zaladowanie domyslnej bazy przy starcie programu
                if (fileName != null)
                {
                    List <Computer> ComputerList = _xmlComputerReader.ReadBooks(fileName);
                    foreach (var computer in ComputerList)
                    {
                        Computers.Add(computer);
                    }
                }
            }
            else
            {
                File.Create(@"serwis.xml");
            }
            NewComp     = new Computer();
            AddComputer = new RelayCommands(p => AddNewComputer(), null);
            OpenFile    = new RelayCommands(p => LoadFile(), null);
            SaveFile    = new RelayCommands(p => SaveToFile(), null);
        }
Esempio n. 3
0
 /// <summary>
 /// Remove a command from the command map
 /// </summary>
 /// <param name="commandName">The name of the command</param>
 internal void RemoveCommand(string commandName)
 {
     if (RelayCommands.ContainsKey(commandName))
     {
         RelayCommands[commandName].Dispose();
         RelayCommands.Remove(commandName);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Add a named command to the command map
 /// </summary>
 /// <param name="commandName">The name of the command</param>
 /// <param name="executeMethod">The method to execute</param>
 /// <param name="canExecuteMethod">The method to execute to check if the command can be executed</param>
 internal void AddCommand(string commandName, Action <object> executeMethod, Predicate <object> canExecuteMethod, bool isVisible)
 {
     if (RelayCommands.ContainsKey(commandName))
     {
         RelayCommands[commandName].Dispose();
     }
     RelayCommands[commandName] = new RelayCommand(executeMethod, canExecuteMethod, isVisible);
 }
Esempio n. 5
0
 public ProductViewModel()
 {
     objProdService = new ProductService();
     LoadData();
     CurrentProduct = new Product();
     _saveCommand   = new RelayCommands(Save);
     _updateCommand = new RelayCommands(Update);
     _deleteCommand = new RelayCommands(Delete);
 }
Esempio n. 6
0
 public ManagerViewModel()
 {
     objManagerService = new ManagerService();
     LoadData();
     CurrentManager = new Manager();
     _saveCommand   = new RelayCommands(Save);
     _updateCommand = new RelayCommands(Update);
     _deleteCommand = new RelayCommands(Delete);
     _showCommand   = new RelayCommands(ShowClients);
 }
Esempio n. 7
0
 public FavouritesViewModel(FavouritesView favouritesView, StateContext stateContext, MovieRepository movieRepository)
 {
     CurrentStateControl             = favouritesView;
     MovieRepository                 = movieRepository;
     CurrentStateControl             = new FavouritesView();
     CurrentStateControl.DataContext = this;
     StateContext        = stateContext;
     GoToSearch          = new RelayCommands(GoToSearchUserControl);
     DeleteFavouriteItem = new RelayCommands <int>(DeleteFavourite);
     FavouriteMovie      = StateContext.FavouritesMovies;
 }
Esempio n. 8
0
 public ClientViewModel()
 {
     objClientService  = new ClientService();
     objManagerService = new ManagerService();
     LoadData();
     CurrentClient  = new Client();
     _saveCommand   = new RelayCommands(Save);
     _updateCommand = new RelayCommands(Update);
     _deleteCommand = new RelayCommands(Delete);
     _showCommand   = new RelayCommands(ShowProducts);
 }
Esempio n. 9
0
        public SearchViewModel(ApiService apiService, MovieRepository movieRepository, StateContext stateContext, SearchView searchView)
        {
            CurrentStateControl             = searchView;
            CurrentStateControl.DataContext = this;
            MoviesRepository = movieRepository;
            _apiService      = apiService;

            GoToFavouriteCommand  = new RelayCommands(GoToFavourite);
            SearchCommand         = new RelayCommands(Search);
            AddToFavouriteCommand = new RelayCommands(AddToFavourite);
            StateContext          = stateContext;

            var t = MoviesRepository.GetMovies();

            t.ToList().ForEach(e => StateContext.Movies.Add(e));
        }
        public MainWindowViewModel(Window window)
        {
            _window = window;

            //fire of all events of properties affected on window state change
            _window.StateChanged += (sender, e) =>
            {
                OnPropertyChanged(nameof(CornerRadius));
                OnPropertyChanged(nameof(ResizeBorderThickness));
            };

            //fire of commands
            Minimize = new RelayCommands(() => _window.WindowState = WindowState.Minimized);
            Maximize = new RelayCommands(() => _window.WindowState ^= WindowState.Maximized);
            Close    = new RelayCommands(() => _window.Close());
        }
        public MainWindowViewModel(SearchViewModel searchViewModel, FavouritesViewModel favouritesViewModel)
        {
            CurrentState = searchViewModel;

            GetChildrenCommand = new RelayCommands <UIElementCollection>(child =>
            {
                Scen = child;
                Scen?.Clear();
                Scen.Add(CurrentState.CurrentStateControl);
            });

            ChangeState = SetNewScen;
            searchViewModel.ChangeState         = ChangeState;
            favouritesViewModel.ChangeState     = ChangeState;
            searchViewModel.FavouritesViewModel = favouritesViewModel;
            favouritesViewModel.SearchViewModel = searchViewModel;
        }
        public MainWindowViewModel()
        {
            MessageHeader            = "Message Header";
            MessageBody              = "Message Body";
            MessagTypeTextBlock      = "Message type:";
            LoadXMLText              = "Load File";
            GenerateReportButtonText = "Generate Report";

            _MessageHeaderTextBox = string.Empty;
            _MessageBodyTextBox   = string.Empty;
            _Subject = string.Empty;
            _Sender  = string.Empty;

            LoadXMLCommand        = new RelayCommands(LoadXMLClick);
            GenerateReportCommand = new RelayCommands(GenerateReportClick);
            AddNewCommand         = new RelayCommands(AddNew);
            AddNewSirCommand      = new RelayCommands(AddNewSir);
            SaveToJsonCommand     = new RelayCommands(SaveToJson);

            p = new MessageProcessor();
            p.loadAbbreviations();
        }
Esempio n. 13
0
 private void InitializeViewsModel()
 {
     _displayContent        = "Please Enter your Number";
     ButtonNumberCommand    = new RelayCommands(new Action <object>(UpdateOperandString));
     ButtonOperationCommand = new RelayCommands(new Action <object>(SetOperation));
 }
Esempio n. 14
0
 public MainViewModel()
 {
     _openManager  = new RelayCommands(OpenManagerWindow);
     _openProducts = new RelayCommands(OpenProdWindow);
     _openClients  = new RelayCommands(OpenClientWindow);
 }
 static RelayCommandAttribute GetCommand(RelayCommands cmd)
 {
     switch (cmd)
     {
         case RelayCommands.Create: return CreateCommand;
         case RelayCommands.Search: return SearchCommand;
         case RelayCommands.Copy: return CopyCommand;
         case RelayCommands.Edit: return EditCommand;
         case RelayCommands.Delete: return DeleteCommand;
         case RelayCommands.DeleteSelected: return DeleteSelectedCommand;
         case RelayCommands.Save: return SaveCommand;
         case RelayCommands.Export: return ExportCommand;
         case RelayCommands.Import: return ImportCommand;
         case RelayCommands.Approve: return ApproveCommand;
         case RelayCommands.Disapprove: return DisapproveCommand;
         case RelayCommands.Undo: return UndoCommand;
         case RelayCommands.Redo: return RedoCommand;
         case RelayCommands.ResetFilter: return ResetFilterCommand;
         case RelayCommands.OpenSearch: return OpenSearchCommand;
         case RelayCommands.BrowseBack: return BrowseBackCommand;
         case RelayCommands.BrowseForward: return BrowseForwardCommand;
         case RelayCommands.FirstPage: return FirstPageCommand;
         case RelayCommands.LastPage: return LastPageCommand;
         case RelayCommands.NextPage: return NextPageCommand;
         case RelayCommands.PreviousPage: return PreviousPageCommand;
         case RelayCommands.GoToPage: return GoToPageCommand;
         case RelayCommands.Refresh: return RefreshCommand;
         case RelayCommands.Print: return PrintCommand;
         case RelayCommands.PrintPreview: return PrintPreviewCommand;
     }
     return null;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="baseOn">命令原型</param>
 public RelayCommandAttribute(RelayCommands baseOn)
     : this(GetCommand(baseOn))
 {
 }