예제 #1
0
        private void btnSaveAsSimulation_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                logger.Info("Guardar Simulación.");
                using (var saveFileDialog = new SaveFileDialog())
                {
                    saveFileDialog.Filter           = "Vic files (*.vic)|*.vic";
                    saveFileDialog.Title            = "Guardar Simulacion";
                    saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ((MainViewModel)this.DataContext).SaveSimulationCommand.Execute(saveFileDialog.FileName);
                    }
                }
                //this.PopupGuardar.IsOpen = false;
            }
            catch (Exception ex)
            {
                var viewException = new AlertPopUp("Se produjo un error al guardar la simulación. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
                //logger.Error("Se produjo un error al guardar la simulación: " + ex.Message);
            }
        }
예제 #2
0
        private void btnExportarSimulacion_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                logger.Info("Exportar Simulación");
                using (var saveFileDialog = new SaveFileDialog())
                {
                    saveFileDialog.Filter           = "Excel files (*.xlsx)|*.xlsx|PDF files (*.pdf)|*.pdf";
                    saveFileDialog.Title            = "Exportar Simulacion";
                    saveFileDialog.InitialDirectory = Environment.CurrentDirectory;

                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ((MainViewModel)this.DataContext).ExportSimulationCommand.Execute(saveFileDialog.FileName);
                    }
                }

                //logger.Info("Fin Exportar Simulación");
            }
            catch (Exception ex)
            {
                var viewException = new AlertPopUp("Se produjo un error al exportar la simulación. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
                //logger.Error("Se produjo un error al exportar la simulación:" + ex.Message);
            }
        }
예제 #3
0
        private void BtnAddChart_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                //logger.Info("Inicio Agregar gráfico");
                List <object> parameters = new List <object>();

                var addChartPopUp = new AddChartPopUp();
                foreach (var variable in ((StageViewModel)this.DataContext).Variables)
                {
                    variable.IsSelected = false;
                }
                addChartPopUp.DataContext = this.DataContext;
                addChartPopUp.ShowDialog();
                switch (addChartPopUp.Result)
                {
                case UI.SharedWPF.DialogResult.Accept:
                {
                    parameters.Add(addChartPopUp.ChartName);
                    parameters.Add(((StageViewModel)this.DataContext).Variables.Where(v => v.IsSelected).ToList());
                    ((StageViewModel)this.DataContext).AddChartCommand.Execute(parameters);
                }
                break;
                }
                //logger.Info("Fin Agregar gráfico");
            }
            catch
            {
                //logger.Error("Se produjo un error al Agregar un gráfico.");
                var viewException = new AlertPopUp("Se produjo un error al agregar un gráfico. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
            }
        }
예제 #4
0
        private void btnAddStage_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                logger.Info("Agregar un escenario.");

                var addStagePopUp = new AddStageWindow();
                addStagePopUp.ShowDialog();
                switch (addStagePopUp.Result)
                {
                case UI.SharedWPF.DialogResult.Accept:
                {
                    ((MainViewModel)this.DataContext).AddStageCommand.Execute(addStagePopUp.StageName);
                }
                break;
                }

                //logger.Info("Fin agregar un escenario.");
            }
            catch (Exception ex)
            {
                var viewException = new AlertPopUp("Se produjo un error al agregar un escenario. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
                //logger.Error("Se produjo un error al agregar un escenario: " + ex.Message);
            }
        }
예제 #5
0
        private void btnExportStage_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                //logger.Info("Inicio Exportar Escenario");
                using (var saveFileDialog = new System.Windows.Forms.SaveFileDialog())
                {
                    saveFileDialog.Filter           = "Excel files (*.xlsx)|*.xlsx|PDF files (*.pdf)|*.pdf";
                    saveFileDialog.Title            = "Exportar Simulacion";
                    saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ((StageViewModel)this.DataContext).ExportStageCommand.Execute(saveFileDialog.FileName);
                    }
                }

                logger.Info("Se ha realizado la exportación del escenario.");
                //logger.Info("Fin Exportar Escenario");
            }
            catch (Exception ex)
            {
                //logger.Error("Se produjo un error al exportar el escenario");
                var viewException = new AlertPopUp("Se produjo un error al exportar el escenario. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
            }
        }
