コード例 #1
0
        public async Task GetStrategySymbols(Strategy arg)
        {
            IsLoadingSymbols = true;

            try
            {
                Strategy = arg;

                if (symbolsCache == null)
                {
                    symbolsCache = symbolsCacheFactory.GetSymbolsCache(Strategy.StrategySubscriptions.First().Exchange);

                    symbolsCache.OnSymbolsCacheException += SymbolsCacheException;
                }

                var strategySymbols = Strategy.StrategySubscriptions.Select(s => s.Symbol);

                var results = await symbolsCache.GetSymbols(strategySymbols).ConfigureAwait(true);

                var symbols = results.Where(r => strategySymbols.Contains($"{r.ExchangeSymbol}")).ToList();

                Symbols.Clear();

                symbols.ForEach(Symbols.Add);

                SymbolsNotification();
            }
            catch (Exception ex)
            {
                OnException($"SymbolsViewModel.GetSymbols {ex.Message}", ex);
            }

            IsLoadingSymbols = false;
        }
コード例 #2
0
        private async Task GetSymbols()
        {
            IsLoadingSymbols = true;

            try
            {
                var results = await ExchangeService.GetSymbolsAsync(userAccount.Exchange, new CancellationToken()).ConfigureAwait(true);

                Func <Symbol, string, Symbol> f = ((s, p) =>
                {
                    s.IsFavourite = true;
                    return(s);
                });

                (from s in results join p in userAccount.Preferences.FavouriteSymbols on s.ExchangeSymbol equals p select f(s, p)).ToList();

                Symbols.Clear();
                Symbols.AddRange(results);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString(), Category.Exception, Priority.Low);
                Dialog.ShowException(ex);
            }
            finally
            {
                IsLoadingSymbols = false;
            }
        }
コード例 #3
0
 protected virtual void ClearNavigationProperties()
 {
     UnitType = null;
     Symbols.Clear();
     Sources.Clear();
     Modifiers.Clear();
 }
        private void OnSearch(object parameter)
        {
            Dictionary <string, string> filters = new Dictionary <string, string>();

            // Clear the current Symbols collection
            Symbols.Clear();

            // Perform the search applying any selected keywords and filters
            IEnumerable <SymbolProperties> symbols = MilitarySymbolDictionary.FindSymbols(filters);

            if (!String.IsNullOrWhiteSpace(SearchString))
            {
                foreach (var ss in SearchString.Split(new char[] { ';', ',' }))
                {
                    if (!String.IsNullOrWhiteSpace(ss))
                    {
                        symbols = symbols.Where(s => s.Name.ToLower().Contains(ss.ToLower().Trim()) || s.Keywords.Count(kw => kw.ToLower().Contains(ss.ToLower().Trim())) > 0);
                    }
                }
            }

            var allSymbols = symbols.ToList();

            // Add symbols to UI collection
            foreach (var s in from symbol in allSymbols select new SymbolViewModel(symbol, _imageSize))
            {
                Symbols.Add(s);
            }
        }
コード例 #5
0
        // Function to search the symbol dictionary based on the selected value in the style file, category and/or geometry type ListBoxes
        private void Search(string keyword)
        {
            // Create empty filter dictionary, not used
            Dictionary <string, string> filters = new Dictionary <string, string>();

            // Clear the current Symbols collection
            Symbols.Clear();

            // Perform the search applying any selected keywords and filters

            IEnumerable <SymbolProperties> symbols = _symbolDictionary.FindSymbols(new List <string>()
            {
                keyword
            }, filters);

            var allSymbols = symbols.ToList();

            RaisePropertyChanged("Keywords");
            Debug.WriteLine(DateTime.Now);
            // Add symbols to UI collection
            foreach (var s in from symbol in allSymbols select new SymbolViewModel(symbol, _imageSize))
            {
                Symbols.Add(s);
            }
            Debug.WriteLine(DateTime.Now);
        }
コード例 #6
0
 public void Reset()
 {
     RootNamespaces.Clear();
     Namespaces.Clear();
     Symbols.Clear();
     LastError = string.Empty;
     FileName  = null;
 }
コード例 #7
0
 /// <summary>
 /// Get symbols (variables) from PLC
 /// </summary>
 private void GetSymbols()
 {
     Symbols.Clear();
     foreach (ISymbol symbol in _symbolLoader.Symbols)
     {
         Tc3Symbols.AddSymbolRecursive(Symbols, symbol);
     }
 }
