コード例 #1
0
        private void RefreshSettings()
        {
            _settings.Clear();

            string settingType = _settingType.ToString();

            foreach (SystemSetting item in _context.SystemSettings.Where(n => n.Type.Equals(settingType)))
            {
                _settings.Add(item);
            }
        }
コード例 #2
0
ファイル: CloudUserControl.cs プロジェクト: rilwal/x360ce
        private void UploadToCloudButton_Click(object sender, EventArgs e)
        {
            data.Clear();
            queueTimer.SleepTimer.Interval = 1000;
            var allControllers = SettingsManager.UserDevices.Items.ToArray();

            Add(CloudAction.Insert, allControllers);
            var allGames = SettingsManager.UserGames.Items.ToArray();

            Add(CloudAction.Insert, allGames);
        }
コード例 #3
0
ファイル: PadListControl.xaml.cs プロジェクト: 4amVim/x360ce
 public void SetBinding(MapTo mappedTo)
 {
     _MappedTo = mappedTo;
     // Remove references which will allows form to be disposed.
     SettingsManager.UserSettings.Items.ListChanged -= UserSettings_Items_ListChanged;
     mappedUserSettings.Clear();
     if (mappedTo != MapTo.None)
     {
         SettingsManager.UserSettings.Items.ListChanged += UserSettings_Items_ListChanged;
         UserSettings_Items_ListChanged(null, null);
     }
 }
コード例 #4
0
        private void Initialize(IEnumerable <Badge> badges)
        {
            dataGridView.DataSource = null;
            _badges.Clear();

            foreach (Badge badge in badges)
            {
                _badges.Add(badge);
            }

            dataGridView.DataSource = _badges;
        }
コード例 #5
0
        private void RefreshSettings(AssetInventoryContext context)
        {
            if (_settings != null)
            {
                _settings.Clear();
            }

            foreach (ServerSetting setting in context.FrameworkServers.Where(n => n.HostName == _serverHostName).SelectMany(n => n.ServerSettings))
            {
                _settings.Add(setting);
            }
        }
コード例 #6
0
        /// <summary>
        /// Populates the platform grid.
        /// </summary>
        private void PopulateGroupsGrid()
        {
            _groups.Clear();

            foreach (UserGroup group in _entities.UserGroups.OrderBy(f => f.GroupName))
            {
                _groups.Add(group);
            }

            groups_DataGridView.DataSource = null;
            groups_DataGridView.DataSource = _groups;
        }
コード例 #7
0
        private void ComboBox_Portfolio_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            if (cb == null)
            {
                return;
            }

            var portfolio       = (ComboOptionItem)cb.SelectedItem;
            var tradeInstOption = LoadTradeInstance(portfolio.Id);

            switch (cb.Name)
            {
            case "cbSrcPortfolio":
            {
                ComboBoxUtil.ClearComboBox(this.cbSrcTradeInst);

                ComboBoxUtil.SetComboBox(this.cbSrcTradeInst, tradeInstOption);

                //TODO: load the gridview
                _srcDataSource.Clear();
            }
            break;

            case "cbDestPortfolio":
            {
                ComboBoxUtil.ClearComboBox(this.cbDestTradeInst);

                ComboBoxUtil.SetComboBox(this.cbDestTradeInst, tradeInstOption);

                //TODO:load the gridview
                _destDataSource.Clear();
            }
            break;

            default:
                break;
            }
        }
