コード例 #1
0
        private void pbImage_Paint(object sender, PaintEventArgs e)
        {
            foreach (var c in lbChars.Items)
            {
                CharHolder ch = c as CharHolder;
                if (ch.DrawRect.IsEmpty)
                {
                    continue;
                }

                Rectangle rect      = ch.GetRelativePosition(PicBoxRelativeImgRect);
                Rectangle imgOffset = PicBoxRelativeImgRect;
                rect.X += imgOffset.X;
                rect.Y += imgOffset.Y;

                e.Graphics.DrawRectangle(this.existentPen, rect);
            }

            if (this.startPoint.HasValue && this.endPoint.HasValue)
            {
                Rectangle rect      = GetRectanglePosition(this.startPoint.Value, this.endPoint.Value);
                Rectangle imgOffset = PicBoxRelativeImgRect;
                rect.X += imgOffset.X;
                rect.Y += imgOffset.Y;

                e.Graphics.DrawRectangle(this.drawPen, rect);
            }
        }
コード例 #2
0
        private static void TestNewConnections(CharHolder Char)
        {
            Char.CTRLAttribut.Charisma.Value.BaseValue++;

            Assert.IsTrue(Char.CTRLAttribut.Charisma.Value.BaseValue == 1);
            Assert.IsTrue(Char.CTRLAttribut.Charisma.Value.Value == 1);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.BaseValue == 0);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.Value == 1);

            Char.CTRLItem.Data[0].Value.BaseValue++;

            Assert.IsTrue(Char.CTRLItem.Data[0].Value.BaseValue == 1);
            Assert.IsTrue(Char.CTRLItem.Data[0].Value.Value == 0);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.BaseValue == 0);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.Value == 1);

            Char.CTRLItem.Data[0].Aktiv = true;

            Assert.IsTrue(Char.CTRLItem.Data[0].Value.BaseValue == 1);
            Assert.IsTrue(Char.CTRLItem.Data[0].Value.Value == 1);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.BaseValue == 0);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.Value == 2);

            Char.CTRLHandlung.Data[0].Value.BaseValue++;

            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.BaseValue == 1);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.Value == 3);

            Char.CTRLItem.Data[0].Aktiv = false;

            Assert.IsTrue(Char.CTRLItem.Data[0].Value.BaseValue == 1);
            Assert.IsTrue(Char.CTRLItem.Data[0].Value.Value == 0);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.BaseValue == 1);
            Assert.IsTrue(Char.CTRLHandlung.Data[0].Value.Value == 2);
        }
コード例 #3
0
 public void Activate(Thing thing, CharHolder mychar)
 {
     MyChar  = mychar;
     MyThing = thing;
     MainContent.BindingContext = MyThing;
     BindingContext             = this;
     try
     {
         Headline.Text = MyThing.ThingType.ThingDefToString(false);
         if (MyThing.ThingType == ThingDefs.Attribut || MyThing.ThingType == ThingDefs.Berechnet)
         {
             NotesContent.IsVisible          = false;
             StandardThingContents.IsVisible = false;
         }
         if (MyThing.ThingType == ThingDefs.Note)
         {
             NotesContent.IsVisible  = false;
             CalcContent.IsVisible   = false;
             NumberContent.IsVisible = false;
         }
         CreateView();
     }
     catch (Exception ex)
     {
         Log.Write("Unexpected Error", ex);
         CloseSelf();
     }
 }
