Ejemplo n.º 1
0
        private void btnDisconnectClient_Click(object sender, EventArgs e)
        {
            string clientName = (string)this.dgvClientNames.SelectedRows[0].Cells[0].Value;

            _clientNames.Remove(_clientNames.First(ant => ant.ClientName == clientName));
            DisconnectClientEvent(this, clientName);
        }
        /// <summary>
        /// Loads matchups for the round.
        /// </summary>
        /// <param name="round">Round number whose matchups are to be displayed.</param>
        private void loadMatchups(int round)
        {
            //Loop thorugh all the rounds in the tournament
            foreach (List <Matchup> matchups in tournament.Rounds)
            {
                //If the desired round is found
                if (matchups.First().MatchupRound == round)
                {
                    //Clear the matchups list from the form
                    selectedMatchups.Clear();

                    //Loop through all the matchups in the round
                    foreach (Matchup m in matchups)
                    {
                        //If the matchup is currently ongoing i.e no winner yet or the unplayed box is unchecked, add the matchup to the list
                        if (m.Winner == null || !unplayedCheckBox.Checked)
                        {
                            selectedMatchups.Add(m);
                        }
                    }
                }
            }

            //If there are matchups in the round, then load the first matchup info
            if (selectedMatchups.Count > 0)
            {
                LoadMatchup(selectedMatchups.First());
            }

            //Display the info of matchup
            DisplayMatchupInfo();
        }
Ejemplo n.º 3
0
        private Boolean Check(Boolean Show)
        {
            Boolean Check = true;

            if (!Edit_AC.Checked && !String.IsNullOrEmpty(Edit_DeviceNumber.Text))
            {
                if (DeviceNumberId.IsEmpty())
                {
                    Edit_DeviceNumber.ErrorText          = DeviceNumberTooltTip;
                    Edit_DeviceNumber.ErrorIconAlignment = ErrorIconAlignment.MiddleRight;
                    Check = false;
                }
                if (!Check || Show)
                {
                    ToolTip t = new ToolTip();
                    t.ToolTipTitle = DeviceNumber;
                    t.ToolTipIcon  = DeviceNumberId.IsEmpty() ? ToolTipIcon.Error : ToolTipIcon.Info;
                    t.Show(DeviceNumberTooltTip, Edit_DeviceNumber, 3000);
                }
            }
            else
            {
                DeviceNumber                = "";
                DeviceNumberId              = Guid.Empty;
                DeviceNumberTooltTip        = "";
                Edit_DeviceNumber.ErrorText = "";
                WarrantyEndDate             = null;
            }
            for (Int32 i = 0; i < DataList.Count; i++)
            {
                DataList[i].Validate();
            }

            View_Sensors.RefreshData();
            if (DataList.Any(sensor => !sensor.Valid))
            {
                Int32 i = DataList.IndexOf(DataList.First(sensor => !sensor.Valid));
                ToolTipControllerShowEventArgs Args = Controller_ToolTip.CreateShowArgs();
                Args.SelectedControl = Control_Sensors;
                Args.ToolTipType     = ToolTipType.SuperTip;
                Args.SuperTip        = new SuperToolTip();
                SuperToolTipSetupArgs toolTipArgs = new SuperToolTipSetupArgs();
                toolTipArgs.Title.Text    = DataList[i].Sensor ?? "<Пусто>";
                toolTipArgs.Contents.Text = DataList[i].ToolTip;
                Args.SuperTip.Setup(toolTipArgs);
                Args.IconType = DataList[i].Valid ? ToolTipIconType.Information : ToolTipIconType.Error;
                GridRowInfo RowInfo = (View_Sensors.GetViewInfo() as GridViewInfo).GetGridRowInfo(i);
                if (RowInfo.IsNull())
                {
                    Controller_ToolTip.ShowHint(Args, Control_Sensors);
                }
                else
                {
                    Controller_ToolTip.ShowHint(Args, Control_Sensors.GetLocation() + (Size)RowInfo.TotalBounds.Location + RowInfo.TotalBounds.Size);
                }
                return(false);
            }
            return(Check);
        }
