Example #1
0
 public void SetRefreshCommand(GalaSoft.MvvmLight.Command.RelayCommand refreshCommand)
 {
     if (_context != null)
     {
         _context.SetRefreshCommand(refreshCommand);
     }
 }
Example #2
0
 public MainLibraryViewModel()
 {
     Client     = new HttpClient();
     ManageTime = new ManageTime();
     GetAllAbstractItems();
     ActiveUser       = Consts.ActiveUser;
     GreetingNameText = $"Hello , {ActiveUser.Username}";
     GreetingTimeText = ManageTime.GetGreeting();
     if (ActiveUser.Type == Models.UserTypes.User)
     {
         EditVisibility      = Visibility.Collapsed;
         DeleteAndRentText   = "Buy";
         SelectemItemCommand = new RelayCommand(BuyItemHandler);
     }
     else if (ActiveUser.Type == Models.UserTypes.Admin)
     {
         DeleteAndRentText   = "Delete";
         SelectemItemCommand = new RelayCommand(DeleteItemHandler);
     }
     OpenCreateBookCommand   = new RelayCommand(CreateBookHendler);
     OpenCreateJornalCommand = new RelayCommand(CreateJornalHendler);
     EditCommand             = new RelayCommand(EditItemHandler);
     DisconectedCommand      = new RelayCommand(DisconectedHandler);
     SearchCommand           = new RelayCommand(SearchItemsHandler);
     OrderByPriceCommand     = new RelayCommand(OrderByPrice);
     OrderByTitleCommand     = new RelayCommand(OrderByTitle);
     OrderByPublisherCommand = new RelayCommand(OrderByPublisher);
     OrderByPrintDateCommand = new RelayCommand(OrderByPrintDate);
 }
Example #3
0
        public MainPageViewModel()
        {
            SptccClient   = new HtmlSptccClient();
            SearchResults = new ObservableCollection <SearchResult>();
            Cards         = new ObservableCollection <Card>();

            if (IsInDesignMode)
            {
                SearchResults.Add(new SearchResult()
                {
                    CardNumber = "96777213213",
                    Balance    = 253.38,
                    Date       = "2015年01月21日"
                });

                SearchResults.Add(new SearchResult()
                {
                    CardNumber = "34696713319",
                    Balance    = 400.12,
                    Date       = "2015年01月21日"
                });
            }
            else
            {
                _settings    = new AppSettings();
                InitDataTask = InitData();
            }

            CommandSearch             = new RelayCommand(async() => await DoSearchAsync());
            CommandEmailSearchResults = new RelayCommand(async() => await DoEmail());
        }
 public OceneViewModel(Frame f)
     : base()
 {
     frame = f;
     // Trenutno je ugasena mogucnost azuriranja ocena, moze samo da se doda i da se brise
     UpdateItemCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() => { }, () => false);
     UpdateItemCommand.RaiseCanExecuteChanged();
 }
Example #5
0
 public VnMainViewModel()
 {
     LoadBindVnDataCommand     = new RelayCommand(LoadCategories);
     ClearCollectionsCommand   = new RelayCommand(ClearVnData);
     AddToCategoryCommand      = new RelayCommand <string>(AddToCategory);
     RemoveFromCategoryCommand = new RelayCommand <string>(RemoveFromCategory);
     LoadCategories();
 }
 public static ICommand Relay <T>(this ICommand command, Action <T> action)
 {
     if (command == null)
     {
         command = new GalaSoft.MvvmLight.Command.RelayCommand <T>(action);
     }
     return(command);
 }
Example #7
0
        public FileViewModel(string fileName, IPersistanceModel persistanceModel, ITagsModel tagsModel)
        {
            Name                           = fileName;
            _tagsModel                     = tagsModel;
            _persistanceModel              = persistanceModel;
            _persistanceModel.FileChanged += PersistanceModelOnFileChanged;

            AddTagCommand    = new GalaSoft.MvvmLight.Command.RelayCommand <TagViewModel>(ExecuteAddTagCommand);
            DeleteTagCommand = new RelayCommand <TagViewModel>(ExecuteDeleteTagCommand);
        }
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel()
 {
     DispatcherHelper.Initialize();
     DispatcherHelper.RunAsync(() =>
     {
         PopulateData();
         data = GetEmployeesDetails(1000000);
     });
     _loadCommand = new GalaSoft.MvvmLight.Command.RelayCommand(LoadData);
 }
 public SearchViewModel()
 {
     if (IsInDesignModeStatic)
     {
     }
     else
     {
         clickCommand = new GalaSoft.MvvmLight.Command.RelayCommand <string>(BtnClick);
     }
 }
Example #10
0
        public KKLabelGroup()
        {
            CopyToClipboardCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                //System.Windows.Clipboard.Clear();

                System.Windows.Clipboard.SetDataObject (PrintedText);

            });
        }
Example #11
0
 public CellViewModel()
 {
     ColumnsCount = 40;
     RowsCount    = 40;
     Board        = new ObservableCollection <Cell>();
     InitBoard();
     CellClickCommand       = new GalaSoft.MvvmLight.Command.RelayCommand <object>(CellClickMethod);
     NextBtnClickCommand    = new RelayCommand(NextBtnClickMethod);
     AnimateBtnClickCommand = new RelayCommand(AnimateBtnClickMethod);
     ClearBtnClickCommand   = new RelayCommand(ClearBoard);
 }
Example #12
0
        /// <summary>
        /// Constructor
        /// </summary>
        public SearchViewModel()
        {
            this.AllEntries = new ObservableCollection <FileEntry>();

            OpenFolderCommand   = new RelayCommand(OpenFolder);
            OpenBrowserCommand  = new RelayCommand(OpenBrowser);
            SearchCommand       = new RelayCommand(DoSearch);
            ModifyEntryCommand  = new RelayCommand(DoModifyEntry);
            SetDirectoryCommand = new RelayCommand(DoSetDirectory);
            ClearSearchCommand  = new RelayCommand(DoClearSearch);
        }
Example #13
0
 public BasketViewModel(NotesLogic notesLogic, BasketLogic basketLogic)
 {
     this.notesLogic  = notesLogic;
     this.basketLogic = basketLogic;
     DeleteNote       = new GalaSoft.MvvmLight.Command.RelayCommand <int>(Delete);
     RecoverNote      = new GalaSoft.MvvmLight.Command.RelayCommand <int>(Recover);
     EditAndViewNote  = new GalaSoft.MvvmLight.Command.RelayCommand <int>(EditAndView);
     dispatcher       = Dispatcher.CurrentDispatcher;
     TextSearch       = "";
     Notes            = new ObservableCollection <Basket>(this.basketLogic.Notes);
     Count            = Notes.Count;
 }