コード例 #4
0
        public static void CompareCharHolder(CharHolder CharA, CharHolder CharB)
        {
            Assert.AreEqual(CharA.HasChanges, CharB.HasChanges);

            Assert.AreEqual(CharA.Settings.CategoryOptions.Count(), CharB.Settings.CategoryOptions.Count());
            foreach (var(CatA, CatB) in CharA.Settings.CategoryOptions.Join(CharB.Settings.CategoryOptions, x => x.ThingType, x => x.ThingType, (x, y) => (x, y)))
            {
                Assert.AreEqual(CatA.Order, CatB.Order);
                Assert.AreEqual(CatA.Pivot, CatB.Pivot);
                Assert.AreEqual(CatA.ThingType, CatB.ThingType);
                Assert.AreEqual(CatA.Visibility, CatB.Visibility);
            }
            Assert.AreEqual(CharA.Favorites.Count(), CharB.Favorites.Count());
            foreach (var(A, B) in CharA.Favorites.Zip(CharB.Favorites, (x, y) => (x, y)))
            {
                CompareThing(A, B);
            }
            foreach (var item in TLIB.ReflectionHelper.GetProperties(CharA.Person, typeof(Used_UserAttribute)))
            {
                object O1 = item.GetValue(CharA.Person);
                object O2 = item.GetValue(CharB.Person);
                Assert.IsTrue(O1 == O2 || O1.Equals(O2)); // == does just a reference comp
            }
            foreach (var(CTRLA, CTRLB) in CharA.Controlers.Zip(CharB.Controlers, (a, b) => (a, b)))
            {
                Assert.AreEqual(CTRLA.eDataTyp, CTRLB.eDataTyp);
                Assert.AreEqual(CTRLA.GetAllData().Count(), CTRLB.GetAllData().Count());
                foreach (var(El1, El2) in CTRLA.GetAllData().Zip(CTRLB.GetAllData(), (a, b) => (a, b)))
                {
                    CompareThing(El1, El2);
                }
            }
        }
コード例 #5
0
 public LinkListChooser(CharHolder myChar, ConnectProperty property)
 {
     MyChar     = myChar;
     MyProperty = property;
     Selected.AddRange(MyProperty.Connected);
     InitializeComponent();
     BindingContext = this;
 }
コード例 #6
0
 private static async void SaveExtern(CharHolder myChar)
 {
     try
     {
         SharedIO.Save(myChar, new FileInfo(Path.Combine((await SharedIO.CurrentIO.PickFolder()).FullName, myChar.FileInfo.Name)));
     }
     catch (Exception)
     {
         Log.Write(AppResources.Error_FileExportFail, true);
     }
 }
コード例 #7
0
 private static void SaveIntern(CharHolder myChar)
 {
     try
     {
         SharedIO.SaveAtCurrentPlace(myChar);
         Log.Write(AppResources.Info_Success_Import, true);
     }
     catch (Exception)
     {
         Log.Write(AppResources.Error_Import, true);
     }
 }
コード例 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            CharHolder ch = lbChars.SelectedItem as CharHolder;

            Rectangle rect = ch.GetRelativePosition(new Rectangle(0, 0, pbImage.Image.Width, pbImage.Image.Height));

            //Rectangle imgOffset = PicBoxRelativeImgRect;
            //rect.X += imgOffset.X;
            //rect.Y += imgOffset.Y;

            MessageBox.Show(rect.ToString());
        }
コード例 #9
0
        public static async Task CharLoadingHandling() //todo was private
        {
            try
            {
                if ((Settings.CHARINTEMPSTORE && !FirstStart || Settings.LOAD_CHAR_ON_START && FirstStart) && Model.MainObject == null || Settings.FORCE_LOAD_CHAR_ON_START)
                {
                    FileInfo info = Settings.LAST_SAVE_INFO;
                    Model.CharInProgress = info;
                    CharHolder TMPChar = await CharHolderIO.Load(info);

                    if (TMPChar.FileInfo.Directory.FullName.Contains(await SharedIO.CurrentIO.GetCompleteInternPath(Place.Temp)))
                    {
                        CharHolderIO.SaveAtCurrentPlace(TMPChar);
                    }

                    CharHolder OldChar = Model.MainObject;
                    Model.MainObject = TMPChar;
                    Settings.COUNT_LOADINGS++;
                    if (OldChar != null)
                    {
                        try
                        {
                            CharHolderIO.SaveAtOriginPlace(OldChar);
                        }
                        catch (Exception ex)
                        {
                            Log.Write(AppResources.Error_FileActivation, ex);
                        }
                    }
                    if (Settings.FORCE_LOAD_CHAR_ON_START)
                    {
                        Log.Write(AppResources.Info_Char_Loaded_File);
                    }
                    else
                    {
                        Log.Write(AppResources.Info_Char_Loaded_Start);
                    }
                }
            }
            catch (Exception ex)
            { Log.Write("Could not", ex, logType: LogType.Error); }
            finally
            {
                Model.CharInProgress = null;
                Settings.FORCE_LOAD_CHAR_ON_START = false;
                FirstStart = false;
                Settings.LAST_SAVE_INFO  = null;
                Settings.CHARINTEMPSTORE = false;
                Model.RequestNavigation(ProjectPages.Char);
            }
        }