Ejemplo n.º 4
0
 private void EditReward()
 {
     if (ctlRewardGrid.SelectedCells.Count != 0)
     {
         var reward     = rewardList.First(r => r.ID == SelectedEntityID(ctlRewardGrid));
         var rewardForm = new RewardForm(reward);
         if (rewardForm.ShowDialog() == DialogResult.OK)
         {
             reward.Title       = rewardForm.Title;
             reward.Description = rewardForm.Description;
         }
     }
     else
     {
         MessageBox.Show($"Вы не выбрали награду для редактирования.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 5
0
 // フォームを表示
 private void frmMultiSelectListBox_Activated(object eventSender, EventArgs eventArgs)
 {
     if (ListBoxItems.Any())
     {
         SRC.GUIStatus.DisplayUnitStatus(SRC.UList.Item(ListBoxItems.First().ListItemID));
     }
     UpdateList();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Save the changes in the table to the file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridScrape_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                // Save all objects in the binding list to the real company list (to save the changed value of "Selected")
                foreach (var gridObject in _bindingList)
                {
                    _companiesManager.Resources.First(o => o.Equals(gridObject.Company)).Selected = gridObject.Selected;
                    _companiesManager.SaveChangesToFile();

                    // Update status
                    _bindingList.First(o => o.Name.Equals(gridObject.Company.Name)).Status =
                        _companiesManager.Resources.First(o => o.Equals(gridObject.Company)).Selected ?
                        @"Waiting" : @"Disabled";
                }
            }
        }
Ejemplo n.º 7
0
        /**
         * NOS BUSCA SI EL ID EXISTE O NO Y NOS DEVUELVE UN BOOLEANO, TODO ESTO A PARTIR DE UN OBJETO Y LA LISTA DEL
         * MISMO TIPO DE OBJECTO
         **/
        public static bool buscarId(object sender, EventArgs e, Object objeto, BindingList <object> lista)
        {
            int    total = lista.Count;
            int    id, id2;
            string nombre, nombre2, lugar, lugar2 = "", hora, hora2 = "", fecha, fecha2, direccion, direccion2 = "";
            bool   igual = false;

            id2     = (int)objeto.GetType().GetProperty("id").GetValue(objeto);
            nombre2 = (string)objeto.GetType().GetProperty("nombre").GetValue(objeto);
            if (objeto is Actividad)
            {
                lugar2 = (string)objeto.GetType().GetProperty("lugar").GetValue(objeto);
                hora2  = (string)objeto.GetType().GetProperty("hora").GetValue(objeto);
                fecha2 = (string)objeto.GetType().GetProperty("fecha").GetValue(objeto);
            }
            else if (objeto is Libreria)
            {
                direccion2 = (string)objeto.GetType().GetProperty("direccion").GetValue(objeto);
            }

            for (int i = 0; i < total; i++)
            {
                id     = (int)lista.First().GetType().GetProperty("id").GetValue(lista[i]);
                nombre = (string)lista.First().GetType().GetProperty("nombre").GetValue(lista[i]);
                if (objeto is Actividad)
                {
                    lugar = (string)lista.First().GetType().GetProperty("lugar").GetValue(lista[i]);
                    hora  = (string)lista.First().GetType().GetProperty("hora").GetValue(lista[i]);
                    fecha = (string)objeto.GetType().GetProperty("fecha").GetValue(lista[i]);
                    if (id != id2 && nombre == nombre2 && lugar == lugar2 && hora == hora2)
                    {
                        igual = true;
                    }
                }
                else if (objeto is Libreria)
                {
                    direccion = (string)objeto.GetType().GetProperty("direccion").GetValue(lista[i]);
                    if (id != id2 && nombre == nombre2 && direccion == direccion2)
                    {
                        igual = true;
                    }
                }
            }
            return(igual);
        }
 public void InitCountries()
 {
     Countries = new BindingList <Country>(CountryService.GetAll());
     if (NewPlace.IsValid())
     {
         NewPlace.Country = Countries.First(x => x.Id == NewPlace.Country.Id); //Necessary because initial value in combo box is not set.
         //Initial value must reference one of the collections members
     }
 }
Ejemplo n.º 9
0
        public void DisplayValue(string name)
        {
            var settingDisplayed = Settings.First(s => s.Name == name);

            if (settingDisplayed != null)
            {
                SettingsValue = settingDisplayed.Value;
            }
        }
Ejemplo n.º 10
0
        private void UpdateInfo(string arvID)
        {
            ArchiveInfoDto arv = arvList.First(q => q.ID == arvID); //(q => q.ArvID == arvID);

            if (arv != null)
            {
                arvList.Remove(arv);
            }
        }
Ejemplo n.º 11
0
        // TODO: Changes to the structureBL need to trigger updates to the tab structureList
        private void remBtn_Click(object sender, EventArgs e)
        {
            string key = structureGrid.SelectedRows[0].Cells["key"].Value.ToString();

            if (key.Length > 0)
            {
                structureBL.Remove(structureBL.First(s => s.Key == key));
            }
        }
Ejemplo n.º 12
0
        private void Start1_Click(object sender, EventArgs e)
        {
            ProjectTableRow CurrentRow = ProjectTable.First(x => x.Id == ProId);

            bworker = new BckWorkerTemplate(ProName, TopTable, AnsTemplate, pausebfconfirm, pausebfnextpost, postQnA, ref CurrentRow);
            workerdict.Add(ProId, bworker);
            workerdict[ProId].bwStartDataGrid(sender, e);
            this.Start1.Enabled = false;
        }
Ejemplo n.º 13
0
        private void recalculateVariables()
        {
            List <Variable> newVariables        = DataSetFactory.createVariables(worksheet, range, rangeLayout, variableNamesInFirstRowOrColumn);
            bool            variablesAdded      = newVariables.Count != variables.Count;
            bool            variablesLengthened = rangeLayout == COLUMNS
                ? newVariables.First().getRange().Rows.Count != variables.First().getRange().Rows.Count
                : newVariables.First().getRange().Columns.Count != variables.First().getRange().Columns.Count;

            bool rangesHaveChanged = variablesAdded || variablesLengthened;

            if (rangesHaveChanged || variables.Count == 0)
            {
                variables.Clear();
                foreach (Variable newVariable in newVariables)
                {
                    variables.Add(newVariable);
                }
            }
        }
Ejemplo n.º 14
0
        public CardStack(Point p, params Card[] c)
            : this(p)
        {
            this.AttachCardsAndMove(true, c);

            if (Cards.Count > 0)
            {
                Native.Document.body.insertBefore(Control, Cards.First().Control);
            }
        }
Ejemplo n.º 15
0
 private void PickOutSelectionButton_Click(object sender, EventArgs e)
 {
     queryChanged = true;
     while (_selectedColumns.Count > 0)
     {
         var movedItem = _selectedColumns.First();
         _selectedColumns.Remove(movedItem);
         _notSelectedColumns.Add(movedItem);
     }
 }
Ejemplo n.º 16
0
 public void InitLists()
 {
     SelectedTracks = new BindingList <Track>(NewStation.Tracks.ToList());
     Places         = new BindingList <Place>(PlaceService.GetAllPlaces());
     AllTracks      = new BindingList <Track>(TrackService.GetUnattachedTracks());
     if (NewStation.IsValid())
     {
         NewStation.Place = Places.First(x => x.Id == NewStation.Place.Id);//Necessary to init value in combo box properly
     }
 }
Ejemplo n.º 17
0
 private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount == 2)
     {
         var tb   = sender as TextBlock;
         var name = tb.Text;
         iocItems.Remove(iocItems.First(p => p.Code == name));
     }
     File.WriteAllText(iocItems_path, JsonConvert.SerializeObject(iocItems));
 }