コード例 #8
0
        private bool Form_LoadData(object sender, object data)
        {
            if (data == null)
            {
                return(false);
            }

            if (!(data is List <CancelRedoItem>))
            {
                return(false);
            }

            //Get the price type
            PriceType        spotBuyPrice    = PriceTypeHelper.GetPriceType(this.cbSpotBuyPrice);
            PriceType        spotSellPrice   = PriceTypeHelper.GetPriceType(this.cbSpotSellPrice);
            PriceType        futureBuyPrice  = PriceTypeHelper.GetPriceType(this.cbFuturesBuyPrice);
            PriceType        futureSellPrice = PriceTypeHelper.GetPriceType(this.cbFuturesSellPrice);
            EntrustPriceType shPriceType     = EntrustPriceTypeHelper.GetPriceType(this.cbSHExchangePrice);
            EntrustPriceType szPriceType     = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice);

            _secuDataSource.Clear();
            var cancelSecuItems = data as List <CancelRedoItem>;

            foreach (var cancelRedoItem in cancelSecuItems)
            {
                if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot)
                {
                    cancelRedoItem.EPriceSetting = spotBuyPrice;
                }
                else if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot)
                {
                    cancelRedoItem.EPriceSetting = spotSellPrice;
                }
                else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.SellOpen)
                {
                    cancelRedoItem.EPriceSetting = futureSellPrice;
                }
                else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.BuyClose)
                {
                    cancelRedoItem.EPriceSetting = futureBuyPrice;
                }

                SetEntrustPriceType(cancelRedoItem, shPriceType, szPriceType);

                _secuDataSource.Add(cancelRedoItem);
            }

            //update the quote
            QueryQuote();

            return(true);
        }
コード例 #9
0
        private void Start(List<MovieDetailsScraperBase> scrapers, bool export = false)
        {
            this.textBoxMsg.Text = String.Empty;
            movies.Clear();
            EnableDisable(false);

            var yrs = new List<int>();
            for(var i = this.numericUpDown1.Value; i <= 2015; i++)
                yrs.Add((int)i);

            NewDBVersion = GetDBVersion() + 1;

            Task.Factory.StartNew(() =>
            {
                running = true;
                try
                {
                    foreach (var scraper in scrapers)
                    {
                        try
                        {
                            List<string> existing = null;
                            using (var db = new MovieFinderEntities())
                            {
                                existing = db.MovieLinks.Select(x => x.DowloadUrl).ToList();
                            }
                            scraper.MovieFound += new EventHandler<MovieFoundEventArgs>(scraper_MovieFound);
                            scraper.ScraperNotFound += new EventHandler<ScraperNotFound>(scraper_ScraperNotFound);
                            scraper.Notify += new EventHandler<NotificationEventArgs>(scraper_Notify);

                            scraper.ScrapeMovies(existing, yrs);
                        }
                        catch { }
                    }

                    if (export && GetDBVersion() >= NewDBVersion)
                        Export();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.InvokeEx(() =>
                    {
                        EnableDisable(true);
                    });
                    running = false;
                }
            });
        }
コード例 #10
0
        private bool Form_LoadData(object sender, object data)
        {
            _tempDataSource.Clear();
            _secuDataSource.Clear();

            var items = _templateBLL.GetTemplates();

            if (items != null)
            {
                foreach (var item in items)
                {
                    _tempDataSource.Add(item);
                }

                if (items.Count > 0)
                {
                    LoadTemplateStock(items[0].ArchiveId);
                }
            }

            return(true);
        }
コード例 #11
0
        private bool InternalLoadData()
        {
            _dataSource.Clear();

            //TODO:
            var instItems = _tradeInstanceBLL.GetAllInstanceItem();

            foreach (var instItem in instItems)
            {
                _dataSource.Add(instItem);
            }

            return(true);
        }
コード例 #12
0
        private void RefreshData()
        {
            using (new BusyCursor())
            {
                Collection <DeviceSimulator> simulators = GetSimulators();

                _simulators.Clear();
                foreach (DeviceSimulator item in simulators)
                {
                    _simulators.Add(item);
                }

                simulator_DataGridView.DataSource = _simulators;
            }
        }
コード例 #13
0
 private void RefreshAvailableChannels(ChannelGroup group)
 {
     _availableChannels.Clear();
     if (group != null)
     {
         foreach (Channel channel in _allChannels)
         {
             if (!GroupContainsChannel(group, channel.ChannelId))
             {
                 _availableChannels.Add(channel);
             }
         }
     }
     _channelsBindingSource.ResetBindings(false);
 }