コード例 #8
0
ファイル: Form1.cs プロジェクト: Vittallya/Calculator-CS
        public void Calculate()
        {
            var    in1     = "";
            var    in2     = "";
            double result  = 0;
            var    second  = false;
            var    operand = '+';

            foreach (var sym in Symbols)
            {
                if (operands.Contains(sym))
                {
                    operand = sym;
                    second  = true;
                }

                if (!second)
                {
                    in1 += sym;
                }
                else
                {
                    in2 += sym;
                }
            }

            if (operand == '/' && in2 == "0")
            {
                textBox.Text = "Бесконечность";
                Symbols.Clear();
                return;
            }
            try
            {
                switch (operand)
                {
                case '+': result = float.Parse(in1) + float.Parse(in2); break;

                case '-': result = float.Parse(in1) - float.Parse(in2); break;

                case '*': result = float.Parse(in1) * float.Parse(in2); break;

                case '/': result = float.Parse(in1) / float.Parse(in2); break;
                }
            }

            catch
            {
                return;
            }

            Symbols.Clear();
            textBox.Text = (result.ToString());
            for (int i = 0; i < result.ToString().Length; i++)
            {
                Symbols.Add(result.ToString()[i]);
            }
        }
コード例 #9
0
 internal void Clear()
 {
     Symbols.Clear();
     CharacterSets.Clear();
     Productions.Clear();
     FAStates.Clear();
     LRActionLists.Clear();
     Groups.Clear();
 }
コード例 #10
0
 private async Task FillTrendSymbols()
 {
     await Dispatcher.BeginInvoke((Action)(() => {
         Symbols.Clear();
         foreach (ExtendedSymbol extendedSymbol in _scanner.Symbols)
         {
             Symbols.Add(new SymbolView(extendedSymbol));
         }
     }));
 }
コード例 #11
0
ファイル: MainViewModel.cs プロジェクト: cezary12/kokos
        private void AddSymbolsToCollection(IEnumerable <SymbolViewModel> symbols)
        {
            Symbols.Clear();
            foreach (var symbol in symbols)
            {
                Symbols.Add(symbol);
            }

            SelectedSymbol = Symbols.FirstOrDefault();
        }
コード例 #12
0
ファイル: DbgEngine.cs プロジェクト: fedor4ever/CrashAnalyser
        public void Prime(TSynchronicity aSynchronicity)
        {
            if (EngineOperation != null)
            {
                EngineOperation(this, TEvent.EPrimingStarted);
            }

            // Reset the plugins
            Code.Clear();
            Symbols.Clear();

            // Categorise the prime list by plugin
            Dictionary <DbgPluginEngine, DbgEntityList> list = new Dictionary <DbgPluginEngine, DbgEntityList>();

            foreach (DbgEntity entity in iEntityManager)
            {
                // Might be null.
                DbgPluginEngine plugin = entity.PluginEngine;
                if (plugin != null)
                {
                    // Find correct list
                    DbgEntityList pluginEntityList = null;
                    if (list.ContainsKey(plugin))
                    {
                        pluginEntityList = list[plugin];
                    }
                    else
                    {
                        pluginEntityList = new DbgEntityList(this);
                        list.Add(plugin, pluginEntityList);
                    }

                    // Now add the entry
                    pluginEntityList.Add(entity);
                }
            }

            // Finally, we can tell all the plugins about the files they are about to receive
            foreach (KeyValuePair <DbgPluginEngine, DbgEntityList> kvp in list)
            {
                kvp.Key.PrepareToPrime(kvp.Value);
            }

            // Now prime the individual entities
            foreach (DbgEntity entity in iEntityManager)
            {
                entity.Prime(aSynchronicity);
            }

            if (EngineOperation != null)
            {
                EngineOperation(this, TEvent.EPrimingComplete);
            }
        }
        // Function to search the symbol dictionary based on the selected value in the style file, category and/or geometry type ListBoxes
        private void Search()
        {
            Dictionary <string, string> filters = new Dictionary <string, string>();

            // Set filters if there is some selected
            if (!string.IsNullOrEmpty((string)cmbStyleFile.SelectedValue))
            {
                filters["StyleFile"] = cmbStyleFile.SelectedValue.ToString();
            }

            if (!string.IsNullOrEmpty((string)cmbCategory.SelectedValue))
            {
                filters["Category"] = cmbCategory.SelectedValue.ToString();
            }

            if (!string.IsNullOrEmpty((string)cmbGeometryType.SelectedValue))
            {
                filters["GeometryType"] = cmbGeometryType.SelectedValue.ToString();
            }

            // Clear the current Symbols collection
            Symbols.Clear();

            // Perform the search applying any selected keywords and filters
            IEnumerable <SymbolProperties> symbols = _symbolDictionary.FindSymbols(SelectedKeywords, filters);
            var allSymbols = symbols.ToList();

            // Update the list of applicable keywords (excluding any keywords that are not on the current result set)
            if (SelectedKeywords == null || SelectedKeywords.Count == 0)
            {
                _keywords = _symbolDictionary.Keywords.Where(k => !IsSymbolId(k)).ToList();
            }
            else
            {
                IEnumerable <string> allSymbolKeywords = allSymbols.SelectMany(s => s.Keywords);
                _keywords = allSymbolKeywords.Distinct()
                            .Except(SelectedKeywords)
                            .Where(k => !IsSymbolId(k))
                            .ToList();
            }
            RaisePropertyChanged("Keywords");

            // Add symbols to UI collection
            foreach (var s in from symbol in allSymbols select new SymbolViewModel(symbol, _imageSize))
            {
                Symbols.Add(s);
            }
        }