Ejemplo n.º 18
0
        private void sfListView1_SelectionChanged(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangedEventArgs e)
        {
            if (e.AddedItems.First().GetType().Name == nameof(GroupResult))
            {
                return;
            }
            var actionInfo = this.actionsDataSource.Find(x => x.Action == ((ActionInfo)e.AddedItems.First()).Action) ?? new ActionInfo()
            {
                Action = { }
            };
            var         records       = gridGroupingControl1.Table.SelectedRecords;
            List <Task> selectedTasks = new List <Task>();

            foreach (var record in records)
            {
                selectedTasks.Add(service.ts.AllTasks.First(t => t.Name.Equals(record.Record.GetValue(nameof(t.Name)))));
            }

            List <Task> tasks = new List <Task>();

            try
            {
                tasks = actionInfo.Action(selectedTasks);
            }
            catch (UnauthorizedAccessException)
            {
                var identity  = WindowsIdentity.GetCurrent();
                var principal = new WindowsPrincipal(identity);
                MessageBox.Show($"Cannot delete task with your current identity '{identity.Name}' permissions level." +
                                "You likely need to run this application 'as administrator' even if you are using an administrator account.", "Attention");
            }

            if (actionInfo.Action == Service.CreateTask)
            {
                tasks.ForEach(t => tasksDataSource.Add(new TaskData(t)));

                gridGroupingControl1.DataSource = tasksDataSource;
            }

            if (actionInfo.Action == service.DeleteTasks)
            {
                tasks.ForEach(t => tasksDataSource.Remove(tasksDataSource.First(x => x.item.Name.Equals(t.Name))));

                gridGroupingControl1.DataSource = tasksDataSource;
            }

            if (actionInfo.Action == Service.EditTask || actionInfo.Action == Service.SwitchStateTasks)
            {
                RefreshGridView();
            }

            var listView = (SfListView)sender;

            listView.SelectedIndex = -1;
        }
        public RateCalculatorForm()
        {
            InitializeComponent();
            closeButton.Click += OnCloseButtonClick;
            saveButton.Click += OnSaveButtonClick;
            testButton.Click += OnTestButtonClick;

            parameters = new Dictionary<int, string>();
            foreach (object[] d in DataHelper.GetParameters())
            {
                parameters.Add((int)d[0], (string)d[1]);
            }
            repositoryItemComboBox1.Items.Add(string.Empty);
            repositoryItemComboBox1.Items.AddRange(parameters.Values.OrderBy(v => v).ToArray());
            formulas = new BindingList<Formula>(DataHelper.GetFormulas());
            gridRateList.DataSource = formulas;
            modifiedObjects = new Dictionary<int, int>();
            modifiedParams = new Dictionary<int, int>();
            viewRateList.CustomDrawCell += (_,e) => OnCustomDrawCell(false, e);
            viewRateList.CellValueChanged += OnCellValueChanged;
            viewRateList.FocusedRowChanged += OnFocusedRowChanged;

            viewRateParams.CustomDrawCell += (_, e) => OnCustomDrawCell(true, e);
            viewRateParams.CellValueChanged += OnParamCellValueChanged;

            if (formulas.Count > 0)
            {
                viewRateList.SelectRow(0);
                formParameters = new BindingList<FormulaParameter>(formulas.First().Parameters);
                tbFormulaExp.Text = formulas.First().Expression;
            }
            else
            {
                formParameters = new BindingList<FormulaParameter>();
                tbFormulaExp.Text = string.Empty;
            }
            testCalcValue.Text = string.Empty;
            gridRateParams.DataSource = formParameters;
            validButton.Click += OnValidButtonClick;
            tbFormulaExp.TextChanged += OnTextChanged;
            testValues = new List<TestValue>();
        }
