Exemple #1
0
        public MainForm()
        {
            InitializeComponent();
            Load += MainForm_Load;

            _viewModel = new MainFormViewModel();
        }
        public MainForm(IGisDataReader dataReader,
                        IDbService dbService,
                        ILogger logger,
                        IGeneralizer generalizer,
                        GeneralizerOptions generalizerOptions,
                        ILinearGeneralizer linearGeneralizer)
        {
            InitializeComponent();

            _viewModel = new MainFormViewModel(Canvas, dataReader, dbService, logger,
                                               generalizer, generalizerOptions, linearGeneralizer);

            InitializeMetaSection();

            InitializeMenu();

            _viewModel.MapsUpdatedEvent += MapsUpdatedEventHandler;

            _scrollTimer              = new ScrollTimer();
            _scrollTimer.ScrollEvent += _scrollTimer_ScrollEvent;


            GeneralizeBtn.Anchor      = AnchorStyles.Bottom | AnchorStyles.Right;
            DrawSourceBtn.Anchor      = AnchorStyles.Bottom | AnchorStyles.Right;
            MinDistanceTextBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            label1.Anchor             = AnchorStyles.Bottom | AnchorStyles.Right;

            WindowState = FormWindowState.Maximized;
        }
Exemple #3
0
 public MainFormPresenter(PanelControl modulesPanel, MainFormViewModel viewModel)
 {
     modulesCache       = new Dictionary <ModuleType, System.Windows.Forms.UserControl>();
     this.modulesPanel  = modulesPanel;
     this.viewModelCore = viewModel;
     ViewModel.SelectedModuleTypeChanged += ViewModel_SelectedModuleTypeChanged;
 }
Exemple #4
0
 public MainForm()
 {
     InitializeComponent();
     ViewModel = new MainFormViewModel();
     _pathManager.Load();
     BindCommands();
 }
Exemple #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var applicationViewModel = new MainFormViewModel();

            Application.Run(new MainForm(applicationViewModel));
        }
Exemple #6
0
        MainForm()
        {
            InitializeComponent();

            vm = new MainFormViewModel();

            PopulateOperationModeComboBox();
        }
Exemple #7
0
 public MainForm(MainFormViewModel mainFormViewModel)
 {
     _mainFormViewModel = mainFormViewModel;
     InitializeComponent();
     InitializeTabs();
     InitializeHarmonicsListBoxPartView();
     InitializeSelectedHarmonicPartView();
     DeleteSelectedButton.DataBindings.Add("Enabled", _mainFormViewModel, "IsCanDeleteHarmonic", true, DataSourceUpdateMode.OnPropertyChanged);
 }
Exemple #8
0
        public void ViewModel_CalculateArea_ThrowsExceptionIfLengthIsNegativeNumber()
        {
            var vm = new MainFormViewModel();

            vm.Width  = "3";
            vm.Length = "-3";

            Assert.Throws <ArgumentException>("Length", () => vm.GetArea());
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainFormViewModel viewModel = new MainFormViewModel();

            //Construct Controller
            Application.Run(viewModel.form);
        }
 private void OnStudentEditViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Parent")
     {
         PropertyChanged -= OnStudentEditViewModelPropertyChanged;
         _menuObject      = Parent as MainFormViewModel;
         BindStudentEdit();
     }
 }
Exemple #11
0
        public void ViewModel_CalculateArea_ThrowsExceptionIfLengthEqualsZero()
        {
            var vm = new MainFormViewModel();

            vm.Width  = "3";
            vm.Length = "0";

            Assert.Throws <ArgumentException>("Length", () => vm.GetArea());
        }
Exemple #12
0
        public void ViewModel_HasWidthProperty()
        {
            var vm = new MainFormViewModel();

            vm.Width = "3";

            Assert.IsType <string>(vm.Width);
            Assert.Equal("3", vm.Width);
        }
 private void OnStudentEditViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Parent")
     {
         PropertyChanged -= OnStudentEditViewModelPropertyChanged;
         var parent = Parent as StudentListViewModel;
         _menuObject = parent.Parent as MainFormViewModel;
         Bind();
     }
 }
