Exemple #1
0
        public void SerializationElementListTest()
        {
            ElementList object1 = new ElementList(true);
            Shape       shape1  = new Shape();
            Shape       shape2  = new Shape();

            shape1.Location = new PointF(10, 10);
            shape2.Location = new PointF(20, 20);

            object1.Add(shape1);
            object1.Add(shape2);

            //Serialize the object
            MemoryStream stream     = new MemoryStream();
            XmlFormatter serializer = new XmlFormatter();

            serializer.Serialize(stream, object1);
            stream.Position = 0; // reset the stream to the beginning
            SqlXml xml = new SqlXml(stream);

            //Recreate the object in object 2
            ElementList object2;

            using (MemoryStream stream2 = new MemoryStream(Encoding.UTF8.GetBytes(xml.Value)))
            {
                object2 = (ElementList)serializer.Deserialize(stream2);
            }

            Shape shape3 = object2[0] as Shape;
            Shape shape4 = object2[1] as Shape;

            Assert.IsTrue(object2.Count == 2, "ElementList collection does not contain 2 items.");
            Assert.IsTrue(shape3.Location == new PointF(10, 10), "Collection item 'shape1' location not deserialized correctly.");
            Assert.IsTrue(shape4.Location == new PointF(20, 20), "Collection item 'shape2' location not deserialized correctly.");
        }
Exemple #2
0
    public GameOver(Player player)
    {
        Button done = new Button("DONE", () => Program.Manager.NextState = new MainMenu(), 50, 200);

        done.Anchor = new Vec2(0.6, 0.2);
        AddExpandElement(done);

        Label Gameover = new Label("GAME OVER", 45);

        Gameover.Anchor = new Vec2(0.5, 0.9);
        Frame.Add(Gameover);

        ElementList names = new ElementList();

        names.Add(new Label("DEATHS", 23));
        names.Add(new Label("KILLS", 23));
        names.Add(new Label("BONUSES", 23));
        names.Horizontal = false;
        names.Anchor     = new Vec2(0.4, 0.5);
        names.Visit((Element e) => e.FixedWidth = 130);
        names.Spacing = 20;
        Frame.Add(names);

        Label p1 = new Label("PLAYER 1", 23);
        Label p2 = new Label("PLAYER 2", 23);

        p1.FixedWidth = 110;
        p2.FixedWidth = 110;
        p1.Anchor     = new Vec2(0.65, 0.75);
        p2.Anchor     = new Vec2(0.85, 0.75);
        Frame.Add(p1);
        Frame.Add(p2);

        ElementList p1stats = new ElementList();

        p1stats.Add(new Label(Program.Statistics.Deaths[0].ToString(), 23));
        p1stats.Add(new Label(Program.Statistics.Kills[0].ToString(), 23));
        p1stats.Add(new Label(Program.Statistics.Bonuses[0].ToString(), 23));
        p1stats.Horizontal = false;
        p1stats.Anchor     = new Vec2(0.65, 0.5);
        p1stats.Visit((Element e) => e.FixedWidth = 110);
        p1stats.Spacing = 20;
        Frame.Add(p1stats);

        ElementList p2stats = new ElementList();

        p2stats.Add(new Label(Program.Statistics.Deaths[1].ToString(), 23));
        p2stats.Add(new Label(Program.Statistics.Kills[1].ToString(), 23));
        p2stats.Add(new Label(Program.Statistics.Bonuses[1].ToString(), 23));
        p2stats.Horizontal = false;
        p2stats.Anchor     = new Vec2(0.85, 0.5);
        p2stats.Visit((Element e) => e.FixedWidth = 110);
        p2stats.Spacing = 20;
        Frame.Add(p2stats);

        player.Dir   = 1;
        Winner       = new Walking(player);
        cam.Position = player.Position + new Vec2(40, 0);
    }
        /// <summary>
        /// Add Image to Pdf from Image path.
        /// </summary>
        /// <param name="ImagePath">A Path</param>
        /// <param name="MaxHeight">Max Height Allowed</param>
        /// <param name="MaxWidth">Max Width Allowed</param>
        /// <exception cref="System.ArgumentNullException">ImagePath is null.</exception>
        /// <exception cref="System.UriFormatException">ImagePath is empty.-or- The scheme specified in ImagePath is not correctly formed.</exception>
        private static void AddImageWithWidthHeight(String ImagePath, Int32 MaxHeight = 700, Int32 MaxWidth = 600)
        {
            System.Drawing.Image  Image = System.Drawing.Bitmap.FromFile(ImagePath);
            iTextSharp.text.Image pic   = iTextSharp.text.Image.GetInstance(Image, System.Drawing.Imaging.ImageFormat.Jpeg);

            if (pic.Height > pic.Width)
            {
                //Maximum height is 800 pixels.
                float percentage = 0.0f;
                percentage = MaxHeight / pic.Height;
                pic.ScalePercent(percentage * 100);
            }
            else
            {
                //Maximum width is 600 pixels.
                float percentage = 0.0f;
                percentage = 600 / pic.Width;
                pic.ScalePercent(percentage * 100);
            }

            pic.Border      = iTextSharp.text.Rectangle.BOX;
            pic.BorderColor = iTextSharp.text.BaseColor.GREEN;
            pic.BorderWidth = 3f;

            ElementList.Add(pic);
        }