コード例 #14
0
        public void SetContent(IEnumerable <ProjectFileEntry> entries)
        {
            entries = entries.ToList();
            var commentIndices =
                commentsDGV.SelectedRows.OfType <DataGridViewRow>()
                .Select(row => row.Index)
                .Where(i => i >= 0)
                .ToList();
            var fileIndices =
                filesDGV.SelectedRows.OfType <DataGridViewRow>().Select(row => row.Index).Where(i => i >= 0)
                .ToList();

            sourceRTB.Clear();
            targetRTB.Clear();
            _commentEntries.Clear();
            _fileEntries.Clear();

            _commentEntries.AddRange(entries.SelectMany(x => x.Comments));
            _fileEntries.AddRange(entries);

            if (commentIndices.Count > 0)
            {
                commentsDGV.ClearSelection();
                foreach (var index in commentIndices)
                {
                    if (commentsDGV.Rows.Count > index)
                    {
                        commentsDGV.CurrentCell          = commentsDGV.Rows[index].Cells[0];
                        commentsDGV.Rows[index].Selected = true;
                    }
                }
            }

            if (fileIndices.Count > 0)
            {
                filesDGV.ClearSelection();
            }

            foreach (var index in fileIndices)
            {
                if (filesDGV.Rows.Count > index)
                {
                    filesDGV.CurrentCell          = filesDGV.Rows[index].Cells[0];
                    filesDGV.Rows[index].Selected = true;
                }
            }
        }
コード例 #15
0
 public void Populate(IEnumerable <TItem> values)
 {
     Items.RaiseListChangedEvents = false;
     try
     {
         Items.Clear();
         foreach (var value in values)
         {
             Items.Add(value);
         }
     }
     finally
     {
         Items.RaiseListChangedEvents = true;
     }
     Items.ResetBindings();
 }
コード例 #16
0
        private void UpdateProcessGrid(object arg)
        {
            try
            {
                var currentProcesses = _computer.GetAllProcesses();
                Invoke((Action)(() =>
                {
                    var selectedProcess = (ProcessModel)processModelBindingSource.Current;
                    var scrollPosition = dataGridView1.FirstDisplayedScrollingRowIndex;
                    var currentSort = new
                    {
                        processModelBindingSource.SortDirection,
                        processModelBindingSource.SortProperty
                    };
                    _currentProcessModels.Clear();
                    foreach (var processModel in currentProcesses)
                    {
                        if (!string.IsNullOrWhiteSpace(processModel.Path) && _computer.RestrictedProcesses.Contains(processModel.Path.ToLower()))
                        {
                            _computer.KillProcess(processModel.Id);
                        }

                        _currentProcessModels.Add(processModel);
                    }

                    if (currentSort.SortProperty != null)
                    {
                        processModelBindingSource.ApplySort(currentSort.SortProperty, currentSort.SortDirection);
                    }

                    processModelBindingSource.Position = _currentProcessModels.IndexOf(selectedProcess);
                    if (scrollPosition > 0 && scrollPosition < _currentProcessModels.Count)
                    {
                        dataGridView1.FirstDisplayedScrollingRowIndex = scrollPosition;
                    }

                    isUpdated = true;
                }));
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Произошла ошибка - " + _computer.Name);
                isUpdated = true;
            }
        }
コード例 #17
0
        private void LoadHedged()
        {
            SortableBindingList <RealTimePositionObject> tmp = new SortableBindingList <RealTimePositionObject>();

            tmp.Load(AllRealTimePositions);
            HedgedRealTimePositions.Clear();

            //now remove the non Hedge
            foreach (RealTimePositionObject rt in tmp)
            {
                if (rt.ContainsHedge)
                {
                    HedgedRealTimePositions.Add(rt);
                }
            }

            HedgedRealTimePositions.Sort("HedgedSortField", ListSortDirection.Descending);
        }
