Ejemplo n.º 1
0
 public void ChangeConditionAtIndex(int index, string newCondition)
 {
     Conditions[index].Object.Condition = newCondition;
     Conditions.Refresh();
     OnDataChanged?.Invoke();
     OnRefresh?.Invoke();
 }
Ejemplo n.º 2
0
 // Used only on UserSignIn!
 public static void SaveAll(bool notifyListeners = true)
 {
     AskToSaveLocal();
     if (notifyListeners)
     {
         OnDataChanged?.Invoke();
     }
 }
Ejemplo n.º 3
0
        public void Edit(string id, ImageInfo newInfo)
        {
            var target = GetById(id);

            target.Copy(newInfo);

            OnDataChanged?.Invoke(target);
        }
Ejemplo n.º 4
0
        public void Remove(string id)
        {
            var target = GetById(id);

            _data.Remove(target);

            OnDataChanged?.Invoke(target);
        }
Ejemplo n.º 5
0
        public void Create(ImageInfo info)
        {
            info.GenerateID( );

            _data.Add(info);

            OnDataChanged?.Invoke(info);
        }
Ejemplo n.º 6
0
        private void DataChanged()
        {
            OnDataChanged?.Invoke();
            CategoryModel currentCategory = OnNeededCurrentCategory?.Invoke();

            if (currentCategory == null)
            {
                return;
            }
            GetData(currentCategory);
        }