コード例 #10
0
 private void NewChar_Clicked(object sender, EventArgs e)
 {
     try
     {
         CharHolder newchar = CharHolderGenerator.CreateCharWithStandardContent();
         SettingsModel.I.COUNT_CREATIONS++;
         AppModel.Instance.MainObject = (newchar);
         AppModel.Instance.RequestNavigation(ProjectPages.Char, ProjectPagesOptions.CharNewChar);
     }
     catch (Exception ex)
     {
         Log.Write("Error reading file", ex);
     }
 }
コード例 #11
0
 private void DebugChar_Clicked(object sender, EventArgs e)
 {
     try
     {
         CharHolder newchar = CharHolderGenerator.TestAllCats(10);
         SettingsModel.I.COUNT_CREATIONS++;
         AppModel.Instance.MainObject = (newchar);
         AppModel.Instance.RequestNavigation(ProjectPages.Char);
     }
     catch (Exception ex)
     {
         Log.Write("Error reading file", ex);
     }
 }
コード例 #12
0
        public static CharHolder CreateEmtpyChar()
        {
            var ret = new CharHolder();

            ret.AfterLoad();
            try
            {
                ret.FileInfo = new FileInfo(ShadowRunHelper.IO.SharedIO.CurrentSavePath + ret.MakeName(false));
            }
            catch (Exception)
            {
            }
            return(ret);
        }
コード例 #13
0
        private void pbImage_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.startPoint.HasValue && this.endPoint.HasValue)
            {
                CharHolder ch = (lbChars.SelectedItem as CharHolder);
                ch.DrawRect       = GetRectanglePosition(this.startPoint.Value, this.endPoint.Value);
                ch.ImageRectangle = PicBoxRelativeImgRect;

                this.startPoint = null;
                this.endPoint   = null;

                pbImage.Refresh();
            }
        }
コード例 #14
0
        private async Task LoadFileInBackgroundAsync(ExtendetFileInfo charfile, Action <CharHolder> afterLoad = null)
        {
            MainPage.Instance.EnableBusy();
            try
            {
                CharHolder newchar = await CharHolderIO.Load(charfile);

                AppModel.Instance.MainObject = (newchar);
                AppModel.Instance.RequestNavigation(ProjectPages.Char);
                afterLoad?.Invoke(newchar);
            }
            catch (Exception ex)
            {
                Log.Write("Error reading file", ex);
            }
            MainPage.Instance.DisableBusy();
        }
コード例 #15
0
        public async Task GenerateCharActivityAsync(CharHolder Char)
        {
            if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.ApplicationModel.UserActivities.UserActivityChannel"))
            {
                return;
            }
            UserActivityChannel channel = UserActivityChannel.GetDefault();
            var          name           = Char.MakeName(false);
            UserActivity userActivity   = await channel.GetOrCreateUserActivityAsync(name);

            userActivity.VisualElements.DisplayText = AppResources.PlayedWith + " " + name.Remove(name.Length - Constants.DATEIENDUNG_CHAR.Length);
            userActivity.ActivationUri = new Uri(Constants.PROTOCOL_CHAR + Char.FileInfo?.FullName);

            await userActivity.SaveAsync();

            CurrentCharActivity?.Dispose();
            ShadowRunHelper.Helper.PlatformHelper.ExecuteOnUIThreadAsync(() => CurrentCharActivity = userActivity.CreateSession());
        }
