コード例 #1
0
ファイル: ProcessingListScreen.cs プロジェクト: mgladilov/Cas
        private void MoveToCommand()
        {
            if (_directivesViewer.SelectedItems.Count == 0)
            {
                return;
            }

            if (GlobalObjects.AircraftsCore.GetAircraftsCount() == 0 &&
                GlobalObjects.CasEnvironment.Stores.Count == 0)
            {
                MessageBox.Show("You dont remove this component because you dont have a aircrafts", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var components = new CommonCollection <Component>();

            foreach (var o in _directivesViewer.SelectedItems)
            {
                IDirective dir;
                if (o is NextPerformance)
                {
                    dir = ((NextPerformance)o).Parent;
                }
                else
                {
                    dir = o as IDirective;
                }

                if (dir == null)
                {
                    continue;
                }
                if (dir is ComponentDirective && !components.Contains(((ComponentDirective)dir).ParentComponent))
                {
                    components.Add(((ComponentDirective)dir).ParentComponent);
                }
                else if (dir is Component && !components.Contains((Component)dir))
                {
                    components.Add((Component)dir);
                }
            }

            if (components.Count <= 0)
            {
                return;
            }

            var dlg = new MoveComponentForm(components.ToArray(), CurrentStore);

            dlg.Text = "Move " +
                       (components.Count > 1
                                           ? "components"
                                           : "component " + components[0].Description)
                       + " to aircraft";

            dlg.ShowDialog();

            if (dlg.DialogResult == DialogResult.OK)
            {
                AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoWork;
                //AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoFilteringWork;
                AnimatedThreadWorker.DoWork += AnimatedThreadWorkerDoWork;

                AnimatedThreadWorker.RunWorkerAsync();
            }
        }