Ejemplo n.º 1
0
 // 确认按钮
 private void okButton_Click(object sender, EventArgs e)
 {
     if (opeType == OpeType.ADD)
     {
         if (orderBinding.Contains(order))
         {
             resLabel.Text = $"{order.orderNumber}号订单已存在!";
         }
         else
         {
             mainForm.afterAdd(order);
             this.Close();
         }
     }
     else if (opeType == OpeType.EDIT)
     {
         if (order.orderNumber != oldOrder.orderNumber && orderBinding.Contains(order)) // 修改了订单号,但是改成了已存在的
         {
             resLabel.Text = $"{order.orderNumber}号订单已存在!";
         }
         else
         {
             mainForm.afterEdit(oldOrder, order);
             this.Close();
         }
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Ejemplo n.º 2
0
 void UpdateHistoryList(object sender, FitsFile file)
 {
     if (!fileHistoryBS.Contains(file))
     {
         fileHistoryBS.Add(file);
     }
     fileHistoryListBox.SelectedItem = file;
 }
Ejemplo n.º 3
0
        private void purchaseButton_Click(object sender, EventArgs e)
        {
            // Loop through shopping cart list
            for (int i = 0; i < cartList.Count; i++)
            {
                // Mark each item in shopping cart list as sold
                cartList[i].Sold = true;

                // Calculate and add commission due to Vendor
                cartList[i].Owner.PaymentDue += (decimal)cartList[i].Owner.Commission * cartList[i].Price;

                // Calculate and add commission due to Store
                storeProfit += (1 - (decimal)cartList[i].Owner.Commission) * cartList[i].Price;

                // Remove sold items from store items once purchased
                if (itemsBinding.Contains(cartList[i]))
                {
                    itemsBinding.Remove(cartList[i]);
                }
            }
            // Remove sold items from shopping cart
            cartList.Clear();
            // Update storeProfitValue Label to reflect store profit
            storeProfitValue.Text = string.Format("{0:0.00}", storeProfit);

            // Resetting Bindings to update textboxes
            cartBinding.ResetBindings(false);
            vendorBinding.ResetBindings(false);
        }
Ejemplo n.º 4
0
        private void SearchMemberBookingButton_Click(object sender, EventArgs e)
        {
            string   s            = MemberFINTextBox.Text; // try S2403293H
            DateTime today        = DateTime.Today;
            DateTime tomorrowDate = today.AddDays(1);

            tomorrowDate = new DateTime(2018, 1, 31); // test using this date
            //tList = context.Transactions.Where(x => x.NRIC == s && x.BookingDate == date).ToList();
            //Transaction t = context.Transactions.FirstOrDefault(x => x.NRIC == s && x.BookingDate == date);


            try
            {
                Member m = context.Members.FirstOrDefault(x => x.NRIC == s);
                if (m is null)
                {
                    throw new ItemNotFound(String.Format("No Member with NRIC/FIN {0} found", s));
                }
                foreach (Transaction t in m.Transactions)
                {
                    if (t.BookingDate == tomorrowDate && !tList.Contains(t))
                    {
                        tList.Add(t);
                        //MessageBox.Show(BookedDataGridView.Rows.Count.ToString());
                        //DataGridViewRow row = BookedDataGridView.Rows[BookedDataGridView.Rows.Count - 1];
                        //row.Cells["Activity"].Value = context.Facilities.First(x => x.FacilityID == t.FacilityID).Activity;
                        BookedDataGridView.Rows[BookedDataGridView.Rows.Count - 2].Cells["Activity"].Value = context.Facilities.First(x => x.FacilityID == t.FacilityID).Activity;
                    }
                }
            }
            catch (ApplicationException error)
            {
                MessageBox.Show(error.Message);
            }
        }
Ejemplo n.º 5
0
        private bool LoadSavedConfig(string craftName)
        {
            var filePath = GetConfigFilePath(craftName);

            if (!File.Exists(filePath))
            {
                return(false);
            }

            var serializer = new JsonSerializer
            {
                Formatting = Formatting.Indented
            };

            List <ParamDescription> paramList;

            using (var sr = new StreamReader(filePath))
                using (var reader = new JsonTextReader(sr))
                {
                    paramList = serializer.Deserialize <List <ParamDescription> >(reader);
                }

            foreach (var item in paramList)
            {
                if (availableParamsBs.Contains(item))
                {
                    availableParamsBs.Remove(item);
                    activeParamsBs.Add(item);
                }
            }

            ConfigNameLbl.Text = craftName + "_hud.json";
            return(true);
        }
Ejemplo n.º 6
0
        public static void StoreHistoryItem(HistoryItem _Item)
        {
            if (_Item == null)
            {
                Log.Warning("NULL object passed to History.StoreHistoryItem. No item stored.");
                return;
            }
            if (m_HistoryBinding.Contains(_Item))
            {
                Log.Warning("Object already in history passed to History.StoreHistoryItem. No item stored.");
                return;
            }

            m_HistoryBinding.Add(_Item);
            historyItemAdded(_Item);

            StoreHistoryOnDisk();
        }
Ejemplo n.º 7
0
        private void CBAllTr_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Put item from all Transport list to selected Transport list
            ComboBox CB = (ComboBox)sender;

            if (!SelTr.Contains(CB.SelectedItem))
            {
                SelTr.Add(CB.SelectedItem);
            }
            LBSelectedTr.DisplayMember = "ComboName";
            LBSelectedTr.ValueMember   = "Transport_SK";
        }
Ejemplo n.º 8
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            float persent = 0;

            if (Items.Count > 0)
            {
                try
                {
                    persent = (float)((float)Items.Count / ((float)progressBar1.Maximum / 100));
                }
                catch { }
            }

            label1.Text = "Всего элементов: " + Items.Count + " из " + progressBar1.Maximum + "                       " + persent + "%";
            if (progressBar1.Maximum >= Items.Count)
            {
                progressBar1.Value = Items.Count;
            }
            progressBar1.Refresh();
            if (Reload.Checked)
            {
                ParseGrid.Refresh();
                //BindingSource source = new BindingSource(Items.ToArray(),"");
                // source.Clear();
                try
                {
                    foreach (var item in Items)
                    {
                        if (!source.Contains(item))
                        {
                            source.Add(item);
                            if (item.ChildrenItems.Count != 0)
                            {
                                foreach (var child in item.ChildrenItems)
                                {
                                    source.Add(child);
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            //dataGridView1.DataSource = source;
        }
Ejemplo n.º 9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            List <string> names = new List <string>();

            foreach (object o in chkProperties.CheckedItems)
            {
                names.Add(o.ToString());
            }

            UniqueConstraintInfo uniq = new UniqueConstraintInfo(names.ToArray());

            if (bs.Contains(uniq))
            {
                MessageService.ShowError("This unique constraint already exists");
            }
            else
            {
                bs.Add(uniq);
            }
        }
        private void AddDiskToListRent(DiskInfoRent disk)
        {
            if (disk.DiskRentalStatus.Equals(STATUS_RENTED))
            {
                MessageBox.Show("Vui lòng kiểm tra lại thông tin\nĐĩa này đã được thuê", "Thuê Đĩa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (disk.DiskRentalStatus.Equals(STATUS_ONHOLD))
            {
                MessageBox.Show("Vui lòng kiểm tra lại thông tin\nĐĩa này đã được đặt trước", "Thuê Đĩa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (binding.Contains(disk))
            {
                MessageBox.Show("Vui lòng kiểm tra lại thông tin\nĐĩa này đã tồn tại trong danh sách", "Thuê Đĩa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //Thêm vào danh sách

            binding.Add(disk);
        }
Ejemplo n.º 11
0
        //checks if a RomMatch with the same ID is already in the BindingSource, if so it's status is reset else it's added
        bool checkRow(RomMatch romMatch)
        {
            if (importerBindingSource.Contains(romMatch))
            {
                return(true);
            }

            foreach (DataGridViewRow row in importGridView.Rows)
            {
                //Game already in gridview, must be previously ignored. Reset status and return
                RomMatch rowRomMatch = (RomMatch)row.DataBoundItem;
                if (romMatch.ID == rowRomMatch.ID)
                {
                    int rowNum = row.Index;
                    importerBindingSource.RemoveAt(rowNum);
                    romMatch.BindingSourceIndex = rowRomMatch.BindingSourceIndex;
                    importerBindingSource.Insert(rowNum, romMatch);
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 12
0
 public bool Contains(object i_Value)
 {
     return(r_OriginalBindingSource.Contains(i_Value));
 }
Ejemplo n.º 13
0
        private void buttonSkillSearch_Click(object sender, EventArgs e)
        {
            // Define a new binding source to hold our list of filtered employees.
            BindingSource filteredEmployees = new BindingSource();

            try
            {
                // Make a list of keywords to search for in
                // Skill entity name and description.
                List <string> keywords = new List <string>();
                int           i        = 0;
                int           j        = 0;

                while (i < textBoxKeywords.Text.Length)
                {
                    j = textBoxKeywords.Text.IndexOf(" ", i);
                    if (-1 == j)
                    {
                        j = textBoxKeywords.Text.Length;
                    }
                    keywords.Add(
                        textBoxKeywords.Text.Substring(i, j - i));

                    i = ++j;
                }

                foreach (string keyword in keywords)
                {
                    // Create ObjectParameter from each keyword
                    // and search properties of Skills.
                    ObjectParameter param = new ObjectParameter(
                        "p", "%" + keyword + "%");

                    // Query for skills that match the supplied string.
                    ObjectQuery <Skill> skillsQuery =
                        context.Skills.Where("it.BriefDescription Like @p " +
                                             "OR it.SkillName Like @p", param);


                    foreach (Skill skill in skillsQuery)
                    {
                        // Load the related employee for the skill.
                        if (!skill.EmployeeReference.IsLoaded)
                        {
                            skill.EmployeeReference.Load();
                        }

                        // Build a BindingSource of Employees based on
                        // the skills returned by the query.
                        if (!filteredEmployees.Contains(skill.Employee))
                        {
                            filteredEmployees.Add(skill.Employee);
                        }
                    }
                }

                if (filteredEmployees.Count > 0)
                {
                    // Bind the constructed list of employees to the binding source.
                    employeesBindingSource.DataSource = filteredEmployees;
                    employeesBindingSource.MoveFirst();

                    // Refresh the employees grid for the current filtered employee.
                    dataGridViewEmployees_CurrentCellChanged(null, null);
                }
                else
                {
                    MessageBox.Show("The supplied query returned no matching employees.",
                                    "No Matching Skills");
                }
            }

            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString(),
                                                     "Error Message");
            }
        }
Ejemplo n.º 14
0
        private void BindingSource_ListChanged(object sender, ListChangedEventArgs e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemMoved:
                if (ucImageListView != null)
                {
                    ucImageListView.Items.Move(ucImageListView.Items[e.OldIndex], e.NewIndex);
                    var item = ucImageListView.Items[e.NewIndex];
                    if (item != null && ucImageListView.IsItemVisible(item) == ItemVisibility.NotVisible)
                    {
                        ucImageListView.EnsureVisible(item.Index);
                    }
                }
                break;

            case ListChangedType.Reset:
                // if (ucImageListView != null) ucImageListView.Items.Clear();
                break;

            case ListChangedType.ItemAdded:

                if (ucImageListView != null)
                {
                    var           img    = BindingSource[e.NewIndex] as ImageDocument;
                    ImageListItem ImgItm = null;
                    if (Path.IsPathRooted(img.Description) && File.Exists(img.Description))
                    {
                        ImgItm = new ImageListItem(img.Description);
                    }
                    else
                    {
                        ImgItm = new ImageListItem(img);

                        if (img.GUid != Guid.Empty)
                        {
                            ImgItm.FileName = img.GUid.ToString();
                        }
                        else
                        {
                            ImgItm.FileName = Guid.NewGuid().ToString();
                        }
                    }

                    ImgItm.Tag    = img;
                    ImgItm.Text   = img.OrderInDocument.ToString();
                    ImgItm.ZOrder = img.OrderInDocument;
                    // var ii = BindingSource.IndexOf(img);


                    if (ucImageListView.Items.Count == 0)      //زمانی که اولین تصویر افزوده می شود مقدار طول و عرض از روی آن مشخص می شود
                    {
                        if (sbnPictureBox1.CurrentImage != null)
                        {
                            ucImageListView.ThumbnailSize = new Size((int)((sbnPictureBox1.CurrentImage.Width - 30) * sbnPictureBox1.Zoom), (int)(sbnPictureBox1.CurrentImage.Height * sbnPictureBox1.Zoom));
                        }
                        else
                        {
                            if (img.Width > 100 && img.Height > 100)
                            {
                                ucImageListView.ThumbnailSize = new Size((int)((img.Width - 30) * sbnPictureBox1.Zoom), (int)(img.Height * sbnPictureBox1.Zoom));
                            }
                        }
                    }


                    ucImageListView.Items.Insert(BindingSource.IndexOf(img), ImgItm);     //.Add(ImgItm);
                }
                break;

            case ListChangedType.ItemDeleted:
                if (ucImageListView != null)
                {
                    foreach (var item in ucImageListView.Items)
                    {
                        if (item.Tag is ImageDocument)
                        {
                            if (!BindingSource.Contains(item.Tag as ImageDocument))
                            {
                                ucImageListView.Items.Remove(item);
                                break;
                            }
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 15
0
        internal void RefreshThumbnailItems()
        {
            //foreach (var imgItm in BindingSource)
            //{
            //    if (imgItm is ImageDocument)
            //    {
            //        ImageListViewItem itm = null;
            //        foreach (ImageListViewItem item in Items)
            //        {
            //            if (item.Tag is ImageDocument)
            //            {
            //                if (object.ReferenceEquals((item.Tag as ImageDocument) , (imgItm as ImageDocument)))
            //                {


            //                    itm = item;
            //                    break;

            //                }

            //            }
            //        }

            //        if (itm == null)
            //        {
            //            AddImage(imgItm as ImageDocument);
            //        }

            //    }
            //}



            Collection <ImageListViewItem> removeItems = new Collection <ImageListViewItem>();

            foreach (var item in Items)
            {
                if (item.Tag is ImageDocument)
                {
                    if (BindingSource.Contains(item.Tag as ImageDocument))
                    {
                        if ((item.Tag as ImageDocument).OrderInDocument != BindingSource.IndexOf(item.Tag) + 1)
                        {
                            (item.Tag as ImageDocument).OrderInDocument = BindingSource.IndexOf(item.Tag) + 1;
                            item.ZOrder = BindingSource.IndexOf(item.Tag) + 1;
                            item.Text   = (item.Tag as ImageDocument).OrderInDocument.ToString();
                        }
                    }
                    else
                    {
                        /// فکر کنم به این دیگر نیازی نباشه
                        // removeItems.Add(item);
                    }
                }
            }

            foreach (var item in removeItems)
            {
                Items.Remove(item);
            }
        }
Ejemplo n.º 16
0
        private async Task UpdateHud(CancellationToken cancellationToken)
        {
            try
            {
                while (true)
                {
                    var text = "";
                    var obj  = await Telemetry.GetFlightData();

                    int delay = 1000;

                    if (obj != null && obj["type"] != "dummy_plane")
                    {
                        if (!prevDataValid)
                        {
                            currentCraftName = obj["type"];

                            prevDataValid                 = true;
                            CurrentCraftNameLbl.Text      = currentCraftName;
                            CurrentCraftNameLbl.ForeColor = System.Drawing.Color.DarkGreen;
                            ReloadBtn.Enabled             = true;
                            LoadBtn.Enabled               = true;

                            LogEntriesLbl.Text  = "0";
                            LogFileSizeLbl.Text = "0 kb";

                            await ReloadParams();

                            LoadSavedConfig();

                            if (LoggingEnableChkBox.Checked)
                            {
                                StartLogging();
                            }
                            else
                            {
                                LogFileNameLbl.Text = "Logging not active";
                            }
                        }

                        if (LoggingEnableChkBox.Checked)
                        {
                            var loggingDict = new Dictionary <byte, float>();

                            byte id = 0;
                            foreach (var item in paramIdToName)
                            {
                                if ((activeParamsBs.Contains(new ParamDescription(item)) && LogShownRB.Checked) || LogAllRB.Checked)
                                {
                                    if (float.TryParse(obj[item], NumberStyles.Any, CultureInfo.InvariantCulture, out float value))
                                    {
                                        loggingDict.Add(id, value);
                                    }
                                }
                                id++;
                            }

                            LogWriter.AddRecord(ref loggingDict);

                            LogEntriesLbl.Text  = LogWriter.NumEntries.ToString();
                            LogFileSizeLbl.Text = $"{LogWriter.FileSize / 1024} kb";
                        }

                        foreach (ParamDescription item in activeParamsBs)
                        {
                            if (!obj.ContainsKey(item.Name))
                            {
                                continue;
                            }

                            try
                            {
                                var formatString = $"{{0,{item.Format}}}";

                                var temp = $"{item.Description,-6}";
                                temp += String.Format(CultureInfo.InvariantCulture, formatString, double.Parse(obj[item.Name], CultureInfo.InvariantCulture));
                                temp += " " + item.Unit + "\n";

                                text += temp;
                            }
                            catch (FormatException)
                            {
                                text += $"{item.Description,-6} Bad format string\n";
                            }
                        }

                        delay = Properties.Settings.Default.RefreshRate;
                    }
                    else
                    {
                        if (prevDataValid)
                        {
                            LogShownRB.Enabled = true;
                            LogAllRB.Enabled   = true;

                            prevDataValid                 = false;
                            ReloadBtn.Enabled             = false;
                            LoadBtn.Enabled               = false;
                            CurrentCraftNameLbl.ForeColor = System.Drawing.Color.DarkRed;

                            LogWriter.FinalizeLog();
                        }
                    }

                    hudForm.HUDLabel.Text = text;

                    Task waitTask = Task.Delay(delay, cancellationToken);
                    try
                    {
                        await waitTask;
                    }
                    catch (TaskCanceledException)
                    {
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Hud update task exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }