Example #1
0
 private FullSpriteSet( IList<AbstractSprite> sprites, System.ComponentModel.BackgroundWorker worker, int tasksComplete, int tasks )
 {
     bool haveWorker = worker != null;
     if ( haveWorker )
         worker.ReportProgress( ( tasksComplete++ * 100 ) / tasks, "Sorting" );
     sprites.Sort( ( a, b ) => a.Name.CompareTo( b.Name ) );
     this.sprites = sprites;
 }
Example #2
0
            public FieldAndTermEnumAnonymousInnerClassHelper(List<Term> terms)
            {
                if (!terms.Any())
                {
                    throw new ArgumentException("no terms provided");
                }

                this.terms = terms;
                terms.Sort();
                iter = terms.GetEnumerator();
            }
Example #3
0
        private FullSpriteSet( IList<AbstractSprite> sprites, System.ComponentModel.BackgroundWorker worker, int tasksComplete, int tasks )
        {
            bool haveWorker = worker != null;
            if ( haveWorker )
                worker.ReportProgress( ( tasksComplete++ * 100 ) / tasks, "Sorting" );
            sprites.Sort( ( a, b ) => a.Name.CompareTo( b.Name ) );
            this.sprites = sprites;
            Thumbnails = new ImageList();
            Thumbnails.ImageSize = new System.Drawing.Size( 80, 48 );
            foreach ( var sprite in sprites )
            {
                if ( haveWorker )
                    worker.ReportProgress( ( tasksComplete++ * 100 ) / tasks, string.Format( "Generating thumbnail for {0}", sprite.Name ) );

                Thumbnails.Images.Add( sprite.Name, sprite.GetThumbnail() );
            }
        }
Example #4
0
 public FieldAndTermEnumAnonymousInnerClassHelper(List<Term> terms)
 {
     this.terms = terms;
     terms.Sort();
     iter = terms.GetEnumerator();
 }
Example #5
0
 public FieldAndTermEnumAnonymousInnerClassHelper2(string field, List<BytesRef> terms)
     : base(field)
 {
     this.terms = terms;
     terms.Sort();
     iter = terms.GetEnumerator();
 }