コード例 #16
0
        public static CharHolder CreateTestChar()
        {
            CharHolder Ret = new CharHolder();
            var        H1  = new Handlung()
            {
                Bezeichner = "Handlung1"
            };

            Ret.Add(H1);
            Ret.Add(new Vorteil()
            {
                Bezeichner = "Vorteil1"
            });

            //H1.LinkedThings.Add(Ret.LinkList.First(x => x.Object == Ret.CTRLAttribut.Charisma));
            //H1.LinkedThings.Add(Ret.LinkList.First(x => x.Object == Ret.CTRLAttribut.Logik));
            //H1.GegenZusammensetzung.Add(Ret.LinkList.First(x => x.Object == Ret.CTRLVorteil[0]));

            return(Ret);
        }
コード例 #17
0
        public void TestOfAddition_N()
        {
            AppModel.Initialize();
            SettingsModel.Initialize();

            CharHolder Char = new CharHolder();
            var        H1   = new Handlung()
            {
                Bezeichner = "Handlung1"
            };

            Char.Add(H1);
            Char.Add(new Item()
            {
                Bezeichner = "Item"
            });

            H1.Value.Connected.Add(Char.CTRLAttribut.Charisma.Value);
            H1.Value.Connected.Add(Char.CTRLItem[0].Value);
            TestNewConnections(Char);
        }
コード例 #18
0
 public ThingCopyChooser(Thing mything, CharHolder mychar, bool move)
 {
     MyThing = mything;
     MyChar  = mychar;
     Move    = move;
     InitializeComponent();
     BindingContext    = this;
     Lists.ItemsSource = TypeHelper.ThingTypeProperties
                         .Where(x => x.Usable)
                         .Where(x => x.ThingType != ThingDefs.Attribut && x.ThingType != ThingDefs.Berechnet && x.ThingType != ThingDefs.Note);
     if (Move)
     {
         MoveText.IsVisible = true;
         CopyText.IsVisible = false;
     }
     else
     {
         MoveText.IsVisible = false;
         CopyText.IsVisible = true;
     }
 }
コード例 #19
0
        public static CharHolder TestAllCats(int count = 1)
        {
            var testChar = new CharHolder();

            try
            {
                testChar.FileInfo = new FileInfo(Path.Combine(SharedIO.CurrentSavePath, "CompleteTestChar" + Constants.DATEIENDUNG_CHAR));
            }
            catch (Exception)
            {
            }

            var c = 0;

            foreach (var item in TypeHelper.ThingTypeProperties.Where(x => x.Usable))
            {
                for (int i = 0; i < count; i++)
                {
                    try
                    {
                        var newThing = testChar.Add(item.ThingType);
                        newThing.Bezeichner      = "Test " + i;
                        newThing.Notiz           = @"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
                        newThing.Typ             = item.Type.Name;
                        newThing.Value.BaseValue = c++;
                        newThing.Zusatz          = TLIB.StaticRandom.Next(0, 2) == 0 ? "-1" : "+1";
                    }
                    catch (System.Exception)
                    {
                        continue;
                    }
                }
            }
            testChar.CTRLItem[0].Value.BaseValue     = 123;
            testChar.CTRLHandlung[0].Bezeichner      = "Handlung mit Cons";
            testChar.CTRLHandlung[0].Value.BaseValue = 55;
            testChar.CTRLHandlung[0].Value.Connected.Add(testChar.CTRLItem[0].Value);
            testChar.AfterLoad();
            return(testChar);
        }
