Ejemplo n.º 1
0
        private bool PredicateFunc(ITableItem tableItem)
        {
            if (this.Type != null && this.Type.IsAssignableFrom(tableItem.GetType()) == false)
            {
                return(false);
            }
            if (this.HasParent == true && tableItem.Parent == null)
            {
                return(false);
            }
            if (this.HasChilds == true && tableItem.Childs.Any() == false)
            {
                return(false);
            }
            if (this.IsLeaf == true && tableItem.Childs.Any() == true)
            {
                return(false);
            }
            if (this.TargetToMove != null && CanMove(this.TargetToMove, tableItem.Path) == false)
            {
                return(false);
            }
            if (this.ExcludedItems != null && this.ExcludedItems.Contains(tableItem) == true)
            {
                return(false);
            }
            if (this.Predicate != null && this.Predicate(tableItem) == false)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 private LogViewModel(Authentication authentication, ITableItem tableItem)
 {
     this.authentication = authentication;
     this.tableItem      = tableItem;
     this.DisplayName    = Resources.Title_ViewLog;
     this.previewCommand = new DelegateCommand((p) => this.Preview(), (p) => this.CanPreview);
 }
Ejemplo n.º 3
0
        private void DrawLeftExpandedSettingsColumn(Rect canvas, [NotNull] ITableItem <TraitItem> trait)
        {
            (Rect addKarmaLabel, Rect addKarmaField) = new Rect(0f, 0f, canvas.width, RowLineHeight).Split();
            UiHelper.Label(addKarmaLabel, _addKarmaTypeText);

            if (Widgets.ButtonText(addKarmaField, trait.Data.Data.KarmaType == null ? _defaultKarmaTypeText : trait.Data.Data.KarmaType.ToString()))
            {
                Find.WindowStack.Add(
                    new FloatMenu(ToolkitUtils.Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => trait.Data.Data.KarmaType = i)).ToList())
                    );
            }

            if (trait.Data.Data.KarmaType != null && UiHelper.FieldButton(addKarmaLabel, Textures.Reset, _resetTraitKarmaTooltip))
            {
                trait.Data.Data.KarmaType = null;
            }

            (Rect removeKarmaLabel, Rect removeKarmaField) = new Rect(0f, RowLineHeight, canvas.width, RowLineHeight).Split();
            UiHelper.Label(removeKarmaLabel, _removeKarmaTypeText);

            if (Widgets.ButtonText(
                    removeKarmaField,
                    trait.Data.TraitData !.KarmaTypeForRemoving == null ? _defaultKarmaTypeText : trait.Data.TraitData.KarmaTypeForRemoving.ToString()
                    ))
            {
                Find.WindowStack.Add(
                    new FloatMenu(ToolkitUtils.Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => trait.Data.TraitData.KarmaTypeForRemoving = i)).ToList())
                    );
            }

            if (trait.Data.TraitData.KarmaTypeForRemoving != null && UiHelper.FieldButton(removeKarmaLabel, Textures.Reset, _resetTraitKarmaTooltip))
            {
                trait.Data.TraitData.KarmaTypeForRemoving = null;
            }
        }
Ejemplo n.º 4
0
 public LogInfoViewModel(Authentication authentication, ITableItem tableItem, LogInfo logInfo)
 {
     this.authentication = authentication;
     this.tableItem      = tableItem;
     this.logInfo        = logInfo;
     this.Target         = tableItem;
 }
Ejemplo n.º 5
0
        public static string GetAccessInfoPath(this ITableItem tableItem, string categoryPath)
        {
            var tableContext = GetTableContext(tableItem);
            var uriString    = UriUtility.Combine(tableContext.BasePath, categoryPath.TrimStart(PathUtility.SeparatorChar) + tableItem.Name + extension);
            var uri          = new Uri(uriString);

            return(uri.LocalPath);
        }
