Beispiel #1
0
        public CheckBox(Vector2f _pos, string _name, bool _default = false)
        {
            isVisable  = true;
            isChecked  = _default;
            stringText = _name;

            texture = new Texture("Resources\\Sprites\\GUI\\CheckBox.png");
            sprite  = new Sprite(texture);

            Pos = _pos;

            text = new Text(stringText, Canvas.Instance.font);
            text.CharacterSize = 14;

            text.Position = new Vector2f(Pos.X + 24, Pos.Y);

            mousePressed = (obj, e) =>
            {
                if (sprite.GetGlobalBounds().Contains(MainWindow.Instance.RenderWindow.MapPixelToCoords(new Vector2i(e.X, e.Y)).X, MainWindow.Instance.RenderWindow.MapPixelToCoords(new Vector2i(e.X, e.Y)).Y) && e.Button == Mouse.Button.Left && isVisable)
                {
                    isChecked = !isChecked;
                    HasChanged?.Invoke(this, new HasChangedArgs(IsChecked));
                }
            };
            MainWindow.Instance.RenderWindow.MouseButtonPressed += mousePressed;
        }
Beispiel #2
0
        public override async Task GetAllItems(HasChanged request, IServerStreamWriter <Item> responseStream, ServerCallContext context)
        {
            _logger.LogInformation("All items requested");

            string query = "SELECT * FROM item;";

            await db.Connection.OpenAsync();

            var command = new MySqlCommand(query, db.Connection);
            var reader  = await command.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                Item item = new Item
                {
                    ItemId     = (uint)(int)reader.GetValue(0),
                    PriceId    = (float)(decimal)reader.GetValue(1),
                    NameId     = (string)reader.GetValue(2),
                    CatagoryId = (uint)(int)reader.GetValue(3)
                };
                await responseStream.WriteAsync(item);
            }
            await reader.CloseAsync();

            await db.Connection.CloseAsync();

            _logger.LogInformation("All items sent");
        }
Beispiel #3
0
        public override async Task GetAllStocks(HasChanged request, IServerStreamWriter <StockTake> responseStream, ServerCallContext context)

        {
            string query = "SELECT * FROM STOCKS;";

            await db.Connection.OpenAsync();

            var command = new MySqlCommand(query, db.Connection);
            var reader  = await command.ExecuteReaderAsync();

            while (await reader.ReadAsync())
            {
                // Use item service to get the item
                Item item = await itemService.GetItem(new ItemGet()
                {
                    ItemId = reader.GetFieldValue <uint>(1)
                }, context);

                // Enter info into StockTake message
                var Stocktake = new StockTake
                {
                    Item = item,
                    Info = new StockInfo
                    {
                        Stock = reader.GetFieldValue <int>(2)
                    }
                };

                // send stock take over stream
                await responseStream.WriteAsync(Stocktake);
            }
        }
Beispiel #4
0
        private async Task DisplayAllItems()
        {
            var client = Gprc_channel_instance.ItemClient;

            var input = new HasChanged
            {
                // Send the list of item details
                ChangedData = false
            };

            // Recieving a stream:
            // each time MoveNext() is called, a new Sale will be returned
            using (var call = client.GetAllItems(input))
            {
                // while there are items in the stream
                while (await call.ResponseStream.MoveNext())
                {
                    // get the current sale information
                    var currentSaleInfo = call.ResponseStream.Current;

                    var catid  = currentSaleInfo.CatagoryId;
                    var itemid = currentSaleInfo.ItemId;
                    var name   = currentSaleInfo.NameId;
                    var price  = currentSaleInfo.PriceId;

                    lbItems.Items.Add(name);
                }
            }
        }