Example #14
0
        //constructors
        public AddinMainViewModel(EA.Repository Repository, IDialogService DialogService)
        {
            this.Repository    = Repository;
            this.DialogService = DialogService;

            AboutCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() => DialogService.ShowAboutDialog(new Model.MetadataModel.GoatAddinInformationModel()));

            EditAssociationCommand = new RelayCommandWithResult <EA.Connector, bool>(
                (connector) => { EditAssociation(connector, EditAssociationCommand); },
                (connector) => { return(connector.MetaType == "Association" || connector.MetaType == "Aggregation"); }
                );
        }
 public ViewModelMain(IDialogService dialogService)
 {
     this.dialogService = dialogService;
     Image                  = new Image();
     Images                 = new ObservableCollection <Image>();
     dataProvider           = new DataProvider();
     BrowseFolderCommand    = new GalaSoft.MvvmLight.Command.RelayCommand(BrowseFolder);
     OpenFileCommand        = new GalaSoft.MvvmLight.Command.RelayCommand(OpenFile);
     setImages              = new RelayCommand(setImagesExecutable);
     SortBySize             = new RelayCommand(sortBySizeExecutable);
     SetSortOption          = new RelayCommand(setExecutableSortoption);
     SortByName             = new RelayCommand(sortByNameExecutable);
     SortByCreationDate     = new RelayCommand(sortByCreationDateExecutable);
     SortByModificationDate = new RelayCommand(sortByModifiactionDateExecutable);
 }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService)
        {
            _dataService = dataService;
            _dataService.GetData(
                (item, error) =>
            {
                if (error != null)
                {
                    // Report error here
                    return;
                }

                WelcomeTitle = item.Title;
            });

            CompareCommand = new RelayCommand(Compare, () =>
            {
                if (string.IsNullOrEmpty(File1Path) || string.IsNullOrEmpty(File2Path))
                {
                    return(false);
                }
                return(true);
            });
            BrowseJsonFilePathCommand = new GalaSoft.MvvmLight.Command.RelayCommand <FileRequestChoiceEnum>((en) => Messenger.Default.Send(new ShowOpenFileDialogMessage(en)));

            Messenger.Default.Register <FilePathChangeRequestedMessage>(this, (msg) =>
            {
                switch (msg.RequestChoice)
                {
                case FileRequestChoiceEnum.File1:
                    File1Path = msg.FileName;
                    break;

                case FileRequestChoiceEnum.File2:
                    File2Path = msg.FileName;
                    break;

                case FileRequestChoiceEnum.SaveRules:
                    break;

                case FileRequestChoiceEnum.LoadRules:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            });
        }
 public CoordinateValueViewModel()
 {
     RespectToWindow            = new RespectToWindowModel();
     TriangleCoordinate         = new TriangleCoordinateModel();
     LineCoordinate             = new LineCoordinateModel();
     KeyDownCommand             = new RelayCommand(OnKeyDownCommandExecuted);
     MouseLeftButtonDownCommand = new RelayCommand <MouseEventArgs>(OnLeftMouseDownCommandExecuted);
     MouseLeftButtonUpCommand   = new RelayCommand <MouseEventArgs>(OnLeftMouseUpCommandExecuted);
     MouseMoveCommand           = new RelayCommand <MouseEventArgs>(OnMouseMoveCommandExecuted);
     MinWindowCommand           = new RelayCommand(OnMinWindowCommandExecute);
     MaximizeOrRestoreCommand   = new RelayCommand(OnMaximizeOrRestoreCommandExecute);
     CloseCommand = new RelayCommand(OnCloseCommand);
     CreateHorizontalRulerListCommand = new RelayCommand <string>(OnCreateHorizontalRulerListExecuted);
     HorizontalSizeChangedCommand     = new RelayCommand <string>(OnHorizontalSizeChangedCommandExecute);
     CreateVerticalRulerListCommand   = new RelayCommand <string>(OnCreateVerticalRulerListExecuted);
     VerticalSizeChangedCommand       = new RelayCommand <string>(OnVerticalSizeChangedCommandExecute);
 }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}

            BindingOperations.EnableCollectionSynchronization(sources, lockObject);
            BindingOperations.EnableCollectionSynchronization(books, booksLockObject);

            CrawlCommand = new GalaSoft.MvvmLight.Command.RelayCommand(Crawl);
            StopCrawlingCommand = new GalaSoft.MvvmLight.Command.RelayCommand(StopCrawling);
        }
Example #19
0
 public MainViewModel(IConfiguration configuration,
                      IMediaService mediaService,
                      IMediaCollection collection,
                      IFileService fileService,
                      Func <IProgressNotifier> progresssNotifierFactory,
                      IMediaFileManager mediaFileManager)
 {
     this.mediaFileManager     = mediaFileManager;
     this._mediaService        = mediaService;
     Collection                = collection;
     Configuration             = configuration;
     _fileService              = fileService;
     _progresssNotifierFactory = progresssNotifierFactory;
     SelectAllCommand          = new RelayCommand(ExecuteSelectAll);
     SelectNoneCommand         = new RelayCommand(ExecuteSelectNone);
     ExecuteCommand            = new RelayCommand(Execute, CanExecute);
     CancelCommand             = new RelayCommand(ExecuteCancel, CanExecuteCancel);
     BrowseSourceCommand       = new RelayCommand(ExecuteBrowseSourcePath);
     BrowseTargetCommand       = new RelayCommand(ExecuteBrowseTargetPath);
     OpenDirectoryCommand      = new RelayCommand <IMediaFile>(OnOpenFileDirectory);
 }
 public TiledWindowViewModel()
 {
     DoubleClickCommand = new Methods.RelayCommand(DoubleClickExecute, DoubleClickCanExecute);
     RemoveImageCommand = new Methods.RelayCommand(RemoveImageExecute, RemoveImageCanExecute);
     DragCommand        = new Methods.RelayCommand(x => ListBeingDragged = (ObservableCollection <Image>)x);
     DropCommand        = new Methods.RelayCommand(MergeListsExecute);
     DragEnterCommand   = new GalaSoft.MvvmLight.Command.RelayCommand <System.Windows.DragEventArgs>(FileDragFromWindows);
     ImageList          = new ObservableCollection <ObservableCollection <Image> >();
     ImageSaver.SendTheLoadedImages(ImageList);
     _aggregator.GetEvent <ClearEvent>().Subscribe(Clear);
     _aggregator.GetEvent <FileDialogEvent>().Subscribe(item =>
     {
         App.Current.Dispatcher.Invoke(new Action(() =>
         {
             ObservableCollection <ObservableCollection <Image> > list = new ObservableCollection <ObservableCollection <Image> >();
             foreach (var image in ImageList)
             {
                 list.Add(image);
             }
             foreach (var image in item)
             {
                 if (!list.Contains(image))
                 {
                     list.Add(image);
                 }
             }
             ImageList = list;
             SynchronizeImageExplorer();
         }));
     });
     _aggregator.GetEvent <SendImage>().Subscribe(item =>
     {
         if (ImageList.Contains(item) == false)
         {
             ImageList.Add(item);
         }
     });
 }
        private void InitRelayCommands()
        {
            ResetCommand = new RelayCommand(() =>
            {
                if (this.KinectSensor == null)
                {
                    StatusMessage = Properties.Resources.ConnectDeviceFirst;
                    return;
                }

                // reset the reconstruction and update the status text
                ResetFusion();
                StatusMessage = Properties.Resources.ResetReconstruction;
            });

            ExportCommand = new RelayCommand(() =>
            {
                if (FusionManager != null)
                {
                    FusionManager.ExportMesh();
                }
            });
        }
Example #22
0
        public ActionMenuViewModel(INavigationService navigationService)
        {
            RegisterMessages();

            string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string path       = (System.IO.Path.GetDirectoryName(executable));

            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            this.navigationService = navigationService;

            AddActionCommand    = new RelayCommand(NewAction);
            EditActionCommand   = new RelayCommand(EditAction);
            RemoveActionCommand = new RelayCommand(RemoveAction);


            windowType  = TypeOfWindow.Actions;
            windowTitle = Helpers.GetDescription(windowType);

            GetActionTypes();
            using (con)
            {
                try
                {
                    con.Open();
                    LoadActions();
                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Błąd połączenia z bazą");
                }
            }

            selectedAction = Actions.ElementAt(0);
        }
 public ReportReasonInputViewModel(ThingData thingData) :
     base("reason for the report", "", Enumerable.Empty<string>(), null)
 {
     _thingData = thingData;
     Dismissed = new GalaSoft.MvvmLight.Command.RelayCommand<string>(OnDismissed);
 }