Exemple #4
0
        /// <summary>
        /// Loads the preambles file
        /// </summary>
        public void LoadPreambles(string PreamblesFile)
        {
            ElementList.Clear();
            try
            {
                if (File.Exists(PreamblesFile))
                {
                    XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <DynPreambleElement>));
                    using (TextReader tr = new StreamReader(PreamblesFile))
                    {
                        List <DynPreambleElement> l = serializer.Deserialize(tr) as List <DynPreambleElement>;
                        if (l != null)
                        {
                            foreach (var model in l)
                            {
                                ElementList.Add(new DynPreambleElementVM(model));
                            }

                            // register property change handlers
                            foreach (var vm in ElementList)
                            {
                                vm.PropertyChanged += (o, e) => NotifyPropertyChanged("Preamble");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();

                _build();
            }

            int        IndexToRemove;
            int        NumberToAdd;
            List <int> RemovedIndexes = new List <int>();

            for (int i = 0; i < ElementNumber;)
            {
                IndexToRemove = Random.Next(0, SetSize - (1 + RemovedIndexes.Count));

                if (RemovedIndexes.IndexOf(IndexToRemove) == -1)
                {
                    NumberToAdd = NumberList[IndexToRemove];
                    ElementList.Add(NumberToAdd);
                    NumberList.RemoveAt(IndexToRemove);
                    RemovedIndexes.Add(IndexToRemove);
                    i++;
                }
            }

            ElementList.Sort();
        }
Exemple #6
0
        /// <summary>Search AvailableElementData by mission code (aka commercial number).</summary>
        /// <param name="commercialNumber">Mission code (aka commercial number)</param>
        /// <returns>list of found AvailableElementData.</returns>
        internal ElementList <AvailableElementData> GetAvailableElementDataListByMissionCode(string commercialNumber)
        {
            ElementList <AvailableElementData> elementDataList = new ElementList <AvailableElementData>();

            if (!string.IsNullOrEmpty(commercialNumber))
            {
                IList <SystemInfo> systemList;
                lock (_systemListLock)
                {
                    systemList = _systemList.Where(element => (element.Value.PisMission != null && element.Value.PisMission.CommercialNumber == commercialNumber)).Select(e => e.Value).ToList();
                }

                elementDataList.Capacity = systemList.Count;
                foreach (SystemInfo system in systemList)
                {
                    AvailableElementData elementData = T2GDataConverter.BuildAvailableElementData(system);

                    if (elementData != null)
                    {
                        elementDataList.Add(elementData);
                    }
                }
            }

            return(elementDataList);
        }
Exemple #7
0
        public void PickElements()
        {
            int randIndex = -1;
            int uniqueNum = 0;

            // If ElementList has element(s) then clear both lists and rebuilt
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();

                _build(); // rebuild _numberList data
            }

            // Loop trhough number of elements need to add
            for (int i = 0; i < ElementNumber; i++)
            {
                // Generate a random index position between 1 to SetSize (inclusive)
                randIndex = _Random.Next(1, SetSize);
                uniqueNum = NumberList.ElementAt(randIndex);
                // Determine its a duplicate number
                while (ElementList.Contains(uniqueNum))
                {
                    // Then again generate number
                    randIndex = _Random.Next(1, SetSize);
                    uniqueNum = NumberList.ElementAt(randIndex);
                }

                // If its a unique number then add to element list
                ElementList.Add(uniqueNum);
            }

            // Sort the ElementList
            ElementList.Sort();
        }
Exemple #8
0
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                //ElementList and NumberList call their clear method:
                ElementList.Clear();
                NumberList.Clear();

                //build method is called:
                this._build();

                //6 random numbers are selected from NumberList, they are added to the ElementList and then removed from NumberList:
                IEnumerable <int> threeRandom = NumberList.OrderBy(x => Random.Next()).Take(this.ElementNumber);
                foreach (int y in threeRandom)
                {
                    ElementList.Add(y);
                }
                ElementList.Sort();
                NumberList.RemoveAll(c => ElementList.ToList().Exists(n => n == c));
            }
            else
            {
                //build method is called:
                this._build();

                //6 random numbers are selected from NumberList, they are added to the ElementList and then removed from NumberList:
                IEnumerable <int> threeRandom = NumberList.OrderBy(x => Random.Next()).Take(ElementNumber);
                foreach (int y in threeRandom)
                {
                    ElementList.Add(y);
                }
                NumberList.RemoveAll(c => ElementList.ToList().Exists(n => n == c));
            }
        }
