Esempio n. 1
0
 public void SetPersonalInformation(TEntity person)
 {
     person.FirstName         = DataLists.GetFirstName();
     person.LastName          = DataLists.GetLastName();
     person.BirthDate         = DateTime.Now.Date.AddYears(-(RandomUtil.GetRandomInt(15, 16))).AddDays(RandomUtil.GetRandomInt(-365, 365));
     person.PersonNationality = DataLists.GetCountry();
 }
        public ShellViewModel(
            IEventAggregator eventAggregator,
            SocketClient socketClient,
            RobotCommand moveCommand,
            ControllerClass controllerClass
            )
        {
            _socketClient    = socketClient;
            _dashboardClient = new SocketClient(eventAggregator);

            _roboServer = new SocketServer(eventAggregator);

            _robotCommand    = moveCommand;
            _controllerClass = controllerClass;

            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this);

            _controllerClass.StartController();

            _serial       = new SerialCommunication(eventAggregator);
            _BTConnection = new BluetoothConnection(eventAggregator);

            ComPortList       = SerialPort.GetPortNames();
            BaudRateList      = DataLists.GetBaudRates();
            MotorStepTypeList = DataLists.GetStepTypes();
        }
Esempio n. 3
0
        /// <summary>数据转换为待绘制区域上的点集
        /// </summary>
        /// <param name="width">待绘制区域的宽度</param>
        /// <param name="height">待绘制区域的高度</param>
        public List <PointF[]> GetPointsToDraw(int width, int height)
        {
            List <PointF[]> pointsLists = new List <PointF[]>();

            if ((DisplayRect.XRange > 0.9F * XDataAccuracy ||
                 DisplayRect.YRange > 0.9F * YDataAccuracy) &&
                DataLists.HasData())
            {
                foreach (DataPairList <float> dataList in DataLists)
                {
                    List <PointF> points = new List <PointF>();
                    foreach (DataPair <float> dataPair in dataList)
                    {
                        points.Add(new PointF
                        {
                            X = (dataPair.X - DisplayRect.XMin) * (width - 1)
                                / DisplayRect.XRange,
                            Y = (dataPair.Y - DisplayRect.YMin) * (height - 1)
                                / DisplayRect.YRange
                        });
                    }
                    pointsLists.Add(points.ToArray());
                }
            }
            return(pointsLists);
        }
Esempio n. 4
0
        public void Add()
        {
            Output = firstValue + secondValue;
            //check The differences between ObservableCollection<T> and List<T> below,
            // DataLists is an ObservableCollection<T> class
            // and DataListsTest is a List<T> class
            if (DataLists != null)
            {
                DataLists.Add(new DataList()
                {
                    Para = "p", Val = "v"
                });
                DataLists[0].Val = "v1";

                DataListsTest.Add(new DataList()
                {
                    Para = "ptest", Val = "vtest"
                });
                DataListsTest[0].Val = "v1test";
            }
            else
            {
                DataLists     = new ObservableCollection <DataList>();
                DataListsTest = new List <DataList>();
            }
        }
Esempio n. 5
0
        /// <summary>根据画图模式和数据调整坐标显示
        /// </summary>
        public void UpdateDisplayRect(DataRect initialRect, GraphMode graphStyle)
        {
            if (DataLists.HasData())
            {
                if (graphStyle == GraphMode.GlobalMode)
                {
                    DisplayRect.XMin = (DataLists.MinX < initialRect.XMin)
                        ? DataLists.MinX : initialRect.XMin;
                    DisplayRect.XMax = (DataLists.MaxX > initialRect.XMax)
                        ? DataLists.MaxX : initialRect.XMax;
                    DisplayRect.YMin = (DataLists.MinY < initialRect.YMin)
                        ? DataLists.MinY : initialRect.YMin;
                    DisplayRect.YMax = (DataLists.MaxY > initialRect.YMax)
                        ? DataLists.MaxY : initialRect.YMax;
                }
                else if (graphStyle == GraphMode.FixMoveMode)
                {
                    if (DataLists.MaxX > DisplayRect.XMax)
                    {
                        DisplayRect.XMin += DataLists.MaxX - DisplayRect.XMax;
                        DisplayRect.XMax  = DataLists.MaxX;
                    }

                    DisplayRect.YMin = (DataLists.MinY < DisplayRect.YMin)
                        ? DataLists.MinY : DisplayRect.YMin;
                    DisplayRect.YMax = (DataLists.MaxY > DisplayRect.YMax)
                        ? DataLists.MaxY : DisplayRect.YMax;
                }
            }
            else
            {
                DisplayRect.UpdateRect(initialRect);
            }
        }
        public ActionResult Add()
        {
            ViewBag.Brands       = DataLists.ProductBrandsWithDescription();
            ViewBag.Descriptions = DataLists.ProductDescription(0);

            return(View(new InventoryAddViewModel()));
        }