Beispiel #5
0
        public void WriteXmlDigest(System.Xml.XmlWriter writer, FFTPatch FFTPatch)
        {
            writer.WriteStartElement(GetType().Name);
            writer.WriteAttributeString("changed", HasChanged.ToString());

            foreach (string req in reqs)
            {
                Requirements r = ReflectionHelpers.GetFieldOrProperty <Requirements>(this, req, false);
                if (r != null)
                {
                    writer.WriteStartElement(req);
                    r.WriteXml(writer);
                    writer.WriteEndElement();
                }
            }

            for (int i = 0; i < levels.Length; i++)
            {
                if (levels[i] != Default.levels[i])
                {
                    writer.WriteStartElement(string.Format("Level{0}", i));
                    writer.WriteAttributeString("changed", (levels[i] != Default.levels[i]).ToString());
                    writer.WriteAttributeString("default", Default.levels[i].ToString());
                    writer.WriteAttributeString("value", levels[i].ToString());
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
        }
Beispiel #6
0
        /// <summary>
        /// Returns true if InlineResponseDefault7Options instances are equal
        /// </summary>
        /// <param name="other">Instance of InlineResponseDefault7Options to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(InlineResponseDefault7Options other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Value == other.Value ||
                     Value != null &&
                     Value.Equals(other.Value)
                     ) &&
                 (
                     Color == other.Color ||
                     Color != null &&
                     Color.Equals(other.Color)
                 ) &&
                 (
                     IsManaged == other.IsManaged ||
                     IsManaged != null &&
                     IsManaged.Equals(other.IsManaged)
                 ) &&
                 (
                     ExternalValue == other.ExternalValue ||
                     ExternalValue != null &&
                     ExternalValue.Equals(other.ExternalValue)
                 ) &&
                 (
                     ParentValues == other.ParentValues ||
                     ParentValues != null &&
                     ParentValues.SequenceEqual(other.ParentValues)
                 ) &&
                 (
                     MetadataId == other.MetadataId ||
                     MetadataId != null &&
                     MetadataId.Equals(other.MetadataId)
                 ) &&
                 (
                     HasChanged == other.HasChanged ||
                     HasChanged != null &&
                     HasChanged.Equals(other.HasChanged)
                 ) &&
                 (
                     Label == other.Label ||
                     Label != null &&
                     Label.Equals(other.Label)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ));
        }
Beispiel #7
0
 public void Update(string text)
 {
     if (Text != text)
     {
         var old = new TestItem(Text);
         Text = text;
         HasChanged?.Invoke(old, this);
     }
 }
        private async System.Threading.Tasks.Task <bool> CreateConnectionAsync()
        {
            bool ret = false;

            try
            {
                Stopwatch sw = Stopwatch.StartNew();


                this.HistoryDic.Clear();
                this.HasChanged.WriteFullFence(false);
                this.DeletedCount.WriteFullFence(0);
                this.AddedCount.WriteFullFence(0);

                //FullMutex for safe multithreading
                SQLiteOpenFlags flags = SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex;
                if (this.ReadOnly)
                {
                    flags = flags | SQLiteOpenFlags.ReadOnly;
                }
                else
                {
                    flags = flags | SQLiteOpenFlags.ReadWrite;
                }

                if (this.IsSQLiteDBConnected())
                {
                    this.DisposeConnection();
                }

                //If the database file doesn't exist, the default behaviour is to create a new file
                sqlite_conn = new SQLiteAsyncConnection(this.Filename, flags, true);


                //make sure table exists:
                CreateTableResult ctr = await sqlite_conn.CreateTableAsync <History>();


                await sqlite_conn.ExecuteScalarAsync <int>(@"PRAGMA journal_mode = 'WAL';", new object[] { });

                await sqlite_conn.ExecuteScalarAsync <int>(@"PRAGMA busy_timeout = 30000;", new object[] { });


                sw.Stop();

                Global.Log($"Created connection to SQLite db v{sqlite_conn.LibVersionNumber} in {sw.ElapsedMilliseconds}ms - TableCreate={ctr.ToString()}: {this.Filename}");

                HasChanged.WriteFullFence(true);
            }
            catch (Exception ex)
            {
                Global.Log("Error: " + Global.ExMsg(ex));
            }

            return(ret);
        }
