예제 #1
0
        private void ShowFullImage(AnalyseRecord record)
        {
            Image imgFull = null;

            if (pictureEdit1.Image != null)
            {
                Image image = pictureEdit1.Image;
                pictureEdit1.Image = null;
                image.Dispose();
            }
            if (record != null && record.Image != null)
            {
                // 不要与图片控件用同一个图片对象
                // 图片控件上的图片可以自己回收
                imgFull = ResultPageViewModel.DecorateFullImage(record);
            }
            pictureEdit1.Image = imgFull;
            pictureEdit1.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Clip;
            if (imgFull != null)
            {
                int x_rate = pictureEdit1.Width * 100 / imgFull.Width;
                int y_rate = pictureEdit1.Height * 100 / imgFull.Height;
                pictureEdit1.Properties.ZoomPercent = Math.Min(x_rate, y_rate);
            }
        }
 public ResulPage(string searchText)
 {
     InitializeComponent();
     this.Title          = searchText;
     this.searchText     = searchText;
     instance            = new ResultPageViewModel();;
     this.BindingContext = instance;
 }
예제 #3
0
        public MainViewModel()
        {
            var firstPage = new TestPageViewModel();

            firstPage.OnTestComplete += (result) =>
            {
                var secondPage = new ResultPageViewModel(result);
                CurrentPage = secondPage;
                PropertyChange(nameof(CurrentPage));
            };

            CurrentPage = firstPage;
        }
예제 #4
0
        public ApplicationViewModel()
        {
            // Add available pages
            PageViewModels.Add(new BinLocPageViewModel());
            PageViewModels.Add(new UserInfoPageViewModel());
            PageViewModels.Add(new NodeListPageViewModel());
            var rsp = new ResultPageViewModel();

            rsp.FinishInstallEventHandler += RaiseFinishInstallEvent;
            PageViewModels.Add(rsp);

            // Set starting page
            CurrentPageViewModel = PageViewModels[0];
        }
예제 #5
0
        public async Task PageLoaded_SavesResultToFile()
        {
            // ARRANGE
            var mockLogger      = new Mock <ILogger>();
            var mockProcess     = new Mock <IProcess>();
            var mockRecycleFile = GetMockRecycleFile();
            Mock <IScannedFileStore> scannedFileStore = new Mock <IScannedFileStore>();
            ResultPageViewModel      viewModel        = new ResultPageViewModel(mockLogger.Object, mockProcess.Object, mockRecycleFile.Object, "C:\\user", scannedFileStore.Object);

            // ACT
            await viewModel.PageLoaded.ExecuteAsync(null);

            // ASSERT
            scannedFileStore.Verify(t => t.SaveScannedFileStoreToFileAsync(It.IsAny <string>()), Times.Once);
        }
예제 #6
0
        public void AddScannedFiles_AddsFileToViewModel()
        {
            // ARRANGE
            var mockLogger                   = new Mock <ILogger>();
            var mockProcess                  = new Mock <IProcess>();
            var mockRecycleFile              = GetMockRecycleFile();
            ResultPageViewModel viewModel    = new ResultPageViewModel(mockLogger.Object, mockProcess.Object, mockRecycleFile.Object, "C:\\user", null);
            List <ScannedFile>  scannedFiles = GetScannedFiles();

            // ACT
            viewModel.AddScannedFiles(scannedFiles);

            // ASSERT
            Assert.AreEqual(scannedFiles.Count, viewModel.Duplicates.Count, "The wrong number of items were added to the view model");
        }
예제 #7
0
        public async Task Preview_NoSelection_DoesNothing()
        {
            // ARRANGE
            string filePath               = "C:\\Foo\\foo.txt";
            var    mockLogger             = new Mock <ILogger>();
            var    mockProcess            = new Mock <IProcess>();
            var    mockRecycleFile        = GetMockRecycleFile();
            ResultPageViewModel viewModel = new ResultPageViewModel(mockLogger.Object, mockProcess.Object, mockRecycleFile.Object, "C:\\user", null);

            viewModel.Duplicates.Add(new ScanResult()
            {
                FilePath   = filePath,
                Hash       = new byte[32],
                IsSelected = false
            });

            // ACT
            await viewModel.Preview.ExecuteAsync(null);

            // ASSERT
            mockProcess.Verify(t => t.StartAsync(filePath), Times.Never, "The IProcess.StartAsync operation was called when it was expected to not.");
        }
예제 #8
0
        public void PageLoaded_WithData_TogglesButtons()
        {
            // ARRANGE
            var mockLogger                = new Mock <ILogger>();
            var mockProcess               = new Mock <IProcess>();
            var mockRecycleFile           = GetMockRecycleFile();
            ResultPageViewModel viewModel = new ResultPageViewModel(mockLogger.Object, mockProcess.Object, mockRecycleFile.Object, "C:\\user", null);

            viewModel.Duplicates.Add(new ScanResult()
            {
                FilePath   = "C:\\Foo\\foo.txt",
                Hash       = new byte[32],
                IsSelected = false
            });

            // ACT
            viewModel.PageLoaded.Execute(null);

            // ASSERT
            Assert.IsTrue(viewModel.Preview.CanExecute(null), "Preview is not enabled");
            Assert.IsTrue(viewModel.Recycle.CanExecute(null), "Recycle is not enabled");
        }
