예제 #1
0
        // Add items to lists.
        internal static void Build()
        {
            AllParts.Clear();
            AllParts.Add(new InHousePart(1, "LCD Screen", 12, 49.25, 25, 25, 2525));
            Inventory.AllParts.Add(new InHousePart(2, "Microphone", 25, 6.32, 50, 0, 9874));
            Inventory.AllParts.Add(new InHousePart(3, "Front Camera", 25, 8.99, 25, 25, 7898));
            Inventory.AllParts.Add(new InHousePart(4, "Rear Camera", 25, 9.99, 50, 0, 8748));
            Inventory.AllParts.Add(new InHousePart(5, "Touch Sensor", 25, 9.99, 50, 0, 1974));
            Inventory.AllParts.Add(new OutSourcedPart(6, "GPS", 25, 15.65, 25, 25, "ABC Tecknology"));
            Inventory.AllParts.Add(new OutSourcedPart(7, "Battery", 25, 24.65, 50, 0, "Duracell Lithium LLC"));
            Inventory.AllParts.Add(new OutSourcedPart(8, "Phone Speaker", 25, 24.65, 50, 0, "Motorola"));
            Inventory.AllParts.Add(new OutSourcedPart(9, "Processor", 25, 24.65, 50, 0, "Intel"));
            Inventory.AllParts.Add(new OutSourcedPart(10, "Processor", 25, 24.65, 50, 0, "AMD"));

            // products partslist
            Inventory.Products.Clear();
            Inventory.Products.Add(new Product(101, "OnePlus", 25, 624.65, 50, 0, Inventory.onePlusPhoneList));
            Inventory.Products.Add(new Product(102, "Moto", 25, 624.65, 50, 0, Inventory.motorolaPhoneList));
            Inventory.Products.Add(new Product(103, "Google Phone", 30, 895.99, 50, 25, Inventory.googlePhoneList));
            Inventory.Products.Add(new Product(104, "Samsung Galaxy", 25, 955.25, 50, 0, Inventory.samsungPhoneList));
            Inventory.Products.Add(new Product(105, "iPhone", 25, 1125.95, 25, 25, Inventory.iPhoneList));
            Inventory.Products.Add(new Product(106, "LG View", 25, 599.65, 50, 0, Inventory.lGPhoneList));

            Inventory.googlePhoneList.Clear();
            Inventory.googlePhoneList.Add(new InHousePart(1, "LCD Screen", 12, 49.25, 25, 25, 2525));
            Inventory.googlePhoneList.Add(new InHousePart(3, "Front Camera", 25, 8.99, 25, 25, 7898));


            // samsung phone partslist
            Inventory.samsungPhoneList.Clear();
            Inventory.samsungPhoneList.Add(new InHousePart(3, "Front Camera", 25, 8.99, 25, 25, 7898));
            Inventory.samsungPhoneList.Add(new InHousePart(4, "Rear Camera", 25, 9.99, 50, 0, 8748));
            Inventory.samsungPhoneList.Add(new OutSourcedPart(6, "GPS", 25, 15.65, 25, 25, "ABC Tecknology"));
            Inventory.samsungPhoneList.Add(new OutSourcedPart(7, "Battery", 25, 24.65, 50, 0, "Duracell Lithium LLC"));
            Inventory.samsungPhoneList.Add(new OutSourcedPart(9, "Processor", 25, 24.65, 50, 0, "Intel"));

            // iPhone partslist
            Inventory.iPhoneList.Clear();
            Inventory.iPhoneList.Add(new InHousePart(1, "LCD Screen", 12, 49.25, 25, 25, 2525));
            Inventory.iPhoneList.Add(new InHousePart(4, "Rear Camera", 25, 9.99, 50, 0, 8748));
            Inventory.iPhoneList.Add(new OutSourcedPart(6, "GPS", 25, 15.65, 25, 25, "ABC Tecknology"));
            Inventory.iPhoneList.Add(new OutSourcedPart(7, "Battery", 25, 24.65, 50, 0, "Duracell Lithium LLC"));
            Inventory.iPhoneList.Add(new OutSourcedPart(10, "Processor", 25, 24.65, 50, 0, "AMD"));

            // LG phone partslist
            Inventory.lGPhoneList.Clear();
            Inventory.lGPhoneList.Add(new InHousePart(1, "LCD Screen", 12, 49.25, 25, 25, 2525));
            Inventory.lGPhoneList.Add(new InHousePart(3, "Front Camera", 25, 8.99, 25, 25, 7898));
            Inventory.lGPhoneList.Add(new InHousePart(4, "Rear Camera", 25, 9.99, 50, 0, 8748));
            Inventory.lGPhoneList.Add(new OutSourcedPart(7, "Battery", 25, 24.65, 50, 0, "Duracell Lithium LLC"));
            Inventory.lGPhoneList.Add(new OutSourcedPart(10, "Processor", 25, 24.65, 50, 0, "AMD"));

            // motorola phone partslist
            Inventory.motorolaPhoneList.Clear();
            Inventory.motorolaPhoneList.Add(new InHousePart(1, "LCD Screen", 12, 49.25, 25, 25, 2525));

            // onePlus phone partlist
            Inventory.onePlusPhoneList.Clear();
            Inventory.onePlusPhoneList.Add(new InHousePart(4, "Rear Camera", 25, 9.99, 50, 0, 8748));
        }
