示例#1
0
        /// <summary>
        /// Reverses the control collection in the controls
        /// </summary>
        /// <param name="originalCollection">The control collection to be reversed</param>
        public static void Reverse(this ControlCollection originalCollection)
        {
            List <Control> newControlCollection = new List <Control>();

            foreach (Control control in originalCollection)
            {
                newControlCollection.Insert(0, control);
            }
            originalCollection.Clear();
            originalCollection.AddRange(newControlCollection.ToArray());
        }
示例#2
0
        /// <summary>
        /// Transformation of entities into controls and adding them to the collection
        /// </summary>
        /// <typeparam name="T">Type of entity</typeparam>
        /// <typeparam name="R">Type of control that the entity represents</typeparam>
        /// <param name="controlCollection"></param>
        /// <param name="newEntity">Entities that need to be transformed into controls and added to the collection</param>
        /// <param name="entityControlView">Сontrol in which entities will be transformed</param>
        /// <param name="token">Cancellation token</param>
        /// <returns></returns>
        public static async Task AddControls <T, R>(
            this ControlCollection controlCollection,
            IList <T> newEntity,
            R entityControlView,
            CancellationToken token)
            where T : IEntity
            where R : IEntityControlView <T>
        {
            if (newEntity.Count == 0)
            {
                return;
            }

            var controls = await newEntity.CreateControlCollectionAsync(entityControlView, token);

            controlCollection.AddRange(controls);
        }
示例#3
0
        public static async Task FillControlCollectionForSearch <T, R>(
            this ControlCollection controlCollection,
            IList <T> entities,
            R entityControlView,
            CancellationToken token)
            where T : class, IEntity
            where R : IEntityControlView <T>
        {
            if (await controlCollection.СollectionEqualityTest(entities, token))
            {
                return;
            }

            var controls = await entities.CreateControlCollectionAsync(entityControlView, token);

            controlCollection.Clear();

            controlCollection.AddRange(controls);
        }
示例#4
0
        private static void BasicInsert(this ControlCollection originalCollection, int index, Control newControl)
        {
            int     i           = 0;
            Control tempControl = new Control();

            // Loop through original collection until point at which index is to be added
            while (originalCollection.Count > 0)
            {
                // Inserts the new control if currently at the desired index
                if (i == index)
                {
                    tempControl.Controls.Add(newControl);
                }
                tempControl.Controls.Add(originalCollection[0]);
                i++;
            }

            // Finally add modified collection
            originalCollection.AddRange(tempControl.Controls.ToArray());
        }
示例#5
0
        public void moveCell(R_ListCell rc, int index)
        {
            List <R_ListCell> list = rightControl.Cast <R_ListCell>().ToList <R_ListCell>();

            list.Remove(rc);

            if (index < 0)
            {
                index = 0;
            }

            if (index < list.Count)
            {
                list.Insert(index, rc);
            }
            else
            {
                list.Add(rc);
            }

            rightControl.Clear();
            rightControl.AddRange(list.ToArray());
            lco.Refresh();
        }
示例#6
0
        public void moveCell(L_ListCell lc, int index)
        {
            List <L_ListCell> list = leftControl.Cast <L_ListCell>().ToList <L_ListCell>();

            list.Remove(lc);

            if (index < 0)
            {
                index = 0;
            }

            if (index < list.Count)
            {
                list.Insert(index, lc);
            }
            else
            {
                list.Add(lc);
            }

            leftControl.Clear();
            leftControl.AddRange(list.ToArray());
            lco.Refresh();
        }
示例#7
0
 /// <summary>Ajoute un tableau d’objets de contrôle à la collection.</summary>
 public static void AddRange(this ControlCollection collection, params Control[] range)
 {
     collection.AddRange(range);
 }
示例#8
0
        public async void LoadReports(int length = -1, bool loadMachines = true, bool loadDates = false)
        {
            if (loading)
            {
                return;
            }
            loading               = true;
            dtpTo.Enabled         = dtpFrom.Enabled =
                cbMachine.Enabled = сhbOnlyUnwhitelisted.Enabled = button1.Enabled = false;

            if (loadDates)
            {
                var maxTime = await DBWorker.Self.lastReport(user.Id);

                dtpFrom.MaxDate = maxTime;
                dtpTo.MaxDate   = maxTime - (new TimeSpan(0, 0, 30));
                if (!loaded)
                {
                    var minTime = await DBWorker.Self.firstReport(user.Id);

                    dtpFrom.MinDate = minTime + (new TimeSpan(0, 0, 30));
                    dtpTo.MinDate   = minTime;
                    dtpTo.Value     = minTime;
                }
            }

            if (loadMachines)
            {
                //загружаю список пк пользователя
                var machines = await DBWorker.Self.fetchUserMachines(user.Id);

                if (cbMachine.Items.Count > 0)
                {
                    foreach (Machine m in machines)
                    {
                        bool exists = false;
                        foreach (Machine cm in cbMachine.Items)
                        {
                            if (cm.Id == m.Id)
                            {
                                exists = true;
                            }
                        }
                        if (!exists)
                        {
                            cbMachine.Items.Add(m);
                        }
                    }
                }
                else
                {
                    cbMachine.Items.AddRange(machines.ToArray());
                    cbMachine.SelectedItem = cbMachine.Items[0];
                }
            }


            DateTime from;
            int      listLength;

            if (reports.Count == 0)
            {
                from       = dtpFrom.Value;
                listLength = length == -1 ? CalculateReportsCount() + (flpReports.ClientRectangle.Width / reportWidth) : length;
            }
            else
            {
                from       = (reports[reports.Count - 1] as ReportView).report.Created;
                listLength = length == -1 ? CalculateReportsCount() : length;
            }
            var loadedReports = await DBWorker.Self.getReportList(from, user.Id, listLength, true, dtpTo.Value, сhbOnlyUnwhitelisted.Checked);

            if (loadedReports != null)
            {
                reports.AddRange(modelToView(loadedReports));
            }
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;

            dtpTo.Enabled = dtpFrom.Enabled = cbMachine.Enabled =
                сhbOnlyUnwhitelisted.Enabled = button1.Enabled = true;
            if (!loaded)
            {
                loaded = true;
            }
            loading = false;
        }