Ejemplo n.º 20
0
 private void EditUser()
 {
     if (ctlUserGrid.SelectedCells.Count != 0)
     {
         var user     = userList.First(u => u.ID == SelectedEntityID(ctlUserGrid));
         var userForm = new UserForm(user);
         userForm.listAllRewards = rewardList.ToList();
         if (userForm.ShowDialog() == DialogResult.OK)
         {
             user.FirstName   = userForm.FirstName;
             user.LastName    = userForm.LastName;
             user.Birthdate   = userForm.Birthdate;
             user.RewardsList = userForm.RewardsList;
         }
     }
     else
     {
         MessageBox.Show($"Вы не выбрали пользователя для редактирования.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 21
0
 private void PickOutOrderedSelectionButton_Click(object sender, EventArgs e)
 {
     queryChanged = true;
     while (_orderedColumns.Count > 0)
     {
         var movedItem = _orderedColumns.First();
         movedItem.Order = ColumnInfo.Ordering.None;
         _orderedColumns.Remove(movedItem);
         _notOrderedColumns.Add(movedItem);
     }
 }
Ejemplo n.º 22
0
 private void SelectAllColsButton_Click(object sender, EventArgs e)
 {
     queryChanged = true;
     while (_notOrderedColumns.Count > 0)
     {
         var movedItem = _notOrderedColumns.First();
         movedItem.Order = ColumnInfo.Ordering.Ascending;
         _notOrderedColumns.Remove(movedItem);
         _orderedColumns.Add(movedItem);
     }
 }
Ejemplo n.º 23
0
 private void AddThreadsToWorkingList()
 {
     if (bsWaiting.Count() > 0)// if the waiting list has any threads
     {
         ThreadWork threadWork = bsWaiting.First(x => x.Number == bsWaiting.Max(y => y.Number));
         bsWaiting.Remove(threadWork);
         bsWorking.Add(threadWork);
         //the semaphore is sent as a parameter to the ThreadWork class.
         threadWork.Start(_s);
     }
 }
Ejemplo n.º 24
0
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            var product        = Products.First(it => it.Name == listBox1.SelectedItem);
            var productCashier = new ProductCashier()
            {
                Name = product.Name, Price = product.Price, UoM = product.UoM, CountByPrices = 1.0
            };

            if (ProductCashiers.Any(it => it.Name == productCashier.Name))
            {
                var productCashierTemp = ProductCashiers.First(it => it.Name == productCashier.Name);
                productCashierTemp.CountByPrices += productCashier.CountByPrices;
                ProductCashiers.First(it => it.Name == productCashier.Name).CountByPrices = productCashierTemp.CountByPrices;
                dataGridView1.DataSource = ProductCashiers;
            }
            else
            {
                ProductCashiers.Add(productCashier);
            }
        }
Ejemplo n.º 25
0
        private void loadSceneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "xml files (*.xml)|*.xml";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                XmlSerializer ser = new XmlSerializer(typeof(DummyXML));
                FileStream    fs  = new FileStream(dialog.FileName, FileMode.Open);
                DummyXML      xml = (DummyXML)ser.Deserialize(fs);
                RefreshTimer.Stop();
                BindingList <Camera> newCameras = new BindingList <Camera>();
                Lights.Clear();
                Figures.Clear();
                xml.Cameras.ForEach(c => newCameras.Add(new Camera(c)));
                xml.Lights.ForEach(l => Lights.Add(new Light(l)));
                xml.Cuboids.ForEach(f => Figures.Add(new Cuboid(f)));
                xml.Spheres.ForEach(f => Figures.Add(new Sphere(f)));
                xml.Cylinders.ForEach(f => Figures.Add(new Cylinder(f)));
                xml.Cones.ForEach(f => Figures.Add(new Cone(f)));
                Cameras = newCameras;
                CameraListBox.DataSource = Cameras;
                CameraListBox.ClearSelected();
                CameraListBox.SetSelected(0, true);
                SelectedCamera = Cameras.First();
                if (Cameras.Count == 1)
                {
                    RemoveCameraButton.Enabled = false;
                }
                else
                {
                    RemoveCameraButton.Enabled = true;
                }
                if (Lights.Count != 0)
                {
                    LightListBox.ClearSelected();
                    LightListBox.SetSelected(0, true);
                    SelectedLight             = Lights[0];
                    LightGroupBox.Enabled     = true;
                    RemoveLightButton.Enabled = true;
                }
                else
                {
                    SelectedLight = null;
                    LightListBox.ClearSelected();
                    LightGroupBox.Enabled     = false;
                    RemoveLightButton.Enabled = false;
                }
                Lights.ResetBindings();
                CameraListBox.SelectedIndex = 0;
                FigureDataGrid.Refresh();
                RefreshTimer.Start();
            }
        }