コード例 #18
0
        /// <summary>
        /// Populates the platform grid.
        /// </summary>
        private void PopulateGroupsGrid()
        {
            _groups.Clear();

            IEnumerable <UserGroup> groups = null;

            lock (_lockObject)
            {
                groups = _entities.UserGroups.OrderBy(f => f.GroupName);
            }
            foreach (UserGroup group in groups)
            {
                _groups.Add(group);
            }

            groups_DataGridView.DataSource = null;
            groups_DataGridView.DataSource = _groups;
        }
コード例 #19
0
        /// <summary>
        /// Populates the platform grid.
        /// </summary>
        private void PopulateUsersGrid()
        {
            _users.Clear();

            IEnumerable <User> users = null;

            lock (_lockObject)
            {
                users = _entities.Users.OrderBy(f => f.UserName);
            }

            foreach (User user in users)
            {
                _users.Add(user);
            }

            users_DataGridView.DataSource = null;
            users_DataGridView.DataSource = _users;
        }
コード例 #20
0
        private bool Form_LoadData(object sender, object data)
        {
            _dataSource.Clear();

            _accountBLL.QueryPortfolio();

            var portfolios = LoginManager.Instance.Portfolios;

            foreach (var p in portfolios)
            {
                Portfolio portfolio = new Portfolio
                {
                    FundCode       = p.AccountCode,
                    AssetNo        = p.AssetNo,
                    PortfolioNo    = p.CombiNo,
                    PortfolioName  = p.CombiName,
                    CapitalAccount = p.CapitalAccount,
                };

                var fund = LoginManager.Instance.Accounts.Find(o => o.AccountCode.Equals(p.AccountCode));
                if (fund != null)
                {
                    portfolio.FundName     = fund.AccountName;
                    portfolio.EAccountType = fund.AccountType;
                }

                var asset = LoginManager.Instance.Assets.Find(o => o.AssetNo.Equals(p.AssetNo));
                if (asset != null)
                {
                    portfolio.AssetName      = asset.AssetName;
                    portfolio.CapitalAccount = asset.CapitalAccount;
                }

                _dataSource.Add(portfolio);
            }

            UFXQueryMoneyBLL queryMoneyBLL = new UFXQueryMoneyBLL();

            queryMoneyBLL.Query();

            return(true);
        }
コード例 #21
0
        private void UpdateStudConnectorList()
        {
            if (CurrentProject == null)
            {
                ConnectorList.Clear();
            }
            else
            {
                var studConnections = CurrentProject.GetAllElements <PartConnection>()
                                      .Where(x => x.ConnectorType == ConnectorType.Custom2DField).ToList();

                foreach (var studConn in studConnections)
                {
                    if (string.IsNullOrEmpty(studConn.ID))
                    {
                        continue;
                    }

                    var comboItem = ConnectorList.FirstOrDefault(x => x.ID == studConn.ID);
                    if (comboItem == null)
                    {
                        comboItem = new ConnectorComboItem(studConn);
                        comboItem.ConnTypeText = studConn.SubType == 22 ? BottomStudsLabel.Text : TopStudsLabel.Text;
                        ConnectorList.Add(comboItem);
                    }
                }

                var validConnectionIDs = studConnections.Select(x => x.ID).ToList();
                var usedConnectionIDs  = CurrentProject.GetAllElements <StudReference>()
                                         .Select(x => x.ConnectionID).Distinct().ToList();

                foreach (var comboItem in ConnectorList.ToArray())
                {
                    if (!validConnectionIDs.Contains(comboItem.ID) &&
                        !usedConnectionIDs.Contains(comboItem.ID))
                    {
                        ConnectorList.Remove(comboItem);
                    }
                }
            }
        }
コード例 #22
0
        private void FillTreeView()
        {
            IsLoadingTreeView = true;
            LifTreeView.Nodes.Clear();
            CurrentLifFolders.Clear();

            string lifRootName = !string.IsNullOrEmpty(CurrentFile.FilePath) ?
                                 Path.GetFileNameWithoutExtension(CurrentFile.FilePath) : "LIF";

            void AddFolderNodes(LifFile.FolderEntry folder, TreeNode parentNode)
            {
                var folderInfo = new LifFolderInfo(folder)
                {
                    LifName = lifRootName
                };

                CurrentLifFolders.Add(folderInfo);

                var node = CreateFolderTreeNode(folderInfo);

                if (parentNode == null)
                {
                    LifTreeView.Nodes.Add(node);
                }
                else
                {
                    parentNode.Nodes.Add(node);
                }
                foreach (var subFolder in folder.Folders)
                {
                    AddFolderNodes(subFolder, node);
                }
            }

            AddFolderNodes(CurrentFile.RootFolder, null);
            ToolBarFolderCombo.ComboBox.DataSource = CurrentLifFolders;

            LifTreeView.Nodes[0].Expand();

            IsLoadingTreeView = false;
        }
コード例 #23
0
 private void UpdateFilteredPlayerList()
 {
     filteredPlayerList.Clear();
     foreach (clsPlayer player in playerList)
     {
         bool playerIsAttendee = false;
         foreach (clsMeetingAttendee attendee in meeting.listMeetingAttendees)
         {
             if (attendee.Player.PlayerID == player.PlayerID)
             {
                 playerIsAttendee = true;
                 break;
             }
         }
         if ((!playerIsAttendee) && ((txtFindPlayer.Text.Trim().Length == 0) ||
                                     (player.FullName.ToLower().Contains(txtFindPlayer.Text.ToLower()))))
         {
             filteredPlayerList.Add(player);
         }
     }
 }
コード例 #24
0
        private void ClearAll()
        {
            if (PurchaseCounterId == 0)
            {
                CustomerDropdown.ComboBox.SelectedIndex = -1;
                CustomerDropdown.SelectedIndex          = -1;
                CounterNumberTextbox.Clear();

                PaymentDatePicker.Value    = DateTime.Today;
                TaxCheckbox.Checked        = false;
                DiscountTextbox.Value      = 0;
                CreditTextbox.Text         = "0.00";
                AmountDueTextbox.Text      = "0.00";
                TotalAmountDueTextbox.Text = "0.00";
                RemarksTextbox.Clear();

                invoiceList.Clear();
                BindInvoices();
            }

            SetupForm();
        }
コード例 #25
0
ファイル: SgtMraForm.cs プロジェクト: rfuj0927/sgt
        private void regressButton_OnClick(object sender, EventArgs e)
        {
            MraParams p = new MraParams();

            p.fromDt     = fromDateTimePicker.Value;
            p.toDt       = toDateTimePicker.Value;
            p.yVariable  = new VariablePair(ySymbolTextBox.Text, (SeriesType)Enum.Parse(typeof(SeriesType), ySeriesTypeComboBox.Text));
            p.returnType = (ReturnType)Enum.Parse(typeof(ReturnType), returnTypeComboBox.Text);

            foreach (DataGridViewRow row in xParamsDgv.Rows)
            {
                if (string.IsNullOrEmpty((string)row.Cells[0].Value))
                {
                    continue;
                }

                p.xVariables.Add(new VariablePair((string)row.Cells[0].Value, (SeriesType)Enum.Parse(typeof(SeriesType), (string)row.Cells[1].Value)));
            }

            mRegressionResults.Clear();
            resultsDgv.Invalidate();

            Task.Run(() => {
                IDataQuerier sourceDataQuerier;
                if (bbgSourceRadioButton.Checked)
                {
                    sourceDataQuerier = new BbgDataApiDataQuerier();
                }
                else
                {
                    sourceDataQuerier = new EikonDataApiDataQuerier(EIKON_DATA_API_KEY);
                }

                AnalysisEngine analysisEngine        = new AnalysisEngine(p, sourceDataQuerier, new CustomTickerHistoryDataQuerier(mCustomTickerHistoryFilePath));
                analysisEngine.AProgressChanged     += OnProgressChanged;
                analysisEngine.AAddRegressionResult += OnAddRegressionResult;
                analysisEngine.Run();
            });
        }