コード例 #20
0
 /// <summary>
 /// Activate
 /// </summary>
 /// <param name="myChar"></param>
 /// <returns></returns>
 public IEnumerable <SubMenuAction> Activate(ProjectPagesOptions pageOptions, CharHolder myChar)
 {
     if (Content is Grid G)
     {
         GCharHolder gChar = new GCharHolder(myChar)
         {
             Margin = 0, Padding = 0, BackgroundColor = Color.Transparent
         };
         G.Children.Add(gChar);
         gChar.AfterLoad(pageOptions);
         return(new[] {
             new SubMenuAction(UiResources.Save, "\xf0c7", new Command(() => myChar.SetSaveTimerTo(0, true))),
             new SubMenuAction(UiResources.SaveAtCurrentPlace, "\xf56f", new Command(() => SaveIntern(myChar))),
             new SubMenuAction(UiResources.SaveExtern, "\xf56e", new Command(() => SaveExtern(myChar))),
             new SubMenuAction(UiResources.OpenFolder, "\xf07c", new Command(() => SharedIO.CurrentIO.OpenFolder(myChar.FileInfo.Directory))),
             new SubMenuAction(UiResources.CharSettings, "\xf4fe", new Command(() => _ = RgPopUp.DisplayDefaultPopUp(new CharSettingsView(myChar)))),
             new SubMenuAction(UiResources.SubtractLifeStyleCost, "\xf155", new Command(() => myChar.SubtractLifeStyleCost())),
             new SubMenuAction(UiResources.Repair, "\xf6e3", new Command(() => myChar.Repair())),
             new SubMenuAction(UiResources.Close, "\xf235", new Command(() => { AppModel.Instance?.RemoveMainObject(myChar); AppModel.Instance.RequestNavigation(ProjectPages.Administration); })),
         });
     }
     return(Array.Empty <SubMenuAction>());
 }
コード例 #21
0
        public void TestLoadAndSave_N()
        {
            AppModel.Initialize();
            SettingsModel.Initialize();
            CharHolder Char = new CharHolder();
            var        H1   = new Handlung()
            {
                Bezeichner = "Handlung1"
            };

            Char.Add(H1);
            Char.Add(new Item()
            {
                Bezeichner = "Item"
            });

            H1.Value.Connected.Add(Char.CTRLAttribut.Charisma.Value);
            H1.Value.Connected.Add(Char.CTRLItem[0].Value);

            string Ser = SharedIO.Serialize(Char);

            TestNewConnections(CharHolderIO.Deserialize(Ser));
        }
コード例 #22
0
        internal override bool Transform(string propName, string propData, ResolutionContext ctx, ConvertionManager cm, ExtensionResolution ex)
        {
            // convert to custom type (with an ObjectConverter registered in ConvertionManager).
            var objectConverter = cm.TryGet(typeof(string), ExtensionDataType);

            if (objectConverter == null)
            {
                return(false);
            }

            // if an property value is provided for the property name, try to convert it.
            object propValue;

            if (!objectConverter.TryConvert(propData, out propValue))
            {
                return(false);
            }

            var holder = new CharHolder(propValue);

            ex.Data.AddDataHolder(propName, holder);

            return(true);
        }
コード例 #23
0
 public ControlCenter(CharHolder Char)
 {
     Model = Char;
     InitializeComponent();
     BindingContext = this;
 }
コード例 #24
0
 public CharSettingsView(CharHolder myChar)
 {
     MyChar = myChar;
     InitializeComponent();
     BindingContext = this;
 }
コード例 #25
0
 public async Task GenerateCharActivityAsync(CharHolder Char)
 {
 }