예제 #9
0
        public async Task Reycle_NoSelection_DoesNothing()
        {
            // ARRANGE
            string filePath               = "C:\\Foo\\foo.txt";
            var    mockLogger             = new Mock <ILogger>();
            var    mockProcess            = new Mock <IProcess>();
            var    mockRecycleFile        = GetMockRecycleFile();
            ResultPageViewModel viewModel = new ResultPageViewModel(mockLogger.Object, mockProcess.Object, mockRecycleFile.Object, "C:\\user", null);

            viewModel.Duplicates.Add(new ScanResult()
            {
                FilePath   = filePath,
                Hash       = new byte[32],
                IsSelected = false
            });

            // ACT
            await viewModel.Recycle.ExecuteAsync(null);

            // ASSERT
            mockRecycleFile.Verify(t => t.RecycleAsync(filePath, It.IsAny <bool>()), Times.Never, "The RecycleAsync operation was called.");
            Assert.AreEqual(1, viewModel.Duplicates.Count, "The file was removed from the collection");
        }
예제 #10
0
        public void AddScannedFiles_AddsAlternatingColors()
        {
            // ARRANGE
            var mockLogger                   = new Mock <ILogger>();
            var mockProcess                  = new Mock <IProcess>();
            var mockRecycleFile              = GetMockRecycleFile();
            ResultPageViewModel viewModel    = new ResultPageViewModel(mockLogger.Object, mockProcess.Object, mockRecycleFile.Object, "C:\\user", null);
            List <ScannedFile>  scannedFiles = GetScannedFiles();

            // ACT
            viewModel.AddScannedFiles(scannedFiles);

            // ASSERT
            string expectedColor1 = BackgroundColor.Transparent.ToString();
            string expectedColor2 = BackgroundColor.DarkGray.ToString();
            string failureMessage = "The background color does not match what was expected";

            Assert.AreEqual(expectedColor1, viewModel.Duplicates[0].Background, failureMessage);
            Assert.AreEqual(expectedColor1, viewModel.Duplicates[1].Background, failureMessage);
            Assert.AreEqual(expectedColor2, viewModel.Duplicates[2].Background, failureMessage);
            Assert.AreEqual(expectedColor2, viewModel.Duplicates[3].Background, failureMessage);
            Assert.AreEqual(expectedColor1, viewModel.Duplicates[4].Background, failureMessage);
            Assert.AreEqual(expectedColor1, viewModel.Duplicates[5].Background, failureMessage);
        }
예제 #11
0
 public ResultPage(UserSurveyStatus userSurveyStatus)
 {
     InitializeComponent();
     BindingContext = ViewModel = new ResultPageViewModel(Navigation);
     ViewModel.SetResult(userSurveyStatus);
 }
예제 #12
0
 public ResultPage(IList <Product> products)
 {
     InitializeComponent();
     BindingContext = new ResultPageViewModel(products);
 }
예제 #13
0
 public void Init(PrxCustomer prxCustomer)
 {
     _prxCustomer = prxCustomer;
     _viewModel   = new ResultPageViewModel();
 }
예제 #14
0
        private void ucResultPage_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                m_ViewModel = new ResultPageViewModel();
                m_ViewModel.PreNewSearch += ViewModel_PreNewSearch;
                m_ViewModel.SearchResult += new EventHandler(ViewModel_SearchResult);

                Framework.Container.Instance.VVMDataBindings.AddBinding(this.lblCtrlFileName, "Text", m_ViewModel, "FileName");

                Framework.Container.Instance.VVMDataBindings.AddBinding(this.chkBoxEdit, "Visible", m_ViewModel, "CanRevise");
                Framework.Container.Instance.VVMDataBindings.AddBinding(this.btnSave, "Visible", m_ViewModel, "CanRevise");

                gridControlResults.DataSource = m_ViewModel.DTAnalyseResults;

                m_labelCtrlsSetting = new LabelControl[] {
                    this.labelControl检索范围,
                    this.labelControl时间范围,
                    this.labelControl车牌,
                    this.labelControl车辆细分,
                    this.labelControl车身颜色,
                    this.labelControl车牌颜色,
                    this.labelControl安全带,
                    this.labelControl车型号
                };

                m_labelCtrlsSettingValue = new LabelControl[] {
                    this.labelControl3,
                    this.labelControl10,
                    this.labelControl13,
                    this.labelControl15,
                    this.labelControl21,
                    this.labelControl23,
                    this.labelControl25,
                    this.lblCtrlModelValue
                };
                this.ucSearchSettings1 = new com.VehicleAnalyse.Main.Views.ucSearchSettings();
                // ucSearchSettings1
                //
                this.ucSearchSettings1.Location = new System.Drawing.Point(3, 3);
                this.ucSearchSettings1.Name     = "ucSearchSettings1";
                this.ucSearchSettings1.Size     = new System.Drawing.Size(222, 470);
                this.ucSearchSettings1.TabIndex = 0;
                this.ucSearchSettings1.Dock     = System.Windows.Forms.DockStyle.Fill;
                //
                this.ucSearchSettings1.SearchClicked += new EventHandler(ucSearchSettings1_SearchClicked);
                this.ucSearchSettings1.CancelClicked += new EventHandler(ucSearchSettings1_CancelClicked);
                this.ucSearchSettings1.ToShowPopup   += new EventHandler(ucSearchSettings1_OnToShow);
                this.ucSearchSettings1.ToHidePopup   += new EventHandler(ucSearchSettings1_OnToHide);

                this.popupControlContainer1.Controls.Add(this.ucSearchSettings1);
                if (!Framework.Environment.RealTimeVersion)
                {
                    this.popupControlContainer1.Height -= 50;
                    this.ucSearchSettings1.Height      -= 50;
                }
            }
            // columnDriverPhoneCall.Visible = Framework.Environment.PhoneCallFeature;
            // this.gridView1.Columns[columnDriverPhoneCall.AbsoluteIndex].Visible = Framework.Environment.PhoneCallFeature;
            ucResultImage1.Reset();
            InitRepositoryItemCtrls();
        }