Exemple #14
0
        public void ViewModel_CalculatePerimeter(string width, string length, int output)
        {
            var vm = new MainFormViewModel();

            vm.Width  = width;
            vm.Length = length;

            int perimeter = vm.GetPerimeter();

            Assert.Equal(output, perimeter);
        }
        public ReturnCode Generate(object context, MainFormViewModel viewModel = null)
        {
            if  (
                    viewModel == null
                )
            {
                return ReturnCode.ModulesExportBabelMetaMySqlGenerateWrongServerParameters;
            }

            throw new NotImplementedException();
        }
 private void OnFamilyMemberEditViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Parent")
     {
         PropertyChanged -= OnFamilyMemberEditViewModelPropertyChanged;
         _treeView = Parent as FamilyMemberTreeViewModel;
         if (_treeView != null)
             _menuObject = _treeView.Parent as MainFormViewModel;
         Bind();
     }
 }
        ReturnCode ICatalogWriter.Generate(object context, MainFormViewModel viewModel)
        {
            _viewModel = viewModel;

            if (!CatalogContext.Instance.Initialized)
            {
                return ReturnCode.ModulesExportCatalogContextNotInitialized;
            }

            throw new NotImplementedException();
        }
Exemple #18
0
 public MainForm()
 {
     MainFormViewModel = new MainFormViewModel();
     Init();
     InitializeComponent();
     InitAccount();
     InitCode();
     InitVendor();
     InitCustomer();
     InitDepartment();
 }
Exemple #19
0
        public void ViewModel_CalculateArea(string width, string length, int output)
        {
            var vm = new MainFormViewModel();

            vm.Width  = width;
            vm.Length = length;

            int area = vm.GetArea();

            Assert.Equal(output, area);
        }
Exemple #20
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var person = new Person {
                DateOfBirth = DateTime.Now
            };
            var viewModel = new MainFormViewModel(person);

            Application.Run(new FrmMain(viewModel));
        }
        public MainForm(AppBrowserViewModel appBrowserViewModel)
        {
            this.appBrowserViewModel = appBrowserViewModel;
            this.viewModel           = appBrowserViewModel.MainForm;

            DataContext = viewModel;

            XamlReader.Load(this);

            ModulesTree.DataContext = viewModel.ModulesTree;
            viewModel.ModulesTree.PropertyChanged += ModulesTreeOnPropertyChanged;
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            _mainFormViewModel = new MainFormViewModel();

            BindingSource bindingSource = new BindingSource(_mainFormViewModel, null);

            MakeTextBox.DataBindings.Add("Text", bindingSource, "ModelCar.Make");
            ModelTextBox.DataBindings.Add("Text", bindingSource, "ModelCar.Model");
            LastUpdatedLabel.DataBindings.Add("Text", bindingSource, "ModelCar.LastUpdated");

            SaveButton.Tag = _mainFormViewModel.SaveCarCommand;
        }
Exemple #23
0
        private void InitializeViews()
        {
            viewModel = new MainFormViewModel();

            this.surveysControl                  = new SurveysControl(this.viewModel.projet.model.id);
            this.surveysControl.Visible          = false;
            this.surveysControl.Dock             = System.Windows.Forms.DockStyle.Fill;
            this.surveysControl.AutoScaleMode    = AutoScaleMode.None;
            this.surveysControl.Name             = "surveysView";
            this.surveysControl.PropertyChanged += HostRemoved;
            this.panelCurrentView.Controls.Add(this.surveysControl);

            // Page Project Context
            this.projectContextView               = new ProjectContext();
            this.projectContextView.Visible       = false;
            this.projectContextView.Dock          = System.Windows.Forms.DockStyle.Fill;
            this.projectContextView.AutoScaleMode = AutoScaleMode.None;
            this.projectContextView.Name          = "projectContextView";
            this.panelCurrentView.Controls.Add(this.projectContextView);

            // Page Project Plan
            this.projectPlanView               = new ProjectPlanControl(this.viewModel.projet.events);
            this.projectPlanView.Visible       = false;
            this.projectPlanView.Dock          = System.Windows.Forms.DockStyle.Fill;
            this.projectPlanView.AutoScaleMode = AutoScaleMode.None;
            this.projectPlanView.Name          = "projectContextView";
            this.panelCurrentView.Controls.Add(this.projectPlanView);

            // Page Model Info
            if (this.viewModel.projet.model == null)
            {
                this.viewModel.projet.model = new PFE.Model.Model();
            }
            this.modelInfoView               = new ModelInfo(this.viewModel.projet.model, this);
            this.modelInfoView.Visible       = false;
            this.modelInfoView.Dock          = System.Windows.Forms.DockStyle.Fill;
            this.modelInfoView.AutoScaleMode = AutoScaleMode.None;
            this.modelInfoView.Name          = "projectContextView";
            this.panelCurrentView.Controls.Add(this.modelInfoView);

            // Page Validation
            this.validationView               = new ValidationControl(this.viewModel.projet.model);
            this.validationView.Visible       = false;
            this.validationView.Dock          = System.Windows.Forms.DockStyle.Fill;
            this.validationView.AutoScaleMode = AutoScaleMode.None;
            this.validationView.Name          = "projectContextView";
            this.panelCurrentView.Controls.Add(this.validationView);

            // First Page
            switchView(projectContextView);
            labelPageName.Text = "Project Context";
        }
