Exemplo n.º 1
0
        private void addRemoveCollection(int from, int to)
        {
            DiskInfo tempdiskInfo = new DiskInfo();

            // tempdiskInfo = null;
            if (from.Equals(1))
            {
                tempdiskInfo = DiskFirstRow.LastOrDefault();
            }
            else if (from.Equals(2))
            {
                tempdiskInfo = DiskSecondRow.LastOrDefault();
            }
            else
            {
                tempdiskInfo = DiskThirdRow.LastOrDefault();
            }

            if (to.Equals(1))
            {
                DiskFirstRow.Add(tempdiskInfo);
            }
            else if (to.Equals(2))
            {
                DiskSecondRow.Add(tempdiskInfo);
            }
            else
            {
                DiskThirdRow.Add(tempdiskInfo);
            }

            if (from.Equals(1))
            {
                DiskFirstRow.Remove(tempdiskInfo);
            }
            else if (from.Equals(2))
            {
                DiskSecondRow.Remove(tempdiskInfo);
            }
            else
            {
                DiskThirdRow.Remove(tempdiskInfo);
            }
            this.textMovement.Text = (++diskMovment).ToString();
        }
Exemplo n.º 2
0
 private void ButtonAddClick(object sender, System.Windows.RoutedEventArgs e)
 {
     this.ButtonAdd.IsEnabled = false;
     Mouse.OverrideCursor     = Cursors.Wait;;
     try
     {
         if (this.TextBoxDiskSize.Text != string.Empty && !String.IsNullOrWhiteSpace(this.TextBoxDiskSize.Text))
         {
             int diskSize      = Convert.ToInt16(this.TextBoxDiskSize.Text);
             var sequenceCheck = DiskFirstRow.LastOrDefault(smallValue => smallValue.DiskSize <= diskSize);
             if (sequenceCheck == null)
             {
                 DiskFirstRow.Add(new DiskInfo {
                     DiskSize = diskSize
                 });
             }
             else
             {
                 throw new Exception(string.Format("Enter a Smaller Disk Size Than {0}", DiskFirstRow.LastOrDefault().DiskSize));
             }
         }
         else
         {
             throw new Exception("Please Enter a Disk Size Between 50 to 90 ");
         }
     }
     catch (Exception error)
     {
         Mouse.OverrideCursor = null;
         MessageBox.Show(error.Message, projectName, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         Mouse.OverrideCursor      = null;
         this.ButtonAdd.IsEnabled  = true;
         this.TextBoxDiskSize.Text = string.Empty;
     }
 }