Beispiel #9
0
 public void Update(string text, DataStore <TestItemCsv> dataStore)
 {
     if (Text != text)
     {
         var old = new TestItemCsv(Text);
         Text = text;
         dataStore.ItemHasChanged(old, this);
         HasChanged?.Invoke(old, this);
     }
 }
Beispiel #10
0
    //public void SetDummyCubeModel()
    //{
    //    balls = BallData.GetEmptyBallDataMatrix(3, 3, 3);
    //    faces = TileData.GetEmptyTileDataMatrix(6, 3, 3);
    //    balls[0, 0, 0] = BallData.GetObjective1Ball();
    //    balls[0, 1, 1] = BallData.GetWall();
    //    balls[1, 1, 1] = BallData.GetWall();
    //    balls[2, 1, 1] = BallData.GetWall();
    //    //balls[0, 0, 2] = BallData.GetWall();
    //    //balls[2, 1, 2] = BallData.GetWall();
    //    //
    //    faces[5, 0, 2] = TileData.GetObjective1Tile();
    //    //faces[0, 2, 2] = TileData.GetObjective2Tile();
    //    //faces[1, 1, 2] = TileData.GetObjective1Tile();
    //    //faces[1, 2, 1] = TileData.GetObjective2Tile();
    //    //faces[2, 1, 0] = TileData.GetObjective1Tile();
    //    //faces[2, 2, 0] = TileData.GetObjective2Tile();
    //    //faces[3, 0, 2] = TileData.GetObjective1Tile();
    //    //faces[3, 2, 1] = TileData.GetObjective2Tile();
    //    //faces[4, 2, 0] = TileData.GetObjective2Tile();
    //    //faces[5, 0, 1] = TileData.GetObjective1Tile();
    //    //faces[5, 0, 2] = TileData.GetObjective2Tile();
    //    HasChanged.Invoke(this);
    //}

    internal void SetData(CubeData data)
    {
        objectivesFilled = new Dictionary <ObjectiveType, bool>();
        foreach (var key in data.Objectives.Keys)
        {
            objectivesFilled.Add(key, false);
        }
        balls = data.balls;
        faces = data.faces;
        HasChanged.Invoke(this);
    }
        public void Update(string text, NotMatchingChildrenListName_Parent parent)
        {
            if (Key >= 0)
            {
                if (parent.Key < 0)
                {
                    throw new Exception($"NotMatchingChildrenListName_Child.Update(): It is illegal to add stored NotMatchingChildrenListName_Child '{this}'" + Environment.NewLine +
                                        $"to Parent '{parent}', which is not stored.");
                }
            }
            var clone       = new NotMatchingChildrenListName_Child(this);
            var isCancelled = false;

            onUpdating(text, parent, ref isCancelled);
            if (isCancelled)
            {
                return;
            }

#if DEBUG
            DC.Trace?.Invoke($"Updating NotMatchingChildrenListName_Child: {ToTraceString()}");
#endif
            var isChangeDetected = false;
            if (Text != text)
            {
                Text             = text;
                isChangeDetected = true;
            }
            if (Parent != parent)
            {
                Parent.RemoveFromChildren(this);
                Parent = parent;
                Parent.AddToChildren(this);
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data.NotMatchingChildrenListName_Childs.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(37, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
#if DEBUG
            DC.Trace?.Invoke($"Updated NotMatchingChildrenListName_Child: {ToTraceString()}");
#endif
        }
        public void Update(string text, Sample sample)
        {
            if (Key >= 0)
            {
                if (sample.Key < 0)
                {
                    throw new Exception($"SampleDetail.Update(): It is illegal to add stored SampleDetail '{this}'" + Environment.NewLine +
                                        $"to Sample '{sample}', which is not stored.");
                }
            }
            var clone       = new SampleDetail(this);
            var isCancelled = false;

            onUpdating(text, sample, ref isCancelled);
            if (isCancelled)
            {
                return;
            }

#if DEBUG
            DC.Trace?.Invoke($"Updating SampleDetail: {ToTraceString()}");
#endif
            var isChangeDetected = false;
            if (Text != text)
            {
                Text             = text;
                isChangeDetected = true;
            }
            if (Sample != sample)
            {
                Sample.RemoveFromSampleDetails(this);
                Sample = sample;
                Sample.AddToSampleDetails(this);
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data.SampleDetails.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(8, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
#if DEBUG
            DC.Trace?.Invoke($"Updated SampleDetail: {ToTraceString()}");
#endif
        }
Beispiel #13
0
        public void Update(string demoChildData, DemoParent parent)
        {
            if (Key >= 0)
            {
                if (parent.Key < 0)
                {
                    throw new Exception($"DemoChild.Update(): It is illegal to add stored DemoChild '{this}'" + Environment.NewLine +
                                        $"to Parent '{parent}', which is not stored.");
                }
            }
            var clone       = new DemoChild(this);
            var isCancelled = false;

            onUpdating(demoChildData, parent, ref isCancelled);
            if (isCancelled)
            {
                return;
            }

#if DEBUG
            DC.Trace?.Invoke($"Updating DemoChild: {ToTraceString()}");
#endif
            var isChangeDetected = false;
            if (DemoChildData != demoChildData)
            {
                DemoChildData    = demoChildData;
                isChangeDetected = true;
            }
            if (Parent != parent)
            {
                Parent.RemoveFromDemoChildren(this);
                Parent = parent;
                Parent.AddToDemoChildren(this);
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data.DemoChildren.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(35, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
#if DEBUG
            DC.Trace?.Invoke($"Updated DemoChild: {ToTraceString()}");
#endif
        }
Beispiel #14
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(this.GetType().Name);
         writer.WriteAttributeString("changed", HasChanged.ToString());
         foreach (MapMoveFindItems m in MoveFindItems)
         {
             m.WriteXml(writer);
         }
         writer.WriteEndElement();
     }
 }
Beispiel #15
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(GetType().Name);
         writer.WriteAttributeString("changed", HasChanged.ToString());
         foreach (Event e in Events)
         {
             e.WriteXml(writer);
         }
         writer.WriteEndElement();
     }
 }
Beispiel #16
0
        public Slider(Vector2f _pos, string[] _variants, int _default = 0)
        {
            isVisable = true;

            variants        = _variants;
            variantCount    = variants.Length;
            selectedVariant = _default;

            texture = new Texture("Resources\\Sprites\\GUI\\Slider.png");

            sprites = new Sprite[variantCount];
            texts   = new Text[variantCount];

            for (int i = 0; i < variantCount; ++i)
            {
                sprites[i] = new Sprite(texture)
                {
                    TextureRect = new IntRect(24, 0, 24, 24),
                    Position    = new Vector2f(_pos.X + 24 * i, _pos.Y)
                };

                texts[i] = new Text(variants[i], Canvas.Instance.font)
                {
                    CharacterSize = 11,
                    Position      = new Vector2f(_pos.X + 24 * i, _pos.Y + 28)
                };
            }

            cursor = new Sprite(texture)
            {
                TextureRect = new IntRect(0, 0, 24, 24),
                Position    = new Vector2f(_pos.X + 24 * selectedVariant, _pos.Y - 4)
            };

            mousePressed = (obj, e) =>
            {
                if (e.Button == Mouse.Button.Left && isVisable)
                {
                    for (int i = 0; i < variantCount; ++i)
                    {
                        if (sprites[i].GetGlobalBounds().Contains(MainWindow.Instance.RenderWindow.MapPixelToCoords(new Vector2i(e.X, e.Y)).X, MainWindow.Instance.RenderWindow.MapPixelToCoords(new Vector2i(e.X, e.Y)).Y) && i != selectedVariant)
                        {
                            selectedVariant = i;
                            HasChanged?.Invoke(this, new HasChangedArgs(selectedVariant));
                        }
                    }
                }
            };
            MainWindow.Instance.RenderWindow.MouseButtonPressed += mousePressed;
        }
        public void Update(string path, string name)
        {
            var clone       = new Location(this);
            var isCancelled = false;

            onUpdating(path, name, ref isCancelled);
            if (isCancelled)
            {
                return;
            }


            //update properties and detect if any value has changed
            var isChangeDetected = false;

            if (Path != path)
            {
                if (Key >= 0)
                {
                    DC.Data._LocationsByPathLower.Remove(PathLower);
                }
                Path      = path;
                PathLower = Path.ToLowerInvariant();
                if (Key >= 0)
                {
                    DC.Data._LocationsByPathLower.Add(PathLower, this);
                }
                isChangeDetected = true;
            }
            if (Name != name)
            {
                Name             = name;
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data._Locations.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(0, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
        }
Beispiel #18
0
    //Get the new ball positions from the slice and place the balls to their new positions
    // It relies on the fact that any balltype/objectiveType combiantion is only present once.
    //If a level has two balls exactly similar, this function may not work anymore
    public void SetNewBallPositions(SliceBoard slice)
    {
        Dictionary <BallData, IntVector3> currentPositions = new Dictionary <BallData, IntVector3>();

        for (int x = 0; x < X_SIZE; x++)
        {
            for (int y = 0; y < Y_SIZE; y++)
            {
                for (int z = 0; z < Z_SIZE; z++)
                {
                    if (balls[x, y, z].BallType == BallType.NORMAL)
                    {
                        currentPositions.Add(balls[x, y, z], new IntVector3(x, y, z));
                    }
                }
            }
        }

        FaceModel faceModel = FaceModel.ModelsDictionary[slice.face];

        var newPositions = slice.GetBallsPositions();
        var filledTiles  = slice.GetFilledTiles();

        foreach (var pair in currentPositions)
        {
            bool wasFilled = filledTiles.Contains(pair.Key.ObjectiveType);
            if (newPositions.ContainsKey(pair.Key) || wasFilled)
            {
                balls.Set(pair.Value, BallData.GetEmptyBall());
            }
        }
        foreach (var pair in currentPositions)
        {
            IntVector3 newPosition;
            if (newPositions.TryGetValue(pair.Key, out newPosition))
            {
                IntVector3 realPosition = new IntVector3();
                realPosition[faceModel.axes[0]] = newPosition.X;
                realPosition[faceModel.axes[1]] = newPosition.Y;
                realPosition[faceModel.axes[2]] = pair.Value[faceModel.axes[2]];

                balls.Set(realPosition, pair.Key);
            }
        }
        CheckLevelCompleted();
        HasChanged.Invoke(this);
    }
Beispiel #19
0
 internal void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("changed", HasChanged.ToString());
     foreach (string field in fields)
     {
         int current = ReflectionHelpers.GetFieldOrProperty <int>(this, field);
         int def     = ReflectionHelpers.GetFieldOrProperty <int>(Default, field);
         if (current > 0 || def > 0)
         {
             writer.WriteStartElement(field);
             writer.WriteAttributeString("changed", (current != def).ToString());
             writer.WriteAttributeString("default", def.ToString());
             writer.WriteAttributeString("value", current.ToString());
             writer.WriteEndElement();
         }
     }
 }
Beispiel #20
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Value != null)
         {
             hashCode = hashCode * 59 + Value.GetHashCode();
         }
         if (Color != null)
         {
             hashCode = hashCode * 59 + Color.GetHashCode();
         }
         if (IsManaged != null)
         {
             hashCode = hashCode * 59 + IsManaged.GetHashCode();
         }
         if (ExternalValue != null)
         {
             hashCode = hashCode * 59 + ExternalValue.GetHashCode();
         }
         if (ParentValues != null)
         {
             hashCode = hashCode * 59 + ParentValues.GetHashCode();
         }
         if (MetadataId != null)
         {
             hashCode = hashCode * 59 + MetadataId.GetHashCode();
         }
         if (HasChanged != null)
         {
             hashCode = hashCode * 59 + HasChanged.GetHashCode();
         }
         if (Label != null)
         {
             hashCode = hashCode * 59 + Label.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #21
0
 public void WriteXmlDigest(System.Xml.XmlWriter writer)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(this.GetType().Name);
         writer.WriteAttributeString("changed", HasChanged.ToString());
         foreach (PoachProbability p in PoachProbabilities)
         {
             if (p.HasChanged)
             {
                 writer.WriteStartElement(p.GetType().Name);
                 writer.WriteAttributeString("name", p.MonsterName);
                 DigestGenerator.WriteXmlDigest(p, writer, false, true);
             }
         }
         writer.WriteEndElement();
     }
 }
Beispiel #22
0
        public void Update(DateTime date, decimal someValue)
        {
            var clone       = new Lookup_ParentNullable(this);
            var isCancelled = false;

            onUpdating(date, someValue, ref isCancelled);
            if (isCancelled)
            {
                return;
            }

#if DEBUG
            DC.Trace?.Invoke($"Updating Lookup_ParentNullable: {ToTraceString()}");
#endif
            var isChangeDetected = false;
            var dateRounded      = date.Floor(Rounding.Days);
            if (Date != dateRounded)
            {
                Date             = dateRounded;
                isChangeDetected = true;
            }
            var someValueRounded = someValue.Round(2);
            if (SomeValue != someValueRounded)
            {
                SomeValue        = someValueRounded;
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data.Lookup_ParentNullables.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(4, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
#if DEBUG
            DC.Trace?.Invoke($"Updated Lookup_ParentNullable: {ToTraceString()}");
#endif
        }
        public void Update(string name)
        {
            var clone       = new Playlist(this);
            var isCancelled = false;

            onUpdating(name, ref isCancelled);
            if (isCancelled)
            {
                return;
            }


            //update properties and detect if any value has changed
            var isChangeDetected = false;

            if (Name != name)
            {
                if (Key >= 0)
                {
                    DC.Data._PlaylistsByNameLower.Remove(NameLower);
                }
                Name      = name;
                NameLower = Name.ToLowerInvariant();
                if (Key >= 0)
                {
                    DC.Data._PlaylistsByNameLower.Add(NameLower, this);
                }
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data._Playlists.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(2, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
        }
Beispiel #24
0
 public void WriteXmlDigest(System.Xml.XmlWriter writer, FFTPatch FFTPatch)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(this.GetType().Name);
         writer.WriteAttributeString("changed", HasChanged.ToString());
         foreach (Job j in Jobs)
         {
             if (j.HasChanged)
             {
                 writer.WriteStartElement(j.GetType().Name);
                 writer.WriteAttributeString("value", j.Value.ToString("X2"));
                 writer.WriteAttributeString("name", j.Name);
                 DigestGenerator.WriteXmlDigest(j, writer, false, true);
             }
         }
         writer.WriteEndElement();
     }
 }
Beispiel #25
0
 public void WriteXmlDigest(System.Xml.XmlWriter writer, FFTPatch FFTPatch)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(GetType().Name);
         writer.WriteAttributeString("value", this.ToString());
         writer.WriteAttributeString("changed", HasChanged.ToString());
         for (int i = 0; i < 16; i++)
         {
             if (Units[i].HasChanged)
             {
                 writer.WriteStartElement(typeof(EventUnit).Name);
                 writer.WriteAttributeString("value", i.ToString());
                 DigestGenerator.WriteXmlDigest(Units[i], writer, false, true);
             }
         }
         writer.WriteEndElement();
     }
 }
Beispiel #26
0
        public void Update(int playlistTrackKey)
        {
            var clone       = new PlayinglistTrack(this);
            var isCancelled = false;

            onUpdating(playlistTrackKey, ref isCancelled);
            if (isCancelled)
            {
                return;
            }


            //update properties and detect if any value has changed
            var isChangeDetected = false;

            if (PlaylistTrackKey != playlistTrackKey)
            {
                if (Key >= 0)
                {
                    DC.Data._PlayinglistTracksByPlaylistTrackKey.Remove(PlaylistTrackKey);
                }
                PlaylistTrackKey = playlistTrackKey;
                if (Key >= 0)
                {
                    DC.Data._PlayinglistTracksByPlaylistTrackKey.Add(PlaylistTrackKey, this);
                }
                isChangeDetected = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data._PlayinglistTracks.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(4, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
        }
Beispiel #27
0
        public void Update(string text, int numberWithDefault)
        {
            var clone       = new SampleMaster(this);
            var isCancelled = false;

            onUpdating(text, numberWithDefault, ref isCancelled);
            if (isCancelled)
            {
                return;
            }

#if DEBUG
            DC.Trace?.Invoke($"Updating SampleMaster: {ToTraceString()}");
#endif
            var isChangeDetected = false;
            if (Text != text)
            {
                Text             = text;
                isChangeDetected = true;
            }
            if (NumberWithDefault != numberWithDefault)
            {
                NumberWithDefault = numberWithDefault;
                isChangeDetected  = true;
            }
            if (isChangeDetected)
            {
                onUpdated(clone);
                if (Key >= 0)
                {
                    DC.Data.SampleMasters.ItemHasChanged(clone, this);
                }
                else if (DC.Data.IsTransaction)
                {
                    DC.Data.AddTransaction(new TransactionItem(6, TransactionActivityEnum.Update, Key, this, oldItem: clone));
                }
                HasChanged?.Invoke(clone, this);
            }
#if DEBUG
            DC.Trace?.Invoke($"Updated SampleMaster: {ToTraceString()}");
#endif
        }
Beispiel #28
0
        public void WriteXmlDigest(System.Xml.XmlWriter writer)
        {
            if (HasChanged)
            {
                writer.WriteStartElement(this.GetType().Name);
                writer.WriteAttributeString("changed", HasChanged.ToString());
                foreach (StatusAttribute attr in StatusAttributes)
                {
                    if (attr.HasChanged)
                    {
                        writer.WriteStartElement(attr.GetType().Name);
                        writer.WriteAttributeString("name", attr.Name);
                        writer.WriteAttributeString("value", attr.Value.ToString("X2"));
                        DigestGenerator.WriteXmlDigest(attr, writer, false, true);
                    }
                }

                writer.WriteEndElement();
            }
        }
Beispiel #29
0
 public void WriteXmlDigest(System.Xml.XmlWriter writer, FFTPatch FFTPatch)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(this.GetType().Name);
         writer.WriteAttributeString("changed", HasChanged.ToString());
         foreach (ItemAttributes attr in ItemAttributes)
         {
             if (attr.HasChanged)
             {
                 writer.WriteStartElement(attr.GetType().Name);
                 writer.WriteAttributeString("value", attr.Value.ToString("X2"));
                 DigestGenerator.WriteXmlDigest(attr, writer, false, false);
                 writer.WriteElementString("CorrespondingItems", attr.GetCorrespondingItems(FFTPatch));
                 writer.WriteEndElement();
             }
         }
         writer.WriteEndElement();
     }
 }
Beispiel #30
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     if (HasChanged)
     {
         writer.WriteStartElement(this.GetType().Name);
         writer.WriteAttributeString("changed", HasChanged.ToString());
         foreach (SkillSet s in SkillSets)
         {
             if (s.HasChanged)
             {
                 writer.WriteStartElement(s.GetType().Name);
                 writer.WriteAttributeString("value", s.Value.ToString("X2"));
                 writer.WriteAttributeString("name", s.Name);
                 DigestGenerator.WriteXmlDigest(s, writer, false, false);
                 writer.WriteElementString("CorrespondingJobs", s.CorrespondingJobs);
                 writer.WriteEndElement();
             }
         }
         writer.WriteEndElement();
     }
 }