예제 #2
0
        public static Part LookupPart(int partID)
        {
            var partToLookup = AllParts.Where(p => p.PartID == partID).FirstOrDefault();

            if (partToLookup == null)
            {
                throw new Exception(message: $"A part with ID #{partID} is not available for look-up.");
            }

            return(partToLookup);
        }
예제 #3
0
        public static bool DeletePart(Part part)
        {
            var partToDelete = AllParts.FirstOrDefault();

            if (partToDelete == null)
            {
                throw new Exception(message: "There are no parts available to be deleted.");
            }

            AllParts.Remove(partToDelete);
            return(true);
        }
예제 #4
0
        public static void SaveComputer(string path)
        {
            // Reset price if discounted
            if (LoadedComputer[0].IsDiscounted)
            {
                LoadedComputer.Select(x => new
                {
                    PartInLoadedComputer   = x,
                    PartInAllPartsDatabase = AllParts.Find(y => x.ToStringNoPrice() == y.ToStringNoPrice())
                })
                .ToList()
                .ForEach(x => x.PartInLoadedComputer.Price = x.PartInAllPartsDatabase.Price);
            }

            Save(path, LoadedComputer, false);
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var quickID = int.Parse(textBox1.Text);
                if (AllParts.Contains(quickID))
                {
                    throw new Exception();
                }
                AllParts.Add(quickID);

                using (var context = new InventoryContext())
                {
                    var part = context.Part.Where(x => x.QuickID == quickID).FirstOrDefault();
                    if (part == null)
                    {
                        throw new ArgumentNullException();
                    }
                    PartList.Add(part);

                    var grid = PartList.Select(x => new
                    {
                        QuickID      = x.QuickID,
                        PartNumber   = x.PartNumber,
                        SerialNumber = x.SerialNumber,
                        Description  = x.Description,
                        Location     = x.Location,
                        Category     = x.Category,
                        Quantity     = 1
                    }).ToList();

                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = grid;
                }
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("That QuickID was not found.");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"You cannot add the same QuickID twice \r\n \r\n {ex.Message}");
            }
        }
예제 #6
0
        //DeletePart
        public bool DeletePart(int i)
        {
            bool success = false;

            for (int j = 0; j < AllParts.Count; j++)
            {
                if (AllParts[j].PartID.Equals(i))
                {
                    AllParts.RemoveAt(CurrentPartIndex);
                    return(success = true);
                }
                else
                {
                    MessageBox.Show("Removal failed.");
                    return(false);
                }
            }
            return(success);
        }