Exemple #9
0
        /// <summary>
        /// Search AvailableElementData By TargetAddress (By Element, MissionOperatorCode, or MissionId)
        /// </summary>
        /// <param name="targetAddress">Target address.</param>
        /// <param name="lstAvailableElementData">[out] Information describing the list available element.</param>
        /// <returns>List of AvailableElementData matching TargetAddress criteria.</returns>
        public T2GManagerErrorEnum GetAvailableElementDataByTargetAddress(TargetAddressType targetAddress, out ElementList <AvailableElementData> lstAvailableElementData)
        {
            T2GManagerErrorEnum lReturn = T2GManagerErrorEnum.eFailed;

            lstAvailableElementData = new ElementList <AvailableElementData>();

            if (targetAddress != null && !string.IsNullOrEmpty(targetAddress.Id))
            {
                // Resolve target elements
                switch (targetAddress.Type)
                {
                case AddressTypeEnum.Element:
                    AvailableElementData element = new AvailableElementData();
                    lReturn = GetAvailableElementDataByElementNumber(targetAddress.Id, out element);
                    if (lReturn == T2GManagerErrorEnum.eSuccess)
                    {
                        lstAvailableElementData.Add(element);
                    }
                    break;

                case AddressTypeEnum.MissionOperatorCode:
                    lReturn = GetAvailableElementDataListByMissionOperatorCode(targetAddress.Id, out lstAvailableElementData);
                    break;

                case AddressTypeEnum.MissionCode:
                    lReturn = GetAvailableElementDataListByMissionCode(targetAddress.Id, out lstAvailableElementData);
                    break;
                }
            }

            return(lReturn);
        }
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        /// <summary>
        /// PickElements method will grantee  unique  and random numbers are exist in number list
        /// </summary>
        public void PickElements()
        {
            if (ElementNumber > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                _build();
                int counter = NumberList.Count;
                for (int i = 0; i < counter; i++)
                {
                    int selectionPostion = random.Next(0, maxValue: NumberList.Count);
                    int selection        = NumberList[selectionPostion];
                    ElementList.Add(selection);
                    NumberList.RemoveAt(selectionPostion);
                }
            }
            else
            {
                _build();
                int counter = 0;
                do
                {
                    int selectionPostion = random.Next(0, maxValue: NumberList.Count);
                    int selection        = NumberList[selectionPostion];
                    ElementList.Add(selection);
                    NumberList.RemoveAt(selectionPostion);
                } while (counter < NumberList.Count);
            }
        }