Ejemplo n.º 26
0
        private void ServerListOnConnectionRemoved(object sender, ConnectionsEventArgs e)
        {
            this.connectionsDataSource.Remove(e.Connection);

            if (connectionsDataSource.Any())
            {
                this.SelectedConnection = connectionsDataSource.First();
            }

            this.filesDock.CloseServer(e.Connection, this.SelectedConnection);
        }
Ejemplo n.º 27
0
        private async void btn_magnet_Click(object sender, EventArgs e)
        {
            if (_tracks.Count == 0)
            {
                return;
            }

            Track  track = _tracks.First();
            string query = $"{track.AlbumName} {track.ArtistName}";

            _searcher.Search(query);
        }
Ejemplo n.º 28
0
        private void textBox5_TextChanged(object sender, EventArgs e)
        {
            BindingSource bs = new BindingSource();

            pallets = data.Pallets
                      .OrderBy(o => o.Name)
                      .Where(o => o.Name.ToLower().Contains(textBox5.Text.ToLower())).ToList();
            bs.DataSource        = pallets;
            comboBox2.DataSource = bs;
            if (comboBox2.Items.Count == 0)
            {
                comboBox2.Text = "";
                textBox3.Text  = "";
                textBox4.Text  = "";
            }
            else
            {
                textBox3.Text = mpallets.First(o => o.Palette.Id == pallets[0].Id).Plus.ToString();
                textBox4.Text = mpallets.First(o => o.Palette.Id == pallets[0].Id).Minus.ToString();
            }
        }