예제 #6
0
        private void BtnExecute_Animations(object sender, RoutedEventArgs e)
        {
            //logger.Info("Inicio Ejecutar Animaciones");
            var hasVectorVariable = (((StageViewModel)this.DataContext).Variables.Any(v => v.Name.Contains("(")));

            if ((((StageViewModel)this.DataContext).Variables.First(v => v.Name == "T").Values.Any() &&
                 ((StageViewModel)this.DataContext).Animations.Any()) || (hasVectorVariable && ((StageViewModel)this.DataContext).Animations.Any()))
            {
                try
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        var animationsToExecute = this.CreateAnimationsClones(((StageViewModel)this.DataContext).Animations);
                        var animationWindow     = new AnimationExecutionWindow(animationsToExecute);

                        animationWindow.Show();
                    }));
                }
                catch
                {
                    //logger.Error("Se produjo un error al intentar ejecutar las animaciones. Por favor revisa la configuracion de las mismas.");
                    var viewException = new AlertPopUp("Se produjo un error al intentar ejecutar las animaciones. Por favor revisa la configuración de las mismas.");
                    viewException.ShowDialog();
                }
            }
            else
            {
                //logger.Error("No se puede abrir la ventana de animaciones si no se ha ejecutado la simulación o no se han creado animaciones.");
                var viewException = new AlertPopUp("No se puede abrir la ventana de animaciones si no se ha ejecutado la simulación o no se han creado animaciones.");
                viewException.ShowDialog();
            }
            //logger.Info("Fin Ejecutar Animaciones");
        }
 private CanvasManager InitializeAlertPopUp()
 {
     GameObject alertPopUp = SRResources.Core.UI.AlertPopUp.Instantiate();
     alertPopUp.transform.SetParent(gameObject.transform,false);
     _alertPopUp = alertPopUp.GetComponent<AlertPopUp>();
     _alertPopUp.Initialize();
     return this;
 }
예제 #8
0
    private MenuCanvas InitializeAlertPopUp()
    {
        GameObject alertPopUp = SRResources.Core.UI.AlertPopUp.Instantiate();

        alertPopUp.transform.SetParent(gameObject.transform, false);
        _alertPopUp = alertPopUp.GetComponent <AlertPopUp>();
        _alertPopUp.Initialize();
        return(this);
    }
예제 #9
0
 public void stopDebug()
 {
     try
     {
         ((MainViewModel)this.DataContext).StopDebugCommand.Execute(null);
     }
     catch (Exception ex)
     {
         var viewException = new AlertPopUp("Se produjo un error al parar la simulacion");
         viewException.ShowDialog();
     }
 }
예제 #10
0
 private void BtnDeleteChart_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         //logger.Info("Inicio Eliminar Gráfico");
         ((StageViewModel)this.DataContext).DeleteChartCommand.Execute(null);
         //logger.Info("Fin Eliminar Grafico");
     }
     catch
     {
         //logger.Error("Se produjo un error al eliminar un gráfico");
         var viewException = new AlertPopUp("Se produjo un error al eliminar un gráfico. Para ver detalles, despliegue el control correspondiente.");
         viewException.ShowDialog();
     }
 }
예제 #11
0
 private void btnSaveSimulation_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         logger.Info("Guardar Simulacion.");
         ((MainViewModel)this.DataContext).SaveSimulationCommand.Execute(null);
         //this.PopupGuardar.IsOpen = false;
     }
     catch (Exception ex)
     {
         var viewException = new AlertPopUp("Se produjo un error al guardar la simulación. Para ver datalles, despliegue el control correspondiente.");
         viewException.ShowDialog();
         //logger.Error("Se produjo un error al guardar la simulación: " + ex.Message);
     }
 }
예제 #12
0
 private void BtnStopExecutionStageCommand_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         //logger.Info("Inicio ejecutar Escenario");
         ((StageViewModel)this.DataContext).StopExecutionStageCommand.Execute(null);
         //logger.Info("Fin Ejecutar Escenario");
     }
     catch
     {
         logger.Error("Se produjo un error al detener la ejecución del escenario");
         var viewException = new AlertPopUp("Se produjo un error al ejecutar el escenario. Para ver detalles, despliegue el control correspondiente.");
         viewException.ShowDialog();
     }
 }
예제 #13
0
        void DesignerItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None)
            {
                if (!Debug.instance().debugModeOn) //Evita agregar breakpoints cuando estoy debugueando
                {
                    try
                    {
                        Grid    grid   = (Grid)this.Content;
                        Path    shape  = (Path)grid.Children[0];
                        TextBox txtBox = (TextBox)grid.Children[1];

                        if (lstNodesToBreakpoint.Contains(shape.ToolTip.ToString()))
                        {
                            //Cambio color del borde a rojo para indicar breakpoint
                            if (!this.hasBreakpoint)
                            {
                                this.originalColor = shape.Stroke;
                                changeColor(this, Brushes.Red);
                                nodesWithBreakPoints.Add(this);
                                nodesWithoutBreakPoints.Remove(this);
                                logger.Info(String.Format("[BREAKPOINT] Tipo de Nodo:'{0}'; Texto: '{1}'.", grid.ToolTip, txtBox.Text));
                            }
                            else
                            {
                                changeColor(this, this.originalColor);
                                nodesWithBreakPoints.Remove(this);
                                nodesWithoutBreakPoints.Add(this);
                            }

                            grid.Tag = ToogleBreakPoint();
                        }
                    }
                    catch (Exception ex)
                    {
                        //Console.WriteLine("No puede agregarse un breakpoint a este nodo");
                        logger.Error("No puede agregarse un breakpoint a este nodo");
                        AlertPopUp alert = new AlertPopUp("No puede agregarse un breakpoint a este nodo");
                        alert.Show();
                    }
                }
                else
                {
                    BreakpointPopUp bkpMessage = new BreakpointPopUp("No puede agregar breakpoints con modo debug activado");
                    bkpMessage.ShowDialog();
                }
            }
        }
