Exemplo n.º 1
0
 /// <summary>
 ///     Given a collection of <see cref="Slice"/> instances, adds them to the
 ///     collection of slices.
 /// </summary>
 /// <param name="slices">
 ///     The collection of <see cref="Slice"/> instances to add.
 /// <exception cref="ArgumentException">
 ///     Thrown if the slice collection already contains a slice with the same name
 ///     or if any of the slices in the given collection have the same name
 /// </exception>
 public void AddSlices(IEnumerable <Slice> slices)
 {
     foreach (Slice slice in slices)
     {
         Slices.Add(slice.Name, slice);
     }
 }
Exemplo n.º 2
0
 public void AddSlice(Slice slice)
 {
     CountMushrooms -= slice.CountMushrooms;
     CountTomatoes  -= slice.CountTomatoes;
     CountPieces    -= slice.CountPieces;
     Slices.Add(slice);
 }
Exemplo n.º 3
0
        public async Task Run()
        {
            var child = new ConsumerRunnerSlice
            {
                Channel = await Client.PullModel(),
                Qos     = Consumer.MinQos
            };

            if (isFirst)
            {
                isFirst = false;
                child.Channel.Model.ExchangeDeclare(Consumer.EventBus.Exchange, "direct", true);
                child.Channel.Model.QueueDeclare(Queue.Queue, true, false, false, null);
                child.Channel.Model.QueueBind(Queue.Queue, Consumer.EventBus.Exchange, Queue.RoutingKey);
            }
            child.Channel.Model.BasicQos(0, Consumer.MinQos, false);

            child.BasicConsumer           = new EventingBasicConsumer(child.Channel.Model);
            child.BasicConsumer.Received += async(ch, ea) =>
            {
                await Process(child, ea, 0);
            };
            child.BasicConsumer.ConsumerTag = child.Channel.Model.BasicConsume(Queue.Queue, Consumer.AutoAck, child.BasicConsumer);
            child.NeedRestart = false;
            Slices.Add(child);
            NowQos   += child.Qos;
            StartTime = DateTimeOffset.UtcNow;
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Given <see cref="Slice"/> instances, add them to the colleciton of
 ///     slices.
 /// </summary>
 /// <param name="slices">
 ///     The <see cref="Slice"/> instances to add.
 /// </param>
 /// <exception cref="ArgumentException">
 ///     Thrown if the slice collection already contains a slice with the same name
 ///     or if any of the slices in the given collection have the same name
 /// </exception>
 public void AddSlices(params Slice[] slices)
 {
     for (int i = 0; i < slices.Length; i++)
     {
         Slices.Add(slices[i].Name, slices[i]);
     }
 }
Exemplo n.º 5
0
        public SectionBase AddSubsection()
        {
            var subsection = new Slice();

            Slices.Add(subsection);
            return(subsection);
        }
Exemplo n.º 6
0
        /**
         * CreateSlice
         * Add a new slice: with at least Coord and Dimension
         */
        public void CreateSlice(Coord position, Dimension dimension, string name = "", AhsvImage image = null)
        {
            // get default name or string passed
            string sliceName = (name.Length < 2) ? "new Slice" + Slices.Count() : name;

            // ahsvImage can be null;

            Slices.Add(new SlicedImage(sliceName, position, dimension, image));
        }
Exemplo n.º 7
0
        public Perceptron(params int[] slicesLength)
        {
            foreach (var sliceLength in slicesLength)
            {
                Slices.Add(new CommonSlice(sliceLength));
            }

            for (var i = 0; i < Slices.Count - 1; i++)
            {
                Slices[i].ConnectWith <CommonAxon>(Slices[i + 1]);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Creates a new <see cref="AnimatedSprite"/> instance.
        /// </summary>
        /// <param name="aseprite">
        ///     An <see cref="AsepriteDocument"/> instace created by
        ///     importing from the content pipeline.
        /// </param>
        /// <param name="position">
        ///     The top-left xy-coordinate position.
        /// </param>
        public AnimatedSprite(AsepriteDocument aseprite, Vector2 position)
            : this(aseprite.Texture, position)
        {
            for (int i = 0; i < aseprite.Frames.Count; i++)
            {
                Frames.Add(new Frame()
                {
                    Bounds   = new Rectangle(aseprite.Frames[i].X, aseprite.Frames[i].Y, aseprite.Frames[i].Width, aseprite.Frames[i].Height),
                    Duration = aseprite.Frames[i].Duration
                });
            }

            foreach (KeyValuePair <string, AsepriteTag> kvp in aseprite.Tags)
            {
                Animation animation = new Animation()
                {
                    Name      = kvp.Value.Name,
                    From      = kvp.Value.From,
                    To        = kvp.Value.To,
                    Direction = (AnimationLoopDirection)kvp.Value.Direction,
                    IsOneShot = kvp.Value.IsOneShot
                }
                ;
                Animations.Add(animation.Name, animation);
            }

            foreach (KeyValuePair <string, AsepriteSlice> kvp in aseprite.Slices)
            {
                Slice slice = new Slice
                {
                    Name  = kvp.Value.Name,
                    Color = kvp.Value.Color,
                    Keys  = new Dictionary <int, SliceKey>()
                };

                foreach (KeyValuePair <int, AsepriteSliceKey> innerKVP in kvp.Value.SliceKeys)
                {
                    SliceKey key = new SliceKey()
                    {
                        Bounds = new Rectangle(innerKVP.Value.X, innerKVP.Value.Y, innerKVP.Value.Width, innerKVP.Value.Height),
                        Frame  = innerKVP.Value.FrameIndex,
                        Color  = slice.Color
                    };

                    slice.Keys.Add(key.Frame, key);
                }
                Slices.Add(slice.Name, slice);
            }

            Play(Animations.First().Key);
        }
Exemplo n.º 9
0
        private void CalculateAxial(double spacing, double sliceDistance)
        {
            var volumeVector = _volume.BoundingMax - _volume.BoundingMin;
            var topLeft      = new Point3D(_volume.BoundingMin.X, _volume.BoundingMin.Y, _volume.BoundingMax.Z);
            var perSliceVec  = new Vector3D(0, 0, -sliceDistance);

            var numberOfSlices = volumeVector.Z / sliceDistance + 1;

            for (int i = 1; i <= numberOfSlices; i++)
            {
                var slice = new Slice(_volume, topLeft, new Vector3D(1, 0, 0), new Vector3D(0, 1, 0), (int)(volumeVector.Y / spacing), (int)(volumeVector.X / spacing), spacing);
                Slices.Add(slice);
                topLeft += perSliceVec;
            }
        }
Exemplo n.º 10
0
        public async Task ExpandQos()
        {
            if (NowQos + Consumer.IncQos <= Consumer.MaxQos)
            {
                var child = new ConsumerRunnerSlice
                {
                    Channel = await Client.PullModel(),
                    Qos     = Consumer.IncQos
                };
                child.Channel.Model.BasicQos(0, Consumer.IncQos, false);

                child.BasicConsumer           = new EventingBasicConsumer(child.Channel.Model);
                child.BasicConsumer.Received += async(ch, ea) =>
                {
                    await Process(child, ea, 0);
                };
                child.BasicConsumer.ConsumerTag = child.Channel.Model.BasicConsume(Queue.Queue, Consumer.AutoAck, child.BasicConsumer);
                child.NeedRestart = false;
                Slices.Add(child);
                NowQos   += child.Qos;
                StartTime = DateTimeOffset.UtcNow;
            }
        }
Exemplo n.º 11
0
 public void DuplicateSelecedSlice() => Slices.Add(Slices[SliceSelected]);
Exemplo n.º 12
0
 public void AddSlice(int sliceId, Slice slice)
 {
     Slices.Add(sliceId, slice);
     Width  = Math.Max(Width, slice.Width);
     Height = Math.Max(Height, slice.Height);
 }
Exemplo n.º 13
0
 /// <summary>
 ///     Given the name, color, and <see cref="SliceKey"/> instances,
 ///     creates a new <see cref="Slice"/> instance and adds it to the
 ///     collection of slices.
 /// </summary>
 /// <param name="name">
 ///     The name of the <see cref="Slice"/>.
 /// </param>
 /// <param name="color">
 ///     The color of the <see cref="Slice"/>.
 /// </param>
 /// <param name="keys">
 ///     The <see cref="SliceKey"/> instances that belong to the slice.
 /// </param>
 /// <exception cref="ArgumentException">
 ///     Thrown if the slice collection already contains a slice with the same name
 /// </exception>
 public void AddSlice(string name, Color color, params SliceKey[] keys)
 {
     Slices.Add(name, new Slice(name, color, keys));
 }
Exemplo n.º 14
0
 /// <summary>
 ///     Given the name, color, and collection of <see cref="SliceKey"/>
 ///     instances, creates a new <see cref="Slice"/> instance and adds it
 ///     to the collection of slices.
 /// </summary>
 /// <param name="name">
 ///     The name of the <see cref="Slice"/>.
 /// </param>
 /// <param name="color">
 ///     The color of the <see cref="Slice"/>.
 /// </param>
 /// <param name="keys">
 ///     The collection of <see cref="SliceKey"/> instances that belong
 ///     to the slice.
 /// </param>
 /// <exception cref="ArgumentException">
 ///     Thrown if the slice collection already contains a slice with the same name
 /// </exception>
 public void AddSlice(string name, Color color, IEnumerable <SliceKey> keys)
 {
     Slices.Add(name, new Slice(name, color, keys));
 }
Exemplo n.º 15
0
 /// <summary>
 ///     Given the name, color, and the key-value pair of <see cref="SliceKey"/>
 ///     instances, creates a new <see cref="Slice"/> instance and adds it
 ///     to the collection of slices.
 /// </summary>
 /// <param name="name">
 ///     The name of the <see cref="Slice"/>.
 /// </param>
 /// <param name="color">
 ///     The color of the <see cref="Slice"/>.
 /// </param>
 /// <param name="keys">
 ///     The key-value pair collection of <see cref="SliceKey"/> instances
 ///     that belong to the slice.
 /// </param>
 /// <exception cref="ArgumentException">
 ///     Thrown if the slice collection already contains a slice with the same name
 /// </exception>
 public void AddSlice(string name, Color color, Dictionary <int, SliceKey> keys)
 {
     Slices.Add(name, new Slice(name, color, keys));
 }
Exemplo n.º 16
0
 /// <summary>
 ///     Given a <see cref="Slice"/> instance, adds it to the collection
 ///     of slices.
 /// </summary>
 /// <param name="slice">
 ///     The <see cref="Slice"/> instance to add.
 /// </param>
 /// <exception cref="ArgumentException">
 ///     Thrown if the slice collection already contains a slice with the same name
 /// </exception>
 public void AddSlice(Slice slice)
 {
     Slices.Add(slice.Name, slice);
 }
        private void UpdateData()
        {
            IsBusy = true;
            Glucose_Data.Clear();
            Slices.Clear();
            Min        = null;
            Max        = null;
            Average    = 0;
            Nbr_Normal = 0;
            Nbr_Hight  = 0;
            Nbr_Low    = 0;
            if (type == "All")
            {
                foreach (var item in DataStore.GetGlucosAsync().Where(i => i.Date.Date >= Selected_MinDate & i.Date.Date <= Selected_MaxDate))
                {
                    Glucose_Data.Add(GlycemiaConverter.Convert(item, Profil.GlycemiaUnit));
                }
            }
            else
            {
                foreach (var item in DataStore.GetGlucosAsync().Where(i => i.Date.Date >= Selected_MinDate & i.Date.Date <= Selected_MaxDate).Where(i => i.Glucose_time == type))
                {
                    Glucose_Data.Add(GlycemiaConverter.Convert(item, Profil.GlycemiaUnit));
                }
            }

            if (Glucose_Data.Count > 0)
            {
                Glucose_Data = new ObservableCollection <Glucose_Model>(Glucose_Data.OrderBy(i => i.Date));
                Min          = Glucose_Data.OrderBy(i => i.Glycemia).First();
                Max          = Glucose_Data.OrderBy(i => i.Glycemia).Last();
                Average      = (Profil.GlycemiaUnit == "mg / dL") ? Math.Round((Glucose_Data.Sum(i => i.Glycemia)) / Glucose_Data.Count, 0) : Math.Round((Glucose_Data.Sum(i => i.Glycemia)) / Glucose_Data.Count, 3);
                Nbr_Normal   = (Profil.GlycemiaUnit == "mg / dL") ? Glucose_Data.Where(i => i.Glycemia >= Objectifs.Min_Glycemia & i.Glycemia <= Objectifs.Max_Glycemia).Count() : Glucose_Data.Where(i => i.Glycemia >= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & i.Glycemia <= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit)).Count();
                Nbr_Hight    = (Profil.GlycemiaUnit == "mg / dL") ? Glucose_Data.Where(i => i.Glycemia > Objectifs.Max_Glycemia).Count() : Glucose_Data.Where(i => i.Glycemia > GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit)).Count();
                Nbr_Low      = (Profil.GlycemiaUnit == "mg / dL") ? Glucose_Data.Where(i => i.Glycemia < Objectifs.Min_Glycemia).Count() : Glucose_Data.Where(i => i.Glycemia < GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit)).Count();
                MaximumChart = (Profil.GlycemiaUnit == "mg / dL") ? Convert.ToInt32(Max.Glycemia + 100) : Convert.ToInt32(Max.Glycemia + 10);
                if (Average < GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit))
                {
                    GlucoseColor = Color.FromHex("#f1c40f");
                }
                if (Average >= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit) & Average <= GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit))
                {
                    GlucoseColor = Color.FromHex("#2ecc71");
                }
                if (Average > GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit))
                {
                    GlucoseColor = Color.FromHex("#e74c3c");
                }
                Min_Glycemia = GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Min_Glycemia, Profil.GlycemiaUnit);
                Max_Glycemia = GlycemiaConverter.DoubleGlycemiaConvert(Objectifs.Max_Glycemia, Profil.GlycemiaUnit);
                Max_Widh     = MaximumChart - Max_Glycemia;
                Good_Wigh    = Max_Glycemia - Min_Glycemia;
            }
            Slices.Add(new Slice_Model
            {
                type  = "Normal",
                value = Nbr_Normal
            });
            Slices.Add(new Slice_Model
            {
                type  = "Elevée",
                value = Nbr_Hight
            });
            Slices.Add(new Slice_Model
            {
                type  = "Basse",
                value = Nbr_Low
            });
            IsBusy = false;
        }