예제 #7
0
 public static void testData()
 {
     AllParts.Add(new Inhouse(2333, 4011, "Small Wheel",
                              10.33m, 12, 2, 50));
     AllParts.Add(new Inhouse(2335, 4016, "Tiny Screw",
                              15.00m, 6, 2, 56));
     AllParts.Add(new Inhouse(2337, 4020, "Funny Horn",
                              60m, 128, 122, 500));
     AllParts.Add(new Inhouse(2411, 4152, "Sounding Brass",
                              45.12m, 5, 2, 12));
     AllParts.Add(new Inhouse(2615, 4144, "Bunny Ears",
                              6.66m, 8, 7, 20));
     AllParts.Add(new Inhouse(2768, 4516, "Noob Sticker",
                              91.13m, 12, 3, 300));
     AllParts.Add(new Inhouse(2222, 4689, "Inside-Out Slinky",
                              82.11m, 47, 40, 244));
     AllParts.Add(new Outsourced("Chain Store", 4152, "Jingley Chain",
                                 17.12m, 7, 1, 50));
     AllParts.Add(new Outsourced("Local Connectors", 4651, "THE Nut",
                                 13.12m, 84, 152, 500));
     AllParts.Add(new Outsourced("Recycled Parts", 4993, "Yellowed Seat",
                                 12.10m, 17, 17, 50));
     AllParts.Add(new Outsourced("Recycled Parts", 4731, "Broken Tire",
                                 147.10m, 10, 2, 544));
     AllParts.Add(new Outsourced("Music Store", 4278, "8 Track",
                                 1412.42m, 47, 2, 147));
     AllParts.Add(new Outsourced("Foreign Imports", 4676, "Chopsticks",
                                 71.10m, 177, 172, 500));
     Products.Add(new Product(5001, "Offroad Unicycle", 100.00m,
                              14, 8, 52, AllParts[1], AllParts[3], AllParts[6]));
     Products.Add(new Product(5021, "Random Organ Teleporter", 1000.00m,
                              122, 56, 123, AllParts[2], AllParts[1]));
     Products.Add(new Product(5087, "Ice Cream Launcher", 4.00m,
                              6, 1, 43, AllParts[3], AllParts[5]));
     Products.Add(new Product(1234, "Missing Pin", 1m, 40, 11, 45, AllParts[4], AllParts[8]));
     Products.Add(new Product(5271, "Potato Shaped Balloon", 111.00m,
                              16, 6, 57, AllParts[12], AllParts[5], AllParts[7]));
     Products.Add(new Product(5501, "Tie Fighter", 121.00m,
                              57, 7, 72, AllParts[11], AllParts[9], AllParts[6]));
     Products.Add(new Product(5901, "Space/Time Parachute", 30.00m,
                              17, 8, 28, AllParts[10], AllParts[6], AllParts[9]));
 }
예제 #8
0
 public static void LoadPartGUI(StringReader partAsCSV)
 {
     Load(null, AddedPart, partAsCSV);
     AllParts.AddRange(AddedPart);
 }