コード例 #26
0
        private void btnClearAll_Click(object sender, EventArgs e)
        {
            if (tcApp.SelectedIndex > 1)
            {
                return;
            }
            bool board = (tcApp.SelectedIndex == 1);                             // Board Tab is open -> board=true; Thread tab -> board=false

            string type = "threads";

            if (board)
            {
                type = "boards";
            }

            DialogResult dialogResult = MessageBox.Show(
                "Are you sure you want to clear all " + type + "?",
                "Clear all " + type,
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning,
                MessageBoxDefaultButton.Button2);    // Confirmation prompt

            if (dialogResult == DialogResult.Yes)
            {
                if (board)
                {
                    BoardListBindingSource.Clear();
                }
                else
                {
                    ThreadListBindingSource.Clear();
                }

                if (Properties.Settings.Default.saveOnClose)
                {
                    Utils.SaveURLs(BoardList, ThreadListBindingSource.ToList());
                }
            }
        }
コード例 #27
0
        private bool Form_LoadData(object sender, object data)
        {
            _monitorDataSource.Clear();
            _securityDataSource.Clear();

            //Load the data of open posoition
            List <OpenPositionItem> monitorList = _monitorUnitBLL.GetOpenItems();

            monitorList.ForEach(p => _monitorDataSource.Add(p));

            //Load the data for each template
            if (monitorList.Count > 0)
            {
                var selectedItems = _monitorDataSource.Where(p => p.Selection).ToList();
                if (selectedItems.Count > 0)
                {
                    LoadSecurityData(selectedItems);
                }
            }

            return(true);
        }
コード例 #28
0
        private void RefreshItems()
        {
            object currentItem = (radGridViewDomainAccountReservation.CurrentRow != null ? radGridViewDomainAccountReservation.CurrentRow.DataBoundItem : null);

            using (new BusyCursor())
            {
                _domainAccountReservations.Clear();
                _domainAccountReservations = GetDomainAccountReservations();

                _bindingSource            = new BindingSource();
                _bindingSource.DataSource = _domainAccountReservations;
                radGridViewDomainAccountReservation.DataSource = _bindingSource;

                if (currentItem != null)
                {
                    GridViewRowInfo foundRow = radGridViewDomainAccountReservation.Rows.FirstOrDefault(x => x.DataBoundItem.Equals(currentItem));
                    if (foundRow != null)
                    {
                        radGridViewDomainAccountReservation.CurrentRow = foundRow;
                    }
                }
            }
        }
コード例 #29
0
        private void LoadReservationData()
        {
            reservation_RadGridView.DataSource = null;
            _reservations.Clear();
            if (toolStripMenuItem_Current.Checked)
            {
                foreach (var item in _context.AssetReservations.Where(x => x.AssetId.Equals(_asset.AssetId)).OrderBy(x => x.Start))
                {
                    _reservations.Add(new AssetReservationLocal(item));
                }
            }

            if (toolStripMenuItem_History.Checked)
            {
                foreach (var item in _context.ReservationHistory.Where(x => x.AssetId.Equals(_asset.AssetId)).OrderBy(x => x.Start))
                {
                    var reservation = new AssetReservationLocal(item);
                    reservation.SessionId = "Expired / Deleted";
                    _reservations.Add(reservation);
                }
            }
            reservation_RadGridView.DataSource = _reservations;
        }
コード例 #30
0
        private bool Form_LoadData(object sender, object data)
        {
            if (data == null)
            {
                return(false);
            }

            if (!(data is List <CancelSecurityItem>))
            {
                return(false);
            }

            _secuDataSource.Clear();

            var calcItems = data as List <CancelSecurityItem>;

            foreach (var calcItem in calcItems)
            {
                _secuDataSource.Add(calcItem);
            }

            return(true);
        }