Example #6
0
        public void BindForecastDataUsage(int siteOrcatid, int activIndex)
        {
            DataRepository.SaveOrUpdateForecastInfo(_forecastInfo);

            _lvHistData.BeginUpdate();
            _lvHistData.Items.Clear();
            List<string> list = new List<string>();
            List<string> plist = new List<string>();
            List<int> plistId = new List<int>();

            if (_activeCategory != null || _activeFSite != null)
            {
                int index = 0;
                int productcount = 0;

                #region MyRegion
                if (_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex).Count > 0)
                {
                    if (_forecastInfo.Methodology == MethodologyEnum.CONSUMPTION.ToString())
                    {
                        if (_forecastInfo.DataUsage == DataUsageEnum.DATA_USAGE3.ToString())
                        {
                            productcatList = (IList<ForecastCategoryProduct>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            productListunsorted = productcatList[0].Id;
                            productcatList.Sort(delegate(ForecastCategoryProduct p1, ForecastCategoryProduct p2) { return p1.DurationDateTime.Value.Date.CompareTo(p2.DurationDateTime.Value.Date); });
                            productcount = productcatList.Count;
                            foreach (ForecastCategoryProduct p in productcatList)
                            {
                                if (list.Contains(p.CDuration) != true)
                                {
                                    list.Add(p.CDuration);
                                }
                                if (plist.Contains(p.Product.ProductName) != true)
                                {
                                    plist.Add(p.Product.ProductName);
                                    plistId.Add(p.Product.Id);
                                }
                                if (productListunsorted < p.Id)
                                    productListunsorted = p.Id;

                            }
                        }
                        else
                        {
                            productsiteList = (IList<ForecastSiteProduct>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            productListunsorted = productsiteList[0].Id;
                            productsiteList.Sort(delegate(ForecastSiteProduct p1, ForecastSiteProduct p2) { return p1.DurationDateTime.Value.Date.CompareTo(p2.DurationDateTime.Value.Date); });
                            productcount = productsiteList.Count;

                            foreach (ForecastSiteProduct p in productsiteList)
                            {
                                if (list.Contains(p.CDuration) != true)
                                {
                                    list.Add(p.CDuration);
                                }
                                if (plist.Contains(p.Product.ProductName) != true)
                                {
                                    plist.Add(p.Product.ProductName);
                                }
                                if (productListunsorted < p.Id)
                                    productListunsorted = p.Id;

                            }

                        }
                    }
                    else
                    {
                        if (_forecastInfo.DataUsage == DataUsageEnum.DATA_USAGE3.ToString())
                        {
                            testcatList = (IList<ForecastCategoryTest>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            testListunsorted = testcatList[0].Id;
                            testcatList.Sort(delegate(ForecastCategoryTest t1, ForecastCategoryTest t2) { return t1.DurationDateTime.Value.Date.CompareTo(t2.DurationDateTime.Value.Date); });
                            productcount = testcatList.Count;

                            foreach (ForecastCategoryTest t in testcatList)
                            {
                                if (list.Contains(t.CDuration) != true)
                                {
                                    list.Add(t.CDuration);
                                }
                                if (plist.Contains(t.Test.TestName) != true)
                                {
                                    plist.Add(t.Test.TestName);
                                    plistId.Add(t.Test.Id);
                                }
                                if (testListunsorted < t.Id)
                                    testListunsorted = t.Id;

                            }
                        }
                        else
                        {
                            testsiteList = (IList<ForecastSiteTest>)_forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex);
                            testListunsorted = testsiteList[0].Id;
                            testsiteList.Sort(delegate(ForecastSiteTest t1, ForecastSiteTest t2) { return t1.DurationDateTime.Value.Date.CompareTo(t2.DurationDateTime.Value.Date); });
                            productcount = testsiteList.Count;

                            foreach (ForecastSiteTest t in testsiteList)
                            {
                                if (list.Contains(t.CDuration) != true)
                                {
                                    list.Add(t.CDuration);
                                }
                                if (plist.Contains(t.Test.TestName) != true)
                                {
                                    plist.Add(t.Test.TestName);
                                }
                                if (testListunsorted < t.Id)
                                    testListunsorted = t.Id;

                            }
                        }
                    }

                    if (_forecastInfo.Period == "YEARLY")
                        list.Sort();
                    int count = list.Count;
                    _lvHistData.Columns.Clear();
                    this._lvHistData.Items.Clear();
                    col = new ColumnHeader[count + 1];
                    ColumnHeader u = new ColumnHeader();
                    u.Text = "";
                    col[0] = u;
                    if (_forecastInfo.Period == ForecastPeriodEnum.Yearly.ToString())
                    {
                        for (int i = count; i >= 1; i--)
                        {
                            ColumnHeader c = new ColumnHeader();
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }

                    }

                    if (_forecastInfo.Period == ForecastPeriodEnum.Monthly.ToString())
                    {
                        DateTime last = _forecastInfo.StartDate;
                        for (int i = 1; i <= count; i++)
                        {
                            ColumnHeader c = new ColumnHeader();
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }

                    }
                    if (_forecastInfo.Period == ForecastPeriodEnum.Bimonthly.ToString())
                    {
                        DateTime last = _forecastInfo.StartDate;
                        for (int i = count; i >= 1; i--)
                        {
                            ColumnHeader c = new ColumnHeader();
                            last = last.AddMonths(-2);
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }

                    }
                    if (_forecastInfo.Period == ForecastPeriodEnum.Quarterly.ToString())
                    {
                        int quar = GetQuarter(_forecastInfo.StartDate);
                        int year = _forecastInfo.StartDate.Year;
                        for (int i = count; i >= 1; i--)
                        {
                            if (quar == 1)
                            {
                                quar = 4;
                                year--;
                            }
                            else
                                quar--;
                            ColumnHeader c = new ColumnHeader();
                            c.Text = list[i - 1].ToString();
                            col[i] = c;
                        }
                    }

                    this._lvHistData.Columns.AddRange(col);
                    addData = false;

                    int j = 0, k = 1;
                    ListViewItem l1 = null;
                    ListViewItem l2 = null;
                    ListViewItem l3 = null;
                    ListViewItem l4 = null;
                    ListViewItem l5 = null;
                    List<string> prolist = new List<string>();

                    for (int z = 0; z < plist.Count; z++)
                    {
                        bool flag = false;
                        bool flag1 = false;
                        int insert = 1, rem = 0;
                        j = 0;

                        foreach (IBaseDataUsage p in _forecastInfo.GetListOfDataUsages(siteOrcatid, activIndex))
                        {

                            if (plist[z] ==( _forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? p.Product.ProductName : p.Test.TestName))
                            {
                            LQTListViewTag tag = new LQTListViewTag();
                            tag.GroupTitle = (_forecastInfo.FMethodologeyEnum == MethodologyEnum.CONSUMPTION ? p.Product.ProductName : p.Test.TestName);
                            tag.Id = p.Id;
                            tag.Index = index;

                                if (flag1 == false)
                                {

                                    l1 = new ListViewItem("ProductUsed/TestPerformed") { Tag = tag };
                                    l2 = new ListViewItem("StockOut") { Tag = tag };
                                    l3 = new ListViewItem("InstrumentDowntime") { Tag = tag };
                                    l4 = new ListViewItem("Adjusted") { Tag = tag };
                                    l5 = new ListViewItem("Note") { Tag = tag };

                                    for (int f = 1; f <= list.Count; f++)
                                        if (list[f - 1] == p.CDuration)
                                        {
                                            insert = f;

                                            for (int l = 1; l < insert; l++)
                                            {
                                                l1.SubItems.Add("-");
                                                l2.SubItems.Add("-");
                                                l3.SubItems.Add("-");
                                                l4.SubItems.Add("-");
                                                l5.SubItems.Add("-");
                                                l1.SubItems.Insert(l, l1.SubItems[l]);
                                                l2.SubItems.Insert(l, l2.SubItems[l]);
                                                l3.SubItems.Insert(l, l3.SubItems[l]);
                                                l4.SubItems.Insert(l, l4.SubItems[l]);
                                                k = k + 2;
                                            }
                                            break;
                                        }

                                    l1.SubItems.Add(p.AmountUsed.ToString());
                                    l2.SubItems.Add(p.StockOut.ToString());
                                    l3.SubItems.Add(p.InstrumentDowntime.ToString());
                                    l4.SubItems.Add(p.Adjusted.ToString());
                                    if (p.AmountUsed != p.Adjusted)
                                    {
                                        l5.SubItems.Add("Adjusted");
                                    }
                                    else
                                    {
                                        l5.SubItems.Add("-");
                                    }
                                    l1.SubItems.Insert(insert, l1.SubItems[k]);
                                    l2.SubItems.Insert(insert, l2.SubItems[k]);
                                    l3.SubItems.Insert(insert, l3.SubItems[k]);
                                    l4.SubItems.Insert(insert, l4.SubItems[k]);

                                    k = k + 2;
                                    flag1 = true;
                                    rem = insert;
                                    insert++;

                                }
                                else if (j == productcount - 1)
                                {

                                    l1.SubItems.Add(p.AmountUsed.ToString());
                                    l2.SubItems.Add(p.StockOut.ToString());
                                    l3.SubItems.Add(p.InstrumentDowntime.ToString());
                                    l4.SubItems.Add(p.Adjusted.ToString());
                                    if (p.AmountUsed != p.Adjusted)
                                    {
                                        l5.SubItems.Add("Adjusted");
                                    }
                                    else
                                    {
                                        l5.SubItems.Add("-");
                                    }

                                    l1.SubItems.Insert(insert, l1.SubItems[k]);
                                    l2.SubItems.Insert(insert, l2.SubItems[k]);
                                    l3.SubItems.Insert(insert, l3.SubItems[k]);
                                    l4.SubItems.Insert(insert, l4.SubItems[k]);
                                    j = 0;
                                    flag = true;
                                    k = 1;
                                    insert++;
                                    rem = insert;

                                    break;

                                }
                                else
                                {

                                    l1.SubItems.Add(p.AmountUsed.ToString());
                                    l2.SubItems.Add(p.StockOut.ToString());
                                    l3.SubItems.Add(p.InstrumentDowntime.ToString());
                                    l4.SubItems.Add(p.Adjusted.ToString());
                                    if (p.AmountUsed != p.Adjusted)
                                    {
                                        l5.SubItems.Add("Adjusted");
                                    }
                                    else
                                    {
                                        l5.SubItems.Add("-");
                                    }

                                    l1.SubItems.Insert(insert, l1.SubItems[k]);
                                    l2.SubItems.Insert(insert, l2.SubItems[k]);
                                    l3.SubItems.Insert(insert, l3.SubItems[k]);
                                    l4.SubItems.Insert(insert, l4.SubItems[k]);

                                    k = k + 2;
                                    rem = insert;
                                    insert++;

                                }
                            }
                                else if (flag == false && j == productcount - 1)
                                {
                                    if (rem > 1)
                                        for (int l = rem + 1; l <= list.Count; l++)
                                        {
                                            l1.SubItems.Add("-");
                                            l2.SubItems.Add("-");
                                            l3.SubItems.Add("-");
                                            l4.SubItems.Add("-");
                                            l5.SubItems.Add("-");
                                            l1.SubItems.Insert(l, l1.SubItems[k]);
                                            l2.SubItems.Insert(l, l2.SubItems[k]);
                                            l3.SubItems.Insert(l, l3.SubItems[k]);
                                            l4.SubItems.Insert(l, l4.SubItems[k]);
                                            k = k + 2;
                                        }

                                    k = 1;
                                    break;
                                }

                                j++;

                            }

                        if (k == 1)
                        {
                            LqtUtil.AddItemToGroup(_lvHistData, l1);
                            LqtUtil.AddItemToGroup(_lvHistData, l2);
                            LqtUtil.AddItemToGroup(_lvHistData, l3);
                            LqtUtil.AddItemToGroup(_lvHistData, l4);
                            LqtUtil.AddItemToGroup(_lvHistData, l5);
                            index++;
                            _lvHistData.Items.AddRange(new ListViewItem[] { l1, l2, l3, l4, l5 });
                            l1.BackColor = System.Drawing.Color.LightBlue;
                            l2.BackColor = System.Drawing.Color.LightBlue;
                            l3.BackColor = System.Drawing.Color.LightBlue;
                            l4.BackColor = System.Drawing.Color.LightBlue;
                            l5.BackColor = System.Drawing.Color.LightBlue;
                        }

                    }

                }
                #endregion

                _lvHistData.EndUpdate();
            }
        }
Example #7
0
        private IList<PatchedByteArray> DoDteCrap( IList<ISerializableFile> dteFiles, BackgroundWorker worker, DoWorkEventArgs args, out IDictionary<byte, string> dteMapping )
        {
            List<PatchedByteArray> patches = new List<PatchedByteArray>();
            dteMapping = null;
            if (worker.CancellationPending)
            {
                args.Cancel = true;
                return null;
            }

            dteFiles.Sort( ( x, y ) => (y.ToCDByteArray().Length - y.Layout.Size).CompareTo( x.ToCDByteArray().Length - x.Layout.Size ) );
            if (worker.CancellationPending)
            {
                args.Cancel = true;
                return null;
            }

            IDictionary<ISerializableFile, Set<KeyValuePair<string, byte>>> filePreferredPairs = null;
            Set<KeyValuePair<string, byte>> currentPairs = null;

            DteResult result = DteResult.Empty;
            if (dteFiles.Count > 0)
            {
                int tries = dteFiles.Count;
                //DteResult result = DoDteForFiles( dteFiles, worker, args, out filePreferredPairs, out currentPairs );
                do
                {
                    result = DoDteForFiles( dteFiles, worker, args, out filePreferredPairs, out currentPairs );
                    switch (result.ResultCode)
                    {
                        case DteResult.Result.Cancelled:
                            args.Cancel = true;
                            return null;
                        case DteResult.Result.Fail:
                            var failedFile = result.FailedFile;
                            if (dteFiles[0] == failedFile)
                            {
                                // Failed on the first file... this is hopeless
                                throw new FFTPatcher.TextEditor.DTE.DteException( failedFile );
                            }

                            // Bump the failed file to the top of the list
                            dteFiles.Remove( failedFile );
                            dteFiles.Insert( 0, failedFile );
                            break;
                        case DteResult.Result.Success:
                            // do nothing
                            break;
                    }
                } while (result.ResultCode != DteResult.Result.Success && --tries >= 0);
            }

            switch (result.ResultCode)
            {
                case DteResult.Result.Fail:
                    throw new FFTPatcher.TextEditor.DTE.DteException( dteFiles[0] );
                case DteResult.Result.Cancelled:
                    args.Cancel = true;
                    return null;
            }

            foreach (var file in dteFiles)
            {
                worker.ReportProgress( 0,
                    new ProgressForm.FileProgress { File = file, State = ProgressForm.TaskState.Starting, Task = ProgressForm.Task.GeneratePatch } );
                var currentFileEncoding = PatcherLib.Utilities.Utilities.DictionaryFromKVPs( filePreferredPairs[file] );
                patches.AddRange( file.GetDtePatches( currentFileEncoding ) );
                worker.ReportProgress( 0,
                    new ProgressForm.FileProgress { File = file, State = ProgressForm.TaskState.Done, Task = ProgressForm.Task.GeneratePatch } );
                if (worker.CancellationPending)
                {
                    args.Cancel = true;
                    return null;
                }
            }

            var myDteMapping = new Dictionary<byte, string>();
            currentPairs.ForEach( kvp => myDteMapping[kvp.Value] = kvp.Key );
            dteMapping = myDteMapping;

            patches.AddRange( DTE.GenerateDtePatches( this.Filetype, currentPairs ) );
            return patches.AsReadOnly();
        }
Example #8
0
 private void AddOrReplaceCharMapDirectoryEntry( IList<PatcherLib.Iso.DirectoryEntry> dir, PatcherLib.Iso.DirectoryEntry newDirEnt )
 {
     var currentCharmapIndex = dir.IndexOf( dir.Find( d => d.Filename == newDirEnt.Filename ) );
     if (currentCharmapIndex != -1)
     {
         dir[currentCharmapIndex] = newDirEnt;
     }
     else
     {
         dir.Add( newDirEnt );
         dir.Sort( ( a, b ) => a.Filename.CompareTo( b.Filename ) );
     }
 }
        /// <summary>
        /// Updates the team assignment detail.
        /// </summary>
        /// <param name="projects">The projects.</param>
        /// <returns>
        /// returns the ProjectFillItem
        /// </returns>
        private IList<ProjectFillItem> UpdateTeamAssignmentDetail(IList<ProjectFillItem> projects)
        {
            if (this.developer != null)
            {
                this.clientsAndProjects = DependencyInjectionContainer.Instance.Container.Resolve<TimesheetService>().OrderClientsAndProjects(this.Clients, projects, this.developer.DeveloperID, this.currentDate);
                this.Clients = this.Clients.Sort();
                projects = projects.Sort();

                this.lastWorkDetail = DependencyInjectionContainer.Instance.Container.Resolve<TimesheetService>().RetrieveLastEntry(this.developer.DeveloperID);
            }

            return projects;
        }
Example #10
0
            public FieldAndTermEnumAnonymousInnerClassHelper2(string field, List<BytesRef> terms)
                : base(field)
            {
                if (!terms.Any())
                {
                    throw new ArgumentException("no terms provided");
                }

                this.terms = terms;
                terms.Sort();
                iter = terms.GetEnumerator();
            }
Example #11
0
        /// <summary>
        /// Populates the list entries.
        /// </summary>
        private void PopulateLists(
			int offset,
			IList<HighScoreEntry> list)
        {
            // Sort it
            list.Sort();

            // Go through the blow away the list
            for (int i = 0; i < HighScoreTable.MaximumEntries; i++)
            {
                // See if we have it
                int n = i + offset;

                if (i > list.Count - 1)
                {
                    entries[n].Reset();
                    continue;
                }

                // Populate the list
                entries[n].Name.Text = list[i].Name;
                entries[n].UtcWhen.Text = list[i].UtcWhen.ToString();
                entries[n].Word.Text = list[i].Word + "";
                entries[n].Score.Text = list[i].Score.ToString("N0");
            }
        }