Example #24
0
        public ImagePresenterViewModel(ObservableCollection <Image> image, int viewModelID, Tools tool, int maxWindows)
        {
            switch (tool)
            {
            case Tools.None:
                break;

            case Tools.RegionSelection:
                Tool = new CreateRegion();
                break;

            case Tools.PixelInformations:
                Tool = new PixelPicker();
                break;

            case Tools.RegionTransformation:
                break;

            case Tools.ImagePan:
                Tool = new PanImage();
                break;

            case Tools.Rotate:
                Tool = new Rotate();
                break;

            default:
                break;
            }
            ViewModelID    = viewModelID;
            MaxWindows     = maxWindows;
            _imageList     = new ObservableCollection <Image>();
            _imageList     = image;
            ImageIndex     = 0;
            DisplayedImage = _imageList[_imageIndex];
            IsSynchronized = true;
            Scale          = 1;
            SubscriptionToken token;

            token = _aggregator.GetEvent <SerializeOutputEvent>().Subscribe(SerializeOutputFromPresenters);
            _subscriptionTokens.Add(typeof(SerializeOutputEvent), token);
            token = _aggregator.GetEvent <RotateImageEvent>().Subscribe(RotateImage);
            _subscriptionTokens.Add(typeof(RotateImageEvent), token);
            token = _aggregator.GetEvent <SynchronizationEvent>().Subscribe(i =>
            {
                if (ViewModelID == i)
                {
                    IsSynchronized = !IsSynchronized;
                }
            });
            _subscriptionTokens.Add(typeof(SynchronizationEvent), token);
            token = _aggregator.GetEvent <SendDisplayedImage>().Subscribe(item =>
            {
                if ((item.PresenterID == ViewModelID || (item.DoReset == true && item.IsSynchronized && IsSynchronized)) && item.Image != null)
                {
                    ImagePosition = item.Image.Position;
                }
                else if (item.IsSynchronized == true && IsSynchronized && item.DoReset == false)
                {
                    ImagePosition = new Thickness(ImagePosition.Left + item.OffsetX, ImagePosition.Top + item.OffsetY, -(ImagePosition.Left + item.OffsetX), -(ImagePosition.Top + item.OffsetY));
                }
                if (item.DoProcessing)
                {
                    CalculateRegionProperties();
                }
            });
            _subscriptionTokens.Add(typeof(SendDisplayedImage), token);
            token = _aggregator.GetEvent <SendToolEvent>().Subscribe(item =>
            {
                Tool = item;
            });
            _subscriptionTokens.Add(typeof(SendToolEvent), token);
            token = _aggregator.GetEvent <SendRegionNameEvent>().Subscribe(SaveRegion);
            _subscriptionTokens.Add(typeof(SendRegionNameEvent), token);
            token = _aggregator.GetEvent <LoadRegionEvent>().Subscribe(region =>
            {
                if (region.PresenterID > MaxWindows)
                {
                    region.PresenterID = DisplayImageWindowViewModel.ImageCounter;
                }
                if (region.PresenterID != ViewModelID)
                {
                    return;
                }

                if (_imageList != region.ImageList)
                {
                    _imageList = region.ImageList;
                }
                DisplayedImage = region.ImageList.First(x => x == region.AttachedImage);
                RegionLocation = new Thickness(region.Position.X * 96.0 / region.DpiX, region.Position.Y * 96.0 / region.DpiY, 0, 0);
                RegionWidth    = (int)(region.Size.Width * 96.0 / region.DpiX);
                RegionHeight   = (int)(region.Size.Height * 96.0 / region.DpiY);
                ImageIndex     = region.ImageIndex;
                Scale          = region.Zoom;
                ImagePosition  = region.ImagePosition;
                if (IsSynchronized)
                {
                    SynchronizeRegions sr = new SynchronizeRegions();
                    sr.PresenterID        = ViewModelID;
                    sr.Position           = RegionLocation;
                    sr.Width        = RegionWidth;
                    sr.Height       = RegionHeight;
                    sr.DoProcessing = true;
                    sr.Zoom         = Scale;
                    _aggregator.GetEvent <SynchronizeRegions>().Publish(sr);
                }
                CalculateRegionProperties();
            });
            _subscriptionTokens.Add(typeof(LoadRegionEvent), token);
            token = _aggregator.GetEvent <SendImageList>().Subscribe(item =>
            {
                try
                {
                    if (item.Count != 0)
                    {
                        if (!item.Any(x => x == _imageList))
                        {
                            _imageList     = item[0];
                            ImageIndex     = 0;
                            DisplayedImage = _imageList[0];
                        }
                    }
                    else
                    {
                        DisplayedImage = null;
                        _imageList     = null;
                    }
                }
                catch (Exception)
                {
                }
            });
            _subscriptionTokens.Add(typeof(SendImageList), token);
            token = _aggregator.GetEvent <ResetRegionsEvent>().Subscribe(() =>
            {
                RegionHeight   = 0;
                RegionWidth    = 0;
                RegionLocation = new Thickness(0, 0, 0, 0);
            });
            _subscriptionTokens.Add(typeof(ResetRegionsEvent), token);

            ImageClickCommand = new GalaSoft.MvvmLight.Command.RelayCommand <RoutedEventArgs>(ImageClickExecute);
            LeftArrowCommand  = new RelayCommand(PreviousImage);
            RightArrowCommand = new RelayCommand(NextImage);
            SaveRegionCommand = new RelayCommand(OpenSaveRegionWindow);
            SerializeOutputFromListCommand = new RelayCommand(SerializeOutputFromList);
            EscapeCommand            = new RelayCommand(EscapeClicked);
            SelectAllCommand         = new RelayCommand(SelectAll);
            ResetPositionCommand     = new RelayCommand(ResetPosition);
            ResetZoomCommand         = new RelayCommand(ResetZoom);
            MouseLeftClickCommand    = new GalaSoft.MvvmLight.Command.RelayCommand <RoutedEventArgs>(MouseLeftClick);
            MouseMoveCommand         = new GalaSoft.MvvmLight.Command.RelayCommand <RoutedEventArgs>(MouseMove);
            MouseOverCommand         = new GalaSoft.MvvmLight.Command.RelayCommand <RoutedEventArgs>(MouseEnter);
            MouseWheelCommand        = new GalaSoft.MvvmLight.Command.RelayCommand <MouseWheelEventArgs>(MouseWheel);
            Filter_BrightnessCommand = new RelayCommand(FilterChoose);
            Filter_ContrastCommand   = new RelayCommand(FilterChoose);
            Filter_GreyScaleCommand  = new RelayCommand(FilterChoose);
            Filter_NegativeCommand   = new RelayCommand(FilterChoose);
            Filter_SepiaCommand      = new RelayCommand(FilterChoose);
            Filter_ResetCommand      = new RelayCommand(FilterChoose);
        }
        /// <summary>
        /// Initializes a new instance of the TournamentViewModel class.
        /// </summary>
        public TournamentViewModel()
        {
            PrinterSettings.InstalledPrinters.Cast <string>();
            _RoundsCount           = 3;
            _QuestionsPerRound     = 12;
            OpenSpreadsheetCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                try
                {
                    var dlg             = new SaveFileDialog();
                    dlg.FileName        = "tournament.ods";
                    dlg.AddExtension    = true;
                    dlg.DefaultExt      = "*.ods";
                    dlg.CheckFileExists = false;
                    dlg.Filter          = "OpenOffice Calc Spreadsheet|*.ods";
                    if (dlg.ShowDialog().Value)
                    {
                        var fileData = Properties.Resources.tournamentFinal;
                        var path     = dlg.FileName;
                        File.WriteAllBytes(path, fileData);
                    }
                }
                catch (Exception ex)
                {
                    ShowError("Не удалось сохранить файл. " + ex.ToString());
                }
            });
            PrintCommand = new GalaSoft.MvvmLight.Command.RelayCommand(() =>
            {
                IsProcessing = true;
                ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
                {
                    try
                    {
                        QuestionForms = new List <AnswersCollection>();

                        if (GroupByQuestion)
                        {
                            QuestionForms =
                                AnswersCollection.BuildGroupedByQuestion(TeamsRangeBegin, TeamsRangeEnd, RoundsCount, QuestionsPerRound, ItemHeaderTemplate);
                        }
                        else
                        {
                            var width  = UseSize_4x9 ? 4 : 3;
                            var height = UseSize_4x9 ? 9 : 5;

                            if (GroupForCutter)
                            {
                                QuestionForms =
                                    AnswersCollection.BuildGroupedByTeamForCutter(TeamsRangeBegin, TeamsRangeEnd, RoundsCount, QuestionsPerRound, ItemHeaderTemplate,
                                                                                  width, height);
                            }
                            else
                            {
                                for (int teamId = TeamsRangeBegin; teamId <= TeamsRangeEnd; teamId++)
                                {
                                    QuestionForms.Add(
                                        AnswersCollection.BuildGroupedByTeam(teamId, RoundsCount, QuestionsPerRound, ItemHeaderTemplate));
                                }
                            }
                        }


                        using (var printDocument1 = new System.Drawing.Printing.PrintDocument())
                        {
                            printDocument1.PrinterSettings.PrinterName = TargetPrinter;
                            printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
                            printDocument1.Print();
                        }
                        IsProcessing = false;
                    }
                    catch (Exception ex)
                    {
                        ShowError("Не удалось напечатать документ. " + ex.ToString());
                    }
                }));
            }, () => !IsProcessing);
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
            }
        }