コード例 #14
0
        public void SetSymbols(List <Symbol> symbols)
        {
            try
            {
                if (symbols == null)
                {
                    throw new ArgumentNullException(nameof(symbols));
                }

                Symbols.Clear();
                symbols.ForEach(Symbols.Add);
            }
            catch (Exception ex)
            {
                OnException($"{nameof(TradePanelViewModel)} - {ex.Message}", ex);
            }
        }
コード例 #15
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <SymbolProperties> symbols = _symbolDictionary.FindSymbols(new List <string>()
            {
                txtSymbolName.Text
            });

            if (symbols == null)
            {
                return;
            }
            Symbols.Clear();
            foreach (var s in from symbol in symbols.ToList() select new SymbolViewModel(symbol, _imageSize))
            {
                Symbols.Add(s);
            }
        }
コード例 #16
0
        /// <summary>
        /// Assembles the Code and populates Instructions, Symbols and Errors.
        /// </summary>
        /// <returns>A value indicating if the assembly has been successful</returns>
        public bool Process()
        {
            Instructions.Clear();
            Symbols.Clear();
            Errors.Clear();

            Parse();
            if (Errors.Count > 0)
            {
                return(false);
            }

            Translate();
            if (Errors.Count > 0)
            {
                return(false);
            }

            return(true);
        }
        // Function to search the symbol dictionary based on the selected value in the style file, category and/or geometry type ListBoxes
        private void Search()
        {
            // Create empty filter dictionary, not used
            Dictionary <string, string> filters = new Dictionary <string, string>();

            // Clear the current Symbols collection
            Symbols.Clear();

            // Perform the search applying any selected keywords
            IEnumerable <SymbolProperties> symbols = _symbolDictionary.FindSymbols(new List <string>()
            {
                _selectedKeyword
            });

            var allSymbols = symbols.ToList();

            // Update the list of applicable keywords (excluding any keywords that are not on the current result set)
            if (SelectedKeyword == null)
            {
                _keywords = _symbolDictionary.Keywords.ToList().Where(k => !IsSymbolId(k)).ToList();
            }
            else
            {
                IEnumerable <string> allSymbolKeywords = allSymbols.SelectMany(s => s.Keywords);
                _keywords = allSymbolKeywords.Distinct()
                            .Except(new List <string>()
                {
                    SelectedKeyword
                })
                            .Where(k => !IsSymbolId(k))
                            .ToList();
            }

            RaisePropertyChanged("Keywords");

            // Add symbols to UI collection
            foreach (var s in from symbol in allSymbols select new SymbolViewModel(symbol, _imageSize))
            {
                Symbols.Add(s);
            }
        }
コード例 #18
0
        public void Reload(string elfFilePath, string linkerScrintFilePath)
        {
            _elfUri = new Uri(elfFilePath);
            try {
                File = new ElfFile(System.IO.File.ReadAllBytes(elfFilePath));
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.Message);
                return;
            }

            _dwarf = new DwarfData(_elfFile);

            _memoryDescriptor = System.IO.File.Exists(linkerScrintFilePath) ? MemoryDescriptor.FromLinkerScript(linkerScrintFilePath) : null;

            Profile = new MemoryProfile(_dwarf, _memoryDescriptor);
            Symbols.Clear();
            foreach (var memoryName in Profile.MemoryNames)
            {
                var adapter = new MemoryTypeAdapter(Profile, memoryName);
                foreach (var section in adapter.Sections)
                {
                    foreach (var symbol in section.Symbols)
                    {
                        if (symbol.Header.Info.SymbolType == Elf32SymbolType.STT_SECTION)
                        {
                            continue;
                        }
                        SymbolDescriptor desc = new SymbolDescriptor();
                        desc.Section = section;
                        desc.Memory  = adapter;
                        desc.Symbol  = symbol;

                        desc.DwarfUnitItem =
                            _dwarf.globalItems.FirstOrDefault(v => v.Name == symbol.Name);

                        /*Uri address1 = new Uri("http://www.contoso.com/");
                         *
                         * // Create a new Uri from a string.
                         * Uri address2 = new Uri("http://www.contoso.com/index.htm?date=today");
                         *
                         * // Determine the relative Uri.
                         * Console.WriteLine("The difference is {0}", address1.MakeRelativeUri(address2));*/

                        if (!string.IsNullOrEmpty(desc.DwarfUnitItem?.FileStr))
                        {
                            if (System.IO.File.Exists(desc.DwarfUnitItem.FileStr))
                            {
                                Uri elfUri       = new Uri(elfFilePath);
                                Uri symbolUri    = new Uri(desc.DwarfUnitItem.FileStr);
                                Uri relativePath = elfUri.MakeRelativeUri(symbolUri);
                                desc.DwarfUnitItem.FileStr = relativePath.ToString();
                            }
                        }

                        Symbols.Add(desc);
                    }
                }
            }
            UpdateTitle();
        }