Exemple #24
0
 private void OnFamilyMemberEditViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Parent")
     {
         PropertyChanged -= OnFamilyMemberEditViewModelPropertyChanged;
         _treeView        = Parent as FamilyMemberTreeViewModel;
         if (_treeView != null)
         {
             _menuObject = _treeView.Parent as MainFormViewModel;
         }
         Bind();
     }
 }
Exemple #25
0
        public void AddParticipantTestMethod()
        {
            //Unit testing basics: https://msdn.microsoft.com/en-us/library/hh694602.aspx

            // arrange
            var viewModel = new MainFormViewModel();

            // act
            viewModel.AddParticipant();

            // assert
            Assert.AreEqual(viewModel.Participants.Count, 1);
        }
        public ReturnCode Generate(object context, MainFormViewModel viewModel = null)
        {
            _viewModel = viewModel;

            if (!CatalogContext.Instance.Initialized)
            {
                return ReturnCode.ModulesExportCatalogContextNotInitialized;
            }

            _sqlOutput = String.Empty;

            GenerateLangs();

            throw new NotImplementedException();
        }
 private void OnStudentEditViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Parent")
     {
         PropertyChanged -= OnStudentEditViewModelPropertyChanged;
         if (Parent != null)
         {
             var parent = Parent as StudentListViewModel;
             if (parent != null)
             {
                 _menuObject = parent.Parent as MainFormViewModel;
             }
         }
         Bind();
     }
 }
Exemple #28
0
 private void OnDocumentEditViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Parent")
     {
         PropertyChanged -= OnDocumentEditViewModelPropertyChanged;
         var parent = Parent as DocumentListViewModel;
         if (parent != null)
         {
             var grandParent = parent.Parent as FolderListViewModel;
             if (grandParent != null)
             {
                 _menuObject = grandParent.Parent as MainFormViewModel;
             }
         }
         DisplayName = "Edit Document #" + Model.DocumentId;
         Bind();
     }
 }
Exemple #29
0
        public static Form Execute()
        {
            var mainForm          = new MainForm();
            var mainFormViewModel = new MainFormViewModel();
            var mainFormPresenter = new MainFormPresenter(mainForm, mainFormViewModel);

            var loginPresenter = new LoginControlPresenter(mainForm, );

            //note that in the real thing instead of adding them like this and calling showControl here,
            //i might actually pass in a list of kvp(pageType, new control) and have the construct gen up all of the pages
            //Then the constructor would go to the first page (login)
            mainFormPresenter.AddControlToPagesDictionaryIfNotPresent(Pages.Login, new LoginControl());
            mainFormPresenter.AddControlToPagesDictionaryIfNotPresent(Pages.Ship, new ShipControl());
            mainFormPresenter.AddControlToPagesDictionaryIfNotPresent(Pages.ScaleSetup, new ScaleSetupControl());
            mainFormPresenter.ShowControl(Pages.Login);

            return(mainForm);
        }