Ejemplo n.º 7
0
        public bool DeleteData(string ActionId, object[] parameters)
        {
            DataChangedEventArgs e = new DataChangedEventArgs
            {
                ActionId    = ActionId,
                ChangedData = parameters
            };

            OnDataChanged?.Invoke(this, e);
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 导入Excel
        /// </summary>
        public ParseResult ImportExcel(Workbook workbook)
        {
            var result = importExcel(workbook);

            if (result == ParseResult.Success)
            {
                IsEdited = true;
                OnDataChanged?.Invoke(Datas[DataIndex]);
                OnStateChanged?.Invoke(HasPrevious, HasNext, !IsCreateNew, CanDelete, IsEdited);
            }
            return(result);
        }
Ejemplo n.º 9
0
        public void AddNewDefaultCondition()
        {
            if (!HasData)
            {
                return;
            }

            ((IList <ConditionHolder>)Conditions.DataSource).Add((ConditionHolder)"Bel([x]) = True");
            Conditions.Refresh();
            OnDataChanged?.Invoke();
            OnRefresh?.Invoke();
        }
Ejemplo n.º 10
0
 public void Update()
 {
     if (actionTimeStemp != timeStamp)
     {
         actionTimeStemp = timeStamp;
         if (OnDataChanged != null)
         {
             //or OnDataChanged();
             OnDataChanged.Invoke();
         }
     }
 }
Ejemplo n.º 11
0
        public void RemoveConditionAt(int index)
        {
            if (!HasData)
            {
                return;
            }

            Conditions.DataSource.RemoveAt(index);
            Conditions.Refresh();
            OnDataChanged?.Invoke();
            OnRefresh?.Invoke();
        }
Ejemplo n.º 12
0
 public void AddNewTask(int offset)
 {
     Tasks.Add(new JobTask
     {
         ProjectJob = Jobs.OrderBy(x => x.Id).FirstOrDefault(),
         Hours      = 0.5,
         Date       = AddBusinessDays(DateTime.Today, offset, 0),
         TaskType   = TaskType.Normal,
         Id         = Guid.NewGuid()
     });
     OnDataChanged?.Invoke();
     SaveTasks(Tasks);
 }
        /// <summary>
        /// 导入Excel
        /// </summary>
        public ParseResult ImportExcel(Workbook workbook)
        {
            var result = importExcel(workbook);

            if (result == ParseResult.Success)
            {
                //0711TODO KO 获取对应的NodeCode的ElementIds
                Datas[DataIndex].LoadData(1);
                IsEdited = true;
                OnDataChanged?.Invoke(Datas[DataIndex]);
                OnStateChanged?.Invoke(HasPrevious, HasNext, !IsCreateNew, CanDelete, IsEdited);
            }
            return(result);
        }
Ejemplo n.º 14
0
        private void LoadJson(string filePath)
        {
            if (!File.Exists(filePath))
            {
                Debug.Log("No existing JSON file");
            }
            using (var reader = new StreamReader(filePath))
            {
                var strdata = reader.ReadToEnd();
                fsJsonParser.Parse(strdata, out _data);
                object deserialized = null;
                Serializer.TryDeserialize(_data, typeof(Entity), ref deserialized).AssertSuccessWithoutWarnings();

                // wtf pretty much describes it, FS decides to create a new game object, this gets rid of it
                var wtf = GameObject.Find("New Game Object");
                if (wtf != null)
                {
                    UnityEngine.Object.DestroyImmediate(wtf);
                }

                if (deserialized != null)
                {
                    //return deserialized as Entity;
                    _newEnt = (Entity)deserialized;
                    foreach (var comp in _newEnt.Components)
                    {
                        if (!ComponentPools.ContainsKey(comp.ComponentType))
                        {
                            ComponentPools[comp.ComponentType] = new List <ComponentEcs>();
                        }
                        ComponentPools[comp.ComponentType].Add(comp);

#if UNITY_EDITOR
                        if (!GroupedComponents.ContainsKey(comp.Grouping))
                        {
                            GroupedComponents[comp.Grouping] = new List <ComponentEcs>();
                        }
                        GroupedComponents[comp.Grouping].Add(comp);
#endif
                    }
                    ShouldPoolEntity = _newEnt.IsPooled;
                }
                else
                {
                    Debug.Log("Not deserialized");
                }
            }
            OnDataChanged?.Invoke();
            AvoidDirtyFlag = true;
        }
Ejemplo n.º 15
0
 public void Insert(IEnumerable <T> entities)
 {
     using (var db = GetDbContext())
     {
         try
         {
             db.Insert(entities).Execute();
         }
         finally
         {
             OnDataChanged?.Invoke(this, new DataChangedEventArgs <T>(ChangedTypes.Inserted)
             {
                 Data = entities
             });
         }
     }
 }
Ejemplo n.º 16
0
 public dynamic Insert(T entity)
 {
     using (var db = GetDbContext())
     {
         try
         {
             return(db.Insert(entity).Execute());
         }
         finally
         {
             OnDataChanged?.Invoke(this, new DataChangedEventArgs <T>(ChangedTypes.Inserted)
             {
                 Data = entity.AsIEnumerable()
             });
         }
     }
 }
Ejemplo n.º 17
0
        public bool InsertData(string ActionId, object[] parameters)
        {
            try
            {
                DataChangedEventArgs e = new DataChangedEventArgs
                {
                    ActionId    = ActionId,
                    ChangedData = parameters
                };

                OnDataChanged?.Invoke(this, e);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 18
0
        public void MoveCondition(int index, int moveAmount)
        {
            AssetBounds(index);

            var newIndex = index + moveAmount;

            AssetBounds(index);

            var l   = Conditions.DataSource;
            var obj = l[index];

            l.RemoveAt(index);
            l.Insert(newIndex, obj);

            Conditions.Refresh();
            OnDataChanged?.Invoke();
            OnRefresh?.Invoke();
        }
Ejemplo n.º 19
0
        public int Update(object entity, Expression <Func <T, bool> > whereExpression)
        {
            using (var db = GetDbContext())
            {
                var result = db.Update <T>().Set(entity).Where(whereExpression).Execute();

                if (result > 0)
                {
                    var data = db.Select <T>().Where(whereExpression).QueryMany();
                    OnDataChanged?.Invoke(this, new DataChangedEventArgs <T>(ChangedTypes.Updated)
                    {
                        Data = data
                    });
                }

                return(result);
            }
        }
Ejemplo n.º 20
0
        public async Task Start()
        {
            _client = new HttpClient();

            var stream = await _client.GetStreamAsync(Host);

            var reader = new StreamReader(stream);

            string eventName = null;
            string data      = null;

            while (_client != null)
            {
                var line = await reader.ReadLineAsync();


                if (string.IsNullOrEmpty(line) || line.StartsWith(":"))
                {
                    eventName = data = null;
                    continue;
                }

                if (line.StartsWith("event: "))
                {
                    eventName = line.Substring("event: ".Length).Trim();
                }
                else if (line.StartsWith("data: "))
                {
                    data = line.Substring("data: ".Length).Trim('"');

                    switch (eventName)
                    {
                    case "data_changed":
                        OnDataChanged?.Invoke(JsonConvert.DeserializeObject <JToken>(data));
                        break;

                    case "layout_changed":
                        OnLayoutChanged?.Invoke(data);
                        break;
                    }
                }
            }
            this.Stop();
        }
Ejemplo n.º 21
0
        public void AddChosenComponent()
        {
            if (!ComponentPools.ContainsKey(TypeToCreate))
            {
                ComponentPools[TypeToCreate] = new List <ComponentEcs>();
            }
            var comp = (ComponentEcs)Activator.CreateInstance(ComponentFactory.ComponentLookup[TypeToCreate]);

            ComponentPools[TypeToCreate].Add(comp);

#if UNITY_EDITOR
            if (!GroupedComponents.ContainsKey(comp.Grouping))
            {
                GroupedComponents[comp.Grouping] = new List <ComponentEcs>();
            }
            GroupedComponents[comp.Grouping].Add(comp);
#endif

            OnDataChanged?.Invoke();
            IsDirty = true;
        }
Ejemplo n.º 22
0
 public void Rollback(bool isDeleteNew = false)
 {
     if (IsCreateNew && isDeleteNew)
     {
         MemorableData = null;
         Datas.RemoveAt(DataIndex);
     }
     else
     {
         //0509 09:57 在编辑后回退,无编辑不回退
         if (IsEdited)
         {
             MemorableData.Rollback();
             if (Datas.Count > 0)
             {
                 Datas[DataIndex] = MemorableData.Data;
             }
             OnDataChanged?.Invoke(Datas[DataIndex]);
             OnStateChanged?.Invoke(HasPrevious, HasNext, CanCreateNew, CanDelete, CanSave);
         }
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 更改选中项
        /// </summary>
        /// <param name="index"></param>
        void ChangeCurrent(int index)
        {
            bool isContinue;

            isContinue = CheckChanges();
            if (!isContinue)
            {
                return;
            }
            DataIndex = index;
            if (index > Datas.Count - 1)//只有新增时index超过Datas的最大值
            {
                IsCreateNew = true;
                Datas.Add(createNew());
            }
            else
            {
                IsCreateNew = false;
            }
            UpdateMemorableData();//将选中内容刷到MemorableData
            OnDataChanged?.Invoke(Datas[DataIndex]);
            OnStateChanged?.Invoke(HasPrevious, HasNext, CanCreateNew, CanDelete, CanSave);
        }
Ejemplo n.º 24
0
 private void BroadCastData()
 {
     OnDataChanged?.Invoke(_CurScore, _Batter, _CurHit);
 }
Ejemplo n.º 25
0
 public void FireDataChange()
 {
     OnDataChanged?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 26
0
 protected internal override void RaiseOnChangeHandler()
 {
     m_OnChangeHandler?.Invoke(this, EventArgs.Empty);
     OnDataChanged?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 27
0
 private void ConfigViewModelOnOnDataChanged(object sender, EventArgs eventArgs)
 {
     OnDataChanged?.Invoke(sender, eventArgs);
 }
Ejemplo n.º 28
0
 public void RemoveTask(JobTask task)
 {
     Tasks.Remove(task);
     OnDataChanged?.Invoke();
     SaveTasks(Tasks);
 }
Ejemplo n.º 29
0
 public void MoveToNewDay(JobTask task, DateTime newTaskDate)
 {
     task.Date = newTaskDate.Date;
     OnDataChanged?.Invoke();
     SaveTasks(Tasks);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 数据发生变化时调用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataChanged(Position p)
        {
            if (OnDataChanged != null)
            {
                //筛选出的线条区间(新的线条)
                List <BrokenLine> lines = new List <BrokenLine>();

                //遍历线条
                for (int i = 0; i < brokenLines.Count; ++i)
                {
                    //筛选出状态点的值
                    List <StatePoint> points = new List <StatePoint>();
                    points.Add(new StatePoint()
                    {
                        state = 0, point = new Point(0, 0)
                    });

                    //选择状态点区间
                    for (int j = (int)((brokenLines[i].Points.Count() - 1) * p.p1);
                         j < (brokenLines[i].Points.Count() - 1) * p.p2; ++j)
                    {
                        if (j == 0 || j == (brokenLines[i].Points.Count() - 1))
                        {
                            continue;
                        }

                        double value = (brokenLines[i].Points[j].point.X - p.p1) / (p.p2 - p.p1);

                        if (value < 0 || value > 1)
                        {
                            continue;
                        }

                        points.Add(new StatePoint()
                        {
                            state = points.Count, point = new Point(value, 0)
                        });
                    }
                    points.Add(new StatePoint()
                    {
                        state = points.Count, point = new Point(1, 0)
                    });

                    lines.Add(new BrokenLine(points, brokenLines[i].Thickness, brokenLines[i].Name));
                }

                //计算时间区间
                TimeSpan timeSpan = EndTime - StartTime;

                TimeInterval t = new TimeInterval(StartTime + new TimeSpan((long)(timeSpan.Ticks * p.p1)),
                                                  StartTime + new TimeSpan((long)(timeSpan.Ticks * p.p2)));
                SelectedStartTime = t.StartTime;
                SelectedEndTime   = t.EndTime;

                //如果区间大于修改右边时间的显示位置,以免覆盖
                if (p.p2 > 0.85)
                {
                    //改变滑块右边的时间位置
                    dragBorder.ChangeRightTimePosition(0);
                    //改变缩略图右边的时间位置
                    tbk_RightTime.SetValue(Canvas.RightProperty, -57.0);
                }
                else
                {
                    dragBorder.ChangeRightTimePosition(1);
                    tbk_RightTime.SetValue(Canvas.RightProperty, -19.0);
                }

                //触发事件
                OnDataChanged?.Invoke(lines, t);
            }
        }