Exemple #11
0
        public void AddDataToElementList()
        {
            var list = new ElementList <Element>("test");
            var data = new Data <string>("data", "value", -1, "", true);

            list.Add(data);
            Assert.IsTrue(data.Categories.Contains(list));
        }
Exemple #12
0
 public bool Create(string measDetId, ElementList sParams) 
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     sParams.Add(new Element("detector_id", l));
     string sSQL1 = "Insert into " + table + " ";
     string sSQL = sSQL1 + sParams.ColumnsValues;            
     return db.Execute(sSQL);
 }
Exemple #13
0
 public long Create(long measid, ElementList sParams) 
 {
     db.SetConnection();
     ArrayList sqlList = new ArrayList();
     string sSQL1 = "Insert into results_rec ";
     sParams.Add(new Element("mid", measid));
     string sSQL = sSQL1 + sParams.ColumnsValues; sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID("results_rec"));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #14
0
 public long Create(long mid, ElementList resParams)
 {
     db.SetConnection();
     resParams.Add(new Element("mid", mid));
     ArrayList sqlList = new ArrayList();
     string sSQL1 = "Insert into " + table + "_m" + " ";
     string sSQL = sSQL1 + resParams.ColumnsValues;
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID(table + "_m" ));
     return db.ExecuteTransactionID(sqlList);
 }
        public BaseDataTypeEdit(string Xmlpath)
        {
            XmlNodeList list = ComeCommonMethod.XmlFunction.GetElementList(Xmlpath, "DataTypeName/Name");

            for (int i = 0; i < list.Count; i++)
            {
                ElementList.Add(new DataBaseTypeElement()
                {
                    ColumnName = list[i].InnerText
                });
            }
        }