Example #26
0
 public UMCMainViewMode()
 {
     if (IsInDesignModeStatic)
     {
         Title            = "扯淡云(并没有)音乐";
         CreateFaviourtes = "CreateFaviourtes";
         Img_Singer       = "1";
         ReSizeBtn        = "Category";
         Portrait         = "Portrait";
         UserName         = "******";
         Message          = "Message";
         Setting          = "Setting";
         //
         Cloud            = "Cloud";
         CreateFaviourtes = "CreateFaviourtes";
         Downloads        = "Downloads";
         Faviourtes       = "Faviourtes";
         Friends          = "Friends";
         Like             = "LikeRed";
         LocalMusic       = "LocalMusic";
         Music            = "Music";
         MusicList        = "MusicList";
         Radio            = "Radio";
         Recent           = "Recent";
         Search           = "Search";
         MV = "MV";
         //
         Previous = "Previous";
         Play     = "Play";
         Next     = "Next";
         //
         StaticButtons = new ObservableCollection <ButtonContent>();
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Search", ButtonContent_Text = "搜索", FuncKey = "1"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Music", ButtonContent_Text = "发现音乐", FuncKey = "2"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "MV", ButtonContent_Text = "MV", FuncKey = "3"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Friends", ButtonContent_Text = "朋友", FuncKey = "4"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Friends", ButtonContent_Text = "朋友", FuncKey = "4"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Friends", ButtonContent_Text = "朋友", FuncKey = "4"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Friends", ButtonContent_Text = "朋友", FuncKey = "4"
         });
         //
         SongName           = "伤不起";
         SingerName         = "王玲";
         PlayingCurrentTime = "00:00";
         PlayingTotalTime   = "03:49";
         //
         PlayMethod = "PlaySingleCycle";
         Volume     = "Volume";
         PlayList   = "PlayList";
     }
     else
     {
         //可以考虑放到xml文档里(反正就是配置文档)
         Title            = "扯淡云(并没有)音乐";
         CreateFaviourtes = "CreateFaviourtes";
         Img_Singer       = "1";
         ReSizeBtn        = "Category";
         Portrait         = "Portrait";
         UserName         = "******";
         Message          = "Message";
         Setting          = "Setting";
         Previous         = "Previous";
         Play             = "Play";
         Next             = "Next";
         PlayMethod       = "PlaySingleCycle";
         Volume           = "Volume";
         Like             = "LikeRed";
         PlayList         = "PlayList";
         StaticButtons    = new ObservableCollection <ButtonContent>();
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Search", ButtonContent_Text = "搜索", FuncKey = "1"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Music", ButtonContent_Text = "发现音乐", FuncKey = "2"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "MV", ButtonContent_Text = "MV", FuncKey = "3"
         });
         StaticButtons.Add(new ButtonContent()
         {
             ButtonContent_Img = "Friends", ButtonContent_Text = "朋友", FuncKey = "4"
         });
         titleButton_Click = new GalaSoft.MvvmLight.Command.RelayCommand <string>(TitleButtonFunc);
         listButton_Click  = new GalaSoft.MvvmLight.Command.RelayCommand <string>(ListButtonFunc);
         previousSong      = new GalaSoft.MvvmLight.Command.RelayCommand(PreviousSongFunc);
         playSong          = new GalaSoft.MvvmLight.Command.RelayCommand(PlaySongFunc);
         nextSong          = new GalaSoft.MvvmLight.Command.RelayCommand(NextSongFunc);
         wo = new NAudio.Wave.WaveOut(NAudio.Wave.WaveCallbackInfo.FunctionCallback());
         wo.PlaybackStopped += PlaybackStopped;
         songList            = playEntity.Traversal();
         getCurrrentTime_th  = new Thread(() =>
         {
             while (!Cancel)
             {
                 PlayingCurrentTime = mp3FileReader.CurrentTime.ToString().Substring(0, 8);
                 Thread.Sleep(500);
             }
         });
     }
 }
        public SchemeViewModel()
        {
            #region 初始化方案

            using (var db = new HomeAutomationEntities())
            {
                Schemes = db.t_Scheme.ToList();
            }
            if (Schemes.Count > 0)
            {
                Scheme     = Schemes[0];
                SchemeName = Schemes[0].SchemeName;
            }

            #endregion

            #region 初始化详细方案//test

            RefreshDetailScheme();

            #endregion

            #region 初始化电器

            using (var db = new HomeAutomationEntities())
            {
                HomeAppliances = db.t_HomeAppliances.ToList();
            }

            #endregion

            #region 新建方案

            CreateSchemeCommand = new RelayCommand(() =>
            {
                if (SchemeState)
                {
                    UMessageBox.Show($"请先停止方案!", false);
                    return;
                }
                if (SchemeNameEidtState)
                {
                    return;
                }
                using (var db = new HomeAutomationEntities())
                {
                    var count = db.t_Scheme.ToList().Count;
                    db.t_Scheme.Add(new t_Scheme()
                    {
                        SchemeName = $"方案{++count}"
                    });
                    db.SaveChanges();
                    Schemes       = db.t_Scheme.ToList();
                    Scheme        = Schemes.Find(x => x.SchemeName == $"方案{count}");
                    DetailSchemes = new ObservableCollection <DetailSchemeModel>();
                }
            });

            #endregion

            #region  除方案

            DeleteSchemeCommand = new RelayCommand(() =>
            {
                if (SchemeState)
                {
                    UMessageBox.Show($"请先停止方案!", false);
                    return;
                }
                if (SchemeNameEidtState)
                {
                    return;
                }
                var result = UMessageBox.Show("确定删除当前方案吗?");
                if (result == false)
                {
                    return;
                }
                using (var db = new HomeAutomationEntities())
                {
                    if (Scheme == null)
                    {
                        return;
                    }
                    var scheme = db.t_Scheme.FirstOrDefault(x => x.Id == Scheme.Id);
                    if (scheme != null)
                    {
                        db.t_Scheme.Remove(scheme);
                    }
                    var detailScheme = db.t_DetailScheme.Where(x => x.SchemeId == Scheme.Id);
                    db.t_DetailScheme.RemoveRange(detailScheme);
                    db.SaveChanges();
                    Schemes = db.t_Scheme.ToList();
                    if (Schemes.Count <= 0)
                    {
                        return;
                    }
                    Scheme     = Schemes[0];
                    SchemeName = Schemes[0].SchemeName;
                }
            });


            #endregion

            #region 刷新方案列表命令

            HomeApplianceScheme = new RelayCommand(() =>
            {
                if (SchemeNameEidtState)
                {
                    return;
                }
                RefreshDetailScheme();
            });

            #endregion

            #region 方案定时开关 (开关定时任务)

            StartSchemeCommand = new RelayCommand((() =>
            {
                if (!UMessageBox.Result)
                {
                    return;
                }
                //是否选择方案,执行方案是否为空
                if (Scheme == null)
                {
                    UMessageBox.Show($"当前没有选中方案!", false);
                    return;
                }
                //是否正在编辑方案
                if (SchemeNameEidtState)
                {
                    return;
                }
                //定时方案停止
                if (SchemeState)
                {
                    //
                    //等待提示框

                    //强制关闭所有电器
                    //var driver =new Rs485Driver();
                    //try
                    //{
                    //    driver.Connect(new NetArg("192.168.0.233", 10001));
                    //}
                    //catch (Exception e)
                    //{
                    //    MessageBox.Show($"连接不上设备", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    //    return;
                    //}
                    //var state=  driver.Read32RelayOutputState();
                    //foreach (var value in state)
                    //{
                    //    if (value.Value==true)
                    //    {
                    //        ControllerHomeAutomation(value.Key, false);
                    //    }
                    //}

                    foreach (var value in DetailSchemes)
                    {
                        value.RunSchemeState = false;
                        value.SchemevisibiState = "Hidden";
                        value.Cancel.Cancel();
                    }
                    SchemeState = false;
                    SchemeList = true;
                }
                //定时方案启动
                else
                {
                    SchemeState = true;
                    SchemeList = false;
                    foreach (var value in DetailSchemes)
                    {
                        value.Cancel = new CancellationTokenSource();
                        value.Task = new Task(() =>
                        {
                            //等待开始
                            var waitTime = 0;
                            while (waitTime < value.DtailScheme.WaitTime)
                            {
                                try
                                {
                                    value.Cancel.Token.ThrowIfCancellationRequested();
                                }
                                catch (Exception e)
                                {
                                    value.RunSchemeState = false;
                                    value.SchemevisibiState = "Hidden";
                                    return;
                                }
                                waitTime++;
                                Thread.Sleep(1000);
                            }

                            value.RunSchemeState = true;
                            value.SchemevisibiState = "Visible";
                            //启动电器
                            //try
                            //{
                            //
                            //    AsyncControllerHomeAutomation(value.DtailScheme.HomeAppliancesId, true);
                            //}
                            //catch (Exception e)
                            //{
                            //    MessageBox.Show($"连接不上设备", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                            //    value.RunSchemeState = false;
                            //    value.SchemevisibiState = "Hidden";
                            //    return;
                            //}
                            //执行时长
                            var runTime = 0;

                            //等待结束
                            while (runTime < value.DtailScheme.RunTime)
                            {
                                var timeSpan = new TimeSpan(0, 0, value.DtailScheme.RunTime - runTime - 1);
                                value.SchemeTime = timeSpan.Hours.ToString() + " h " + timeSpan.Minutes + " m " +
                                                   timeSpan.Seconds + " s";
                                try
                                {
                                    value.Cancel.Token.ThrowIfCancellationRequested();
                                }
                                catch (Exception e)
                                {
                                    value.RunSchemeState = false;
                                    value.SchemevisibiState = "Hidden";
                                    return;
                                }
                                runTime++;
                                Thread.Sleep(1000);
                            }
                            //关闭电器
                            //try
                            //{

                            //    AsyncControllerHomeAutomation(value.DtailScheme.HomeAppliancesId, false);
                            //}
                            //catch (Exception e)
                            //{
                            //    MessageBox.Show($"连接不上设备", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                            //}
                            value.RunSchemeState = false;
                        }, value.Cancel.Token);
                        value.Task.Start();
                    }
                }
            }));

            #endregion

            #region 添加 定时命令

            AddSchemeCommand = new RelayCommand(() =>
            {
                if (DetailSchemes.FirstOrDefault(x => x.DtailScheme.HomeAppliancesName == "选择电器") != null)
                {
                    //提示选择电器
                    UMessageBox.Show($"请选择电器!", false);
                    return;
                }
                using (var db = new HomeAutomationEntities())
                {
                    //遍历详细方案
                    for (var i = 0; i < DetailSchemes.Count; i++)
                    {
                        if (DetailSchemes[i].DtailScheme.WaitTime < 0 || DetailSchemes[i].DtailScheme.RunTime <= 0)
                        {
                            UMessageBox.Show($"{DetailSchemes[i].DtailScheme.HomeAppliancesName} 时间运行太短!", false);
                            return;
                        }
                        //id= 100表示没有选中
                        if (DetailSchemes[i] == null || DetailSchemes[i].DtailScheme.HomeAppliancesId == 100)
                        {
                            continue;
                        }
                        //判断时间重复
                        for (var j = 0; j < i; j++)
                        {
                            //根据电器名称相同,断定同一电器
                            if (DetailSchemes[i].DtailScheme.HomeAppliancesName !=
                                DetailSchemes[j].DtailScheme.HomeAppliancesName)
                            {
                            }
                            //判断同一电器启动,一分钟间隔以上
                            else if (DetailSchemes[i].DtailScheme.WaitTime >
                                     (DetailSchemes[j].DtailScheme.RunTime +
                                      DetailSchemes[j].DtailScheme.WaitTime) + 60 ||
                                     DetailSchemes[i].DtailScheme.RunTime + DetailSchemes[i].DtailScheme.WaitTime + 60 <
                                     DetailSchemes[j].DtailScheme.WaitTime)
                            {
                            }
                            else
                            {
                                UMessageBox.Show($"{DetailSchemes[i].DtailScheme.HomeAppliancesName} 运行时间冲突或者间隔太近!", false);
                                return;
                            }
                        }
                        var detail        = DetailSchemes[i];
                        var homeAppliance =
                            db.t_HomeAppliances.FirstOrDefault(
                                x => x.Name == detail.DtailScheme.HomeAppliancesName);
                        if (homeAppliance != null)
                        {
                            db.t_DetailScheme.AddOrUpdate(new t_DetailScheme()
                            {
                                Id = DetailSchemes[i].DtailScheme.DetailSchemeId,
                                HomeAppliancesId = homeAppliance.Id,
                                RunTime          = DetailSchemes[i].DtailScheme.RunTime,
                                WaitTime         = DetailSchemes[i].DtailScheme.WaitTime,
                                SchemeId         = DetailSchemes[i].DtailScheme.SchemeId
                            });
                        }
                    }
                    db.SaveChanges();
                    Schemes = db.t_Scheme.ToList();
                    Scheme  = Schemes.FirstOrDefault(x => x.Id == SchemmeId);
                }
                RefreshDetailScheme();
                DetailSchemes.Add(new DetailSchemeModel()
                {
                    DtailScheme = new v_DtailScheme()
                    {
                        RunTime            = 0,
                        WaitTime           = 0,
                        SchemeId           = Scheme.Id,
                        HomeAppliancesName = "选择电器"
                    }
                });
            });

            #endregion

            #region 更新选中定时

            UpdataSchemeCommand = new RelayCommand <long>((detailSchemeId) =>
            {
                var detailscheme = DetailSchemes.FirstOrDefault(x => x.DtailScheme.DetailSchemeId == detailSchemeId);
                //id 100表示没有选中
                if (detailscheme == null || detailSchemeId == 100)
                {
                    return;
                }
                //判断时间重复

                using (var db = new HomeAutomationEntities())
                {
                    var homeAppliance =
                        db.t_HomeAppliances.FirstOrDefault(x => x.Name == detailscheme.DtailScheme.HomeAppliancesName);
                    var detailScheme =
                        db.t_DetailScheme.FirstOrDefault(x => x.Id == detailscheme.DtailScheme.DetailSchemeId);
                    if (detailScheme == null || homeAppliance == null)
                    {
                        return;
                    }
                    detailScheme.HomeAppliancesId = homeAppliance.Id;
                    detailScheme.RunTime          = detailscheme.DtailScheme.RunTime;
                    detailScheme.WaitTime         = detailscheme.DtailScheme.WaitTime;

                    db.SaveChanges();
                }
                RefreshDetailScheme();
            });

            #endregion

            #region  除选中定时命令

            DeleletChooseDetailScheme = new RelayCommand <long>(((detailSchemeId) =>
            {
                using (var db = new HomeAutomationEntities())
                {
                    //删除定时
                    var descheme = db.t_DetailScheme.FirstOrDefault(x => x.Id == detailSchemeId);
                    if (descheme != null)
                    {
                        db.t_DetailScheme.Remove(descheme);
                    }
                    db.SaveChanges();
                }
                DetailSchemes.Remove(DetailSchemes.FirstOrDefault(x => x.DtailScheme.DetailSchemeId == detailSchemeId));
            }));

            #endregion

            #region 编辑选中方案

            UpdataChooseDatailScheme = new RelayCommand((() =>
            {
                if (SchemeState)
                {
                    UMessageBox.Show($"请先停止方案!", false);
                    return;
                }
                if (SchemeName == null)
                {
                    return;
                }

                if (SchemeEidtState)
                {
                    SchemmeId = Scheme.Id;
                    SchemeEidtState = false;
                    ButtonNameSave = "完成";
                    SchemeAddState = "Visible";
                    SchemeNameEidtState = true;
                }
                else
                {
                    for (var i = DetailSchemes.Count() - 1; i >= 0; i--)
                    {
                        if (DetailSchemes[i].DtailScheme.HomeAppliancesName == "选择电器")
                        {
                            DetailSchemes.Remove(DetailSchemes[i]);
                        }
                    }
                    using (var db = new HomeAutomationEntities())
                    {
                        //更新方案名称
                        var scheme = db.t_Scheme.FirstOrDefault(x => x.Id == SchemmeId);
                        if (scheme != null)
                        {
                            scheme.SchemeName = SchemeName;
                        }



                        //遍历详细方案
                        for (var i = 0; i < DetailSchemes.Count; i++)
                        {
                            if (DetailSchemes[i].DtailScheme.WaitTime <= 0 || DetailSchemes[i].DtailScheme.RunTime <= 0)
                            {
                                UMessageBox.Show($"{DetailSchemes[i].DtailScheme.HomeAppliancesName} 时间运行太短!", false);
                                return;
                            }
                            //id= 100表示没有选中
                            if (DetailSchemes[i] == null || DetailSchemes[i].DtailScheme.HomeAppliancesId == 100)
                            {
                                continue;
                            }
                            //判断时间重复
                            for (var j = 0; j < i; j++)
                            {
                                //根据电器名称相同,断定同一电器
                                if (DetailSchemes[i].DtailScheme.HomeAppliancesName !=
                                    DetailSchemes[j].DtailScheme.HomeAppliancesName)
                                {
                                }
                                //判断同一电器启动,一分钟间隔以上
                                else if (DetailSchemes[i].DtailScheme.WaitTime >
                                         (DetailSchemes[j].DtailScheme.RunTime +
                                          DetailSchemes[j].DtailScheme.WaitTime) + 60 ||
                                         DetailSchemes[i].DtailScheme.RunTime + DetailSchemes[i].DtailScheme.WaitTime +
                                         60 <
                                         DetailSchemes[j].DtailScheme.WaitTime)
                                {
                                }
                                else
                                {
                                    UMessageBox.Show($"{DetailSchemes[i].DtailScheme.HomeAppliancesName} 时间冲突!", false);
                                    return;
                                }
                            }
                            var detail = DetailSchemes[i];
                            var homeAppliance =
                                db.t_HomeAppliances.FirstOrDefault(
                                    x => x.Name == detail.DtailScheme.HomeAppliancesName);
                            if (homeAppliance != null)
                            {
                                db.t_DetailScheme.AddOrUpdate(new t_DetailScheme()
                                {
                                    Id = DetailSchemes[i].DtailScheme.DetailSchemeId,
                                    HomeAppliancesId = homeAppliance.Id,
                                    RunTime = DetailSchemes[i].DtailScheme.RunTime,
                                    WaitTime = DetailSchemes[i].DtailScheme.WaitTime,
                                    SchemeId = DetailSchemes[i].DtailScheme.SchemeId
                                });
                            }
                        }
                        db.SaveChanges();
                        Schemes = db.t_Scheme.ToList();
                        Scheme = Schemes.FirstOrDefault(x => x.Id == SchemmeId);
                    }

                    RefreshDetailScheme();
                    SchemeEidtState = true;
                    ButtonNameSave = "方案编辑";
                    SchemeAddState = "Hidden";
                    SchemeNameEidtState = false;
                }
            }));

            #endregion

            #region 编辑运行时间

            InstallRunTimeCommand = new RelayCommand <long>(detailSchemeId =>
            {
                if (SchemeEidtState)
                {
                    return;
                }
                var detailScheme =
                    DetailSchemes.FirstOrDefault(x => x.DtailScheme.DetailSchemeId == detailSchemeId);
                if (detailScheme == null)
                {
                    return;
                }
                var result      = UTimePiker.ChooseEquals(detailScheme.DtailScheme.RunTime);
                var dtailScheme = new v_DtailScheme()
                {
                    DetailSchemeId     = detailSchemeId,
                    HomeAppliancesId   = detailScheme.DtailScheme.HomeAppliancesId,
                    HomeAppliancesName = detailScheme.DtailScheme.HomeAppliancesName,
                    RunTime            = result,
                    SchemeId           = detailScheme.DtailScheme.SchemeId,
                    SchemeName         = detailScheme.DtailScheme.SchemeName,
                    WaitTime           = detailScheme.DtailScheme.WaitTime
                };
                detailScheme.DtailScheme = dtailScheme;
            });

            #endregion
            #region 编辑等待时间

            InstallWaitTimeCommand = new RelayCommand <long>(detailSchemeId =>
            {
                if (SchemeEidtState)
                {
                    return;
                }
                var detailScheme =
                    DetailSchemes.FirstOrDefault(x => x.DtailScheme.DetailSchemeId == detailSchemeId);
                if (detailScheme == null)
                {
                    return;
                }
                var result      = UTimePiker.ChooseEquals(detailScheme.DtailScheme.WaitTime);
                var dtailScheme = new v_DtailScheme()
                {
                    DetailSchemeId     = detailSchemeId,
                    HomeAppliancesId   = detailScheme.DtailScheme.HomeAppliancesId,
                    HomeAppliancesName = detailScheme.DtailScheme.HomeAppliancesName,
                    RunTime            = detailScheme.DtailScheme.RunTime,
                    SchemeId           = detailScheme.DtailScheme.SchemeId,
                    SchemeName         = detailScheme.DtailScheme.SchemeName,
                    WaitTime           = result
                };
                detailScheme.DtailScheme = dtailScheme;
            });

            #endregion
        }