コード例 #19
0
 public void ClearParameters()
 {
     Symbols.Clear();
 }
コード例 #20
0
 public void Clear()
 {
     MinimumWidth = 0;
     Symbols.Clear();
 }
コード例 #21
0
        private void LoadScanner()
        {
            string scanName = cboScanners.Text.Trim();

            if (string.IsNullOrEmpty(scanName))
            {
                return;
            }

            m_loading = true;

            cmdSave.Enabled     = false;
            cmdDelete.Enabled   = false;
            cboScanners.Enabled = false;
            txtScannerName.Text = scanName;

            string data;

            try
            {
                data = svc.GetUserData(frmMain2.ClientId, frmMain2.ClientPassword, frmMain2.LicenseKey, "Scanner Settings: " + scanName);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to load scanner.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmdSave.Enabled     = true;
                cmdDelete.Enabled   = true;
                cboScanners.Enabled = true;
                return;
            }

            string[] text = data.Split(Utils.Chr(134));
            if (text.Length < 4)
            {
                return;
            }

            List <string> strRows = new List <string>(text[0].Split(Utils.Chr(145)));
            char          d       = Utils.Chr(182);

            //Clear everything
            m_stop = false;
            m_TSAlertDictionary.Clear();
            m_DGVRowDictionary.Clear();
            grdResults.Rows.Clear();
            DataGridViewBarGraphColumn volumeCol = (DataGridViewBarGraphColumn)grdResults.Columns["Volume"];

            if (volumeCol != null)
            {
                volumeCol.MaxValue = 0;
            }

            //Load all symbols
            Symbols.Clear();
            string[] strRow;

            for (int n = 0; n < strRows.Count - 1; n++)
            {
                strRow = strRows[n].Split(d);
                Symbols.Add(strRow[0]);
            }

            //Global settings
            switch (text[1])
            {
            case "Minutely":
                Periodicity = (int)M4Core.Entities.Periodicity.Minutely;
                break;

            case "Hourly":
                Periodicity = (int)M4Core.Entities.Periodicity.Hourly;
                break;

            case "Daily":
                Periodicity = (int)M4Core.Entities.Periodicity.Daily;
                break;

            case "Weekly":
                Periodicity = (int)M4Core.Entities.Periodicity.Weekly;
                break;
            }
            Interval = Convert.ToInt32(text[2]);
            Bars     = Convert.ToInt32(text[3]);
            Script   = text[4];

            //Prime data
            LoadAllSymbolsIntoMemory();

            //Go back through for settings
            for (int n = 0; n < strRows.Count - 2; n++)
            {
                strRow = strRows[n].Split(new[] { d });
                if (strRow.Length < 3)
                {
                    continue;
                }

                for (int j = 0; j < grdResults.Rows.Count; j++)
                {
                    if (string.Compare(grdResults.Rows[j].Cells["Symbol"].Value.ToString(), strRow[0], true) == 0)
                    {
                        DataGridViewImageButtonCell start = (DataGridViewImageButtonCell)grdResults.Rows[j].Cells["Start"];
                        start.Checked = string.Compare(strRow[3], "true", true) == 0;

                        Alert oAlert = m_TSAlertDictionary[strRow[0]];
                        if (oAlert != null)
                        {
                            if (!start.Checked)
                            {
                                oAlert.AlertScript = strRow[1];
                            }
                            else
                            {
                                oAlert.AlertScript = strRow[1];
                            }
                        }//oAlert != null


                        DataGridViewImageButtonCell @lock = (DataGridViewImageButtonCell)grdResults.Rows[j].Cells["Locked"];
                        @lock.Checked = string.Compare(strRow[2], "true", true) == 0;

                        break;
                    } //if grdResults
                }     //for j
            }         //for n

            m_loading = false;
            m_changed = false;

            UpdateName(txtScannerName.Text);

            cmdSave.Enabled     = true;
            cmdDelete.Enabled   = true;
            cboScanners.Enabled = true;

            cmdDelete.Enabled = cboScanners.SelectedIndex != -1;
        }
コード例 #22
0
 /// <summary>
 /// Clears all variables
 /// (used for tests only, given the fact that the Fit variables are in fact static)
 /// </summary>
 public virtual void clearAll()
 {
     _symbols.Clear();
 }