예제 #9
0
        private void BackgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Craft File (*.craft)|*.craft";
            open.Title = "Open Launcher .craft";
            open.FileName = "";
            if (open.ShowDialog() == DialogResult.Cancel)
                return;
            System.IO.StreamReader read = new System.IO.StreamReader(new System.IO.FileStream(open.FileName, System.IO.FileMode.Open));
            open.Dispose();
            string[] lel = { Environment.NewLine };
            Tex = read.ReadToEnd().Split(lel, StringSplitOptions.None);
            read.BaseStream.Close();
            read.Close();

            open = new OpenFileDialog();
            open.Filter = "Craft File (*.craft)|*.craft";
            open.Title = "Open Payload .craft";
            open.FileName = "";
            if (open.ShowDialog() == DialogResult.Cancel)
                return;
            read = new System.IO.StreamReader(new System.IO.FileStream(open.FileName, System.IO.FileMode.Open));
            Tex = Tex.Concat(read.ReadToEnd().Split(lel, StringSplitOptions.None)).ToArray();
            read.BaseStream.Close();
            read.Close();

            string partname = "";
            bool b = false;
            string ignorelist = "";
            int i = 0;
            int i2 = -1;
            ListView2.Items.Clear();
            ProgressBar1.Maximum = Tex.GetUpperBound(0) + 1;
            int namecount = 0;
            string firstname = "";
            foreach (string Str in Tex)
            {
                int stage = 0;
                if (Str.Contains("ship = "))
                {
                    if (namecount == 0)
                    {
                        firstname = Str.Remove(0, Str.LastIndexOf("=") + 1).Trim();
                        namecount = 1;
                    }
                    else
                    {
                        Label3.Text = "Launcher: " + firstname + Environment.NewLine + "Payload: " + Str.Remove(0, Str.LastIndexOf("=") + 1).Trim();
                    }
                }
                //-----------------------------------------------------------------------------------------------------
                if (Str.Contains("PART"))
                {
                    b = true;
                }
                if (Str.Contains("part =") & b == true)
                {
                    partname = Str.Remove(0, Str.LastIndexOf("=") + 1).Replace(" ", "");
                    try
                    {
                        partname = partname.Remove(partname.IndexOf("_"));

                    }
                    catch
                    {
                    }
                }
                if (Str.Contains("sqor") & b == true)
                {
                    stage = Convert.ToInt32(Str.Remove(0, Str.LastIndexOf("=") + 1).Replace(" ", ""));
                    Part p = new Part();
                    try
                    {
                        p = Parts[partname];
                    }
                    catch
                    {
                        if (ignorelist.Contains(partname) == false)
                        {
                            MessageBox.Show("Part not defined in part list: \"" + partname + "\"");
                            ignorelist = ignorelist + partname;
                        }
                    }
                    p.Stage = stage;
                    Array.Resize(ref PartList, i2 + 2);
                    i2 += 1;
                    PartList[i2] = p;
                }
                if (Str.Contains("}") & b == true)
                {
                    b = false;
                }
                i += 1;
                ProgressBar1.Value = i;
            }
            AllParts all = new AllParts(PartList);
            ListView2.Items.Add("Total Cost").SubItems.Add(all.Cost.ToString());
            ListView2.Items.Add("Total Mass").SubItems.Add(Math.Round(all.Mass, 2, MidpointRounding.AwayFromZero).ToString());
            ListView2.Items.Add("Total Dry Mass").SubItems.Add(all.DryMass.ToString());
            ListView2.Items.Add("Total Thrust").SubItems.Add(all.Thrust.ToString());
            ListView2.Items.Add("Total LiquidFuel").SubItems.Add(all.LiquidFuel.ToString());
            ListView2.Items.Add("Total Oxidizer").SubItems.Add(all.Oxidizer.ToString());
            ListView2.Items.Add("Total MonoPropellant").SubItems.Add(all.MonoPropellant.ToString());
            ListView2.Items.Add("Total Electricity").SubItems.Add(all.Electricity.ToString());
            ListView2.Items.Add("Minimum TWR").SubItems.Add(Math.Round(MassToTWR(all.Mass), 2, MidpointRounding.AwayFromZero).ToString());
            ListView2.Items.Add("Maximum TWR").SubItems.Add(Math.Round(MassToTWR(all.DryMass), 2, MidpointRounding.AwayFromZero).ToString());
            ListView2.Items.Add("Estimated ISP").SubItems.Add(all.ISP.ToString());
            ListView2.Items.Add("Estimated Delta-V").SubItems.Add(Math.Round((Math.Log(all.Mass / all.DryMass) * all.ISP * 9.81), 2, MidpointRounding.AwayFromZero).ToString());
        }
 public static void UpdatePart(int idx, Part selectedPart)
 {
     AllParts.Insert(idx, selectedPart);
     AllParts.RemoveAt(idx + 1);
 }
 internal void AddPart(Part part)
 {
     AllParts.Add(part);
 }