Esempio n. 7
0
 public static void Load()
 {
     RuntimeData      = new DataLists();
     RuntimeProperty  = RuntimeData.GlobalProperties.First();
     RuntimeIndex     = new IndexViewModel();
     RuntimePlane     = new PlaneViewModel();
     RuntimeMaxValues = new MaxValues();
 }
Esempio n. 8
0
        public ICollection <DataList> GetGlobalDataLists()
        {
            if (DataLists == null)
            {
                return(new List <DataList>());
            }

            return(DataLists.Where(d => !d.IsAdHoc).ToList());
        }
        public ActionResult Edit(int id)
        {
            ViewBag.Categories = DataLists.Categories();
            ViewBag.Brands     = DataLists.ProductBrands();
            Product product = Product.GetById(id);
            ProductAddEditViewModel model = new ProductAddEditViewModel(product.Id, product.CategoryId, product.BrandId, product.Description);

            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            Inventory inventory = Inventory.GetById(id);
            Product   product   = Product.GetById(inventory.ProductId);

            ViewBag.Categories   = DataLists.Categories();
            ViewBag.Brands       = DataLists.ProductBrandsWithDescription();
            ViewBag.Descriptions = DataLists.ProductDescription(product.BrandId);

            InventoryEditViewModel model = new InventoryEditViewModel()
            {
                Id               = inventory.Id,
                BrandId          = product.BrandId,
                Description      = product.Description,
                PricePaidPerUnit = inventory.PricePaidPerUnit,
                UnitsPurchased   = inventory.UnitsPurchased,
                UnitsSold        = inventory.UnitsSold,
                CategoryId       = product.CategoryId
            };

            return(View(model));
        }
