コード例 #1
0
ファイル: ApplicationViews.cs プロジェクト: Tylland/altidude
 public ApplicationViews(IUserView users, IUserLevelView levels, IProfileView profiles, IPlaceView places, IChartTypeView chartTypes)
 {
     Users      = users;
     Levels     = levels;
     Profiles   = profiles;
     Places     = places;
     ChartTypes = chartTypes;
 }
コード例 #2
0
 public ProfilePresenter(IProfileView view, ISessionProvider session)
     : base(view, session)
 {
     _view             = base.GetView <IProfileView>();
     _view.InitView   += new EventHandler(_view_InitView);
     _view.LoadView   += new EventHandler(_view_LoadView);
     _view.UnloadView += new EventHandler(_view_UnloadView);
 }
コード例 #3
0
 public void Init()
 {
     mocks   = new MockRepository();
     config  = mocks.StrictMock <IUserConfiguration>();
     view    = mocks.DynamicMock <IProfileView>();
     manager = mocks.DynamicMock <IDataManager>();
     ClientServiceLocator.Register(config);
 }
コード例 #4
0
 public void Init()
 {
     mocks = new MockRepository();
     config = mocks.StrictMock<IUserConfiguration>();
     view = mocks.DynamicMock<IProfileView>();
     manager = mocks.DynamicMock<IDataManager>();
     ClientServiceLocator.Register(config);
 }
コード例 #5
0
        internal ProfilePresenter(IProfileView view) : base(view)
        {
            _view = view;

            _view.ProfileAdded           += ProfileAdded;
            _view.ProfileRenamed         += ProfileRenamed;
            _view.SelectedProfileChanged += SelectedProfileChanged;
            _view.SelectedProfileDeleted += SelectedProfileDeleted;
        }
コード例 #6
0
        /// <summary>
        /// Processes the profile edit view.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <param name="profilePicture">The profile picture.</param>
        /// <param name="profileCV">The profile cv.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Profile</exception>
        public string ProcessProfileEditView(IProfileView profileInfo, HttpPostedFileBase profilePicture,
                                             HttpPostedFileBase profileCV)
        {
            if (profileInfo == null)
            {
                throw new ArgumentNullException(nameof(Profile));
            }

            var processingMessage = string.Empty;

            var imageDigitalFileId = -1;

            var documentDigitalFileId = -1;

            if (profilePicture != null)
            {
                var processingImage =
                    this.digitalFileService.SaveFile(FileType.Image, profilePicture, out imageDigitalFileId);
            }

            if (profileCV != null)
            {
                var procecssingCV =
                    this.digitalFileService.SaveFile(FileType.Pdf, profileCV, out documentDigitalFileId);
            }


            // check if file saved to database and save the Id as part of the profile record
            if (imageDigitalFileId > 0)
            {
                profileInfo.PictureDigitalFileId = imageDigitalFileId;

                session.RemoveSessionValue(SessionKey.ProfilePicture);

                var digitalFile = this.digitalFileRepository.GetDigitalFileDetail(profileInfo.PictureDigitalFileId);

                var imgSrc = "";

                if (profilePicture != null)
                {
                    var base64 = Convert.ToBase64String(digitalFile.TheDigitalFile);
                    imgSrc = string.Format("data:{0};base64,{1}", profilePicture.ContentType, base64);
                    session.AddValueToSession(SessionKey.ProfilePicture, imgSrc);
                }
            }

            if (documentDigitalFileId > 0)
            {
                profileInfo.CVDigitalFileId = documentDigitalFileId;
            }

            processingMessage = this.profileRepository.UpdateProfileInfo(profileInfo);


            return(processingMessage);
        }
コード例 #7
0
        public void ShouldAttachToAllEvents()
        {
            view = mocks.StrictMock <IProfileView>();
            EventHelper.EventIsAttached(() => { view.Confirm += null; });
            EventHelper.EventIsAttached(() => { view.SelectProfileIcon += null; });
            mocks.ReplayAll();
            var controller = new ProfileController();

            controller.SetView(view);
        }
コード例 #8
0
        /// <summary>
        /// Gets the profile view.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <param name="processingMessage">The processing message.</param>
        /// <returns></returns>
        public IProfileView GetProfileView(IProfileView profileInfo, string processingMessage)
        {
            var genderCollection  = this.lookupRepository.GetGenderCollection();
            var countryCollection = this.lookupRepository.GetCountryCollection();
            var userInfo          = this.usersRepository.GetUserById(profileInfo.UserId);
            var viewModel         =
                this.profileViewModelFactory.CreateProfileView(profileInfo, userInfo, genderCollection, countryCollection, processingMessage);

            return(viewModel);
        }