コード例 #26
0
        public static CharHolder CreateCharWithStandardContent()
        {
            var ret = new CharHolder();

            #region STD Content
            {
                ret.CTRLAttribut.Konsti.Value.BaseValue    = 1;
                ret.CTRLAttribut.Geschick.Value.BaseValue  = 1;
                ret.CTRLAttribut.Reaktion.Value.BaseValue  = 1;
                ret.CTRLAttribut.Staerke.Value.BaseValue   = 1;
                ret.CTRLAttribut.Charisma.Value.BaseValue  = 1;
                ret.CTRLAttribut.Logik.Value.BaseValue     = 1;
                ret.CTRLAttribut.Intuition.Value.BaseValue = 1;
                ret.CTRLAttribut.Willen.Value.BaseValue    = 1;
            }
            {
                var item = new Item
                {
                    Bezeichner = ModelResources.Content_SmartLink,
                };
                item.Value.BaseValue = 1;
                item.Aktiv           = false;
                item.Besitz          = true;
                ret.Add(item);
                item = new Item
                {
                    Bezeichner = ModelResources.Content_SmartLinkPrecision,
                };
                item.Value.BaseValue = 2;
                item.Aktiv           = true;
                item.Besitz          = true;
                ret.Add(item);
            }
            {
                var item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_Wahrnehmung,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Intuition.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_Schleichen,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Intuition.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_Akrobatik,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Geschick.Value);
                ret.Add(item);

                item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_ErsteHilfe,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Logik.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_Bodenfahrzeuge,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Geschick.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_FeuerwaffeFertigkeit,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Geschick.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Bezeichner = ModelResources.Content_Nahkampf,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Geschick.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Typ        = ModelResources.Content_Typ_Elektronik,
                    Bezeichner = ModelResources.Content_Computer,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Logik.Value);
                ret.Add(item);
                item = new Fertigkeit
                {
                    Typ        = ModelResources.Content_Typ_Sprache,
                    Bezeichner = ModelResources.Content_Muttersprache,
                };
                item.Value.BaseValue = 99;
                ret.Add(item);
            }
            {
                var item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Physisch,
                    Bezeichner = ModelResources.Content_Ini,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Reaktion.Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Intuition.Value);
                ret.Add(item);
                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Physisch,
                    Bezeichner = ModelResources.Content_FeuerwaffeHandlung,
                };
                item.Value.Connected.Add(ret.CTRLFertigkeit.Data.FirstOrDefault(x => x.Bezeichner == ModelResources.Content_FeuerwaffeFertigkeit).Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Geschick.Value);
                item.Limit.Connected.Add(ret.CTRLFernkampfwaffe.ActiveItem.Precision);
                item.Value.Connected.Add(ret.CTRLItem.Data.FirstOrDefault(x => x.Bezeichner == ModelResources.Content_SmartLink).Value);
                item.Limit.Connected.Add(ret.CTRLItem.Data.FirstOrDefault(x => x.Bezeichner == ModelResources.Content_SmartLinkPrecision).Value);
                ret.Add(item);
                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Physisch,
                    Bezeichner = ModelResources.Content_Ausweichen,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Reaktion.Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Intuition.Value);
                ret.Add(item);
                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Physisch,
                    Bezeichner = ModelResources.Content_Schadenswiderstand,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Konsti.Value);
                item.Value.Connected.Add(ret.CTRLPanzerung.ActiveItem.Value);
                ret.Add(item);
                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Physisch,
                    Bezeichner = ModelResources.Content_Widerstand,
                    Notiz      = ModelResources.Content_Widerstand_Note,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Konsti.Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Willen.Value);
                ret.Add(item);

                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Mental,
                    Bezeichner = ModelResources.Content_Selbstbeherrschung,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Charisma.Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Willen.Value);
                ret.Add(item);
                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Mental,
                    Bezeichner = ModelResources.Content_Menschenkenntnis,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Intuition.Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Charisma.Value);
                ret.Add(item);
                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Mental,
                    Bezeichner = ModelResources.Content_Erinnerung,
                };
                item.Value.Connected.Add(ret.CTRLAttribut.Logik.Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Willen.Value);
                ret.Add(item);

                item = new Handlung
                {
                    Typ        = ModelResources.Content_Typ_Matrix,
                    Bezeichner = ModelResources.Content_Matrixsuche,
                };
                item.Value.Connected.Add(ret.CTRLFertigkeit.Data.FirstOrDefault(x => x.Bezeichner == ModelResources.Content_Computer).Value);
                item.Value.Connected.Add(ret.CTRLAttribut.Intuition.Value);
                ret.Add(item);
            }
            #endregion STD Content

            ret.AfterLoad();
            ret.HasChanges = true;
            try
            {
                ret.FileInfo = new FileInfo(SharedIO.CurrentSavePath + ret.MakeName(false));
            }
            catch (Exception ex)
            {
                TLIB.Log.Write("Error setting newchar saveplace", ex);
            }
            return(ret);
        }
