Esempio n. 1
0
        /// <summary>
        /// Draws the first item of a ComboBox, in italic and grey
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal static void cbItalizeFirstItem_DrawItem(object sender, DrawItemEventArgs e)
        {
            // Exit if no data
            if (e.Index == -1 || sender == null)
            {
                return;
            }

            ComboBox cb = (ComboBox)sender;
            Font     fFont;
            Brush    bBrush;
            String   sItem;

            if (e.Index == 0) // First item
            {
                fFont  = new Font(e.Font.FontFamily, e.Font.Size, FontStyle.Italic);
                bBrush = Brushes.Gray;
            }
            else // Every other item
            {
                e.DrawBackground();
                fFont  = e.Font;
                bBrush = SystemBrushes.ControlText;

                // Item is hovered over
                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    bBrush = SystemBrushes.HighlightText;
                }

                //e.DrawFocusRectangle();
                //e.Graphics.FillRectangle( new SolidBrush( e.BackColor ), e.Bounds );
            }

            // Get itemtype and proper text
            if (cb.Items[e.Index] is MarketLog && cb.Name.IndexOf("Item") > 0)   // Make exeption for Item combo
            {
                MarketLog ml = (MarketLog)cb.Items[e.Index];
                sItem = ml.Item;
            }
            else
            {
                sItem = cb.Items[e.Index].ToString();
            }

            // Draw the item
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.DrawString(sItem, fFont, bBrush, e.Bounds);
            e.DrawFocusRectangle();
        }
Esempio n. 2
0
            public override int Add(MarketLog x)
            {
                int result = 0;

                rwLock.AcquireWriterLock(timeout);

                try
                {
                    result = collection.Add(x);
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }

                return(result);
            }
Esempio n. 3
0
            public override bool Contains(MarketLog x)
            {
                bool result = false;

                rwLock.AcquireReaderLock(timeout);

                try
                {
                    result = collection.Contains(x);
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }

                return(result);
            }
Esempio n. 4
0
            public override int IndexOf(MarketLog x)
            {
                int result = 0;

                rwLock.AcquireReaderLock(timeout);

                try
                {
                    result = collection.IndexOf(x);
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }

                return(result);
            }
Esempio n. 5
0
        /// <summary>
        ///		Inserts an element into the <c>MarketLogVector</c> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
        /// <param name="item">The <see cref="MarketLog"/> to insert.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///		<para><paramref name="index"/> is less than zero</para>
        ///		<para>-or-</para>
        ///		<para><paramref name="index"/> is equal to or greater than <see cref="MarketLogVector.Count"/>.</para>
        /// </exception>
        public virtual void Insert(int index, MarketLog item)
        {
            ValidateIndex(index, true);               // throws

            if (m_count == m_array.Length)
            {
                EnsureCapacity(m_count + 1);
            }

            if (index < m_count)
            {
                Array.Copy(m_array, index, m_array, index + 1, m_count - index);
            }

            m_array[index] = item;
            m_count++;
            m_version++;
        }
Esempio n. 6
0
        /// <summary>
        ///		Removes the element at the specified index of the <c>MarketLogVector</c>.
        /// </summary>
        /// <param name="index">The zero-based index of the element to remove.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///		<para><paramref name="index"/> is less than zero</para>
        ///		<para>-or-</para>
        ///		<para><paramref name="index"/> is equal to or greater than <see cref="MarketLogVector.Count"/>.</para>
        /// </exception>
        public virtual void RemoveAt(int index)
        {
            ValidateIndex(index);               // throws

            m_count--;

            if (index < m_count)
            {
                Array.Copy(m_array, index + 1, m_array, index, m_count - index);
            }

            // We can't set the deleted entry equal to null, because it might be a value type.
            // Instead, we'll create an empty single-element array of the right type and copy it
            // over the entry we want to erase.
            MarketLog[] temp = new MarketLog[1];
            Array.Copy(temp, 0, m_array, m_count, 1);
            m_version++;
        }