Exemple #16
0
        //Adds a diagram lines and shapes to an svg document
        private void AddModelImplementation(Model model)
        {
            ElementList list = new ElementList(true);

            //Add each sorted shape to the svg document
            foreach (Element element in model.Lines.Values)
            {
                if (element.Visible)
                {
                    list.Add(element);
                }
            }

            //Add each sorted line to the svg document
            foreach (Element element in model.Shapes.Values)
            {
                if (element.Visible)
                {
                    list.Add(element);
                }
            }

            list.Sort();

            //Go through the diagram and add the element by layer;
            foreach (Layer layer in model.Layers)
            {
                if (layer.Visible)
                {
                    foreach (Element element in list)
                    {
                        if (element.Layer == layer)
                        {
                            AddElement(element);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Add Image to Pdf from Image path with Scale size.
        /// </summary>
        /// <param name="ImagePath"></param>
        /// <param name="ImageSize"></param>
        /// <exception cref="System.ArgumentNullException">ImagePath is null.</exception>
        /// <exception cref="System.UriFormatException">ImagePath is empty.-or- The scheme specified in ImagePath is not correctly formed.</exception>
        private static void AddImageWithSize(String ImagePath, float ImageSize = 100f)
        {
            System.Drawing.Image Image = System.Drawing.Bitmap.FromFile(ImagePath);

            iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(Image, System.Drawing.Imaging.ImageFormat.Jpeg);

            pic.ScaleAbsolute(ImageSize, ImageSize);
            PdfPTable table = new PdfPTable(1);

            table.AddCell(new PdfPCell(pic));
            table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
            ElementList.Add(table);
        }
Exemple #18
0
        public ElementList ToElementList(string layerName)
        {
            TMXLayer thisLayer = this.Map.Layers.FirstOrDefault(s => s.Name == layerName);

            if (thisLayer == null)
            {
                throw new Exception("Unable to find layer '" + layerName + "'");
            }

            ElementList newElementList = new ElementList();
            MapCellList list           = ParseTMXData(thisLayer.Data);

            int tileX = 0;
            int tileY = 0;

            foreach (MapCell cell in list)
            {
                if (cell.TileID > 0)
                {
                    TMXTile tile = GetTileById(cell.TileID);
                    string  type = tile.Properties.FirstOrDefault(p => p.Name.ToLower() == "type").Value;
                    if (type == null)
                    {
                        type = "0";
                    }
                    string state = tile.Properties.FirstOrDefault(p => p.Name.ToLower() == "state").Value;
                    if (state == null)
                    {
                        state = "0";
                    }

                    Element ele = new Element()
                    {
                        Type  = type,
                        State = state,
                        X     = (tileX * this.Map.TileWidth),
                        Y     = (tileY * this.Map.TileHeight)
                    };
                    newElementList.Add(ele);
                }

                tileX++;
                if (tileX > this.Map.Width)
                {
                    tileX = 0;
                    tileY++;
                }
            }

            return(newElementList);
        }
        /// <summary>
        /// Appends the specified element to the end of this queue.
        /// </summary>
        /// <remarks>
        /// Queues may place limitations on what elements may be added
        /// to this Queue. In particular, some Queues will impose restrictions
        /// on the type of elements that may be added. Queue implementations
        /// should clearly specify in their documentation any restrictions on
        /// what elements may be added.
        /// </remarks>
        /// <param name="obj">
        /// Element to be appended to this Queue.
        /// </param>
        /// <returns>
        /// <b>true</b> (as per the general contract of the IList.Add method)
        /// </returns>
        /// <exception cref="InvalidCastException">
        /// If the class of the specified element prevents it from being added
        /// to this Queue.
        /// </exception>
        public virtual bool Add(object obj)
        {
            lock (this)
            {
                ElementList.Add(obj);

                // this Queue reference is waited on by the blocking remove
                // method; use notify to wake up a thread waiting
                // to remove
                Monitor.Pulse(this);

                return(true);
            }
        }
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------

        /*
         * build the _elementList with a set of random numbers.
         */
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                _build();
            }

            for (int i = 0; i < ElementNumber; i++)
            {
                int randomPosition = Random.Next(0, NumberList.Count);
                ElementList.Add(NumberList[randomPosition]);
                NumberList.RemoveAt(randomPosition);
            }

            ElementList.Sort();
        }
Exemple #21
0
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();

                this._build();
            }

            for (int i = 0; i < ElementNumber; i++)
            {
                int chance = this.random.Next(0, NumberList.Count);
                NumberList.Remove(chance);
                ElementList.Add(chance);
            }
            ElementList.Sort();
        }
Exemple #22
0
        public void Handle(UserChangedEvent message)
        {
            var viewmodel = (from vm in ElementList where vm.Id == message.User.Id select vm).FirstOrDefault();

            if (viewmodel == null)
            {
                viewmodel = new UserRowViewModel(message.User);
                ElementList.Add(viewmodel);
                ConnectElement(viewmodel);
            }
            else
            {
                viewmodel.ExchangeData(message.User);
                viewmodel.Refresh();
            }
            NotifyOfPropertyChange(() => ItemSelected);
            NotifyOfPropertyChange(() => ItemsSelected);
        }
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                _build();
            }

            for (int i = 1; i <= ElementNumber; i++)
            {
                int n = _random.Next(1, 50);

                NumberList.Remove(n);
                ElementList.Add(n);
            }
            ElementList.Sort();
        }
Exemple #24
0
        // PUBLIC METHODS +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+

        // CREATING the public PickElements method here --------------------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                this._build();
            }

            for (int i = 0; i < ElementNumber; i++)
            {
                int Number = aa_random.Next(NumberList.Count);

                ElementList.Add(NumberList[Number]);
                NumberList.RemoveAt(Number);
            }

            ElementList.Sort();
        }
Exemple #25
0
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                _build();
            }

            for (int i = 1; i <= ElementNumber; i++)
            {
                int r = _random.Next(NumberList.Count);

                ElementList.Add(NumberList[r]);

                NumberList.RemoveAt(r);
            }
            ElementList.Sort();
        }
Exemple #26
0
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();

                _build();
            }

            for (int i = 0; i < ElementNumber; i++)
            {
                int index = random.Next(NumberList.Count);
                ElementList.Add(NumberList[index]);
                NumberList.RemoveAt(index);
            }

            ElementList.Sort();
        }