Ejemplo n.º 29
0
        private void UpdateListDisplays()
        {
            _loadedFeats.Clear();

            //todo: try and get rid of this loop
            foreach (var dbFeat in _dbFeats)
            {
                _loadedFeats.Add(new FEATS
                {
                    f_id          = dbFeat.f_id,
                    f_name        = dbFeat.f_name,
                    f_description = dbFeat.f_description,
                    f_source      = dbFeat.f_source
                });
            }

            foreach (var feat in _loadedCharacterFeats)
            {
                _loadedFeats.Remove(_loadedFeats.First(x => x.f_id == feat.f_id));
            }
        }
Ejemplo n.º 30
0
 public void Reemplazar(List <OOB.LibInventario.Producto.Data.Ficha> lista)
 {
     foreach (var it in lista)
     {
         var t = blLista.First(f => f.identidad.auto == it.identidad.auto);
         if (t != null)
         {
             blLista.Remove(t);
             blLista.Add(it);
         }
     }
     ActualizarLista();
 }
Ejemplo n.º 31
0
        private BindingList <OrderEditDto> DealStorageAdvanceDays(BindingList <OrderEditDto> list)
        {
            if (list.First().StorageFinishedFlag != "1")
            {
                foreach (var orderEditDto in list)
                {
                    orderEditDto.StorageAdvanceDays =
                        (orderEditDto.PlanStorageDate - Convert.ToDateTime(DateTime.Now.ToShortDateString())).Days;
                }
            }

            return(list);
        }
        private void AssertMatchShows(BindingList<IJointShow> sourceShows, BindingList<IJointShow> loadedShows)
        {
            Assert.AreEqual(sourceShows.Count, loadedShows.Count);

            foreach (IJointShow jointShow in loadedShows)
            {
                IJointShow matchingSourceShow = sourceShows.First(sourceShow => sourceShow.Name == jointShow.Name);
                Assert.NotNull(matchingSourceShow);

                BindingList<IShow> importedShows = (BindingList<IShow>)matchingSourceShow.ImportedShowsDataSource;
                BindingList<IShow> showOrderShows = (BindingList<IShow>)matchingSourceShow.ShowOrderDataSource;
                foreach (IShow showOrderShow in jointShow.ShowOrderShows)
                    Assert.IsTrue(importedShows.Any(show => show.Path == showOrderShow.Path));

                foreach (IShow importedShow in showOrderShows)
                    Assert.IsTrue(importedShows.Any(show => show.Path == importedShow.Path));
            }
        }
Ejemplo n.º 33
0
        private MainViewModel()
        {
            NewCommand = new RelayCommand(CreateNew);
            OpenCommand = new RelayCommand(Open);
            SaveCommand = new RelayCommand(Save, CanSave);
            SaveAsCommand = new RelayCommand(SaveAs, CanSave);
            ExportCommand = new RelayCommand(Export, CanSave);
            UndoCommand = new RelayCommand(Undo, CanUndo);
            RedoCommand = new RelayCommand(Redo, CanRedo);

            OpenProjects = new BindingList<Project>();
            EditorModes = new BindingList<EditorMode>
            {
                EditorMode.Cursor,
                EditorMode.Line,
                EditorMode.Arc,
                EditorMode.Bezier,
                EditorMode.Spline,
            };
            currentEditorMode = EditorModes.First();
        }
        private void DoProcesses(BindingList<Process> _processes)
        {
            while (programIsRunning || _processes.Count > 0)
            {
                if (_processes.Count > 0)
                {
                    mut.WaitOne();
                    List<Process> sortedProcesses = _processes.OrderBy(x => x.Priority).ToList();
                    mut.ReleaseMutex();
                    sortedProcesses[0].Execute();
                    this.Invoke((Action) (() =>
                    {
                        results.First(x => x.ProcessId == sortedProcesses[0].Id).PauseTime =
                            sortedProcesses[0].GetPauseTime();
                        results.First(x => x.ProcessId == sortedProcesses[0].Id).EndTime = watch.ElapsedMilliseconds;
                        _processes.Remove(_processes.First(x => x.Id == sortedProcesses[0].Id));
                        dataGridViewResults.Refresh();
                    }));
                }
                else
                {
                    Thread.Sleep(10);
                    processorFreeTime += 10;
                }

            }
            ActionsAfterProgramStops();
        }