예제 #14
0
        private void btnOpenSimulation_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                logger.Info("Abrir Simulacion.");
                if (((MainViewModel)this.DataContext).IsSimulationOpen)
                {
                    var closeSimulationDialog = new CloseSimulationDialog();
                    closeSimulationDialog.ShowDialog();

                    switch (closeSimulationDialog.Result)
                    {
                    case UI.SharedWPF.DialogResult.SaveAndClose:
                    {
                        ((MainViewModel)this.DataContext).SaveSimulationCommand.Execute(null);
                    }
                    break;

                    case UI.SharedWPF.DialogResult.Cancel:
                    {
                        return;
                    }
                    }

                    ((MainViewModel)this.DataContext).DeleteAllStages();
                }

                using (var openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Filter           = "Vic files (*.vic)|*.vic";
                    openFileDialog.Title            = "Abrir Simulacion";
                    openFileDialog.InitialDirectory = Environment.CurrentDirectory;
                    if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        //validar que el xml sea valido sino error.
                        ((MainViewModel)this.DataContext).OpenSimulationCommand.Execute(openFileDialog.FileName);
                    }
                }

                //logger.Info("Fin abrir Simulacion.");
            }
            catch (Exception ex)
            {
                var viewException = new AlertPopUp("Se produjo un error al abrir la simulación. Para obtener más detalles despligue el control.");
                viewException.ShowDialog();
                //logger.Error("Se produjo un error al abrir la simulación: " + ex.Message);
            }
        }
예제 #15
0
 private void BtnExecute_Animations(object sender, RoutedEventArgs e)
 {
     try
     {
         logger.Info("Ejecutar Animaciones");
         ((AnimationExecutionViewModel)this.DataContext).ExecuteButtonEnabled = false;
         ((AnimationExecutionViewModel)this.DataContext).ExecuteAnimationsCommand.Execute(null);
         //logger.Info("Fin Crear copia de variable");
     }
     catch (Exception ex)
     {
         var viewException = new AlertPopUp("Se produjo un error al intentar ejecutar las animaciones. Por favor revisa la configuración de las mismas.");
         //logger.Error("Se produjo un error al intentar ejecutar las animaciones:" + ex.Message);
         viewException.ShowDialog();
     }
 }
예제 #16
0
        private void BtnAddAnimation_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                //logger.Info("Inicio Agregar Animación");
                if (!((StageViewModel)this.DataContext).DllConfigurations.Any())
                {
                    //logger.Error("No se encontraron animaciones disponbles. Revise la configuración de Victoria");
                    var viewException = new AlertPopUp("No se encontraron animaciones disponibles. Revise la configuración de Victoria.");
                    viewException.ShowDialog();
                    return;
                }

                var dllConfigurationsClone = new List <AnimationConfigurationBase>();
                foreach (var config in ((StageViewModel)this.DataContext).DllConfigurations)
                {
                    var newDllConfig = Activator.CreateInstance(config.GetType(), config.Variables) as AnimationConfigurationBase;
                    dllConfigurationsClone.Add(newDllConfig);
                }

                var addAnimationPopUp = new AddAnimationPopUp(((StageViewModel)this.DataContext).Variables, dllConfigurationsClone);

                addAnimationPopUp.ShowDialog();
                switch (addAnimationPopUp.Result)
                {
                case UI.SharedWPF.DialogResult.Accept:
                {
                    List <object> parameters = new List <object>();

                    parameters.Add(addAnimationPopUp.ResultConfig);
                    parameters.Add(((StageViewModel)this.DataContext).DllAnimations);

                    ((StageViewModel)this.DataContext).AddAnimationToCanvasCommand.Execute(parameters);
                }
                break;
                }
                //logger.Info("Fin Agregar Animación");

                logger.Info("Se ha incorporado una nueva animación.");
            }
            catch
            {
                //logger.Error("Se produjo un error al agregar una animación");
                var viewException = new AlertPopUp("Se produjo un error al agregar una animación. Para ver detalles, despliegue el control correspondiente.");
                viewException.ShowDialog();
            }
        }
예제 #17
0
 public void executeSimulation(bool debugginMode)
 {
     try
     {
         if (debugginMode)
         {
             ((MainViewModel)this.DataContext).DebugSimulationCommand.Execute(null);
         }
         else
         {
             ((MainViewModel)this.DataContext).ExecuteSimulationCommand.Execute(null);
         }
     }
     catch (Exception ex)
     {
         var viewException = new AlertPopUp("Se produjo un error al ejecutar la simulación. Para ver detalles, despliegue el control correspondiente.");
         viewException.ShowDialog();
         //logger.Error("Se produjo un error al ejecutar la simulacón: " + ex.Message);
     }
 }
예제 #18
0
    public static void RequestAlert(string statement, string ok)
    {
        AlertPopUp alert = GameObject.Find("AlertPopUp").GetComponent <AlertPopUp>();

        alert.SetAlert(statement, ok);
    }