protected virtual void OnItemModifing(ItemUpdatedEventArgs <T> e)
 {
     if (ItemModifing != null)
     {
         ItemModifing(this, e);
     }
 }
 protected virtual void OnItemAdded(ItemUpdatedEventArgs <T> e)
 {
     if (ItemAdded != null)
     {
         ItemAdded(this, e);
     }
 }
        private void Instance_ItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            if (e.PrimaryKeys.Count > 0)
            {
                if (cboExistTemplates.Enabled == true && cboExistTemplates.SelectedItem is AssessmentSetupRecord)
                {
                    AssessmentSetupRecord source = cboExistTemplates.SelectedItem as AssessmentSetupRecord;
                    bool executeRequired         = false;

                    List <AEIncludeRecordEditor> aeincludeEditors = new List <AEIncludeRecordEditor>();
                    foreach (var each in source.GetAEIncludes())
                    {
                        AEIncludeRecordEditor aeincludeEditor = AEInclude.Instance.AddAEInclude();
                        aeincludeEditor.RefAssessmentSetupID = e.PrimaryKeys[0];
                        aeincludeEditor.RefExamID            = each.RefExamID;
                        aeincludeEditor.UseScore             = each.UseScore;
                        aeincludeEditor.UseText   = each.UseText;
                        aeincludeEditor.UseEffort = each.UseEffort;
                        aeincludeEditor.Weight    = each.Weight;
                        aeincludeEditor.StartTime = each.StartTime;
                        aeincludeEditor.EndTime   = each.EndTime;

                        aeincludeEditors.Add(aeincludeEditor);
                        executeRequired = true;
                    }
                    if (executeRequired)
                    {
                        aeincludeEditors.SaveAllEditors();
                    }
                }
            }
            AssessmentSetup.Instance.ItemUpdated -= new EventHandler <ItemUpdatedEventArgs>(Instance_ItemUpdated);
        }
Exemplo n.º 4
0
        void NotificationListItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            CustomNotification notification = e.Item as CustomNotification;

            if (notification.RequiresMonitoring())
            {
                if (notification.Enabled)
                {
                    if (notification.Running)
                    {
                        log.DebugFormat("Notification {0} restarting", notification.ToString());
                        notification.Stop();
                    }
                    else
                    {
                        log.DebugFormat("Notification {0} starting", notification.ToString());
                    }
                    notification.Start();
                }
                else if (notification.Running)
                {
                    log.DebugFormat("Notification {0} stopping", notification.ToString());
                    notification.Stop();
                }
            }
        }
        public void EventsArgsBufferedTest()
        {
            using (var temp = TempDirectory.Create())
            {
                ItemCollectionChangedEventArgs <DatabaseObject> itemColArgs    = null;
                ItemUpdatedEventArgs <DatabaseObject>           itemUpdateArgs = null;
                var col = new ItemCollection <DatabaseObject>(temp.TempPath);
                col.ItemUpdated           += (e, args) => itemUpdateArgs = args;
                col.ItemCollectionChanged += (e, args) => itemColArgs = args;
                var item = new DatabaseObject();

                col.BeginBufferUpdate();
                col.Add(item);
                col.Update(item);
                col.Update(item);
                col.Remove(item);
                Assert.IsNull(itemColArgs);
                Assert.IsNull(itemUpdateArgs);

                col.EndBufferUpdate();
                Assert.AreEqual(1, itemColArgs.AddedItems.Count);
                Assert.AreEqual(1, itemColArgs.RemovedItems.Count);
                Assert.AreEqual(2, itemUpdateArgs.UpdatedItems.Count);
            }
        }
Exemplo n.º 6
0
        public void EventsArgsNonBufferedTest()
        {
            using (var temp = TempDirectory.Create())
            {
                ItemCollectionChangedEventArgs <DatabaseObject> itemColArgs    = null;
                ItemUpdatedEventArgs <DatabaseObject>           itemUpdateArgs = null;
                var col = new ItemCollection <DatabaseObject>(temp.TempPath);
                col.ItemUpdated           += (e, args) => itemUpdateArgs = args;
                col.ItemCollectionChanged += (e, args) => itemColArgs = args;
                var item = new DatabaseObject()
                {
                    Name = "Original"
                };

                col.Add(item);
                Assert.AreEqual(1, itemColArgs.AddedItems.Count);
                Assert.AreEqual(item, itemColArgs.AddedItems[0]);
                Assert.AreEqual(0, itemColArgs.RemovedItems.Count);

                item.Name = "New";
                col.Update(item);
                Assert.AreEqual(1, itemUpdateArgs.UpdatedItems.Count);
                Assert.AreEqual("Original", itemUpdateArgs.UpdatedItems[0].OldData.Name);
                Assert.AreEqual("New", itemUpdateArgs.UpdatedItems[0].NewData.Name);

                col.Remove(item);
                Assert.AreEqual(0, itemColArgs.AddedItems.Count);
                Assert.AreEqual(1, itemColArgs.RemovedItems.Count);
                Assert.AreEqual(item, itemColArgs.RemovedItems[0]);
            }
        }