예제 #12
0
 public int GetThrust(int Stage = 0)
 {
     AllParts all = new AllParts(PartList);
     return all.Thrust;
 }
예제 #13
0
 // Add Part.
 internal static Part AddPart(Part part)
 {
     AllParts.Add(part);
     return(part);
 }
예제 #14
0
 // Remove Part by Part.
 internal static void RemovePart(Part part)
 {
     AllParts.RemoveAt(CurrentPartIndex);
 }
예제 #15
0
 // Insert Part.
 internal static void InsertPart(Part part)
 {
     AllParts.Insert(CurrentPartIndex, part);
 }
예제 #16
0
 // SwapParts.
 internal static void SwapPart(Part part)
 {
     AllParts.Insert(CurrentPartIndex, part);
     AllParts.RemoveAt(CurrentPartIndex + 1);
 }
예제 #17
0
 public static bool deletePart(int i)
 {
     AllParts.RemoveAt(i);
     return(true);
 }
예제 #18
0
 public static void updatePart(int i, Part part)
 {
     AllParts.Insert(i, part);
     AllParts.RemoveAt(i + 1);
 }
 internal Part LookupPart(int partID)
 {
     return(AllParts.Where(x => x.PartID == partID).FirstOrDefault());
 }
예제 #20
0
        private void ProcessFile()
        {
            string[] allLines = File.ReadAllLines(FilePath);

            var   i            = 0;
            Regex indexRegex   = new Regex(@"(\d+)");
            Regex timingsRegex = new Regex(@"(\d+):(\d+):(\d+),*(\d*)\s*-->\s*(\d+):(\d+):(\d+),*(\d*)");

            while (i < allLines.Length)
            {
                if (!string.IsNullOrEmpty(allLines[i]))
                {
                    SubtitlePart part = new SubtitlePart(this);

                    //Read Index
                    Match indexMatch = indexRegex.Match(allLines[i]);
                    if (indexMatch != null && indexMatch.Success)
                    {
                        if (indexMatch.Groups.Count > 0)
                        {
                            if (indexMatch.Groups[0].Success)
                            {
                                part.Index = indexMatch.Groups[0].Value;
                            }
                        }
                    }

                    i++;

                    //Read Timings
                    if (!string.IsNullOrEmpty(allLines[i]))
                    {
                        Match timingsMatch = timingsRegex.Match(allLines[i]);

                        if (timingsMatch != null && timingsMatch.Success)
                        {
                            if (timingsMatch.Groups.Count >= 9)
                            {
                                part.PopulateTiming(timingsMatch.Groups);
                            }
                        }
                    }

                    i++;


                    //Read Content (multiple lines)

                    while (i < allLines.Length && !string.IsNullOrEmpty(allLines[i]))
                    {
                        var line = allLines[i].TrimEnd();
                        part.AddContentLine(MainWindowVM.ReplaceProfanePhrases(line));
                        i++;
                    }

                    part.SerialNumber = AllParts.Count + 1;

                    //Add the part
                    AllParts.Add(part);
                }

                i++; //Added for empty lines
            }
        }
예제 #21
0
 public static void updatePart(int k, Part part)
 {
     AllParts.RemoveAt(k);
     AllParts.Add(part);
 }