Ejemplo n.º 35
0
 public void init()
 {
     smartphones = DataManager.getSmartphones();
     phonesListBox.DataSource = smartphones;
     phonePictureBox.Image = smartphones.First().image;
 }
        public AnimatedToolbarCanvas()
        {
            var ButtonOuterWidth = 16 + 4;

            Items = new BindingList<AnimatedToolbarItem>();
            Items.WithEvents(
                (AddedSource, AddedIndex) =>
                {
                    AddedSource.x = AddedIndex * ButtonOuterWidth;
                    AddedSource.cx = 8;

                    AddedSource.Button = new Canvas
                    {
                        Cursor = Cursors.Hand
                    }.AttachTo(this);

                    AddedSource.MoveTo =
                        delegate
                        {
                            AddedSource.Button.MoveTo(AddedSource.x + AddedSource.cx, 0);
                        };

                    #region ItemClicked
                    AddedSource.Button.MouseLeftButtonUp +=
                        delegate
                        {
                            if (ItemClicked != null)
                                ItemClicked(AddedSource);
                        };
                    #endregion

                    #region ItemMouseEnter
                    AddedSource.Button.MouseEnter +=
                        (e, s) =>
                        {

                            if (ItemMouseEnter != null)
                                ItemMouseEnter(AddedSource, s);
                        };
                    #endregion

                    #region ItemMouseLeave
                    AddedSource.Button.MouseLeave +=
                      (e, s) =>
                      {


                          if (ItemMouseLeave != null)
                              ItemMouseLeave(AddedSource, s);
                      };
                    #endregion

                    AddedSource.Button.MouseEnter +=
                        delegate
                        {
                            SelectedItem = AddedSource;
                        };

                    AddedSource.a = AddedSource.Button.ToAnimatedOpacity();
                    AddedSource.a.Opacity = 0;

                    #region fade in and slide left
                    AddedSource.Image.AttachTo(AddedSource.Button);

                    AddedSource.a.Opacity = 1;

                    if (AddedSource.cx > 0)
                        (1000 / 60).AtIntervalWithTimerAndCounter(
                            (t, c) =>
                            {
                                AddedSource.cx--;

                                AddedSource.MoveTo();

                                if (AddedSource.cx > 0)
                                    return;

                                t.Stop();
                            }
                        );
                    #endregion

                    #region StartAnimatingRemove
                    Action StartAnimatingRemove =
                        delegate
                        {
                            if (Items.Count > MaxItems)
                            {
                                Items.First().With(
                                    RemovedSource =>
                                    {
                                        RemovedSource.a.SetOpacity(0,
                                            delegate
                                            {
                                                RemovedSource.Button.Orphanize();
                                                RemovedSource.Button = null;
                                            }
                                        );

                                        Items.Remove(RemovedSource);

                                    }
                                );
                            }
                        };

                    StartAnimatingRemove();
                    #endregion


                    return (RemovedSource, RemovedIndex) =>
                    {
                        //RemovedSource.Button.Orphanize();
                        //RemovedSource.Button = null;

                        if (SelectedItem == RemovedSource)
                            SelectedItem = null;

                        var u = Items.ToArray();
                        200.AtDelay(
                            delegate
                            {
                                (1000 / 20).AtIntervalWithTimerAndCounter(
                                    (t, c) =>
                                    {
                                        u.WithEach(
                                            k =>
                                            {
                                                k.x -= 4;
                                                k.MoveTo();


                                            }
                                        );

                                        if (c < 4)
                                            return;

                                        t.Stop();

                                    }
                                );
                            }
                        );
                    };
                }
            );

        }