Exemple #27
0
        /// <summary>Get all AvailableElementData</summary>
        /// <returns>list of all AvailableElementData.</returns>
        internal ElementList <AvailableElementData> GetAvailableElementDataList()
        {
            ElementList <AvailableElementData> elementDataList = new ElementList <AvailableElementData>();

            lock (_systemListLock)
            {
                elementDataList.Capacity = _systemList.Count;
                foreach (KeyValuePair <string, SystemInfo> system in _systemList)
                {
                    AvailableElementData elementData = T2GDataConverter.BuildAvailableElementData(system.Value);

                    if (elementData != null)
                    {
                        elementDataList.Add(elementData);
                    }
                }
            }

            return(elementDataList);
        }
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // CREATE the public PickElements method here ----------------------------
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();

                _build();
            }

            for (int i = 0; i < ElementNumber; i++)
            {
                int lottery = _random.Next(NumberList.Count);                           // element list real number, numberlist = how many list you have

                ElementList.Add(NumberList[lottery]);                                   // Add
                NumberList.RemoveAt(lottery);                                           // remove above
            }

            ElementList.Sort();
        }
        /// <summary>
        /// Extended version of AddParagraph to avoid passing the Document object.
        /// </summary>
        /// <param name="ParagraphContent"></param>
        /// <param name="FontFamily"></param>
        /// <param name="FontSize"></param>
        /// <param name="FontColor"></param>
        public static void AddParagraph2(String ParagraphContent, String FontFamily, float FontSize, Color?FontColor = null)
        {
            //baseFont = BaseFont.CreateFont(TextFont.Name, BaseFont.TIMES_ROMAN, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font ltFont;
            BaseColor            basecolor;

            if (FontColor != null)
            {
                basecolor = new BaseColor((Color)FontColor);
                ltFont    = FontFactory.GetFont(FontFamily, FontSize, basecolor);
            }
            else
            {
                ltFont = FontFactory.GetFont(FontFamily, FontSize);
            }

            Paragraph ltParagraph = new Paragraph(ParagraphContent, ltFont);

            ElementList.Add(ltParagraph);
        }
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        public void PickElements()
        {
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                _build();
            }
            int j = 0;

            while (j < ElementNumber)
            {
                int randPosition = _random.Next(NumberList.Count);
                ElementList.Add(NumberList[randPosition]);
                NumberList.Remove(NumberList[randPosition]);
                j++;
            }

            ElementList.Sort();
        }
Exemple #31
0
        /// <summary>
        /// Constructs a block selector window.
        /// </summary>
        public BlockPlacer(Engine engine, LevelEditor parentEditor)
            : base("Block Selector")
        {
            this.parentEditor = parentEditor;

            ScreenButton _but = new ScreenButton(this, "Back", "<", engine.FontMain);

            _but.Position.X = boarderSize;
            _but.Size.X     = 32;
            ElementList.Add(_but);
            _but            = new ScreenButton(this, "Forward", ">", engine.FontMain);
            _but.Position.X = boarderSize + 32 + boarderSize;
            _but.Size.X     = 32;
            _but.Position.Y = headerSize + boarderSize;
            ElementList.Add(_but);
            _but            = new ScreenButton(this, "New Block", "New", engine.FontMain);
            _but.Position.X = boarderSize + 32 + boarderSize + 32 + boarderSize;
            _but.Size.X     = 48;
            _but.Position.Y = headerSize + boarderSize;
            ElementList.Add(_but);
            _but            = new ScreenButton(this, "Edit Block", "Edit", engine.FontMain);
            _but.Position.X = boarderSize + 32 + boarderSize + 32 + boarderSize + 48 + boarderSize;
            _but.Size.X     = 48;
            _but.Position.Y = headerSize + boarderSize;
            ElementList.Add(_but);
            _but            = new ScreenButton(this, "Save/Load", "Sv/Ld", engine.FontMain);
            _but.Position.X = boarderSize + 32 + boarderSize + 32 + boarderSize + 48 + boarderSize + 48 + boarderSize;
            _but.Size.X     = 48;
            _but.Position.Y = headerSize + boarderSize;
            ElementList.Add(_but);

            InputField = new ScreenInput(this, engine.FontMain);
            AddElement(InputField);

            PrevPosition = new Vector2((Size.X - PrevBoxWidth * PrevMaximumColumns) / 2, GetTotalElementHeight());
            this.Size.Y  = PrevPosition.Y + Screen.boarderSize + PrevMaximumRows * PrevBoxHeight;

            FilterBlocks(engine);

            this.Position = new Vector2(engine.windowSize.X - this.Size.X, 0);
        }