예제 #22
0
        private void BackgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Craft File (*.craft)|*.craft";
            open.FileName = "";
            if (open.ShowDialog() == DialogResult.Cancel)
                return;
            System.IO.StreamReader read = new System.IO.StreamReader(new System.IO.FileStream(open.FileName, System.IO.FileMode.Open));
            open.Dispose();
            string partname = "";
            string[] lel = { Environment.NewLine };
            Tex = read.ReadToEnd().Split(lel, StringSplitOptions.None);
            read.BaseStream.Close();
            read.Close();
            bool b = false;
            string ignorelist = "";
            int i = 0;
            int i2 = -1;
            ListView1.Items.Clear();
            ListView2.Items.Clear();
            ProgressBar1.Maximum = Tex.GetUpperBound(0) + 1;
            foreach (string Str in Tex)
            {
                int stage = 0;
                if (Str.Contains("ship = "))
                {
                    Label3.Text = Str.Remove(0, Str.LastIndexOf("=") + 1).Trim();
                }
                //-----------------------------------------------------------------------------------------------------
                if (Str.Contains("PART"))
                {
                    b = true;
                }
                if (Str.Contains("part =") & b == true)
                {
                    partname = Str.Remove(0, Str.LastIndexOf("=") + 1).Replace(" ", "");
                    try
                    {
                        partname = partname.Remove(partname.IndexOf("_"));

                    }
                    catch
                    {
                    }
                }
                if (Str.Contains("sqor") & b == true)
                {
                    stage = Convert.ToInt32(Str.Remove(0, Str.LastIndexOf("=") + 1).Replace(" ", ""));
                    Part p = new Part();
                    try
                    {
                        p = Parts[partname];
                    }
                    catch
                    {
                        if (ignorelist.Contains(partname) == false)
                        {
                            MessageBox.Show("Part not defined in part list: \"" + partname + "\"");
                            ignorelist = ignorelist + partname;
                        }
                    }
                    p.Stage = stage;
                    Array.Resize(ref PartList, i2 + 2);
                    i2 += 1;
                    PartList[i2] = p;
                }
                if (Str.Contains("}") & b == true)
                {
                    b = false;
                }
                i += 1;
                ProgressBar1.Value = i;
            }
            AllParts all = new AllParts(PartList);
            ListView2.Items.Add("Total Cost").SubItems.Add(all.Cost.ToString());
            ListView2.Items.Add("Total Mass").SubItems.Add(all.Mass.ToString());
            ListView2.Items.Add("Total Dry Mass").SubItems.Add(all.DryMass.ToString());
            ListView2.Items.Add("Total Thrust").SubItems.Add(all.Thrust.ToString());
            ListView2.Items.Add("Total LiquidFuel").SubItems.Add(all.LiquidFuel.ToString());
            ListView2.Items.Add("Total Oxidizer").SubItems.Add(all.Oxidizer.ToString());
            ListView2.Items.Add("Total MonoPropellant").SubItems.Add(all.MonoPropellant.ToString());
            ListView2.Items.Add("Total Electricity").SubItems.Add(all.Electricity.ToString());
            for (i = 0; i <= 40; i++)
            {
                double i3 = (i * 0.1) + 1;
                double s1 = TWRToMass(i3) - all.Mass;
                ListView1.Items.Add(i3.ToString()).SubItems.Add(Math.Round(s1, 2, MidpointRounding.AwayFromZero).ToString());
                double s2 = all.Cost / (TWRToMass(i3) - all.Mass);
                ListView1.Items[ListView1.Items.Count - 1].SubItems.Add(Math.Round(s2, 2, MidpointRounding.AwayFromZero).ToString());
            }
        }
예제 #23
0
 //
 //Parts
 //
 //AddPart
 public static void AddPart(Part part)
 {
     AllParts.Add(part);
 }
 internal bool DeletePart(Part part)
 {
     // Check if part exists - return false if not?
     AllParts.Remove(part);
     return(true);
 }
 public static void AddPart(Part newPart)
 {
     AllParts.Add(newPart);
 }
 internal void UpdatePart(int partID, Part part)
 {
     AllParts.Remove(AllParts.Where(x => x.PartID == partID).FirstOrDefault());
     AllParts.Add(part);
 }
예제 #27
0
 public static void addPart(Part addPart)
 {
     AllParts.Add(addPart);
 }