コード例 #27
0
        // Notes that this method will load the related assembly which defined the IExtensionBuilder implementation into memory.
        /// <summary>
        /// The required properties of extension builder (marked by ExtensionDataAttribute) must be provided by the extension data.
        /// </summary>
        /// <returns></returns>
        internal static bool ExtensionDataMatchesExtensionBuilder(this ExtensionResolution ex, IMessageDialog dialog,
                                                                  ResolutionContext ctx, ConvertionManager convertionManager)
        {
            var ebProperties = ex.ExtensionBuilder.Type.GetSettableRuntimeProperties();

            if (ebProperties == null)
            {
                return(true);
            }

            var data = ex.Data;

            foreach (var ebProp in ebProperties)
            {
                var    propName = ebProp.Name;
                string propInput;
                if (!data.TryGetString(propName, out propInput))
                {
                    var exPropAttrib = ebProp.GetCustomAttribute <ExtensionPropertyAttribute>(false, false);
                    if (exPropAttrib != null && exPropAttrib.Required)
                    {
                        dialog.AddError("a required property is missing!");
                        return(false);
                    }
                    continue;
                }

                #region specific types
                if (ebProp.PropertyType == typeof(string))
                {
                    var holder = new StringHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }

                // convert to TypeId
                if (ebProp.PropertyType == typeof(TypeId))
                {
                    TypeResolution type;
                    // a type dependency is introduced here.
                    // should it be added to the current addin's reference set?
                    if (!ctx.TryGetAddinType(ex.DeclaringAddin, propInput, out type))
                    {
                        dialog.AddError("");
                        return(false);
                    }
                    var holder = new LazyTypeIdHolder(type);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                #endregion

                // convert to custom type (with an ObjectConverter registered in ConvertionManager).
                var objectConverter = convertionManager.TryGet(typeof(string), ebProp.PropertyType);
                if (objectConverter == null)
                {
                    dialog.AddError("No converter is registered for !");
                    return(false);
                }

                // if an property value is provided for the property name, try to convert it.
                object propValue;
                if (!objectConverter.TryConvert(propInput, out propValue))
                {
                    dialog.AddError("The string [] can not be converted to !");
                    return(false);
                }

                #region common types
                if (ebProp.PropertyType == typeof(Int32))
                {
                    var holder = new Int32Holder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Boolean))
                {
                    var holder = new BooleanHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Version))
                {
                    var holder = new VersionHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(DateTime))
                {
                    var holder = new DateTimeHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Guid))
                {
                    var holder = new GuidHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(TimeSpan))
                {
                    var holder = new TimeSpanHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Int64))
                {
                    var holder = new Int64Holder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(UInt64))
                {
                    var holder = new UInt64Holder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(UInt32))
                {
                    var holder = new UInt32Holder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Int16))
                {
                    var holder = new Int16Holder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(UInt16))
                {
                    var holder = new UInt16Holder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Byte))
                {
                    var holder = new ByteHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(SByte))
                {
                    var holder = new SByteHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Char))
                {
                    var holder = new CharHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Decimal))
                {
                    var holder = new DecimalHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Double))
                {
                    var holder = new DoubleHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                if (ebProp.PropertyType == typeof(Single))
                {
                    var holder = new SingleHolder(propInput);
                    data.AddSerializableHolder(propName, holder);
                    continue;
                }
                #endregion
            }

            return(true);
        }
コード例 #28
0
 public static CharHolder SaveOpen(CharHolder Char)
 {
     return(CharHolderIO.Deserialize(SharedIO.Serialize(Char)));
 }