コード例 #31
0
        public bool Load(SortableBindingList<PlayListData> playlist, string fileName)
        {
            string basePath = String.Empty;
              Stream stream;

              basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
              stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

              playlist.Clear();
              Encoding fileEncoding = Encoding.Default;
              StreamReader file = new StreamReader(stream, fileEncoding, true);
              if (file == null)
              {
            return false;
              }

              string line;
              line = file.ReadLine();
              if (line == null)
              {
            file.Close();
            return false;
              }

              string strLine = line.Trim();
              //CUtil::RemoveCRLF(strLine);
              if (strLine != START_PLAYLIST_MARKER)
              {
            fileEncoding = Encoding.Default;
            stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            file = new StreamReader(stream, fileEncoding, true);
              }

              string infoLine = "";
              string durationLine = "";
              fileName = "";
              line = file.ReadLine();
              while (line != null)
              {
            strLine = line.Trim();
            //CUtil::RemoveCRLF(strLine);
            int equalPos = strLine.IndexOf("=");
            if (equalPos > 0)
            {
              string leftPart = strLine.Substring(0, equalPos);
              equalPos++;
              string valuePart = strLine.Substring(equalPos);
              leftPart = leftPart.ToLower();
              if (leftPart.StartsWith("file"))
              {
            if (valuePart.Length > 0 && valuePart[0] == '#')
            {
              line = file.ReadLine();
              continue;
            }

            if (fileName.Length != 0)
            {
              PlayListData newItem = new PlayListData(infoLine, fileName, "0");
              playlist.Add(newItem);
              fileName = "";
              infoLine = "";
              durationLine = "";
            }
            fileName = valuePart;
              }
              if (leftPart.StartsWith("title"))
              {
            infoLine = valuePart;
              }
              else
              {
            if (infoLine == "")
            {
              infoLine = Path.GetFileName(fileName);
            }
              }
              if (leftPart.StartsWith("length"))
              {
            durationLine = valuePart;
              }

              if (durationLine.Length > 0 && infoLine.Length > 0 && fileName.Length > 0)
              {
            string duration = durationLine;

            // Remove trailing slashes. Might cause playback issues
            if (fileName.EndsWith("/"))
            {
              fileName = fileName.Substring(0, fileName.Length - 1);
            }

            Util.GetQualifiedFilename(basePath, ref fileName);
            PlayListData newItem = new PlayListData(infoLine, fileName, Util.SecondsToHMSString(duration));
            playlist.Add(newItem);
            fileName = "";
            infoLine = "";
            durationLine = "";
              }
            }
            line = file.ReadLine();
              }
              file.Close();

              if (fileName.Length > 0)
              {
            PlayListData newItem = new PlayListData(infoLine, fileName, "0");
              }

              return true;
        }
コード例 #32
0
        public bool Load(SortableBindingList<PlayListData> incomingPlaylist, string playlistFileName)
        {
            if (playlistFileName == null)
              {
            return false;
              }
              playlist = incomingPlaylist;
              playlist.Clear();

              try
              {
            basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName));

            using (file = new StreamReader(playlistFileName, Encoding.Default, true))
            {
              if (file == null)
              {
            return false;
              }

              string line = file.ReadLine();
              if (line == null || line.Length == 0)
              {
            return false;
              }

              string trimmedLine = line.Trim();

              if (trimmedLine != M3U_START_MARKER)
              {
            string fileName = trimmedLine;
            if (!AddItem("", "0", fileName))
            {
              return false;
            }
              }

              line = file.ReadLine();
              while (line != null)
              {
            trimmedLine = line.Trim();

            if (trimmedLine != "")
            {
              if (trimmedLine.StartsWith(M3U_INFO_MARKER))
              {
                string songName = null;
                string lDuration = "0";

                if (ExtractM3uInfo(trimmedLine, ref songName, ref lDuration))
                {
                  line = file.ReadLine();
                  if (!AddItem(songName, Util.SecondsToHMSString(lDuration), line))
                  {
                    break;
                  }
                }
              }
              else
              {
                if (!AddItem("", "0", trimmedLine))
                {
                  break;
                }
              }
            }
            line = file.ReadLine();
              }
            }
              }
              catch (Exception ex)
              {
            log.Error("exception loading playlist {0} err:{1} stack:{2}", playlistFileName, ex.Message, ex.StackTrace);
            return false;
              }
              return true;
        }