Exemple #30
0
        public MainForm()
        {
            InitializeComponent();

            _model              = new MainFormViewModel(new SelectionManager());
            _model.StateChange += Model_StateChange;

            _cursors = new Dictionary <SelectionComponentType, Cursor>();
            _cursors.Add(SelectionComponentType.BottomEdge, Cursors.SizeNS);
            _cursors.Add(SelectionComponentType.LeftEdge, Cursors.SizeWE);
            _cursors.Add(SelectionComponentType.NECorner, Cursors.SizeNESW);
            _cursors.Add(SelectionComponentType.NWCorner, Cursors.SizeNWSE);
            _cursors.Add(SelectionComponentType.RightEdge, Cursors.SizeWE);
            _cursors.Add(SelectionComponentType.SECorner, Cursors.SizeNWSE);
            _cursors.Add(SelectionComponentType.SWCorner, Cursors.SizeNESW);
            _cursors.Add(SelectionComponentType.TopEdge, Cursors.SizeNS);
            _cursors.Add(SelectionComponentType.Inside, Cursors.SizeAll);
        }
Exemple #31
0
        public MainPage()
        {
            InitializeComponent();
            BindingContext = new MainFormViewModel();

            List <string> testItems = new List <string>();

            testItems.Add("Test From 1");
            testItems.Add("Test From 2");
            testItems.Add("Test From 3");

            //works to set the data w/n the container
            testPicker.ItemsSource = ((MainFormViewModel)(this.BindingContext)).pickerListItems;

            //testPicker.ItemsSource = testItems;

            // custom controls
            testCustomPicker.BackgroundColor = Color.Brown;
            testCustomPicker.BorderColor     = Color.Orange;
            testCustomPicker.ItemsSource     = testItems;
        }
Exemple #32
0
 public void Initialize()
 {
     _model = new MainFormViewModel(new SelectionManager());
 }
        /// <summary>
        /// Main parsing method implementing ICatalogReader interface.
        /// </summary>
        /// <param name="ofd"></param>
        /// <param name="formatType"></param>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public async Task<ReturnCode> Parse(OpenFileDialog ofd, FileFormatType formatType, MainFormViewModel viewModel = null)
        {
            if (ofd == null)
            {
                return ReturnCode.ModulesImportDefaultParseEmptyStream;
            }

            if (formatType == FileFormatType.ExcelWorkbook || formatType == FileFormatType.ExcelXml2003)
            {
                _fileFormatType = formatType;
            }
            else 
            {
                return ReturnCode.ModulesImportDefaultParseUnknownFormat;
            }

            switch (_fileFormatType)
            {
                case FileFormatType.ExcelWorkbook:
                    _excelLastRow = new Dictionary<String, int>();
                    _excelLastColumn = new Dictionary<String, int>();
                    if (String.IsNullOrEmpty(ofd.FileName))
                    {
                        return ReturnCode.ModulesImportDefaultParseEmptyStream;
                    }
                    _excelApplication = new Excel.Application();
                    _excelDocument = _excelApplication.Workbooks.Open(ofd.FileName);
                    if (_excelDocument == null)
                    {
                        return ReturnCode.ModulesImportDefaultParseEmptyStream;
                    }
                    break;
                case FileFormatType.ExcelXml2003:
                    try
                    {
                        Stream s = ofd.OpenFile();
                        _xmlDocument = new XmlDocument();
                        _xmlDocument.Load(s);
                        break;
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(this, "TemplatedCatalogReader.Parse, case=FileFormatType.ExcelXml2003, exception=" + ex.Message);
                        Notify("The XML parsing failed.");
                        return ReturnCode.ModulesImportDefaultParseEmptyStream;
                    }
            }

            if (viewModel != null)
            {
                _mainFormViewModel = viewModel;
                _mainFormViewModel.InputProgressBarValue = 0;
                _mainFormViewModel.InputProgressBarMax = InitPayload + 1; // initial payload and 'symbolic' last bit of payload before last return 
            }

            if (!(await IsValidWorkbook()))
            {
                Notify("Invalid Workbook.");
                return ReturnCode.ModulesImportDefaultParseInvalidWorkbook;
            }

            if (_mainFormViewModel != null)
            {
                if (_langs != null) _mainFormViewModel.InputProgressBarMax += _langs.Count;
                if (_tags != null) _mainFormViewModel.InputProgressBarMax += _tags.Count;
                if (_roles != null) _mainFormViewModel.InputProgressBarMax += _roles.Count;
                if (_qualities != null) _mainFormViewModel.InputProgressBarMax += _qualities.Count;
                if (_artists != null) _mainFormViewModel.InputProgressBarMax += _artists.Count;
                if (_works != null) _mainFormViewModel.InputProgressBarMax += _works.Count;
                if (_assets != null) _mainFormViewModel.InputProgressBarMax += _assets.Count;
                if (_albums != null) _mainFormViewModel.InputProgressBarMax += _albums.Count;
                if (_tracks != null) _mainFormViewModel.InputProgressBarMax += _tracks.Count;

                // Init phase 'completed'
                _mainFormViewModel.InputProgressBarValue = InitPayload;

                // Langs were already parsed
                if (_langs != null) _mainFormViewModel.InputProgressBarValue += _langs.Count;

            }

            await ParseTags();
            await ParseRoles();
            await ParseQualities();
            await ParseArtists();
            await ParseWorks();
            await ParseAssets();
            await ParseAlbums();
            await ParseTracks();

            Notify("Finalization...");
            FinalizeAlbums();
            FinalizeAssets();

            if (_mainFormViewModel != null)
            {
                if (_mainFormViewModel.FilterArtistChecked)
                {
                    CatalogContext.Instance.FilterUnusedArtists();
                }
                else if (_mainFormViewModel.FilterWorkChecked)
                {
                    CatalogContext.Instance.FilterUnusedWorks();
                }
                _mainFormViewModel.InputProgressBarValue = _mainFormViewModel.InputProgressBarMax;
            }

            CatalogContext.Instance.Initialized = true;
            Notify("Parsing completed.");
            return ReturnCode.Ok;
        }
 ReturnCode ICatalogWriter.Generate(object context, MainFormViewModel viewModel)
 {
     throw new NotImplementedException();
 }