Esempio n. 7
0
        internal MarketLog parseMarketLog(FileInfo fi, ref Dictionary <int, string> dRegionNames)
        {
            String sFileName    = fi.Name.Substring(0, fi.Name.LastIndexOf('.')).ToString();
            string sDateCreated = string.Empty;
            string sItem        = string.Empty;
            string sRegion      = string.Empty;
            int    iLastHyphen  = sFileName.LastIndexOf('-');
            int    iFirstHyphen = sFileName.IndexOf('-');

            if (iLastHyphen != -1 && iFirstHyphen != -1 && !(iLastHyphen == iFirstHyphen))
            {
                sDateCreated = sFileName.Substring(iLastHyphen + 1, sFileName.Length - iLastHyphen - 1).Trim();
                sItem        = sFileName.Substring(iFirstHyphen + 1, iLastHyphen - iFirstHyphen - 1).Trim();
                sRegion      = sFileName.Substring(0, iFirstHyphen).Trim();

                // Check for regions with hyphens
                if (!dRegionNames.ContainsValue(sRegion))
                {
                    string[] saFileNameParts = sFileName.Split('-');
                    sRegion = string.Format("{0}-{1}", saFileNameParts);
                    // If error give light error message and return null, but continue parsing.
                    if (!dRegionNames.ContainsValue(sRegion)) //throw new Exception("Error parsing file: " + sFileName);
                    {
                        MarketScanner.Main.LightErrorMessage += string.Format("Error parsing file:{1}{0}", Environment.NewLine, fi.Name);
                        return(null);
                    }
                    // Fix the item
                    sItem = sItem.Substring(sItem.IndexOf('-') + 1).Trim();
                }

                MarketLog oMarketLog = new MarketLog();
                oMarketLog.Created  = parseTimestamp(sDateCreated);
                oMarketLog.Item     = sItem;
                oMarketLog.Region   = sRegion;
                oMarketLog.FileName = fi.Name;
                oMarketLog.FilePath = fi.FullName;

                return(oMarketLog);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 8
0
        internal MarketLog parseCachedMarketLog(FileInfo fi, ref Dictionary<int, string> dRegionNames)
        {
            string sItem = string.Empty;
            string sRegion = string.Empty;

            KeyValuePair<object, object> result = EveCacheParser.Parser.Parse(fi);
            List<object> key = (List<object>)((Tuple<object>)result.Key).Item1;

            long regionID = (long)key[2];
            sRegion = Values.dRegionNames[unchecked((int)regionID)];

            short typeID = (short)key[3];
            sItem = Values.dItemNames[(int)typeID];

            MarketLog oMarketLog = new MarketLog();
            oMarketLog.Created = fi.CreationTime;
            oMarketLog.Item = sItem;
            oMarketLog.Region = sRegion;
            oMarketLog.FileName = fi.Name;
            oMarketLog.FilePath = fi.FullName;

            return oMarketLog;
        }
 internal static DataRow MarketLogToDataRow(MarketLog ml, DataTable dtSource)
 {
     DataRow dr = dtSource.NewRow();
     dr["region"] = ml.Region;
     dr["item"] = ml.Item;
     dr["created"] = ml.Created;
     dr["filename"] = ml.FileName;
     dr["filepath"] = ml.FilePath;
     return dr;
 }
Esempio n. 10
0
        internal MarketLog parseMarketLog(FileInfo fi, ref Dictionary<int, string> dRegionNames)
        {
            String sFileName = fi.Name.Substring(0, fi.Name.LastIndexOf('.')).ToString();
            string sDateCreated = string.Empty;
            string sItem = string.Empty;
            string sRegion = string.Empty;
            int iLastHyphen = sFileName.LastIndexOf('-');
            int iFirstHyphen = sFileName.IndexOf('-');

            if (iLastHyphen != -1 && iFirstHyphen != -1 && !(iLastHyphen == iFirstHyphen))
            {
                sDateCreated = sFileName.Substring(iLastHyphen + 1, sFileName.Length - iLastHyphen - 1).Trim();
                sItem = sFileName.Substring(iFirstHyphen + 1, iLastHyphen - iFirstHyphen - 1).Trim();
                sRegion = sFileName.Substring(0, iFirstHyphen).Trim();

                // Check for regions with hyphens
                if (!dRegionNames.ContainsValue(sRegion))
                {
                    string[] saFileNameParts = sFileName.Split('-');
                    sRegion = string.Format("{0}-{1}", saFileNameParts);
                    // If error give light error message and return null, but continue parsing.
                    if (!dRegionNames.ContainsValue(sRegion)) //throw new Exception("Error parsing file: " + sFileName);
                    {
                        MarketScanner.Main.LightErrorMessage += string.Format("Error parsing file:{1}{0}", Environment.NewLine, fi.Name);
                        return null;
                    }
                    // Fix the item
                    sItem = sItem.Substring(sItem.IndexOf('-') + 1).Trim();
                }

                MarketLog oMarketLog = new MarketLog();
                oMarketLog.Created = parseTimestamp(sDateCreated);
                oMarketLog.Item = sItem;
                oMarketLog.Region = sRegion;
                oMarketLog.FileName = fi.Name;
                oMarketLog.FilePath = fi.FullName;

                return oMarketLog;
            }
            else
            {
                return null;
            }
        }
Esempio n. 11
0
 public override void Remove(MarketLog x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
Esempio n. 12
0
 public override bool Contains(MarketLog x)
 {
     return(m_collection.Contains(x));
 }
            public override void CopyTo( MarketLog[] array )
            {
                rwLock.AcquireReaderLock( timeout );

                try
                {
                    collection.CopyTo( array );
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }
            }
            public override int AddRange( MarketLog[] x )
            {
                int result = 0;
                rwLock.AcquireWriterLock( timeout );

                try
                {
                    result = collection.AddRange( x );
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }

                return result;
            }
 public override int IndexOf( MarketLog x )
 {
     return m_collection.IndexOf( x );
 }
        /// <summary>
        ///		Copies the entire <c>MarketLogVector</c> to a one-dimensional
        ///		<see cref="MarketLog"/> array, starting at the specified index of the target array.
        /// </summary>
        /// <param name="array">The one-dimensional <see cref="MarketLog"/> array to copy to.</param>
        /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
        public virtual void CopyTo( MarketLog[] array, int start )
        {
            if ( m_count > array.GetUpperBound( 0 ) + 1 - start )
                throw new System.ArgumentException( "Destination array was not long enough." );

            Array.Copy( m_array, 0, array, start, m_count );
        }
 /// <summary>
 ///		Copies the entire <c>MarketLogVector</c> to a one-dimensional
 ///		<see cref="MarketLog"/> array.
 /// </summary>
 /// <param name="array">The one-dimensional <see cref="MarketLog"/> array to copy to.</param>
 public virtual void CopyTo( MarketLog[] array )
 {
     this.CopyTo( array, 0 );
 }
 /// <summary>
 ///		Determines whether a given <see cref="MarketLog"/> is in the <c>MarketLogVector</c>.
 /// </summary>
 /// <param name="item">The <see cref="MarketLog"/> to check for.</param>
 /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>MarketLogVector</c>; otherwise, <c>false</c>.</returns>
 public virtual bool Contains( MarketLog item )
 {
     for ( int i = 0; i != m_count; ++i )
         if ( m_array[i].Equals( item ) )
             return true;
     return false;
 }
        /// <summary>
        ///		Adds the elements of a <see cref="MarketLog"/> array to the current <c>MarketLogVector</c>.
        /// </summary>
        /// <param name="x">The <see cref="MarketLog"/> array whose elements should be added to the end of the <c>MarketLogVector</c>.</param>
        /// <returns>The new <see cref="MarketLogVector.Count"/> of the <c>MarketLogVector</c>.</returns>
        public virtual int AddRange( MarketLog[] x )
        {
            if ( m_count + x.Length >= m_array.Length )
                EnsureCapacity( m_count + x.Length );

            Array.Copy( x, 0, m_array, m_count, x.Length );
            m_count += x.Length;
            m_version++;

            return m_count;
        }
        /// <summary>
        ///		Adds a <see cref="MarketLog"/> to the end of the <c>MarketLogVector</c>.
        /// </summary>
        /// <param name="item">The <see cref="MarketLog"/> to be added to the end of the <c>MarketLogVector</c>.</param>
        /// <returns>The index at which the value has been added.</returns>
        public virtual int Add( MarketLog item )
        {
            if ( m_count == m_array.Length )
                EnsureCapacity( m_count + 1 );

            m_array[m_count] = item;
            m_version++;

            return m_count++;
        }
            public override void Remove( MarketLog x )
            {
                rwLock.AcquireWriterLock( timeout );

                try
                {
                    collection.Remove( x );
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }
            }
            public override void Insert( int pos, MarketLog x )
            {
                rwLock.AcquireWriterLock( timeout );

                try
                {
                    collection.Insert( pos, x );
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }
            }
 public override void CopyTo( MarketLog[] array, int start )
 {
     m_collection.CopyTo( array, start );
 }
 /// <summary>
 ///		Returns the zero-based index of the first occurrence of a <see cref="MarketLog"/>
 ///		in the <c>MarketLogVector</c>.
 /// </summary>
 /// <param name="item">The <see cref="MarketLog"/> to locate in the <c>MarketLogVector</c>.</param>
 /// <returns>
 ///		The zero-based index of the first occurrence of <paramref name="item"/> 
 ///		in the entire <c>MarketLogVector</c>, if found; otherwise, -1.
 ///	</returns>
 public virtual int IndexOf( MarketLog item )
 {
     for ( int i = 0; i != m_count; ++i )
         if ( m_array[i].Equals( item ) )
             return i;
     return -1;
 }
 public override void Remove( MarketLog x )
 {
     throw new NotSupportedException( "This is a Read Only Collection and can not be modified" );
 }
        /// <summary>
        ///		Inserts an element into the <c>MarketLogVector</c> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
        /// <param name="item">The <see cref="MarketLog"/> to insert.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///		<para><paramref name="index"/> is less than zero</para>
        ///		<para>-or-</para>
        ///		<para><paramref name="index"/> is equal to or greater than <see cref="MarketLogVector.Count"/>.</para>
        /// </exception>
        public virtual void Insert( int index, MarketLog item )
        {
            ValidateIndex( index, true ); // throws

            if ( m_count == m_array.Length )
                EnsureCapacity( m_count + 1 );

            if ( index < m_count )
            {
                Array.Copy( m_array, index, m_array, index + 1, m_count - index );
            }

            m_array[index] = item;
            m_count++;
            m_version++;
        }
            public override bool Contains( MarketLog x )
            {
                bool result = false;
                rwLock.AcquireReaderLock( timeout );

                try
                {
                    result = collection.Contains( x );
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }

                return result;
            }
        /// <summary>
        ///		Removes the first occurrence of a specific <see cref="MarketLog"/> from the <c>MarketLogVector</c>.
        /// </summary>
        /// <param name="item">The <see cref="MarketLog"/> to remove from the <c>MarketLogVector</c>.</param>
        /// <exception cref="ArgumentException">
        ///		The specified <see cref="MarketLog"/> was not found in the <c>MarketLogVector</c>.
        /// </exception>
        public virtual void Remove( MarketLog item )
        {
            int i = IndexOf( item );
            if ( i < 0 )
                throw new System.ArgumentException( "Cannot remove the specified item because it was not found in the specified Collection." );

            ++m_version;
            RemoveAt( i );
        }
Esempio n. 29
0
        /// <summary>
        /// Populates the marketlog views.
        /// </summary>
        /// <param name="mlSelected">The selected marketlog</param>
        /// <param name="bValidItem">If the marketlog is a valid Marketlog object</param>
        private bool MarketItemSelected(MarketLog mlSelected, bool bValidItem)
        {
            if (EnableBargainCombos(bValidItem))
            {
                MarketLog mlChosenItem = mlSelected;
                string sItem = DataHandler.ReplaceEscapeChars(mlChosenItem.Item);

                // Save Item hash for reselection if list changes
                _iItemSelectedHash = mlChosenItem.ItemHash;
                lblItemsChanged.Visible = false; // Reset notification

                DataRow[] drFoundRows = Values.dtMarketLogsListTable.Select("item = \'" + sItem + "\'", "region DESC, created DESC");

                Hashtable htRegions = new Hashtable();
                MarketLog ml;

                foreach (DataRow dr in drFoundRows)
                {
                    ml = DataHandler.DataRowToMarketLog(dr);

                    // If optional date filter is set in options, then filter logs
                    /*if (Values.IsLogsDateFilterSet && ml.Created <= Values.LogsDateFilter)
                    {
                            MessageBox.Show( "MARKETLOG FILTERED BY ITS DATE" );
                            continue;
                    }*/

                    // make list for item selection combobox
                    if (!htRegions.Contains(ml.RegionHash)) // if key exists
                    {
                        htRegions.Add(ml.RegionHash, ml);
                    }
                    else
                    { // compare dates of marketlog and replace if newer
                        MarketLog oldItem = (MarketLog)htRegions[ml.RegionHash];
                        if (oldItem.Created < ml.Created)
                        {
                            htRegions.Remove(ml.RegionHash);
                            htRegions.Add(ml.RegionHash, ml);
                        }
                    }
                }

                // Convert regions for current item to arraylist for comboboxes
                ArrayList alRegionsForCurrentItem = new ArrayList();
                MarketLog mlFirstInlistMessage = new MarketLog();
                mlFirstInlistMessage.Region = "!!!";
                alRegionsForCurrentItem.Insert(0, mlFirstInlistMessage);

                // Convert to arraylist for sorting
                foreach (MarketLog mlr in htRegions.Values)
                {
                    // If optional date filter is set in options, then filter logs
                    if (Values.IsLogsDateFilterSet && mlr.Created <= Values.LogsDateFilter) continue;

                    alRegionsForCurrentItem.Add(mlr);
                }

                MarketLogComparer compareOn = new MarketLogComparer(MarketLogCompareField.Region);
                alRegionsForCurrentItem.Sort(compareOn);
                mlFirstInlistMessage.Region = Values.MSG_SELECT_REGION;

                ArrayList alRegionsForCurrentItemClone = (ArrayList)alRegionsForCurrentItem.Clone();

                _abDoneFirstRegionLoad[0] = false;
                cbRegionsL.DataSource = alRegionsForCurrentItem;

                _abDoneFirstRegionLoad[1] = false;
                cbRegionsR.DataSource = alRegionsForCurrentItemClone;

                // Do a refresh after new item selected
                RefreshRegions();
            }
            return bValidItem;
        }
        /// <summary>
        ///		Removes the element at the specified index of the <c>MarketLogVector</c>.
        /// </summary>
        /// <param name="index">The zero-based index of the element to remove.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        ///		<para><paramref name="index"/> is less than zero</para>
        ///		<para>-or-</para>
        ///		<para><paramref name="index"/> is equal to or greater than <see cref="MarketLogVector.Count"/>.</para>
        /// </exception>
        public virtual void RemoveAt( int index )
        {
            ValidateIndex( index ); // throws

            m_count--;

            if ( index < m_count )
            {
                Array.Copy( m_array, index + 1, m_array, index, m_count - index );
            }

            // We can't set the deleted entry equal to null, because it might be a value type.
            // Instead, we'll create an empty single-element array of the right type and copy it
            // over the entry we want to erase.
            MarketLog[] temp = new MarketLog[1];
            Array.Copy( temp, 0, m_array, m_count, 1 );
            m_version++;
        }
Esempio n. 31
0
 public override int IndexOf(MarketLog x)
 {
     return(m_collection.IndexOf(x));
 }
Esempio n. 32
0
        /// <summary>
        /// The initial load of Market logs from cache files.
        /// ...
        /// TODO: write the rest...
        /// ...
        /// Fills the item ComboBox.
        /// </summary>
        private void LoadMarketLogsFromCache()
        {
            try
            {
                MarketLog ml;
                Parser    p = new Parser();

                //reset market logs
                Values.dtMarketLogsListTable = DataHandler.CreateMarketLogsListTable();

                EveCacheParser.Parser.SetCachedFilesFolders("CachedMethodCalls");
                EveCacheParser.Parser.SetIncludeMethodsFilter("GetOrders");
                FileInfo[]    cachedFiles = EveCacheParser.Parser.GetMachoNetCachedFiles();
                DirectoryInfo di          = new DirectoryInfo(Values.MarketLogPath + "\\Cache");
                if (!di.Exists)
                {
                    di.Create();
                }
                Hashtable htItems = _htAvailLogItems;

                //EVEMon's integrated unified uploader deletes cache files so we have to protect them
                foreach (FileInfo fi in cachedFiles)
                {
                    fi.CopyTo(Values.MarketLogPath + "\\Cache\\" + fi.Name, true);
                }

                foreach (FileInfo fi in di.GetFiles())
                {
                    ml = p.parseCachedMarketLog(fi, ref Values.dRegionNames);
                    if (ml != null)
                    {
                        Values.dtMarketLogsListTable.Rows.Add(DataHandler.MarketLogToDataRow(ml, Values.dtMarketLogsListTable));
                        // make list for item selection combobox, filter by date created from options
                        if (!htItems.Contains(ml.ItemHash))
                        {
                            // If Date filtering is set and logs created date is less than set date, then skip it.
                            if (Values.IsLogsDateFilterSet && ml.Created < Values.LogsDateFilter)
                            { /* skip */
                            }
                            else
                            {
                                htItems.Add(ml.ItemHash, ml);
                            }
                        }
                    }
                    // Step the progress bar
                    toolStripProgressBar1.PerformStep();
                    //pbGeneralProgressbar.PerformStep();
                }

                // Put the unique item in an arraylist to sort and use as datasource for combobox
                ArrayList alItems = new ArrayList();
                MarketLog mlFirstInlistMessage = new MarketLog {
                    Item = "!!!"
                };
                alItems.Insert(0, mlFirstInlistMessage);
                alItems.InsertRange(1, htItems.Values);
                MarketLogComparer compareOn = new MarketLogComparer(MarketLogCompareField.Item);
                alItems.Sort(compareOn);

                // Check for any items at all
                _isMarketlogsLoaded       = alItems.Count > 1;
                mlFirstInlistMessage.Item = _isMarketlogsLoaded ? Values.MSG_SELECT_ITEM : Values.MSG_NO_LOGS;

                cbItems.DataSource       = alItems;
                cbItems.MaxDropDownItems = 25;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Values.MSG_ERROR);
            }
            // Clear the progressbar
            toolStripProgressBar1.Value = 0;

            // Load the market tree view
            if (!splitContainerMain.Panel1Collapsed && _isMarketlogsLoaded)
            {
                ItemTreeView.LoadTreeView(ref _htAvailLogItems);
            }

            LightErrorHandler();
        }
Esempio n. 33
0
        /// <summary>
        /// The initial load of Market logs from cache files. 
        /// ...
        /// TODO: write the rest...
        /// ...
        /// Fills the item ComboBox.
        /// </summary>
        private void LoadMarketLogsFromCache()
        {
            try
            {
                MarketLog ml;
                Parser p = new Parser();

                //reset market logs
                Values.dtMarketLogsListTable = DataHandler.CreateMarketLogsListTable();

                EveCacheParser.Parser.SetCachedFilesFolders("CachedMethodCalls");
                EveCacheParser.Parser.SetIncludeMethodsFilter("GetOrders");
                FileInfo[] cachedFiles = EveCacheParser.Parser.GetMachoNetCachedFiles();
                DirectoryInfo di = new DirectoryInfo(Values.MarketLogPath + "\\Cache");
                if (!di.Exists)
                    di.Create();
                Hashtable htItems = _htAvailLogItems;

                //EVEMon's integrated unified uploader deletes cache files so we have to protect them
                foreach (FileInfo fi in cachedFiles)
                {
                    fi.CopyTo(Values.MarketLogPath + "\\Cache\\" + fi.Name, true);
                }

                foreach (FileInfo fi in di.GetFiles())
                {
                    ml = p.parseCachedMarketLog(fi, ref Values.dRegionNames);
                    if (ml != null)
                    {
                        Values.dtMarketLogsListTable.Rows.Add(DataHandler.MarketLogToDataRow(ml, Values.dtMarketLogsListTable));
                        // make list for item selection combobox, filter by date created from options
                        if (!htItems.Contains(ml.ItemHash))
                        {
                            // If Date filtering is set and logs created date is less than set date, then skip it.
                            if (Values.IsLogsDateFilterSet && ml.Created < Values.LogsDateFilter)
                            { /* skip */ }
                            else
                                htItems.Add(ml.ItemHash, ml);
                        }
                    }
                    // Step the progress bar
                    toolStripProgressBar1.PerformStep();
                    //pbGeneralProgressbar.PerformStep();
                }

                // Put the unique item in an arraylist to sort and use as datasource for combobox
                ArrayList alItems = new ArrayList();
                MarketLog mlFirstInlistMessage = new MarketLog { Item = "!!!" };
                alItems.Insert(0, mlFirstInlistMessage);
                alItems.InsertRange(1, htItems.Values);
                MarketLogComparer compareOn = new MarketLogComparer(MarketLogCompareField.Item);
                alItems.Sort(compareOn);

                // Check for any items at all
                _isMarketlogsLoaded = alItems.Count > 1;
                mlFirstInlistMessage.Item = _isMarketlogsLoaded ? Values.MSG_SELECT_ITEM : Values.MSG_NO_LOGS;

                cbItems.DataSource = alItems;
                cbItems.MaxDropDownItems = 25;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Values.MSG_ERROR);
            }
            // Clear the progressbar
            toolStripProgressBar1.Value = 0;

            // Load the market tree view
            if (!splitContainerMain.Panel1Collapsed && _isMarketlogsLoaded) ItemTreeView.LoadTreeView(ref _htAvailLogItems);

            LightErrorHandler();
        }
Esempio n. 34
0
 internal static MarketLog DataRowToMarketLog(DataRow dr)
 {
     MarketLog ml = new MarketLog();
     ml.Region = (string)dr["region"];
     ml.Item = (string)dr["item"];
     ml.Created = (DateTime)dr["created"];
     ml.FileName = (string)dr["filename"];
     ml.FilePath = (string)dr["filepath"];
     return ml;
 }
 public override bool Contains( MarketLog x )
 {
     return m_collection.Contains( x );
 }
 public override void CopyTo( MarketLog[] array )
 {
     m_collection.CopyTo( array );
 }
 /// <summary>
 ///		Initializes a new instance of the <c>MarketLogVector</c> class
 ///		that contains elements copied from the specified <see cref="MarketLog"/> array.
 /// </summary>
 /// <param name="a">The <see cref="MarketLog"/> array whose elements are copied to the new list.</param>
 public MarketLogVector( MarketLog[] a )
 {
     m_array = new MarketLog[a.Length];
     AddRange( a );
 }
            public override int IndexOf( MarketLog x )
            {
                int result = 0;
                rwLock.AcquireReaderLock( timeout );

                try
                {
                    result = collection.IndexOf( x );
                }
                finally
                {
                    rwLock.ReleaseReaderLock();
                }

                return result;
            }
Esempio n. 39
0
        /// <summary>
        /// Populates the marketlog views.
        /// </summary>
        /// <param name="mlSelected">The selected marketlog</param>
        /// <param name="bValidItem">If the marketlog is a valid Marketlog object</param>
        private bool MarketItemSelected(MarketLog mlSelected, bool bValidItem)
        {
            if (EnableBargainCombos(bValidItem))
            {
                MarketLog mlChosenItem = mlSelected;
                string    sItem        = DataHandler.ReplaceEscapeChars(mlChosenItem.Item);

                // Save Item hash for reselection if list changes
                _iItemSelectedHash      = mlChosenItem.ItemHash;
                lblItemsChanged.Visible = false; // Reset notification

                DataRow[] drFoundRows = Values.dtMarketLogsListTable.Select("item = \'" + sItem + "\'", "region DESC, created DESC");

                Hashtable htRegions = new Hashtable();
                MarketLog ml;

                foreach (DataRow dr in drFoundRows)
                {
                    ml = DataHandler.DataRowToMarketLog(dr);

                    // If optional date filter is set in options, then filter logs

                    /*if (Values.IsLogsDateFilterSet && ml.Created <= Values.LogsDateFilter)
                     * {
                     *      MessageBox.Show( "MARKETLOG FILTERED BY ITS DATE" );
                     *      continue;
                     * }*/

                    // make list for item selection combobox
                    if (!htRegions.Contains(ml.RegionHash)) // if key exists
                    {
                        htRegions.Add(ml.RegionHash, ml);
                    }
                    else
                    { // compare dates of marketlog and replace if newer
                        MarketLog oldItem = (MarketLog)htRegions[ml.RegionHash];
                        if (oldItem.Created < ml.Created)
                        {
                            htRegions.Remove(ml.RegionHash);
                            htRegions.Add(ml.RegionHash, ml);
                        }
                    }
                }

                // Convert regions for current item to arraylist for comboboxes
                ArrayList alRegionsForCurrentItem = new ArrayList();
                MarketLog mlFirstInlistMessage    = new MarketLog();
                mlFirstInlistMessage.Region = "!!!";
                alRegionsForCurrentItem.Insert(0, mlFirstInlistMessage);

                // Convert to arraylist for sorting
                foreach (MarketLog mlr in htRegions.Values)
                {
                    // If optional date filter is set in options, then filter logs
                    if (Values.IsLogsDateFilterSet && mlr.Created <= Values.LogsDateFilter)
                    {
                        continue;
                    }

                    alRegionsForCurrentItem.Add(mlr);
                }

                MarketLogComparer compareOn = new MarketLogComparer(MarketLogCompareField.Region);
                alRegionsForCurrentItem.Sort(compareOn);
                mlFirstInlistMessage.Region = Values.MSG_SELECT_REGION;

                ArrayList alRegionsForCurrentItemClone = (ArrayList)alRegionsForCurrentItem.Clone();

                _abDoneFirstRegionLoad[0] = false;
                cbRegionsL.DataSource     = alRegionsForCurrentItem;

                _abDoneFirstRegionLoad[1] = false;
                cbRegionsR.DataSource     = alRegionsForCurrentItemClone;

                // Do a refresh after new item selected
                RefreshRegions();
            }
            return(bValidItem);
        }
 public override int AddRange( MarketLog[] x )
 {
     throw new NotSupportedException( "This is a Read Only Collection and can not be modified" );
 }