コード例 #1
0
        private void RunClock()
        {
            if (Plans.Count == 0)
            {
                return;
            }
            if (IsSavedRecord == true)
            {
                if (RecordName != "" || RecordName != null)
                {
                    using (MyDBContext db = new MyDBContext())
                    {
                        db.Records.Add(new Model.Record()
                        {
                            Name = RecordName, IsSaved = true, Today = DateTime.Today.Date
                        });
                        db.SaveChanges();
                        var rid = (from r in db.Records
                                   where r.Today == DateTime.Today.Date
                                   select r.RID).FirstOrDefault();
                        foreach (var p in Plans)
                        {
                            db.Plans.Add(new Model.Plan()
                            {
                                RID = rid, BID = (p.Ban == null?0:p.Ban.BID), StartTime = p.StartTime, EndTime = p.EndTime, Tip = p.Tip
                            });
                        }
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                using (MyDBContext db = new MyDBContext())
                {
                    db.Records.Add(new Model.Record()
                    {
                        Today = DateTime.Today.Date
                    });
                    db.SaveChanges();
                    var rid = (from r in db.Records
                               where r.Today == DateTime.Today.Date
                               select r.RID).FirstOrDefault();
                    foreach (var p in Plans)
                    {
                        db.Plans.Add(new Model.Plan()
                        {
                            RID = rid, BID = (p.Ban == null ? 0 : p.Ban.BID), StartTime = p.StartTime, EndTime = p.EndTime, Tip = p.Tip
                        });
                    }
                    db.SaveChanges();
                }
            }
            RunWindow runWindow = new RunWindow();

            runWindow.Show();
            OnCloseView();
        }
コード例 #2
0
        /// <summary>
        /// Crée un nouvel objet et affiche la view d'édition
        /// </summary>
        /// <returns>
        /// OperationState.CONTINUE si la création a réussi
        /// OperationState.STOP sinon
        /// </returns>
        public OperationState Create()
        {
            List <InputTableBrowserData> items = this.Service.getRunnedTableBrowserDatas();

            if (items.Count > 0)
            {
                runWindow       = new RunWindow(false);
                runWindow.Owner = ApplicationManager.MainWindow;
                runWindow.initializeGroup(this.Service);
                runWindow.SetRunClearLabel("Clear");
                runWindow.Controller = this;
                runWindow.Service    = this.Service;
                runWindow.DisplayDatas(items);
                runWindow.ShowDialog();
            }
            else
            {
                MessageDisplayer.DisplayInfo("Clear Grid/Table", "There is no runned Grid/Table!");
            }
            return(OperationState.CONTINUE);
            //   return Clear();
        }
コード例 #3
0
        private void SetupRunButton(LayoutDocument document)
        {
            var modelSystem = document.Content as ModelSystemDisplay;

            RunMenu.IsEnabled  = false;
            RunLabel.IsEnabled = false;
            if (modelSystem != null)
            {
                var session = modelSystem.Session;
                if (session.CanRun)
                {
                    RunMenu.IsEnabled  = true;
                    RunLabel.IsEnabled = true;
                    _CurrentRun        = () =>
                    {
                        var           runName    = "Run Name";
                        StringRequest req        = new StringRequest("Run Name", ValidateName);
                        var           trueWindow = Window.GetWindow(document.Content as DependencyObject);
                        var           testWindow = GetWindow(document.Content as DependencyObject);
                        var           vis        = document.Content as UserControl;
                        if (vis != null && testWindow != trueWindow)
                        {
                            var topLeft = vis.PointToScreen(new Point());
                            // Since the string request dialog isn't shown yet we need to use some defaults as width and height are not available.
                            req.Left = topLeft.X + ((vis.ActualWidth - StringRequest.DefaultWidth) / 2);
                            req.Top  = topLeft.Y + ((vis.ActualHeight - StringRequest.DefaultHeight) / 2);
                        }
                        else
                        {
                            req.Owner = trueWindow;
                        }
                        if (req.ShowDialog() == true)
                        {
                            runName = req.Answer;
                            string error = null;
                            var    run   = session.Run(runName, ref error);
                            if (run != null)
                            {
                                RunWindow window = new RunWindow(session, run, runName);
                                var       doc    = AddNewWindow("New Run", window);
                                doc.Closing += (o, e) =>
                                {
                                    if (!window.CloseRequested())
                                    {
                                        e.Cancel = true;
                                        return;
                                    }
                                };
                                doc.CanClose   = true;
                                doc.IsSelected = true;
                                Keyboard.Focus(window);
                                window.Focus();
                            }
                            else
                            {
                                MessageBox.Show(this, error, "Unable to run", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                    };
                }
            }
        }