Exemple #32
0
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // CREATE the public PickElements method here ----------------------------
        public void PickElement()
        {  /* using if statement to clean previously Element list and Number list, then create
            * new number list so that the newest Element list can be created through for statement */
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();
                _build();
            }
            for (int i = 1; i <= ElementNumber; i++)
            {
                //Select random number between 1 to 49
                int randomNumber = random.Next(1, 50);
                //Remove selected number from Number list to avoid selecting repeated number
                NumberList.Remove(randomNumber);
                //Add selected number to Element list
                ElementList.Add(randomNumber);
                //Sort element list ordered by ascending
                ElementList.Sort();
            }
        }
        private void Start()
        {
            ElementList.Clear();

            var message = Resources.Message_BusyIndicator_Title;

            var result = _BusyWindow.ExecuteAndWait(message, InspectDirectory);

            if (_BusyWindow.IsSuccessfullyExecuted == true)
            {
                ElementList.Add(result);
                result.IsExpanded = true;

                RefreshElementsVisibilities();
            }
            else
            {
                MessageBox.Show(
                    string.Format(Resources.Message_Error_ParsingDirectoryFailed, _BusyWindow.ExecutionException.Message),
                    Resources.Message_ApplicationTitle, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public bool Update(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";
            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
                table = "LMMultiplicity";

            Detectors dets = new Detectors(db);
            long l = dets.PrimaryKey(DetectorName);
            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return false;
            }

            if (table.Equals("LMMultiplicity"))
                dr = HasRow(DetectorName, CounterType, table, sParams[faidx].Value); // the FA parameter
            else
                dr = HasRow(DetectorName, CounterType, table);
            if (dr == null)
            {
                sParams.Add(new Element("detector_id", l));
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return db.Execute(sSQL);
            }
            else
            {
                //NEXT: not tested(?)
                string sSQL = "UPDATE " + table + " SET ";
                sSQL += (sParams.ColumnEqValueList + " where counter_type=" + SQLSpecific.QVal(CounterType) + " AND detector_id=" + l.ToString());
                if (table.Equals("LMMultiplicity"))
                    sSQL += " AND " + sParams[faidx].Name + "=" + sParams[faidx].Value;
                return db.Execute(sSQL);
            }
        }
        public void VerityCtor()
        {
            ElementList noargslist = new ElementList();
            noargslist.Add(new Element("b").Update("Chris"));
            Assert.AreEqual("<b>Chris</b>", noargslist.ToString());

            ElementList argslist = new ElementList(
                new Element("b").Update("Riley"),
                new Element("i").Update("Emmitt"));
            string actual = argslist;
            Assert.AreEqual("<b>Riley</b><i>Emmitt</i>", actual);
        }
Exemple #36
0
 protected string CycleInsertStatement(long Measurement_ID, ElementList sParams)
 {
     sParams.Add(new Element("mid", Measurement_ID));
     return "Insert into cycles " + sParams.ColumnsValues;
 }
Exemple #37
0
 protected string HVPRunInsertStatement(long HVPId, ElementList sParams)
 {
     sParams.Add(new Element("hvp_id", HVPId));
     return "Insert into HVStatus " + sParams.ColumnsValues;
 }
Exemple #38
0
 public long CreateMethod(long resid, long mid, ElementList resParams)
 {
     db.SetConnection();
     resParams.Add(new Element("rid", resid));
     resParams.Add(new Element("mid", mid));
     ArrayList sqlList = new ArrayList();
     string sSQL1 = "Insert into " + MethodTableName(resParams.OptTable) + " ";
     string sSQL = sSQL1 + resParams.ColumnsValues;
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID(MethodTableName(resParams.OptTable)));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #39
0
        public bool Update(string DetectorName, string ItemType, ElementList sParams)
        {
                bool res = false;
                db.SetConnection();
                //NEXT: this duo-lookup part takes too long, so get the values once in a wrapper call, then cache them, then reuse them
                DataRow dr = HasRow(DetectorName, ItemType); // sets the connection
                Detectors dets = new Detectors(db);
                long l = dets.PrimaryKey(DetectorName);
                Descriptors mats = new Descriptors("material_types", db);
                long m = mats.PrimaryKey(ItemType);

                if (l == -1 || m == -1)
                {
                    DBMain.AltLog(LogLevels.Warning, 70130, "Missing Det/Mat keys ({0},{1}) selecting AnalysisMethods", l, m);
                    return false;
                }


                if (dr == null) // a new entry!
                {
                    string sSQL = "insert into analysis_method_rec ";
                    sParams.Add(new Element("item_type_id", m));
                    sParams.Add(new Element("analysis_method_detector_id", l));
                    sSQL = sSQL + sParams.ColumnsValues;
                    res = db.Execute(sSQL);
                }
                else
                {
                    string wh = " where item_type_id= " + m.ToString() + " AND analysis_method_detector_id=" + l.ToString();
                    string sSQL1 = "UPDATE analysis_method_rec SET ";
                    string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
                    res = db.Execute(sSQL);
                }
            
            return res;
        }
Exemple #40
0
       ///////////////////////

        public bool UpdateCalib(string DetectorName, string ItemType, string calib_table, ElementList sParams)
        {
            //NEXT: this duo-lookup part takes too long, so get the values once in a wrapper call, then cache them, then reuse them
            long l, m; 
            GetKeys(DetectorName, ItemType, out l, out m);
            DataRow dr = HasRow(l, m); // sets the connection

            if (l == -1 || m == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det/Mat keys ({0},{1}) selecting method calibration params", l, m);
                return false;
            }
            string wh = " where item_type_id= " + m.ToString() + " AND detector_id=" + l.ToString();
            string exsql = "select item_type_id from " + calib_table + wh; // 1 column is sufficient to show existence

            DataTable dt = db.DT(exsql);
            if (dt.Rows.Count < 1)
            {
                string sSQL = "insert into " + calib_table + " ";
                sParams.Add(new Element("item_type_id", m));
                sParams.Add(new Element("detector_id", l));
                sSQL += sParams.ColumnsValues;
                return db.Execute(sSQL);
            }
            else
            {
                string sSQL1 = "UPDATE " + calib_table + " SET ";
                string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
                return db.Execute(sSQL);
            }
        }
        public bool Insert(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";
            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
                table = "LMMultiplicity";

            Detectors dets = new Detectors(db);
            long l = dets.PrimaryKey(DetectorName);
            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return false;
            }

            if (table.Equals("LMMultiplicity"))
                dr = HasRow(l, CounterType, table, sParams, sParams[faidx].Value); // the FA parameter
            else
                dr = HasRow(l, CounterType, table, sParams);
            if (dr == null)
            {
                sParams.Add(new Element("detector_id", l));
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return db.Execute(sSQL);
            }
            else
            {
                // identical row found, skip it
                return false;
            }
        }
Exemple #42
0
 public long CreateTbl(long id, string table, ElementList sParams, IDB db) 
 {
     sParams.Add(new Element("detector_id", id));
     string sSQL1 = "Insert into " + table + " ";
     string sSQL = sSQL1 + sParams.ColumnsValues;
     
     ArrayList sqlList = new ArrayList(); 
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID(table));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #43
0
 protected string CIInsertStatement(long cid, ElementList sParams)
 {
     sParams.Add(new Element("cid", cid));
     return "Insert into composite_isotopic_rec " + sParams.ColumnsValues;
 }