コード例 #9
0
        /// <summary>
        /// Edits the update profile view.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <param name="proceesingMessage">The proceesing message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">profileInfo</exception>
        public IProfileView EditUpdateProfileView(IProfileView profileInfo, string proceesingMessage)
        {
            if (profileInfo == null)
            {
                throw new ArgumentNullException(nameof(profileInfo));
            }

            profileInfo.ProcessingMessage = proceesingMessage;

            return(profileInfo);
        }
コード例 #10
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model             = model as Model;
            this.view              = view as IProfileView;
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);
            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);

            // Create a list of profile (array) properties. Create a table from them and
            // hand the table to the profile grid.
            this.FindAllProperties(this.model);

            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    this.parentForGraph.Children.Add(this.graph);
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                }
            }

            // Trap the invoking of the ProfileGrid 'CellValueChanged' event so that
            // we can save the contents.
            this.view.ProfileGrid.CellsChanged += this.OnProfileGridCellValueChanged;

            // Trap the right click on column header so that we can potentially put
            // units on the context menu.
            this.view.ProfileGrid.ColumnHeaderClicked += this.OnColumnHeaderClicked;

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ProfileGrid.ResizeControls();
            this.view.PropertyGrid.ResizeControls();
            this.view.ShowView(true);
        }
コード例 #11
0
        /// <summary>
        /// Stores the profile information.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">profileInfo</exception>
        public string UpdateProfileInfo(IProfileView profileInfo)
        {
            if (profileInfo == null)
            {
                throw new ArgumentNullException(nameof(profileInfo));
            }


            //Get Profile From Database to Perform Update

            var result = string.Empty;

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var userProfile = dbContext.Profiles.Find(profileInfo.ProfileId);

                    userProfile.ProfileSummary = profileInfo.ProfileSummary;
                    userProfile.Address        = profileInfo.Address;
                    userProfile.CountryId      = profileInfo.CountryId;
                    userProfile.DateOfBirth    = profileInfo.DateOfBirth;
                    userProfile.GenderId       = profileInfo.GenderId;
                    userProfile.Nationality    = profileInfo.Nationality;
                    userProfile.StateOfOrigin  = profileInfo.StateOfOrigin;

                    if (profileInfo.PictureDigitalFileId > 0)
                    {
                        userProfile.PictureDigitalFileId = profileInfo.PictureDigitalFileId;
                    }

                    if (profileInfo.CVDigitalFileId > 0)
                    {
                        userProfile.CVDigitalFileId = profileInfo.CVDigitalFileId;
                    }

                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("Update Profile Information - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
コード例 #12
0
        private void OnNewProfile(object sender, EventArgs e)
        {
            var profile = manager.New();

            using (IProfileView profileView = ClientServiceLocator.GetService <IViewFactory>().CreateProfileView()) {
                var controller = ClientServiceLocator.GetService <IProfileController>();
                controller.SetView(profileView);
                controller.SetManager(manager);
                controller.SetProfile(profile, true);
                if (controller.Show())
                {
                    manager.Add(profile);
                    view.ReloadList();
                    view.SetSelectByName(profile.Name);
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Saves the profile information.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <param name="profilePicture">The profile picture.</param>
        /// <param name="profileCV">The profile cv.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">profileInfo</exception>
        public string SaveProfileInfo(IProfileView profileInfo, HttpPostedFileBase profilePicture,
                                      HttpPostedFileBase profileCV)
        {
            if (profileInfo == null)
            {
                throw new ArgumentNullException(nameof(profileInfo));
            }

            var userInfo = this.usersRepository.GetUserById(profileInfo.UserId);

            var employee = this.employeeOnBoardRepository.GetEmployeeByEmail(userInfo.Email);


            var processingMessage = string.Empty;

            var imageDigitalFileId = -1;

            var documentDigitalFileId = -1;

            var processingImage =
                this.digitalFileService.SaveFile(FileType.Image, profilePicture, out imageDigitalFileId);

            var procecssingCV = this.digitalFileService.SaveFile(FileType.Pdf, profileCV, out documentDigitalFileId);

            // check if file saved to database and save the Id as part of the profile record
            if (imageDigitalFileId > 0)
            {
                profileInfo.PictureDigitalFileId = imageDigitalFileId;
            }

            if (documentDigitalFileId > 0)
            {
                profileInfo.CVDigitalFileId = documentDigitalFileId;
            }

            if (employee != null)
            {
                employee.PhotoDigitalFileId = imageDigitalFileId;
                employeeOnBoardRepository.UpdateEmployeePhotoId(employee);
            }

            var message = this.profileRepository.StoreProfileInfo(profileInfo);


            return(message);
        }
コード例 #14
0
        /// <summary>
        /// Creates the profile view.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <param name="users">The users.</param>
        /// <param name="genderCollection">The gender collection.</param>
        /// <param name="countryCollection">The country collection.</param>
        /// <param name="processingMesage">The processing mesage.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">genderCollection</exception>
        public IProfileView CreateProfileView(IProfileView profileInfo, IUserDetail users, IList <IYourGender> genderCollection, IList <ICountry> countryCollection, string processingMesage)
        {
            if (genderCollection == null)
            {
                throw new ArgumentException(nameof(genderCollection));
            }

            var genderDLL  = GetDropDownList.GenderListItems(genderCollection, profileInfo.GenderId);
            var countryDLL = GetDropDownList.CountryListItem(countryCollection, profileInfo.CountryId);

            profileInfo.GenderDropDown    = genderDLL;
            profileInfo.CountryDropDown   = countryDLL;
            profileInfo.User              = users;
            profileInfo.ProcessingMessage = processingMesage;


            return(profileInfo);
        }
コード例 #15
0
        /// <summary>
        /// Stores the profile information.
        /// </summary>
        /// <param name="profileInfo">The profile information.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">profileInfo</exception>
        public string StoreProfileInfo(IProfileView profileInfo)
        {
            if (profileInfo == null)
            {
                throw new ArgumentNullException(nameof(profileInfo));
            }

            var result     = string.Empty;
            var newProfile = new Profile
            {
                UserId               = profileInfo.UserId,
                ProfileSummary       = profileInfo.ProfileSummary,
                Address              = profileInfo.Address,
                DateOfBirth          = profileInfo.DateOfBirth,
                GenderId             = profileInfo.GenderId,
                Nationality          = profileInfo.Nationality,
                StateOfOrigin        = profileInfo.StateOfOrigin,
                DateCreated          = DateTime.Now,
                PictureDigitalFileId = profileInfo.PictureDigitalFileId,
                CVDigitalFileId      = profileInfo.CVDigitalFileId,
                CountryId            = profileInfo.CountryId
            };

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.Profiles.Add(newProfile);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                result = string.Format("StoreProfileInfo - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.Message : "");
            }

            return(result);
        }
コード例 #16
0
        private void OnChangeProfile(object sender, EventArgs e)
        {
            string name = view.GetSelectedProfile();

            if (name == null)
            {
                return;
            }
            Profile profile = manager.Clone(name);

            using (IProfileView profileView = ClientServiceLocator.GetService <IViewFactory>().CreateProfileView()) {
                var controller = ClientServiceLocator.GetService <IProfileController>();
                controller.SetView(profileView);
                controller.SetManager(manager);
                controller.SetProfile(profile, false);
                if (controller.Show())
                {
                    manager.Change(name, profile);
                    view.ReloadList();
                    view.SetSelectByName(profile.Name);
                }
            }
        }
コード例 #17
0
        public ProfileController(IProfileView view)
        {
            _view = view;

            view.SetController(this);
        }
コード例 #18
0
 public ProfilePresenter(IProfileView view)
 {
     _view       = view;
     _repository = new MyProfileRepository();
 }
コード例 #19
0
 public void ShouldAttachToAllEvents()
 {
     view = mocks.StrictMock<IProfileView>();
     EventHelper.EventIsAttached(() => { view.Confirm += null; });
     EventHelper.EventIsAttached(() => { view.SelectProfileIcon += null; });
     mocks.ReplayAll();
     var controller = new ProfileController();
     controller.SetView(view);
 }
コード例 #20
0
ファイル: Subscribe.cs プロジェクト: Isur/a-d-d
 public Subscribe(User user, IProfileView profile)
 {
     InitializeComponent();
     this.user    = user;
     this.profile = profile;
 }
コード例 #21
0
 public void SetView(IProfileView view)
 {
     actView = view;
     actView.SelectProfileIcon += OnSelectProfileIcon;
     actView.Confirm           += OnActViewConfirm;
 }
コード例 #22
0
ファイル: ProfilePresenter.cs プロジェクト: hut104/ApsimX
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view = view as IProfileView;
            this.explorerPresenter = explorerPresenter;

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);

            // Create a list of profile (array) properties. Create a table from them and
            // hand the table to the profile grid.
            this.FindAllProperties(this.model);

            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    this.parentForGraph.Children.Add(this.graph);
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                }
            }

            // Trap the invoking of the ProfileGrid 'CellValueChanged' event so that
            // we can save the contents.
            this.view.ProfileGrid.CellsChanged += this.OnProfileGridCellValueChanged;

            // Trap the right click on column header so that we can potentially put
            // units on the context menu.
            this.view.ProfileGrid.ColumnHeaderClicked += this.OnColumnHeaderClicked;

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ProfileGrid.ResizeControls();
            this.view.PropertyGrid.ResizeControls();
        }
コード例 #23
0
ファイル: ProfilePresenter.cs プロジェクト: shenyczz/ApsimX
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view  = view as IProfileView;
            profileGrid.Attach(model, this.view.ProfileGrid, explorerPresenter);
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);
            propertyPresenter.ScalarsOnly = true;
            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource("WaterGraph");
            graph.Name = "";
            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                // The graph's series contain many variables such as [Soil].LL. We now replace
                // these relative paths with absolute paths.
                foreach (Series series in graph.FindAllChildren <Series>())
                {
                    series.XFieldName  = series.XFieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                    series.X2FieldName = series.X2FieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                    series.YFieldName  = series.YFieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                    series.Y2FieldName = series.Y2FieldName?.Replace("[Soil]", this.model.Parent.FullPath);
                }

                this.parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    // Don't add the graph as a child of the soil. This causes problems
                    // (see bug #4622), and adding the soil as a parent is sufficient.
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    for (int i = 0; i < this.profileGrid.Properties.Length; i++)
                    {
                        string columnName = profileGrid.Properties[i].Name;

                        if (columnName.Contains("\r\n"))
                        {
                            StringUtilities.SplitOffAfterDelimiter(ref columnName, "\r\n");
                        }

                        // crop colours
                        if (columnName.Contains("LL"))
                        {
                            if (profileGrid.Properties[i].Object is SoilCrop)
                            {
                                string soilCropName = (profileGrid.Properties[i].Object as SoilCrop).Name;
                                string cropName     = soilCropName.Replace("Soil", "");
                                columnName = cropName + " " + columnName;
                            }

                            Series cropLLSeries = new Series();
                            cropLLSeries.Name         = columnName;
                            cropLLSeries.Colour       = ColourUtilities.ChooseColour(this.graph.Children.Count);
                            cropLLSeries.Line         = LineType.Solid;
                            cropLLSeries.Marker       = MarkerType.None;
                            cropLLSeries.Type         = SeriesType.Scatter;
                            cropLLSeries.ShowInLegend = true;
                            cropLLSeries.XAxis        = Axis.AxisType.Top;
                            cropLLSeries.YAxis        = Axis.AxisType.Left;
                            cropLLSeries.YFieldName   = (parentForGraph is Soil ? parentForGraph.FullPath : "[Soil]") + ".Physical.DepthMidPoints";
                            cropLLSeries.XFieldName   = ((profileGrid.Properties[i].Object as IModel)).FullPath + "." + profileGrid.Properties[i].Name;
                            //cropLLSeries.XFieldName = ((property.Object as Model)).FullPath + "." + property.Name;
                            cropLLSeries.Parent = this.graph;

                            this.graph.Children.Add(cropLLSeries);
                        }
                    }

                    this.graph.LegendPosition = Graph.LegendPositionType.RightTop;
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                    graphPresenter.LegendInsideGraph = false;
                }
            }

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ShowView(true);
        }