Esempio n. 11
0
//========================================================================================
// Reading ROM data.


        // Read the project file in Xml format.
        private bool ReadProjectFileXml(
            out List <Tuple <int, int, string> > rooms,
            out List <Tuple <int, int, string> > doorAsms,
            out List <Tuple <int, int, string> > setupAsms,
            out List <Tuple <int, int, string> > mainAsms,
            out List <Tuple <int, string> > backgrounds)
        {
            RomFileName = null;
            rooms       = new List <Tuple <int, int, string> > ();
            doorAsms    = new List <Tuple <int, int, string> > ();
            setupAsms   = new List <Tuple <int, int, string> > ();
            mainAsms    = new List <Tuple <int, int, string> > ();
            backgrounds = new List <Tuple <int, string> > ();

            Stream stream;

            try { stream = new FileStream(ProjectPath + ProjectFileName, FileMode.Open,
                                          FileAccess.Read, FileShare.Read); }
            catch
            {
                throw new ProjectLoadException(ProjectLoadException.Type.ProjectFileNotAccessible,
                                               ProjectPath + ProjectFileName);
            }
            var      reader = XmlReader.Create(stream);
            XElement root   = XElement.Load(reader);

            stream.Close();

            RomFileName = root.Attribute("rom")?.Value;
            if (root.Name != "Project" || RomFileName == null)
            {
                throw new ProjectLoadException(ProjectLoadException.Type.RomFileNotSpecified,
                                               ProjectPath + ProjectFileName);
            }
            try
            {
                CurrentRom = new Rom(ProjectPath + RomFileName);
            }
            catch (FileNotFoundException)
            {
                throw new ProjectLoadException(ProjectLoadException.Type.RomFileNotFound,
                                               ProjectPath + RomFileName);
            }
            catch
            {
                throw new ProjectLoadException(ProjectLoadException.Type.RomFileNotAccessible,
                                               ProjectPath + RomFileName);
            }

            foreach (XElement x in root.Elements())
            {
                switch (x.Name.ToString())
                {
                case "Areas":
                    foreach (XElement area in x.Elements("Area"))
                    {
                        string areaIndex = area.Attribute("index")?.Value;
                        string areaName  = area.Attribute("name")?.Value;
                        if (areaIndex != null && areaName != null)
                        {
                            int i = Convert.ToInt32(areaIndex);
                            Areas [i] = areaName;
                        }
                    }
                    break;

                case "Sections":
                    foreach (XElement section in x.Elements("Section"))
                    {
                        string sectionName = section.Attribute("name")?.Value;
                        string sectionType = section.Attribute("type")?.Value;
                        if (sectionName == null || sectionType == null)
                        {
                            continue;
                        }
                        CurrentRom.AddSection(sectionName, RomSection.StringToType(sectionType));
                        foreach (XElement data in section.Elements("Data"))
                        {
                            string dataName = data.Attribute("name")?.Value;
                            if (dataName != null && DataLists.ContainsKey(dataName))
                            {
                                CurrentRom.AddDataList(sectionName, dataName, DataLists [dataName]);
                            }
                        }
                        foreach (XElement block in section.Elements("Block"))
                        {
                            string blockAddress = block.Attribute("address")?.Value;
                            string blockEnd     = block.Attribute("end")?.Value;
                            if (blockAddress != null && blockEnd != null)
                            {
                                CurrentRom.AddBlock(sectionName, Tools.HexToInt(blockAddress),
                                                    Tools.HexToInt(blockEnd) - Tools.HexToInt(blockAddress));
                            }
                        }
                    }
                    break;

                case "Rooms":
                    foreach (XElement room in x.Elements("Room"))
                    {
                        string roomAddress = room.Attribute("address")?.Value;
                        string doorCount   = room.Attribute("doorCount")?.Value;
                        string roomName    = room.Attribute("name")?.Value;
                        if (roomAddress != null)
                        {
                            int address = Tools.HexToInt(roomAddress);
                            int count   = doorCount != null?Tools.DecToInt(doorCount) : 0;

                            rooms.Add(new Tuple <int, int, string> (address, count,
                                                                    roomName ?? String.Empty));
                        }
                    }
                    break;

                case "Asms":
                    foreach (XElement asm in x.Elements())
                    {
                        List <Tuple <int, int, string> > asmList;
                        switch (asm.Name.ToString())
                        {
                        case "DoorAsm":
                            asmList = doorAsms;
                            break;

                        case "SetupAsm":
                            asmList = setupAsms;
                            break;

                        case "MainAsm":
                            asmList = mainAsms;
                            break;

                        default:
                            continue;
                        }
                        string asmName    = asm.Attribute("name")?.Value;
                        string asmAddress = asm.Attribute("address")?.Value;
                        string asmEnd     = asm.Attribute("end")?.Value;
                        if (asmAddress != null && asmEnd != null)
                        {
                            asmList.Add(new Tuple <int, int, string> (Tools.HexToInt(asmAddress),
                                                                      Tools.HexToInt(asmEnd),
                                                                      asmName ?? asmAddress));
                        }
                    }
                    break;

                case "Backgrounds":
                    foreach (XElement background in x.Elements("Background"))
                    {
                        string address = background.Attribute("address")?.Value;
                        string name    = background.Attribute("name")?.Value;
                        if (address != null)
                        {
                            backgrounds.Add(new Tuple <int, string> (Tools.HexToInt(address),
                                                                     name ?? address));
                        }
                    }
                    break;

                default:
                    break;
                }
            }

            return(true);
        }
 public ActionResult Add()
 {
     ViewBag.Categories = DataLists.Categories();
     ViewBag.Brands     = DataLists.ProductBrands();
     return(View(new ProductAddEditViewModel()));
 }
Esempio n. 13
0
 public static void InitialiseDataSet()
 {
     IntegerVariables();
     StringVariables();
     DataLists.InitialiseDataLists();
 }