private void Ok_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;

            switch (_mode)
            {
            default:
            case Mode.New:
                var domain    = MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
                var address   = AddressBox.ToLong() ?? 0;
                var notes     = NotesBox.Text;
                var type      = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString());
                var bigEndian = BigEndianCheckBox.Checked;
                switch (SizeDropDown.SelectedIndex)
                {
                case 0:
                    Watches.Add(Watch.GenerateWatch(domain, address, WatchSize.Byte, type, bigEndian, notes));
                    break;

                case 1:
                    Watches.Add(Watch.GenerateWatch(domain, address, WatchSize.Word, type, bigEndian, notes));
                    break;

                case 2:
                    Watches.Add(Watch.GenerateWatch(domain, address, WatchSize.DWord, type, bigEndian, notes));
                    break;
                }

                break;

            case Mode.Edit:
                DoEdit();
                break;

            case Mode.Duplicate:
                var tempWatchList = new List <Watch>();
                tempWatchList.AddRange(Watches);
                Watches.Clear();
                foreach (var watch in tempWatchList)
                {
                    Watches.Add(Watch.GenerateWatch(
                                    watch.Domain,
                                    watch.Address,
                                    watch.Size,
                                    watch.Type,
                                    watch.BigEndian,
                                    watch.Notes));
                }

                DoEdit();
                break;
            }

            Close();
        }
        private void AddWatch(string name, object message)
        {
            var watch = Watches.FirstOrDefault(w => w.Name == name);

            if (watch == null)
            {
                watch = new WatchViewModel {
                    Name = name
                };
                Watches.Add(watch);
            }

            watch.Value = message;
        }
Esempio n. 3
0
 public void Test()
 {
     Watches.Clear();
     for (int i = 0; i < Times; i++)
     {
         var sw = Stopwatch.StartNew();
         for (int o = 0; o < Iterations; o++)
         {
             Function();
         }
         sw.Stop();
         Watches.Add(sw);
     }
 }
Esempio n. 4
0
        public void AddTrackingItem(ProductMasterItem item)
        {
            if (!Watches.Contains(item))
            {
                double currentInv = 0;
                var    inv        = StaticInventoryTracker.InventoryItems.FirstOrDefault(x => x.MasterID == item.MasterID);
                if (inv != null)
                {
                    currentInv = inv.Units;
                }

                Watches.Add(item);
                foreach (var trackingDay in TrackingDays)
                {
                    currentInv = trackingDay.AddTracking(item, currentInv);
                }
            }
        }
Esempio n. 5
0
        public void Load()
        {
            try
            {
                using (FileStream stream = File.OpenRead(saveFile))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    Watches.Clear();

                    int watchCount = (int)formatter.Deserialize(stream);

                    for (; watchCount > 0; watchCount--)
                    {
                        ProductMasterItem watch = (ProductMasterItem)formatter.Deserialize(stream);
                        Watches.Add(watch);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 6
0
 public void AddWatch(Watch watch)
 {
     Watches.Add(watch);
 }