コード例 #24
0
 public ProfilePresenter(IProfileView view)
 {
     _view = view;
 }
コード例 #25
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view  = view as IProfileView;
            profileGrid.Attach(model, this.view.ProfileGrid, explorerPresenter);
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);

            // Create a list of profile (array) properties. Create a table from them and
            // hand the table to the profile grid.
            this.FindAllProperties(this.model);

            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");

            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                this.parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    this.parentForGraph.Children.Add(this.graph);
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    for (int col = 0; col < this.propertiesInGrid.Count; col++)
                    {
                        VariableProperty property   = this.propertiesInGrid[col];
                        string           columnName = property.Description;

                        // crop colours
                        if (property.CropName != null && columnName.Contains("LL"))
                        {
                            Series cropLLSeries = new Series();
                            cropLLSeries.Name         = columnName;
                            cropLLSeries.Colour       = ColourUtilities.ChooseColour(this.graph.Children.Count);
                            cropLLSeries.Line         = LineType.Solid;
                            cropLLSeries.Marker       = MarkerType.None;
                            cropLLSeries.Type         = SeriesType.Scatter;
                            cropLLSeries.ShowInLegend = true;
                            cropLLSeries.XAxis        = Axis.AxisType.Top;
                            cropLLSeries.YAxis        = Axis.AxisType.Left;
                            cropLLSeries.YFieldName   = "[Soil].DepthMidPoints";
                            cropLLSeries.XFieldName   = "[" + (property.Object as Model).Name + "]." + property.Name;
                            cropLLSeries.Parent       = this.graph;

                            this.graph.Children.Add(cropLLSeries);
                        }
                    }

                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                }
            }

            // Trap the invoking of the ProfileGrid 'CellValueChanged' event so that
            // we can save the contents.
            this.view.ProfileGrid.CellsChanged += this.OnProfileGridCellValueChanged;

            // Trap the right click on column header so that we can potentially put
            // units on the context menu.
            this.view.ProfileGrid.GridColumnClicked += this.OnGridColumnClicked;

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ShowView(true);
        }