Example #28
0
 private void initCommand()
 {
     NavigateUserHomeCommand = new GalaSoft.MvvmLight.Command.RelayCommand(OnExecuteNavigateUserHomeCommand);
 }
Example #29
0
 private void initCommand()
 {
     UserHomeCommand = new GalaSoft.MvvmLight.Command.RelayCommand(OnExecuteUserHomeCommand);
     NewHouseCommand = new GalaSoft.MvvmLight.Command.RelayCommand(OnExecuteNewHouseCommand);
 }
Example #30
0
 public AttachmentViewModel(FeedbackViewModel vm)
 {
     ViewModel = vm;
     Delete    = new GalaSoft.MvvmLight.Command.RelayCommand(OnDelete);
 }
Example #31
0
        private void InitRelayCommands()
        {
            ResetCommand = new RelayCommand(() =>
            {
                if (this.KinectSensor == null)
                {
                    StatusMessage = Properties.Resources.ConnectDeviceFirst;
                    return;
                }

                // reset the reconstruction and update the status text
                ResetFusion();
                StatusMessage = Properties.Resources.ResetReconstruction;
            });

            ExportCommand = new RelayCommand(() =>
            {
                if (FusionManager != null)
                {
                    FusionManager.ExportMesh();
                }
            });
        }
Example #32
0
        public ItemFPSearchViewModel()
        {
            Client.AccWithConfigAndSizeCompleted += (s, sv) =>
            {
                bool isSearchItem    = false;
                var  itemSearchModel = SearchResultList.FirstOrDefault(i => i.ItemId == sv.Result.Iserial && i.ItemType == sv.Result.ItemGroup);
                CRUDManagerService.ItemsDto item;
                if (itemSearchModel != null)
                {
                    item         = itemSearchModel.ItemPerRow ?? (itemSearchModel.ItemPerRow = new CRUDManagerService.ItemsDto());
                    isSearchItem = true;
                }
                else
                {
                    item = ItemPerRow;
                }

                item.AccConfigList   = sv.Result.AccConfigList;
                item.SizesList       = new ObservableCollection <string>();
                item.CombinationList = sv.Result.CombinationList;

                var tblAccessoryAttributesDetails = sv.Result.CombinationList.FirstOrDefault();
                if (tblAccessoryAttributesDetails != null)
                {
                    item.SizesList.Add(tblAccessoryAttributesDetails.Size);
                }
                if (item.CombinationList != null)
                {
                    item.SizesList = new ObservableCollection <string>();
                }
                if (isSearchItem)
                {
                    if (item.AccConfigList == null)
                    {
                        item.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>();
                    }
                    itemSearchModel.ColorPerRow = item.AccConfigList.FirstOrDefault(c => c.Iserial == itemSearchModel.ColorToId);
                }
            };
            CancelCommand = new RelayCommand((o) => // هقفل وارجع فولس يعرف انه كنسل
            {
                var view = (o as ChildWindowsOverride);
                if (view != null)
                {
                    view.DialogResult = false;
                    view.Close();
                }
            });
            ApplyCommand = new RelayCommand((o) =>
            {
                var view = (o as ItemFPSearchChildWindow);
                if (view != null)
                {
                    //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية
                    ApplySelectedItem(view);
                }
            });
            OkCommand = new RelayCommand((o) =>
            {
                var view = (o as ItemFPSearchChildWindow);
                if (view != null)
                {
                    //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية لو مكانش راح
                    //وهقفل الشاشة فى الاخر
                    try
                    {
                        var item = view.DataContext as ItemFPSearchViewModel;
                        ItemDimensionFPSearchViewModel newSearchData = new ItemDimensionFPSearchViewModel();
                        newSearchData.ItemPerRow  = item.ItemPerRow;
                        newSearchData.ColorPerRow = item.ColorPerRow;
                        item.FPAppliedSearchResultList.Add(newSearchData);
                        view.DialogResult = true;
                        view.Close();
                    } catch { }
                }
            });
            LoadingRow = new GalaSoft.MvvmLight.Command.RelayCommand <object>((o) =>
            {
                //var e = o as System.Windows.Controls.DataGridRowEventArgs;
                //if (SearchResultList.Count < PageSize)
                //{
                //    return;
                //}
                //if (SearchResultList.Count - 2 < e.Row.GetIndex() && !Loading)
                //{
                //    GetInspectionWarehouseRows();
                //}
            });
        }
        public ItemDimensionSearchViewModel()
        {
            Client.AccWithConfigAndSizeCompleted += (s, sv) =>
            {
                bool isSearchItem    = false;
                var  itemSearchModel = SearchResultList.FirstOrDefault(i => i.ItemId == sv.Result.Iserial && i.ItemType == sv.Result.ItemGroup);
                CRUDManagerService.ItemsDto item;
                if (itemSearchModel != null)
                {
                    item         = itemSearchModel.ItemPerRow ?? (itemSearchModel.ItemPerRow = new CRUDManagerService.ItemsDto());
                    isSearchItem = true;
                }
                else
                {
                    item = ItemPerRow;
                }

                item.AccConfigList   = sv.Result.AccConfigList;
                item.SizesList       = new ObservableCollection <string>();
                item.CombinationList = sv.Result.CombinationList;

                var tblAccessoryAttributesDetails = sv.Result.CombinationList.FirstOrDefault();
                if (tblAccessoryAttributesDetails != null)
                {
                    item.SizesList.Add(tblAccessoryAttributesDetails.Size);
                }
                if (item.CombinationList != null)
                {
                    item.SizesList = new ObservableCollection <string>();
                }
                if (isSearchItem)
                {
                    if (item.AccConfigList == null)
                    {
                        item.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>();
                    }
                    itemSearchModel.ColorPerRow = item.AccConfigList.FirstOrDefault(c => c.Iserial == itemSearchModel.ColorToId);
                }
            };
            Client.InspectionRouteCompleted += (o, e) =>
            {
                foreach (var batchNo in e.Result.Select(x => x.RollBatch))
                {
                    if (!BatchNoList.Contains(batchNo))
                    {
                        BatchNoList.Add(batchNo);
                    }
                }
            };
            // Client.SearchF
            WarehouseClient.GetAccWarehouseRowsCompleted += (s, e) =>
            {
                if (e.Result.Count <= 0)
                {
                    MessageBox.Show(strings.NoDataFound);
                }
                foreach (var iR in e.Result)
                {
                    // هشوف لو موجود مش هحطه
                    if (!SearchResultList.Any(sr => sr.ItemDimFromIserial == iR.ItemDimFromIserial))
                    {
                        var qtemp = iR.AvailableQuantity;
                        iR.AvailableQuantity = 0;
                        // iR.CountedQuantity = 0;
                        iR.AvailableQuantity = qtemp;
                        if (iR.PendingQuantity > 0)
                        {
                            iR.TransferredQuantity = iR.AvailableQuantity;
                        }
                        else
                        {
                            iR.TransferredQuantity = iR.AvailableQuantity + iR.PendingQuantity;
                        }
                        ItemDimensionSearchModel item = new ItemDimensionSearchModel();
                        item.InjectFrom(iR);
                        if (item.ItemPerRow == null)
                        {
                            item.ItemPerRow = new CRUDManagerService.ItemsDto();
                        }
                        if (ItemPerRow.Iserial > 0)
                        {
                            item.ItemPerRow.InjectFrom(ItemPerRow);
                        }
                        //else
                        //    Client.AccWithConfigAndSizeAsync(new CRUDManagerService.ItemsDto()
                        //    {
                        //        Iserial = item.ItemId,
                        //        ItemGroup = item.ItemType,
                        //        Code=item.ItemCode,
                        //    });
                        if (item.ItemPerRow.AccConfigList == null)
                        {
                            item.ItemPerRow.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>();
                        }
                        var colorRow = item.ItemPerRow.AccConfigList.FirstOrDefault(c => c.Iserial == iR.ColorPerRow.Iserial);
                        if (colorRow == null)
                        {
                            colorRow = new CRUDManagerService.TblColor()
                            {
                                Iserial = item.ColorFromId,
                                Code    = item.ColorFromCode
                            };
                        }
                        item.ColorPerRow = colorRow;

                        SearchResultList.Add(item);
                    }
                }
                Loading = false;
            };
            WarehouseClient.GetItemDimensionsOrCreteForTransferCompleted += (s, e) =>
            {
                SelectedSearchResultList.Clear();
                foreach (var item in e.Result)
                {
                    ItemDimensionSearchModel temp = new ItemDimensionSearchModel();
                    temp.InjectFrom(item);
                    temp.ItemPerRow = ItemPerRow;
                    temp.ColorPerRow.InjectFrom(item.ColorPerRow);
                    SelectedSearchResultList.Add(temp);
                }
                IsWorking = false;
            };
            CancelCommand = new RelayCommand((o) => // هقفل وارجع فولس يعرف انه كنسل
            {
                var view = (o as ChildWindowsOverride);
                if (view != null)
                {
                    view.DialogResult = false;
                    view.Close();
                }
            });
            ApplyCommand = new RelayCommand((o) =>
            {
                var view = (o as ItemDimensionSearchChildWindow);
                if (view != null)
                {
                    //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية
                    ApplySelectedItem(view);
                }
            });
            OkCommand = new RelayCommand((o) =>
            {
                var view = (o as ItemDimensionSearchChildWindow);
                if (view != null)
                {
                    //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية لو مكانش راح
                    //وهقفل الشاشة فى الاخر
                    ApplySelectedItem(view);
                    view.DialogResult = true;
                    view.Close();
                }
            });
            LoadingRow = new GalaSoft.MvvmLight.Command.RelayCommand <object>((o) =>
            {
                var e = o as System.Windows.Controls.DataGridRowEventArgs;
                if (SearchResultList.Count < PageSize)
                {
                    return;
                }
                if (SearchResultList.Count - 2 < e.Row.GetIndex() && !Loading)
                {
                    GetInspectionWarehouseRows();
                }
            });
            DetailSelectionChanged = new GalaSoft.MvvmLight.Command.RelayCommand <object>(
                (o) => {
                var e    = o as System.Windows.Controls.SelectionChangedEventArgs;
                var temp = new Web.DataLayer.ItemDimensionSearchModel();
                if (e.AddedItems != null && e.AddedItems.Count > 0)
                {
                    temp.InjectFrom(e.AddedItems[0]);
                    WarehouseClient.GetItemToQuantitiesAsync(temp, WarehouseToCode);
                }
            });
            WarehouseClient.GetItemToQuantitiesCompleted += (s, e) =>
            {
                var item = SearchResultList.FirstOrDefault(rl =>
                                                           rl.ItemId == e.Result.ItemId && rl.ItemType == e.Result.ItemType &&
                                                           rl.ItemDimFromIserial == e.Result.ItemDimFromIserial &&
                                                           rl.ColorFromId == e.Result.ColorFromId &&
                                                           rl.SizeFrom == e.Result.SizeFrom && rl.BatchNoFrom == e.Result.BatchNoFrom &&
                                                           rl.ColorToId == e.Result.ColorToId && rl.SizeTo == e.Result.SizeTo &&
                                                           rl.BatchNoTo == e.Result.BatchNoTo);
                if (item != null)
                {
                    item.ItemDimToIserial    = e.Result.ItemDimToIserial;
                    item.AvailableToQuantity = e.Result.AvailableToQuantity;
                    item.PendingToQuantity   = e.Result.PendingToQuantity;
                }
                else
                {
                    //item.AvailableToQuantity = 0;
                    //item.PendingToQuantity = 0;
                }
            };

            WarehouseClient.GetItemGroupCompleted += (s, e) =>
            {
                foreach (var item in e.Result)
                {
                    ItemTypes.Add(item);
                }
            };
            WarehouseClient.GetItemGroupAsync();
        }