Ejemplo n.º 6
0
        private void DrawRightExpandedSettingsColumn(Rect canvas, [NotNull] ITableItem <TraitItem> trait)
        {
            bool proxy = trait.Data.TraitData !.CanBypassLimit;

            if (UiHelper.LabeledPaintableCheckbox(new Rect(0f, 0f, canvas.width, RowLineHeight), _bypassLimitText, ref proxy))
            {
                trait.Data.TraitData.CanBypassLimit = proxy;
            }
        }
Ejemplo n.º 7
0
        private TableItemViewModel CreateNewTableItem(ITableItem expense)
        {
            TableItemViewModel result = new ViewModels.TableItemViewModel(expense);

            result.DoubleValue  = expense.DoubleValue;
            result.ExpenseName  = expense.Item.ToString();
            result.StringValue  = expense.StringValue;
            result.StringValues = expense.StringValues;
            return(result);
        }
Ejemplo n.º 8
0
        public bool TryGetItem(string id, out ITableItem item)
        {
            var r = data.TryGetValue(id, out item);

            if (!r)
            {
                Debug.Log($"{id} is not in {typeof(T).Name}");
            }
            return(r);
        }
Ejemplo n.º 9
0
 public bool CreateItem(ITableItem currentGame)
 {
     if (currentGame is null)
     {
         return(false);
     }
     context.Games.Add((Game)currentGame);
     context.SaveChanges();
     return(true);
 }
Ejemplo n.º 10
0
 public void InvokeTableItemDelete(Authentication authentication, ITableItem tableItem)
 {
     if (tableItem.AccessInfo.Path == tableItem.Path)
     {
         var accessInfoPath = tableItem.GetAccessInfoPath();
         if (File.Exists(accessInfoPath) == true)
         {
             this.repository.Delete(accessInfoPath);
         }
     }
 }
Ejemplo n.º 11
0
 public void AddItem(string id, ITableItem item)
 {
     try
     {
         data.Add(id, item);
     }
     catch (Exception e)
     {
         Debug.Log(e.ToString());
     }
 }
Ejemplo n.º 12
0
 public void InvokeTableItemMove(Authentication authentication, ITableItem tableItem, string newCategoryPath)
 {
     if (tableItem.AccessInfo.Path == tableItem.Path)
     {
         var accessInfoPath1 = tableItem.GetAccessInfoPath();
         var accessInfoPath2 = tableItem.GetAccessInfoPath(newCategoryPath);
         if (File.Exists(accessInfoPath1) == true)
         {
             this.repository.Move(accessInfoPath1, accessInfoPath2);
         }
     }
 }
Ejemplo n.º 13
0
 public void InvokeTableItemRename(Authentication authentication, ITableItem tableItem, string newName)
 {
     if (tableItem.AccessInfo.Path == tableItem.Path)
     {
         var accessInfoPath1 = tableItem.GetAccessInfoPath();
         var directoryName   = Path.GetDirectoryName(accessInfoPath1);
         var extension       = Path.GetExtension(accessInfoPath1);
         var accessInfoPath2 = Path.Combine(directoryName, newName + extension);
         if (File.Exists(accessInfoPath1) == true && accessInfoPath1 != accessInfoPath2)
         {
             this.repository.Move(accessInfoPath1, accessInfoPath2);
         }
     }
 }