Exemple #35
0
 /// <summary>
 /// Default contructor.
 /// </summary>
 public MainFormViewPresenter()
 {
     viewModel = new MainFormViewModel();
 }
        /// <summary>
        /// Main generation method.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public ReturnCode Generate(object context, MainFormViewModel viewModel = null)
        {
            var rootFolder = (String)context;
            if (String.IsNullOrEmpty(rootFolder))
            {
                return ReturnCode.ModulesExportFugaXmlGenerateNullFolderName;
            }

            if ((rootFolder.ToCharArray())[rootFolder.Length-1] != '\\')
            {
                rootFolder += "\\";
            }

            _mainFormViewModel = viewModel;

            if (!CatalogContext.Instance.Initialized)
            {
                return ReturnCode.ModulesExportCatalogContextNotInitialized;
            }

            foreach (var album in CatalogContext.Instance.Albums)
            {
                var i = new ingestion
                {
                    album = new ingestionAlbum
                    {
                        tracks = new ingestionAlbumTracks(),
                    },
                };

                // There MUST be a subfolder for each album
                if (String.IsNullOrEmpty(album.Ean.ToString()))
                {
                    Notify(String.Format("Album [{0}]: Ean is empty.", album.CatalogReference));
                    continue;
                }

                var subfolder = rootFolder + album.Ean;
                if (!Directory.Exists(subfolder))
                {
                    Directory.CreateDirectory(subfolder);
                }
                subfolder += "\\";

                var files = Directory.GetFiles(subfolder, "*.*");

                GenerateAlbumWiseData(album, i, files);

                if (album.Tracks != null)
                {
                    foreach (var volume in album.Tracks)
                    {
                        GenerateTrackWiseData(album, volume, i, files);
                    }
                }

                var tw = new StreamWriter(subfolder + i.album.upc_code + ".xml", false, Encoding.UTF8);
                tw.Write(i.Serialize().WithFugaXmlHeader());
                tw.Close();

                // Generate the empty '.complete' file as requested
                var complete = new StreamWriter(subfolder + album.Ean + ".complete", false, Encoding.ASCII); // ASCII encoding is to ensure strict 0Kb on disk
                complete.Close();

                Notify("Album " + album.Ean + " generated.");
            }

            return ReturnCode.Ok;
        }
 Task<AppConfig.ReturnCode> ICatalogReader.Parse(System.Windows.Forms.OpenFileDialog ofd, FileFormatType formatType, MainFormViewModel viewModel)
 {
     throw new NotImplementedException();
 }
Exemple #38
0
 public MainForm(MainFormViewModel viewmodel) : this()
 {
     m_viewmodel = viewmodel;
     ViewModelBinding.DataSource = m_viewmodel;
 }
Exemple #39
0
 public void BindToViewModel(MainFormViewModel viewModel)
 {
     throw new NotImplementedException();
 }