Example #34
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            Log.Info("Client: Main View Model initializing...");
            _oidTreeViewModel = new OidTreeViewModel();
            IfDeviceAvaliableCommand = new RelayCommand(CheckDevice, CanCheckDevice);
            PerformActionCommand = new RelayCommand(PerformActionAsync, CanPerformAction);
            CopyToClipboardCommand = new RelayCommand(CopyToClipboard, CanCopy);
            _snmpService = new SnmpServiceService(Log);

            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
        }
Example #35
0
 public Thing()
 {
     Command = new GalaSoft.MvvmLight.Command.RelayCommand <bool>(DoIt);
 }
        public MainPageViewModel()
        {
            SptccClient = new HtmlSptccClient();
            SearchResults = new ObservableCollection<SearchResult>();
            Cards = new ObservableCollection<Card>();

            if (IsInDesignMode)
            {
                SearchResults.Add(new SearchResult()
                {
                    CardNumber = "96777213213",
                    Balance = 253.38,
                    Date = "2015年01月21日"
                });

                SearchResults.Add(new SearchResult()
                {
                    CardNumber = "34696713319",
                    Balance = 400.12,
                    Date = "2015年01月21日"
                });
            }
            else
            {
                _settings = new AppSettings();
                InitDataTask = InitData();
            }

            CommandSearch = new RelayCommand(async () => await DoSearchAsync());
            CommandEmailSearchResults = new RelayCommand(async () => await DoEmail());
        }
 public SoundPlayerSourceViewModel(string request)
 {
     RequestUrl = request;
     PlayCommand = new GalaSoft.MvvmLight.Command.RelayCommand(Play);
 }