Exemplo n.º 7
0
 private void ScoreCalcRule_ItemUpdated(object sender, ItemUpdatedEventArgs e)
 {
     if (e.PrimaryKeys.Count > 0)
     {
         RefreshItemPanel(e.PrimaryKeys[0]);
     }
 }
Exemplo n.º 8
0
        public void BufferConsolidationTest()
        {
            using (var temp = TempDirectory.Create())
            {
                ItemCollectionChangedEventArgs <DatabaseObject> colChanges = null;
                ItemUpdatedEventArgs <DatabaseObject>           colUpdates = null;
                var col = new ItemCollection <DatabaseObject>(temp.TempPath);
                col.ItemUpdated           += (e, args) => colUpdates = args;
                col.ItemCollectionChanged += (e, args) => colChanges = args;

                var item = new DatabaseObject()
                {
                    Name = "Original"
                };
                col.Add(item);

                col.BeginBufferUpdate();
                item.Name = "Change1";
                col.Update(item);
                item.Name = "Change2";
                col.Update(item);
                col.EndBufferUpdate();
                Assert.AreEqual(1, colUpdates.UpdatedItems.Count);
                Assert.AreEqual("Original", colUpdates.UpdatedItems[0].OldData.Name);
                Assert.AreEqual("Change2", colUpdates.UpdatedItems[0].NewData.Name);
            }
        }
Exemplo n.º 9
0
        private static void Configuration_ConfigurationUpdated(object sender, ItemUpdatedEventArgs e)
        {
            if (e.PrimaryKeys.Contains("系統設定"))
                SysConfig = null;

            if (e.PrimaryKeys.Contains("學校資訊"))
                SchoolConfig = null;
        }
Exemplo n.º 10
0
 private void Instance_ItemUpdated(object sender, ItemUpdatedEventArgs e)
 {
     foreach (string key in e.PrimaryKeys)
     {
         if (key == PrimaryKey)
         {
             OnPrimaryKeyChanged(EventArgs.Empty);
             break;
         }
     }
 }
Exemplo n.º 11
0
 private void Database_GameUpdated(object sender, ItemUpdatedEventArgs <Game> args)
 {
     foreach (var update in args.UpdatedItems)
     {
         var existingItem = Items.FirstOrDefault(a => a.Game.Id == update.NewData.Id);
         if (existingItem != null)
         {
             // Forces CollectionView to re-sort items without full list refresh.
             Items.OnItemMoved(existingItem, 0, 0);
         }
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// 處理 Tag 的 ItemUpdated 事件。
        /// 當有使用者修改 Tag 與  Entity 之間的關係時,此事件會做相對應的處理。
        /// </summary>
        private void TagUpdatedDelegate <Cache, List, Record>(object sender, ItemUpdatedEventArgs e)
            where Cache : GeneralTag <Record>
            where List : List <Record>, new()
            where Record : GeneralTagRecord, new()
        {
            Cache cacher = sender as Cache;

            if (e.PrimaryKeys.Contains(PrimaryKey))
            {
                DisplayTags <List, Record>(cacher[PrimaryKey] as List, "<無類別資訊>");
            }
        }
        private void OnItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.Message, e.Error.GetType().Name, MessageBoxButton.OK);
                    return;
                }

                this.NavigationService.Navigate(new Uri("/Views/List.xaml", UriKind.Relative));
            });
        }
        private void OnItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.Message, e.Error.GetType().Name, MessageBoxButton.OK);
                    return;
                }

                // Remove Draft Item from local storage if update to server is successful.
                DraftItemStore.RemoveDraftItem(viewModel.ID.ToString());
                this.NavigationService.Navigate(new Uri("/Views/List.xaml", UriKind.Relative));
            });
        }
        private void OnItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.Message, e.Error.GetType().Name, MessageBoxButton.OK);
                    return;
                }

                // Remove Draft Item from local storage if update to server is successful.
                DraftItemStore.RemoveDraftItem(viewModel.ID.ToString());
                this.NavigationService.Navigate(new Uri("/Views/List.xaml", UriKind.Relative));
            });
        }
Exemplo n.º 16
0
 private void Games_ItemUpdated(object sender, ItemUpdatedEventArgs <Game> e)
 {
     if (IsFinished)
     {
         Task.Run(() =>
         {
             IsFinished = false;
             AutoUpdate(false, e.UpdatedItems[0].NewData);
         })
         .ContinueWith(antecedent =>
         {
             IsFinished = true;
         });
     }
 }
        private void OnItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(e.Error.Message, e.Error.GetType().Name, MessageBoxButton.OK);
                    return;
                }

                this.NavigationService.Navigate(new Uri("/Views/List.xaml", UriKind.Relative));
            });
        }
 void Instance_ItemUpdated(object sender, ItemUpdatedEventArgs e)
 {
     Layout(mPrimaryKeys);
 }
Exemplo n.º 19
0
 private void Details_ItemUpdated(object sender, ItemUpdatedEventArgs e)
 {
     iconView.SelectedItem.Text = e.Text;
 }
Exemplo n.º 20
0
 void Instance_ItemUpdated(object sender, ItemUpdatedEventArgs e)
 {
     Layout(mPrimaryKeys);
 }