Exemplo n.º 1
0
 /// <summary>Set the value of the graph models property</summary>
 /// <param name="name">The name of the property to set</param>
 /// <param name="value">The value of the property to set it to</param>
 private void SetModelProperty(string name, object value)
 {
     try
     {
         ChangeProperty command = new ChangeProperty(series, name, value);
         explorerPresenter.CommandHistory.Add(command);
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
 /// <summary>
 /// The relative to field in the view has changed.
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void OnRelativeToChanged(object sender, EventArgs e)
 {
     try
     {
         ChangeProperty command = new ChangeProperty(initialWater, "RelativeTo", initialWaterView.RelativeTo);
         explorerPresenter.CommandHistory.Add(command);
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Track changes made to the view
        /// </summary>
        private void OnTrackChanges(object sender, PivotTableView.TrackChangesArgs args)
        {
            // Change the information of the property in the model
            var p = table.GetType().GetProperty(args.Name);

            p.SetValue(table, args.Value);

            // Track this change in the command history
            ChangeProperty command = new ChangeProperty(table, args.Name, args.Value);

            explorer.CommandHistory.Add(command);
        }
 /// <summary>
 /// The PAW field in the view has changed.
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void OnPAWChanged(object sender, EventArgs e)
 {
     try
     {
         ChangeProperty command = new ChangeProperty(initialWater, "PAW", Convert.ToDouble(initialWaterView.PAW, System.Globalization.CultureInfo.InvariantCulture));
         explorerPresenter.CommandHistory.Add(command);
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Track changes made to the view
        /// </summary>
        private void TrackChanges()
        {
            ChangeProperty sqlcom = new ChangeProperty(this.query, "Sql", view.Sql);

            explorer.CommandHistory.Add(sqlcom);

            //ChangeProperty filecom = new ChangeProperty(this.query, "Filename", view.Filename);
            //explorer.CommandHistory.Add(filecom);

            //ChangeProperty tablecom = new ChangeProperty(this.query, "Tablename", view.Tablename);
            //explorer.CommandHistory.Add(tablecom);
        }
Exemplo n.º 6
0
 /// <summary>
 /// The percent full field in the view has changed.
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void OnPercentFullChanged(object sender, EventArgs e)
 {
     try
     {
         double         fractionFull = (initialWaterView.PercentFull * 1.0) / 100;
         ChangeProperty command      = new ChangeProperty(initialWater, "FractionFull", fractionFull);
         explorerPresenter.CommandHistory.Add(command);
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Set the value of the specified property
 /// </summary>
 /// <param name="property">The property to set the value of</param>
 /// <param name="value">The value to set the property to</param>
 private void SetPropertyValue(IVariable property, object value)
 {
     try
     {
         value = FormatValueForProperty(property, value);
         ChangeProperty cmd = new ChangeProperty(model, property.Name, value);
         presenter.CommandHistory.Add(cmd);
     }
     catch (Exception err)
     {
         presenter.MainPresenter.ShowError(err);
     }
 }
 /// <summary>
 /// Set the value of the specified property
 /// </summary>
 /// <param name="property">The property to set the value of</param>
 /// <param name="value">The value to set the property to</param>
 private void SetPropertyValue(ChangeProperty changedProperty)
 {
     presenter.CommandHistory.ModelChanged -= OnModelChanged;
     try
     {
         presenter.CommandHistory.Add(changedProperty);
     }
     catch (Exception err)
     {
         presenter.MainPresenter.ShowError(err);
     }
     presenter.CommandHistory.ModelChanged += OnModelChanged;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Set the value of the specified property
 /// </summary>
 /// <param name="property">The property to set the value of</param>
 /// <param name="value">The value to set the property to</param>
 private void SetPropertyValue(IVariable property, object value)
 {
     presenter.CommandHistory.ModelChanged -= OnModelChanged;
     try
     {
         ChangeProperty cmd = new ChangeProperty(property.Object, property.Name, value);
         presenter.CommandHistory.Add(cmd);
     }
     catch (Exception err)
     {
         presenter.MainPresenter.ShowError(err);
     }
     presenter.CommandHistory.ModelChanged += OnModelChanged;
 }
Exemplo n.º 10
0
        public void Enabled(object sender, EventArgs e)
        {
            try
            {
                IModel model = explorerPresenter.CurrentNode as IModel;
                if (model != null)
                {
                    // Toggle the enabled property on the model, and change the enabled property
                    // on all descendants to the new value of the model's enabled property.
                    List <ChangeProperty.Property> changes = new List <ChangeProperty.Property>();
                    changes.Add(new ChangeProperty.Property(model, nameof(model.Enabled), !model.Enabled));
                    foreach (IModel child in model.FindAllDescendants())
                    {
                        changes.Add(new ChangeProperty.Property(child, nameof(model.Enabled), !model.Enabled));
                    }

                    ChangeProperty command = new ChangeProperty(changes);
                    explorerPresenter.CommandHistory.Add(command);

                    // Now call OnCreated() for all changed models. Note ToList() to force greedy evaluation.
                    bool showModelStructure = ShowModelStructureChecked();
                    if (model.Enabled)
                    {
                        model.OnCreated();
                        foreach (IModel descendant in model.FindAllDescendants().ToList())
                        {
                            descendant.OnCreated();
                        }
                        if (model is ModelCollectionFromResource)
                        {
                            foreach (IModel child in model.Children)
                            {
                                child.IsHidden = !showModelStructure;
                                if (!showModelStructure)
                                {
                                    explorerPresenter.Tree.Delete(child.FullPath);
                                }
                            }
                        }
                    }

                    explorerPresenter.PopulateContextMenu(explorerPresenter.CurrentNodePath);
                    explorerPresenter.RefreshNode(model);
                }
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 11
0
 /// <summary>Set the value of the graph models property</summary>
 /// <param name="name">The name of the property to set</param>
 /// <param name="value">The value of the property to set it to</param>
 private void SetModelPropertyInAllSeries(string name, object value)
 {
     try
     {
         foreach (var s in series.Parent.FindAllChildren <Series>())
         {
             ChangeProperty command = new ChangeProperty(s, name, value);
             explorerPresenter.CommandHistory.Add(command);
         }
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// User has changed the value of a cell.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void OnCellValueChanged1(object sender, GridCellsChangedArgs e)
 {
     foreach (GridCellChangedArgs cell in e.ChangedCells)
     {
         try
         {
             tables[0] = view.Grid1.DataSource;
             ChangeProperty cmd = new ChangeProperty(tableModel, "Tables", tables);
             presenter.CommandHistory.Add(cmd);
         }
         catch (Exception ex)
         {
             presenter.MainPresenter.ShowError(ex);
         }
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Sets the enabled status of a given list of simulations.
        /// </summary>
        /// <param name="names">Names of the simulations to modify.</param>
        /// <param name="flag">If true, the selected simulations will be enabled. If false, they will be disabled.</param>
        private void ToggleSims(List <string> names, bool flag)
        {
            foreach (string name in names)
            {
                int index = GetSimFromName(name);
                if (simulations[index].Item3 != flag)
                {
                    List <string> data = simulations[index].Item2;
                    simulations[index] = new Tuple <string, List <string>, bool>(name, data, flag);
                }
            }
            UpdateView();
            ChangeProperty changeDisabledSims = new ChangeProperty(model, "DisabledSimNames", GetDisabledSimNames());

            changeDisabledSims.Do(presenter.CommandHistory);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Save the data table
        /// </summary>
        private void SaveTable()
        {
            // It would be better to check what precisely has been changed, but for now,
            // just load all of the UI components into one big ChangeProperty command, and
            // execute the command.
            ChangeProperty changeTemporalData = new ChangeProperty(new List <ChangeProperty.Property>()
            {
                new ChangeProperty.Property(forestryModel, "Table", forestryViewer.SpatialData),
                new ChangeProperty.Property(forestryModel, "Dates", forestryViewer.Dates.ToArray()),
                new ChangeProperty.Property(forestryModel, "Heights", forestryViewer.Heights.ToArray()),
                new ChangeProperty.Property(forestryModel, "NDemands", forestryViewer.NDemands.ToArray()),
                new ChangeProperty.Property(forestryModel, "ShadeModifiers", forestryViewer.ShadeModifiers.ToArray())
            });

            presenter.CommandHistory.ModelChanged -= OnModelChanged;
            presenter.CommandHistory.Add(changeTemporalData);
            presenter.CommandHistory.ModelChanged += OnModelChanged;
        }
Exemplo n.º 15
0
        private static void Run(GameSession.ChangeStateResponse message)
        {
            GameSession.ChangeStateResponse.Types.Success success = message.Success;
            if (success != null)
            {
                ulong heroId        = success.Success_.HeroId;
                ulong previousState = success.Success_.PreviousState;
                ulong currentState  = success.Success_.CurrentState;

                Debug.Log($"ChangeStateResponse: heroid = {heroId}, prestate = {previousState}, curstate = {currentState}");

                if (success.Success_.ExMessage != null && success.Success_.ExMessage.BehaviorMessage != null)
                {
                    ChangeProperty changeProperty = new ChangeProperty();
                    changeProperty.SpacecraftMotionInfo = new SpacecraftMotionInfo()
                    {
                        LineAcceleration              = success.Success_.ExMessage.BehaviorMessage.Force,
                        ReverseLineAcceleration       = success.Success_.ExMessage.BehaviorMessage.Invforce,
                        ResistanceLineAcceleration    = success.Success_.ExMessage.BehaviorMessage.Stopforce,
                        LineVelocityMax               = success.Success_.ExMessage.BehaviorMessage.Maxsp,
                        ReverseLineVelocityMax        = success.Success_.ExMessage.BehaviorMessage.Invmaxsp,
                        AngularAcceleration           = success.Success_.ExMessage.BehaviorMessage.Torque,
                        ResistanceAngularAcceleration = success.Success_.ExMessage.BehaviorMessage.Stoptourque,
                        AngularVelocityMax            = success.Success_.ExMessage.BehaviorMessage.Maxanglespeed,
                        CruiseLeapAcceleration        = success.Success_.ExMessage.BehaviorMessage.Leapforce,
                        CruiseLeapReverseAcceleration = success.Success_.ExMessage.BehaviorMessage.Leapstopforce
                    };

                    //Debug.LogError("OnChangeProperty heroId:" + heroId + " "  + JsonUtility.ToJson(changeProperty));

                    GameplayManager.Instance.GetEntityManager().SendEventToEntity((uint)heroId, ComponentEventName.ChangeProperty, changeProperty);
                    return;
                }

                GameplayManager.Instance.GetEntityManager().SendEventToEntity((uint)heroId, ComponentEventName.G2C_ChangeState, new G2C_ChangeState()
                {
                    EntityId      = heroId,
                    PreviousState = previousState,
                    CurrentState  = currentState,
                    ExData        = success.Success_.ExMessage
                });
            }
        }
Exemplo n.º 16
0
        public void Enabled(object sender, EventArgs e)
        {
            try
            {
                IModel model = explorerPresenter.CurrentNode as IModel;
                if (model != null)
                {
                    // Toggle the enabled property on the model, and change the enabled property
                    // on all descendants to the new value of the model's enabled property.
                    List <ChangeProperty.Property> changes = new List <ChangeProperty.Property>();
                    changes.Add(new ChangeProperty.Property(model, nameof(model.Enabled), !model.Enabled));
                    foreach (IModel child in model.FindAllDescendants())
                    {
                        changes.Add(new ChangeProperty.Property(child, nameof(model.Enabled), !model.Enabled));
                    }

                    ChangeProperty command = new ChangeProperty(changes);
                    explorerPresenter.CommandHistory.Add(command);

                    explorerPresenter.PopulateContextMenu(explorerPresenter.CurrentNodePath);
                    explorerPresenter.RefreshNode(model);
                    explorerPresenter.HideRightHandPanel();
                    explorerPresenter.ShowRightHandPanel();

                    if (model.Enabled)
                    {
                        if (model is Manager manager)
                        {
                            manager.RebuildScriptModel();
                        }
                        foreach (Manager m in model.FindAllDescendants <Manager>())
                        {
                            m.RebuildScriptModel();
                        }
                    }
                }
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// User has changed the value of a cell.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void OnCellValueChanged1(object sender, GridCellsChangedArgs e)
 {
     foreach (IGridCell cell in e.ChangedCells)
     {
         try
         {
             if (e.InvalidValue)
             {
                 throw new Exception("The value you entered was not valid for its datatype.");
             }
             tables[0] = view.Grid1.DataSource;
             ChangeProperty cmd = new ChangeProperty(tableModel, "Tables", tables);
             presenter.CommandHistory.Add(cmd);
         }
         catch (Exception ex)
         {
             presenter.MainPresenter.ShowError(ex);
         }
     }
 }
Exemplo n.º 18
0
        public override void Visit(PropertyNode node, ControlDiffContext context)
        {
            if (!(context.Theirs is PropertyNode theirs))
            {
                return;
            }

            var currentControlKind = context.Path.Current;

            if (TryGetUpdatedCustomPropertyMetadata(currentControlKind, node.Identifier, out var customProperty))
            {
                _deltas.Add(ChangeProperty.GetComponentCustomPropertyChange(context.Path, node.Identifier, node.Expression.Expression, customProperty));
                return;
            }

            if (node.Expression.Expression != theirs.Expression.Expression)
            {
                _deltas.Add(ChangeProperty.GetNormalPropertyChange(context.Path, node.Identifier, node.Expression.Expression));
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Invoked whenever the user modifies the contents of the grid.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="args">Event arguments.</param>
        private void OnGridChanged(object sender, GridCellsChangedArgs args)
        {
            try
            {
                if (args.InvalidValue)
                {
                    throw new Exception("The value you entered was not valid for its datatype.");
                }
                foreach (IGridCell cell in args.ChangedCells)
                {
                    int    index       = GetModelIndex(cell.RowIndex);
                    IModel removalType = Apsim.Child(model, grid.GetCell(0, index).Value.ToString());
                    if (removalType != null)
                    {
                        List <MemberInfo> members  = PropertyPresenter.GetMembers(removalType);
                        MemberInfo        member   = members[cell.RowIndex - index - 1];
                        IVariable         property = null;
                        if (member is PropertyInfo)
                        {
                            property = new VariableProperty(model, member as PropertyInfo);
                        }
                        else if (member is FieldInfo)
                        {
                            property = new VariableField(model, member as FieldInfo);
                        }
                        else
                        {
                            throw new Exception(string.Format("Unable to find property {0} in model {1}", grid.GetCell(0, cell.RowIndex).Value.ToString(), removalType.Name));
                        }
                        object value = PropertyPresenter.FormatValueForProperty(property, cell.Value);

                        ChangeProperty command = new ChangeProperty(removalType, property.Name, value);
                        presenter.CommandHistory.Add(command);
                    }
                }
            }
            catch (Exception err)
            {
                presenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// A node has been deleted. Propagate this change to the model.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event data.</param>
        private void OnDelNode(object sender, DelNodeEventArgs e)
        {
            List <ChangeProperty.Property> changes = new List <ChangeProperty.Property>();

            List <StateNode> newNodes = new List <StateNode>();

            newNodes.AddRange(model.Nodes);
            newNodes.RemoveAll(n => n.Name == e.nodeNameToDelete);
            changes.Add(new ChangeProperty.Property(model, nameof(model.Nodes), newNodes));

            // Need to also delete any arcs going to/from this node.
            List <RuleAction> newArcs = new List <RuleAction>();

            newArcs.AddRange(model.Arcs);
            newArcs.RemoveAll(a => a.DestinationName == e.nodeNameToDelete || a.SourceName == e.nodeNameToDelete);
            changes.Add(new ChangeProperty.Property(model, nameof(model.Arcs), newArcs));

            ICommand removeNode = new ChangeProperty(changes);

            presenter.CommandHistory.Add(removeNode);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Set the value of the specified property
        /// </summary>
        /// <param name="property">The property to set the value of</param>
        /// <param name="value">The value to set the property to</param>
        private void SetPropertyValue(IVariable property, object value)
        {
            presenter.CommandHistory.ModelChanged -= OnModelChanged;
            try
            {
                ChangeProperty cmd = new ChangeProperty(property.Object, property.Name, value);
                presenter.CommandHistory.Add(cmd);
            }
            catch (Exception err)
            {
                presenter.MainPresenter.ShowError(err);
            }
            presenter.CommandHistory.ModelChanged += OnModelChanged;

            for (int i = 0; i < properties.Count; i++)
            {
                IGridCell cell = grid.GetCell(1, i);
                cell.IsRowReadonly = !IsPropertyEnabled(i);
            }
            grid.Refresh();
        }
Exemplo n.º 22
0
 /// <summary>
 /// The depth of wet soil field in the view has changed.
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void OnDepthWetSoilChanged(object sender, EventArgs e)
 {
     try
     {
         double depthOfWetSoil;
         if (initialWaterView.DepthOfWetSoil == int.MinValue)
         {
             depthOfWetSoil = Double.NaN;
         }
         else
         {
             depthOfWetSoil = Convert.ToDouble(initialWaterView.DepthOfWetSoil, System.Globalization.CultureInfo.InvariantCulture) * 10; // cm to mm
         }
         ChangeProperty command = new ChangeProperty(initialWater, "DepthWetSoil", depthOfWetSoil);
         explorerPresenter.CommandHistory.Add(command);
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Exemplo n.º 23
0
        public void ReadOnly(object sender, EventArgs e)
        {
            try
            {
                IModel model = Apsim.Get(explorerPresenter.ApsimXFile, explorerPresenter.CurrentNodePath) as IModel;
                if (model == null)
                {
                    return;
                }

                // Don't allow users to change read-only status of released models.
                if (Apsim.Parent(model, typeof(ModelCollectionFromResource)) is ModelCollectionFromResource)
                {
                    return;
                }

                bool readOnly = !model.ReadOnly;
                List <ChangeProperty.Property> changes = new List <ChangeProperty.Property>();

                // Toggle read-only on the model and all descendants.
                changes.Add(new ChangeProperty.Property(model, nameof(model.ReadOnly), readOnly));
                foreach (IModel child in Apsim.ChildrenRecursively(model))
                {
                    changes.Add(new ChangeProperty.Property(child, nameof(child.ReadOnly), readOnly));
                }

                // Apply changes.
                ChangeProperty command = new ChangeProperty(changes);
                explorerPresenter.CommandHistory.Add(command);

                // Refresh the context menu.
                explorerPresenter.PopulateContextMenu(explorerPresenter.CurrentNodePath);
                explorerPresenter.Refresh();
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 24
0
        /// <summary>The user has changed the commands</summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event arguments</param>
        private void OnCommandsChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.view.Lines != this.cultivar.Command)
                {
                    this.explorerPresenter.CommandHistory.ModelChanged -= this.OnModelChanged;

                    if (!cultivar.Command.SequenceEqual(view.Lines))
                    {
                        ChangeProperty command = new ChangeProperty(cultivar, nameof(cultivar.Command), this.view.Lines);
                        explorerPresenter.CommandHistory.Add(command);
                    }

                    explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;
                }
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 25
0
        public void Enabled(object sender, EventArgs e)
        {
            try
            {
                IModel model = explorerPresenter.ApsimXFile.FindByPath(explorerPresenter.CurrentNodePath)?.Value as IModel;
                if (model != null)
                {
                    // Toggle the enabled property on the model, and change the enabled property
                    // on all descendants to the new value of the model's enabled property.
                    List <ChangeProperty.Property> changes = new List <ChangeProperty.Property>();
                    changes.Add(new ChangeProperty.Property(model, nameof(model.Enabled), !model.Enabled));
                    foreach (IModel child in model.FindAllDescendants())
                    {
                        changes.Add(new ChangeProperty.Property(child, nameof(model.Enabled), !model.Enabled));
                    }

                    ChangeProperty command = new ChangeProperty(changes);
                    explorerPresenter.CommandHistory.Add(command);

                    // Now call OnCreated() for all changed models. Note ToList() to force greedy evaluation.
                    if (model.Enabled)
                    {
                        model.OnCreated();
                        foreach (IModel descendant in model.FindAllDescendants().ToList())
                        {
                            descendant.OnCreated();
                        }
                    }

                    explorerPresenter.PopulateContextMenu(explorerPresenter.CurrentNodePath);
                    explorerPresenter.Refresh();
                }
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// The filled from top field in the view has changed.
        /// </summary>
        /// <param name="sender">Sender of event</param>
        /// <param name="e">Event arguments</param>
        private void OnFilledFromTopChanged(object sender, EventArgs e)
        {
            try
            {
                InitialWater.PercentMethodEnum percentMethod;
                if (initialWaterView.FilledFromTop)
                {
                    percentMethod = InitialWater.PercentMethodEnum.FilledFromTop;
                }
                else
                {
                    percentMethod = InitialWater.PercentMethodEnum.EvenlyDistributed;
                }

                ChangeProperty command = new ChangeProperty(initialWater, "PercentMethod", percentMethod);

                explorerPresenter.CommandHistory.Add(command);
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 27
0
    private void OnChangeProperty(IComponentEvent obj)
    {
        ChangeProperty changeProperty = obj as ChangeProperty;

        RefreshSpacecraftMotionState(changeProperty);
    }
Exemplo n.º 28
0
        /// <summary>
        /// Get data from the weather file and present it to the view as both a table and a summary
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="sheetName">The name of the sheet</param>
        private void WriteTableAndSummary(string filename, string sheetName = "")
        {
            // Clear any previos error message
            this.explorerPresenter.MainPresenter.ShowMessage(" ", Simulation.MessageType.Information);
            // Clear any previous summary
            this.weatherDataView.Summarylabel = string.Empty;
            this.weatherDataView.GraphSummary.Clear();
            this.weatherDataView.GraphSummary.Refresh();
            this.weatherDataView.GraphRainfall.Clear();
            this.weatherDataView.GraphRainfall.Refresh();
            this.weatherDataView.GraphMonthlyRainfall.Clear();
            this.weatherDataView.GraphMonthlyRainfall.Refresh();
            this.weatherDataView.GraphTemperature.Clear();
            this.weatherDataView.GraphTemperature.Refresh();
            this.weatherDataView.GraphRadiation.Clear();
            this.weatherDataView.GraphRadiation.Refresh();
            this.graphMetData = new DataTable();
            if (filename != null)
            {
                this.weatherDataView.Filename = PathUtilities.GetAbsolutePath(filename, this.explorerPresenter.ApsimXFile.FileName);
                try
                {
                    if (ExcelUtilities.IsExcelFile(filename))
                    {
                        // Extend height of Browse Panel to show Drop Down for Sheet names
                        this.weatherDataView.ShowExcelSheets(true);
                        if (this.sheetNames == null)
                        {
                            this.sheetNames = ExcelUtilities.GetWorkSheetNames(filename);
                            this.weatherDataView.ExcelSheetChangeClicked -= this.ExcelSheetValueChanged;
                            this.weatherDataView.PopulateDropDownData(this.sheetNames);
                            this.weatherDataView.ExcelSheetChangeClicked += this.ExcelSheetValueChanged;
                        }
                    }
                    else
                    {
                        // Shrink Browse Panel so that the sheet name dropdown doesn't show
                        this.weatherDataView.ShowExcelSheets(false);
                    }

                    ViewBase.MasterView.WaitCursor = true;
                    try
                    {
                        this.weatherData.ExcelWorkSheetName = sheetName;
                        string newFileName = PathUtilities.GetAbsolutePath(filename, this.explorerPresenter.ApsimXFile.FileName);
                        var    changes     = new List <ChangeProperty.Property>();
                        if (weatherData.FullFileName != newFileName)
                        {
                            changes.Add(new ChangeProperty.Property(weatherData, nameof(weatherData.FullFileName), newFileName));
                        }
                        // Set constants file name to null iff the new file name is not a csv file.
                        if (Path.GetExtension(newFileName) != ".csv" && weatherData.ConstantsFile != null)
                        {
                            changes.Add(new ChangeProperty.Property(weatherData, nameof(weatherData.ConstantsFile), null));
                        }
                        if (changes.Count > 0)
                        {
                            ICommand changeFileName = new ChangeProperty(changes);
                            explorerPresenter.CommandHistory.Add(new ChangeProperty(changes));
                        }
                        using (DataTable data = this.weatherData.GetAllData())
                        {
                            this.dataStartDate = this.weatherData.StartDate;
                            this.dataEndDate   = this.weatherData.EndDate;
                            this.WriteTable(data);
                            this.WriteSummary(data);
                            this.DisplayDetailedGraphs(data);
                        }
                    }
                    catch (Exception err)
                    {
                        explorerPresenter.MainPresenter.ShowError(err);
                    }
                    finally
                    {
                        ViewBase.MasterView.WaitCursor = false;
                        this.weatherData.CloseDataFile();
                    }
                }
                catch (Exception err)
                {
                    string message = err.Message;
                    message += "\r\n" + err.StackTrace;
                    this.weatherDataView.Summarylabel = err.Message;
                    this.explorerPresenter.MainPresenter.ShowError(err);
                }
            }

            // this.weatherDataView.Filename = PathUtilities.GetRelativePath(filename, this.explorerPresenter.ApsimXFile.FileName);
            this.weatherDataView.Filename           = PathUtilities.GetAbsolutePath(filename, this.explorerPresenter.ApsimXFile.FileName);
            this.weatherDataView.ConstantsFileName  = weatherData.ConstantsFile;
            this.weatherDataView.ExcelWorkSheetName = sheetName;
        }
Exemplo n.º 29
0
        private void OnErrorCheckBoxChanged(object sender, EventArgs e)
        {
            ChangeProperty command = new ChangeProperty(summaryModel, "CaptureErrors", summaryView.ErrorCheckBox.IsChecked);

            explorerPresenter.CommandHistory.Add(command);
        }
Exemplo n.º 30
0
    private void RefreshSpacecraftMotionState(ChangeProperty changeProperty = null)
    {
        InitializeMovionAttribute();
        if (m_Property.GetCurrentState().IsHasSubState(EnumSubState.Overload))
        {
            m_CurrentMotionInfo = m_OverloadModeMotionInfo;
        }
        else if (m_Property.GetCurrentState().GetMainState() == EnumMainState.Fight)
        {
            m_CurrentMotionInfo = m_FightModeMotionInfo;
        }
        else
        {
            m_CurrentMotionInfo = m_CruiseModeMotionInfo;
        }

        /// 6dof运动类型使用过载运动参数
        if (m_Property.GetMotionType() == MotionType.Dof6)
        {
            m_CurrentMotionInfo = m_OverloadModeMotionInfo;
        }

        SendEvent(ComponentEventName.RefreshSpacecraftMimesisData, new RefreshSpacecraftMimesisDataEvent()
        {
            MimesisData = m_CurrentMotionInfo.MimesisData
        });

        if (changeProperty != null)
        {
            m_CurrentMotionInfo = changeProperty.SpacecraftMotionInfo;
        }

        m_Property.SetCurrentSpacecraftMotionInfo(m_CurrentMotionInfo);

        m_BehaviorController.InitBehaviorAbility(
            m_CurrentMotionInfo.LineAcceleration,
            m_CurrentMotionInfo.ReverseLineAcceleration,
            m_CurrentMotionInfo.ResistanceLineAcceleration,
            m_CurrentMotionInfo.LineVelocityMax,
            m_CurrentMotionInfo.ReverseLineVelocityMax,
            m_CurrentMotionInfo.AngularAcceleration,
            m_CurrentMotionInfo.ResistanceAngularAcceleration,
            m_CurrentMotionInfo.AngularVelocityMax,
            m_CurrentMotionInfo.CruiseLeapAcceleration,
            m_CurrentMotionInfo.CruiseLeapReverseAcceleration
            );

        if (m_Property.GetHeroType() == KHeroType.htPlayer)
        {
            switch (m_Property.GetMotionType())
            {
            case MotionType.Mmo:
                if (m_BehaviorController.HasBehaviorType(BehaviorController.BehaviorType.BT_WorldForceCtlMove))
                {
                    m_BehaviorController.WorldForceControlMove(m_EngineAxis, m_cameraRotate);
                }
                break;

            case MotionType.Dof4:
                if (m_BehaviorController.HasBehaviorType(BehaviorController.BehaviorType.BT_4DOFForwardMove))
                {
                    m_BehaviorController.DOF4ForwardMove(m_EngineAxis, m_cameraRotate);
                }
                break;

            case MotionType.Dof6:
                if (m_BehaviorController.HasBehaviorType(BehaviorController.BehaviorType.BT_6DOFForwardMove))
                {
                    m_BehaviorController.DOF6ForwardMove(m_EngineAxis, m_cameraRotate);
                }
                break;

            default:
                break;
            }
        }
    }