コード例 #26
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view  = view as IProfileView;
            profileGrid.Attach(model, this.view.ProfileGrid, explorerPresenter);
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);

            // Create a list of profile (array) properties. Create a table from them and
            // hand the table to the profile grid.
            this.FindAllProperties(this.model);

            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");

            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                // The graph's series contain many variables such as [Soil].LL. We now replace
                // these relative paths with absolute paths.
                foreach (Series series in Apsim.Children(graph, typeof(Series)))
                {
                    series.XFieldName  = series.XFieldName?.Replace("[Soil]", Apsim.FullPath(this.model.Parent));
                    series.X2FieldName = series.X2FieldName?.Replace("[Soil]", Apsim.FullPath(this.model.Parent));
                    series.YFieldName  = series.YFieldName?.Replace("[Soil]", Apsim.FullPath(this.model.Parent));
                    series.Y2FieldName = series.Y2FieldName?.Replace("[Soil]", Apsim.FullPath(this.model.Parent));
                }

                this.parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    this.parentForGraph.Children.Add(this.graph);
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    for (int col = 0; col < this.propertiesInGrid.Count; col++)
                    {
                        string columnName = propertiesInGrid[col].ColumnName;

                        if (columnName.Contains("\r\n"))
                        {
                            StringUtilities.SplitOffAfterDelimiter(ref columnName, "\r\n");
                        }

                        // crop colours
                        if (columnName.Contains("LL"))
                        {
                            Series cropLLSeries = new Series();
                            cropLLSeries.Name         = columnName;
                            cropLLSeries.Colour       = ColourUtilities.ChooseColour(this.graph.Children.Count);
                            cropLLSeries.Line         = LineType.Solid;
                            cropLLSeries.Marker       = MarkerType.None;
                            cropLLSeries.Type         = SeriesType.Scatter;
                            cropLLSeries.ShowInLegend = true;
                            cropLLSeries.XAxis        = Axis.AxisType.Top;
                            cropLLSeries.YAxis        = Axis.AxisType.Left;
                            cropLLSeries.YFieldName   = (parentForGraph is Soil ? Apsim.FullPath(parentForGraph) : "[Soil]") + ".DepthMidPoints";
                            cropLLSeries.XFieldName   = Apsim.FullPath((propertiesInGrid[col].ObjectWithProperty as Model)) + "." + propertiesInGrid[col].PropertyName;
                            //cropLLSeries.XFieldName = Apsim.FullPath(property.Object as Model) + "." + property.Name;
                            cropLLSeries.Parent = this.graph;

                            this.graph.Children.Add(cropLLSeries);
                        }
                    }

                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                }
            }

            // Trap the invoking of the ProfileGrid 'CellValueChanged' event so that
            // we can save the contents.
            this.view.ProfileGrid.CellsHaveChanged += this.OnProfileGridCellValueChanged;

            // Trap the right click on column header so that we can potentially put
            // units on the context menu.
            this.view.ProfileGrid.ColumnMenuClicked += this.OnColumnMenuItemClicked;

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ShowView(true);
        }