Exemplo n.º 1
0
        /// <summary>
        /// Executes the command.
        /// Execute CopyCmd and PasteCmd until cancelled.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            services.Run(new CopyCmd());
            PasteCmd cmd;

            do
            {
                services.Run(cmd = new PasteCmd());
                services.Model.ChangeModel();
            }while (cmd.ObjectCount > 0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the command.
        /// Opens the Open File Dialog and Loads the selected tsm file.
        /// Asks to save changes if needed.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            if (services.Model.Modified)
            {
                DialogResult dr = MessageBox.Show(Culture.Get("askSaveChangesAndExit"), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                if (dr == DialogResult.Cancel)
                {
                    return;
                }
                else if (dr == DialogResult.Yes)
                {
                    services.Run(new SaveModelCmd());
                }
            }
            string path = "";

            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.Filter       = "Treu Structure Model (*.tsm)|*.tsm";
            dlg.DefaultExt   = "tsm";
            dlg.AddExtension = true;
            dlg.Title        = Culture.Get("OpenFileTitle");
            if (services.Model.CurrentPath.Length > 0)
            {
                dlg.FileName = services.Model.CurrentPath;
            }
            dlg.CheckPathExists = true;
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                path = dlg.FileName;
            }
            try
            {
                if (path.Length > 0)
                {
                    services.Model.Load(path);
                }
            }
            catch
            {
                MessageBox.Show(Culture.Get("errorLoadingFile") + " " + path, Culture.Get("error"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the command.
        /// Asks to save changes if needed and Resets the current Model.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            try
            {
                if (services.Model.Modified)
                {
                    DialogResult dr = MessageBox.Show(Culture.Get("askSaveChangesAndExit"), Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                    else if (dr == DialogResult.Yes)
                    {
                        services.Run(new SaveModelCmd());
                    }
                }

                services.Model.Reset();
            }
            catch (Exception)
            {
                MessageBox.Show("Error creating new file.");
            }
        }
Exemplo n.º 4
0
 private void addAnalysisCaseButton_Click(object sender, EventArgs e)
 {
     services.Run(new Commands.Load.AddLoadCaseCmd());
     UpdateDialog();
 }