Ejemplo n.º 14
0
 private static TableContext GetTableContext(this ITableItem tableItem)
 {
     if (tableItem is Table table)
     {
         return(table.Context);
     }
     else if (tableItem is TableCategory category)
     {
         return(category.Context);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 15
0
 public static void ClassInit(TestContext context)
 {
     app = new CremaBootstrapper();
     app.Initialize(context, nameof(ITableItem_DispatcherTest));
     cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost;
     cremaHost.Dispatcher.Invoke(() =>
     {
         authentication = cremaHost.Start();
         dataBase       = cremaHost.DataBases.Random();
         dataBase.Load(authentication);
         dataBase.Enter(authentication);
         dataBase.Initialize(authentication);
         tableItem = dataBase.TableContext.Random();
     });
 }
Ejemplo n.º 16
0
 public static void WriteAccessInfo(this ITableItem tableItem, string accessInfoPath, AccessInfo accessInfo)
 {
     if (tableItem is Table table)
     {
         WriteAccessInfo(accessInfoPath, accessInfo);
     }
     else if (tableItem is TableCategory category)
     {
         WriteAccessInfo(accessInfoPath, accessInfo);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 17
0
        public void setup()
        {
            // Creates Substitutes
            _db                = Substitute.For <IDatabaseService>();
            _tableItem         = Substitute.For <ITableItem>();
            _tableFloorplan    = Substitute.For <ITableFloorplan>();
            _tableItemGroup    = Substitute.For <ITableItemGroup>();
            _tablePlacement    = Substitute.For <ITableItemSectionPlacement>();
            _tableStoreSection = Substitute.For <ITableStoreSection>();
            _searcher          = Substitute.For <ISearcher>();

            // Sets common empty returns
            _tablePlacement.FindPlacementsByItem(Arg.Any <long>()).Returns(new List <StoreSection>());
            _tableItemGroup.GetItemGroup(Arg.Any <long>()).Returns(new ItemGroup("", 0, 0));
            LoadBLL();
        }
Ejemplo n.º 18
0
 private static bool CanMove(ITableItem tableItem, string parentPath)
 {
     if (tableItem.Parent == null)
     {
         return(false);
     }
     if (tableItem.Parent.Path == parentPath)
     {
         return(false);
     }
     if (NameValidator.VerifyCategoryPath(parentPath) == false)
     {
         return(false);
     }
     return(parentPath.StartsWith(tableItem.Path) == false);
 }
Ejemplo n.º 19
0
        public void InvokeTableItemRemoveAccessMember(Authentication authentication, ITableItem tableItem, AccessInfo accessInfo, string memberID)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableItemRemoveAccessMember), tableItem, memberID);
            var accessInfoPath = tableItem.GetAccessInfoPath();

            try
            {
                accessInfo.Remove(authentication.SignatureDate, memberID);
                tableItem.WriteAccessInfo(accessInfoPath, accessInfo);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 20
0
        private void DrawLeftExpandedSettingsColumn(Rect region, [NotNull] ITableItem <PawnKindItem> item)
        {
            (Rect karmaLabel, Rect karmaField) = new Rect(0f, 0f, region.width, RowLineHeight).Split(0.6f);
            UiHelper.Label(karmaLabel, _karmaTypeText);

            if (Widgets.ButtonText(karmaField, item.Data.Data.KarmaType == null ? _defaultKarmaTypeText : item.Data.Data.KarmaType.ToString()))
            {
                Find.WindowStack.Add(
                    new FloatMenu(ToolkitUtils.Data.KarmaTypes.Values.Select(i => new FloatMenuOption(i.ToString(), () => item.Data.Data.KarmaType = i)).ToList())
                    );
            }

            if (item.Data.Data.KarmaType != null && UiHelper.FieldButton(karmaLabel, Textures.Reset, _resetPawnKarmaTooltip))
            {
                item.Data.Data.KarmaType = null;
            }
        }
Ejemplo n.º 21
0
        public void InvokeTableItemSetPublic(Authentication authentication, ITableItem tableItem, AccessInfo accessInfo)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableItemSetPrivate), tableItem);
            var accessInfoPath = tableItem.GetAccessInfoPath();

            try
            {
                accessInfo.SetPublic();
                this.repository.Delete(accessInfoPath);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 22
0
        public void InvokeTableItemSetPrivate(Authentication authentication, ITableItem tableItem, AccessInfo accessInfo)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTableItemSetPrivate), tableItem);
            var accessInfoPath = tableItem.GetAccessInfoPath();

            try
            {
                accessInfo.SetPrivate(tableItem.GetType().Name, authentication.SignatureDate);
                tableItem.WriteAccessInfo(accessInfoPath, accessInfo);
                this.repository.Add(accessInfoPath);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 23
0
        public int Update(ITableItem item)
        {
            Hraci        hrac = (Hraci)item;
            List <Hraci> hraci;
            List <Hraci> temp = DeserializeFromXml <List <Hraci> >(GetContentOfXML("hraci.xml"));

            hraci = temp ?? new List <Hraci>();
            for (int i = 0; i < hraci.Count; i++)
            {
                if (hraci[i].hID == hrac.hID)
                {
                    hraci.RemoveAt(i);
                }
            }
            hraci.Add(hrac);
            hraci = hraci.OrderBy(x => x.hID).ToList();
            SerializeToXml(hraci, "hraci.xml");
            return(0);
        }
Ejemplo n.º 24
0
        public int Update(ITableItem item)
        {
            Trener        tren = (Trener)item;
            List <Trener> treneri;
            List <Trener> temp = DeserializeFromXml <List <Trener> >(GetContentOfXML("trener.xml"));

            treneri = temp ?? new List <Trener>();
            for (int i = 0; i < treneri.Count; i++)
            {
                if (treneri[i].ID_Trenera == tren.ID_Trenera)
                {
                    treneri.RemoveAt(i);
                }
            }
            treneri.Add(tren);
            treneri = treneri.OrderBy(x => x.ID_Trenera).ToList();
            SerializeToXml(treneri, "trener.xml");
            return(0);
        }
Ejemplo n.º 25
0
 public static void ReadAccessInfo(this ITableItem tableItem, string accessInfoPath)
 {
     if (tableItem is Table table)
     {
         if (ReadAccessInfo(accessInfoPath, out var accessInfo))
         {
             table.SetAccessInfo(accessInfo);
         }
     }
     else if (tableItem is TableCategory category)
     {
         if (ReadAccessInfo(accessInfoPath, out var accessInfo))
         {
             category.SetAccessInfo(accessInfo);
         }
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 26
0
        public int Insert(ITableItem item)
        {
            Trener        tren = (Trener)item;
            List <Trener> treneri;
            List <Trener> temp = DeserializeFromXml <List <Trener> >(GetContentOfXML("trener.xml"));

            treneri = temp ?? new List <Trener>();
            int id;

            if (treneri.Count > 0)
            {
                id = treneri.Last().ID_Trenera + 1;
            }
            else
            {
                id = 1;
            }
            tren.ID_Trenera = id;
            treneri.Add(tren);
            SerializeToXml(treneri, "hraci.xml");
            return(0);
        }
Ejemplo n.º 27
0
        public int Insert(ITableItem item)
        {
            Hraci        hrac = (Hraci)item;
            List <Hraci> hraci;
            List <Hraci> temp = DeserializeFromXml <List <Hraci> >(GetContentOfXML("hraci.xml"));

            hraci = temp ?? new List <Hraci>();
            int id;

            if (hraci.Count > 0)
            {
                id = hraci.Last().hID + 1;
            }
            else
            {
                id = 1;
            }
            hrac.hID = id;
            hraci.Add(hrac);
            SerializeToXml(hraci, "hraci.xml");
            return(0);
        }
Ejemplo n.º 28
0
 public int Insert(ITableItem item)
 {
     return(TableData.NonQuerry(SqlInsert, item.GetArgs()));
 }
Ejemplo n.º 29
0
 public int Delete(ITableItem item)
 {
     return(TableData.NonQuerry(SqlDelete, item.GetArgs()));
 }
Ejemplo n.º 30
0
 private static bool DefaultPredicate(ITableItem _) => true;
Ejemplo n.º 31
0
 public bool Equals(ITableItem other)
 {
     return Id == other.Id;
 }