public void ChangeGruppenFrame(string finalrunde)
        {
            spiele = new List<Spiel>();

            switch (finalrunde)
            {
                case "A":
                    spiele.AddRange(_wmController.GetFinalrundenSpiele(new DateTime(2010, 06, 26), new DateTime(2010, 06, 29)));
                    break;

                case "V":
                    spiele.AddRange(_wmController.GetFinalrundenSpiele(new DateTime(2010, 07, 02), new DateTime(2010, 07, 03)));
                    break;

                case "H":
                    spiele.AddRange(_wmController.GetFinalrundenSpiele(new DateTime(2010, 07, 06), new DateTime(2010, 07, 07)));
                    break;

                case "F":
                    spiele.AddRange(_wmController.GetFinalrundenSpiele(new DateTime(2010, 07, 10), new DateTime(2010, 07, 11)));
                    break;

                default:
                    return;
            }

            SetFinalrunde(finalrunde);

        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            WindowPosition.Move(this);

            var items = new List<VersionListViewItem>();
            var files = new List<string>();
            files.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.TopDirectoryOnly));
            files.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory(), "*.exe", SearchOption.TopDirectoryOnly));
            files.Sort((x, y) =>
            {
                return System.IO.Path.GetFileName(x).CompareTo(System.IO.Path.GetFileName(y));
            });

            foreach (var path in files)
            {
                var info = System.Diagnostics.FileVersionInfo.GetVersionInfo(path);
                var item = new VersionListViewItem();
                item.FileName = System.IO.Path.GetFileName(path);
                item.Version = info.FileVersion;

                items.Add(item);
            }

            foreach (var item in items)
            {
                _versionListView.Items.Add(item);
            }
        }
        public ConditionSettings(ConnectionXML conn)
        {
            InitializeComponent();
            this.connection = conn;
            //this.connection.Type = ConnectionTypes.eCondition;
            if (this.connection.Condition == null)
            {
                this.connection.Condition = new GameClasses.Condition();
                this.connection.Condition.Predicates = new List<Predicate>();
            }
            else
            {
                this.txtText.Text = this.connection.Condition.Text;
            }

            this.dgPredicates.ItemsSource = this.connection.Condition.Predicates;
            var lstItems = new List<ItemStrings>();
            lstItems.AddRange(Globals.GameElements.Items);
            lstItems.AddRange(Globals.GameElements.Stats);
            lstItems.AddRange(Globals.GameElements.Skills);
            this.dgcmbPredicateName.ItemsSource = lstItems;

            List<PredicateTypeList> Dict = new List<PredicateTypeList>();
            Dict.Add(new PredicateTypeList{ Key = PredicateTypes.eInventory, Value = "Inventory"});
            Dict.Add(new PredicateTypeList { Key = PredicateTypes.eStat, Value = "Stat"});
            Dict.Add(new PredicateTypeList{ Key = PredicateTypes.eSkill, Value = "Skill"});
            this.dgcmbPredicateType.ItemsSource = Dict;
        }
        // Найти все вершины диаметра
        public List<int> buildPath(int u, int v)
        {
            List<int> ans = new List<int>();

            if (p[u][v] == -1)
            {
                ans.Add(u);
                ans.Add(v);
            }
            else
            {
                List<int> r = buildPath(u, p[u][v]);
                List<int> l = buildPath(p[u][v], v);
                ans.AddRange(r);
                ans.AddRange(l);
            }
            for (int i = 0; i+1 < ans.Count;) {
                if (ans[i] == ans[i + 1])
                {
                    ans.RemoveAt(i);
                }
                else {
                    i++;
                }
            }

                return ans;
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var htmlText = value as string;
            if (string.IsNullOrWhiteSpace(htmlText))
                return value;

            var splits = Regex.Split(htmlText, "<a ");
            var result = new List<Inline>();
            foreach (var split in splits)
            {
                if (!split.StartsWith("href=\""))
                {
                    result.AddRange(FormatText(split));
                    continue;
                }

                var match = Regex.Match(split, "^href=\"(?<url>(.+?))\" class=\".+?\">(?<text>(.*?))</a>(?<content>(.*?))$", RegexOptions.Singleline);
                if (!match.Success)
                {
                    result.Add(new Run(split));
                    continue;
                }
                var hyperlink = new Hyperlink(new Run(match.Groups["text"].Value))
                {
                    NavigateUri = new Uri(match.Groups["url"].Value)
                };
                hyperlink.RequestNavigate += Hyperlink_RequestNavigate;
                result.Add(hyperlink);

                result.AddRange(FormatText(match.Groups["content"].Value));
            }
            return result;
        }
Exemple #6
0
        private void btnpool3_Click(object sender, EventArgs e)
        {
            deck = new List<int>();
            deck.AddRange(pool1);
            deck.AddRange(pool3);
            deck.AddRange(pool2);

            iteration();
        }
 private void AddToIgnoreListButton_Click(object sender, RoutedEventArgs e)
 {
     var l = new List<DatabaseObject>();
     l.AddRange(_Tables.Where(el => el.IsChecked).Select(el => el.Item));
     l.AddRange(_StoredProcedures.Where(el => el.IsChecked).Select(el => el.Item));
     l.AddRange(_UserDefinedTableTypes.Where(el => el.IsChecked).Select(el => el.Item));
     var w = new ManageIgnoreObjectWindow(l);
     w.ShowDialog();
 }
Exemple #8
0
 private static IEnumerable<string> ReadBlocks(IEnumerable<Block> blocks)
 {
     var result = new List<string>();
     foreach (var block in blocks)
     {
         result.AddRange(ReadRuns(block));
         result.AddRange(ReadTables(block));
     }
     return result;
 }
        public LaunchWindow()
        {
            string gameConfigurationFolder = "GameConfiguration";
            string gameConfigurationsPath = Path.Combine(gameConfigurationFolder, "gameConfigs.json");

            InitializeComponent();

            if (!Directory.Exists(gameConfigurationFolder))
                Directory.CreateDirectory(gameConfigurationFolder);

            //Loading the last used configurations for hammer
            RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Hammer\General");

            var configs = new List<GameConfiguration>();

            //try loading json
            if (File.Exists(gameConfigurationsPath))
            {
                string jsonLoadText = File.ReadAllText(gameConfigurationsPath);
                configs.AddRange(JsonConvert.DeserializeObject<List<GameConfiguration>>(jsonLoadText));
            }

            //try loading from registry
            if (rk != null)
            {
                string BinFolder = (string)rk.GetValue("Directory");

                string gameData = Path.Combine(BinFolder, "GameConfig.txt");

                configs.AddRange(GameConfigurationParser.Parse(gameData));
            }

            //finalise config loading
            if (configs.Any())
            {
                //remove duplicates
                configs = configs.GroupBy(g => g.Name).Select(grp => grp.First()).ToList();

                //save
                string jsonSaveText = JsonConvert.SerializeObject(configs, Formatting.Indented);
                File.WriteAllText(gameConfigurationsPath, jsonSaveText);

                if (configs.Count == 1)
                    Launch(configs.First());

                GameGrid.ItemsSource = configs;
            }
            else//oh noes
            {
                LaunchButton.IsEnabled = false;
                WarningLabel.Content = "No Hammer configurations found. Cannot launch.";
            }
        }
 private IList<Block> GenerateParagraphsForReference(IEnumerable<ISbItem> itens)
 {
     string lastTitle = string.Empty;
     List<Block> blocks = new List<Block>();
     foreach (ISbItem item in itens)
     {
         if (item is Versiculo)
         {
             if (lastTitle != GetTitle(item))
             {
                 Paragraph t = NewParagraph();
                 t.Style = StyleTitle;
                 t.Inlines.Add(new Run(GetTitle(item)));
                 lastTitle = GetTitle(item);
                 blocks.Add(t);
             }
             Paragraph p = NewParagraph();
             p.Inlines.Add(new Run(item.Display));
             blocks.Add(p);
         }
         else
         {
             blocks.AddRange(GenerateParagraphsForReference(item.Children));
         }
     }
     return blocks;
 }
        public SlowkaClass()
        {
            slowka = new List<Slowko>();
            XDocument doc = null;
            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream storageStream = null;

            if(storage.FileExists("slowka.xml"))
            {
                storageStream = new IsolatedStorageFileStream("slowka.xml", System.IO.FileMode.Open, FileAccess.Read, storage);
                doc = XDocument.Load(storageStream);
                storageStream.Close();
            }
            else
            {
                doc = XDocument.Load("slowka.xml");
                storageStream = new IsolatedStorageFileStream("slowka.xml", System.IO.FileMode.CreateNew, FileAccess.Write, storage);
                doc.Save(storageStream);
                storageStream.Close();

            }

            //var vSlowka = from s in XElement.Load("slowka.xml").Element("slowko").Elements() select s;
            var v = from s in doc.Descendants("slowko") select new Slowko(s);

            slowka.AddRange(v);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Load Images
            List<string> DirectoryPaths = new List<string>();
            //Search all Files in diferents formats
            DirectoryPaths.AddRange(Directory.GetFiles(_collagePath, "*.jpg").ToList());
            DirectoryPaths.AddRange(Directory.GetFiles(_collagePath, "*.png").ToList());
            DirectoryPaths.AddRange(Directory.GetFiles(_collagePath, "*.bmp").ToList());

            for(int x=0; x < DirectoryPaths.Count; x++)
            {
                ImgCollection.Add(ImgManger.LoadImageFromFile(DirectoryPaths[x], "", 150, 150, "Img"));
            }

            Lbx_Img.ItemsSource = ImgCollection;
        }
        public ListMenu(string DataPath, AppsModules Modul, ListType Type, string ModLabel)
        {
            InitializeComponent();

            //Set Label Format
            Lbl_List.Foreground = new SolidColorBrush(FontColor);
            Lbl_List.FontFamily = TitleFont;
            //Set Title
            Lbl_List.Content = ModLabel;

            //Search for the Files or Directories
            if (Type == ListType.Folder)
            {
                //Search all Directories
                DirectoryPaths = Directory.GetDirectories(DataPath).ToList();
            }
            else if (Type == ListType.None)
            {
                //Dummy
            }
            else
            {
                DirectoryPaths = new List<string>();
                //Search all Files in diferents formats
                for(int x=0; x < FileMgr.GetFileFormats(Type).Length; x++)
                    DirectoryPaths.AddRange(Directory.GetFiles(DataPath, FileMgr.GetFileFormats(Type)[x]).ToList());
            }

            //Copy the Option Information
            CurrentModul = Modul;
            SelModul = 0;

            myType = Type;
        }
        public void Refresh()
        {
            var File = FileManager.Instance.CurrentFile;

            if (File == null)
            {
                ComboBox_Table.ItemsSource = null;
                ComboBox_Member.ItemsSource = null;
            }
            else if (ComboBox_Table.ItemsSource != File.Members)
            {
                ComboBox_Table.ItemsSource = File.Members;

                var list = new List<LuaMember>();
                foreach (var member in File.Members)
                {
                    if (member is LuaTable)
                    {
                        list.AddRange((member as LuaTable).Members);
                    }
                    else
                    {
                        list.Add(member);
                    }
                }
                ComboBox_Member.ItemsSource = list;
            }
        }
            private object GetValue(string key)
            {
                switch (key)
                {
                case StandardTableKeyNames.Text:
                case StandardTableKeyNames.FullText:
                    return DefinitionItem.DisplayParts.JoinText();

                case StandardTableKeyNames2.TextInlines:
                    var inlines = new List<Inline> { new Run(" ") };
                    inlines.AddRange(DefinitionItem.DisplayParts.ToInlines(_presenter._typeMap));
                    foreach (var inline in inlines)
                    {
                        inline.SetValue(TextElement.FontWeightProperty, FontWeights.Bold);
                    }
                    return inlines;

                case StandardTableKeyNames2.DefinitionIcon:
                    return DefinitionItem.Tags.GetGlyph().GetImageMoniker();

                    //case StandardTableKeyNames2.TextInlines:
                    //    // content of the bucket displayed as a rich text
                    //    var inlines = new List<Inline>();
                    //    inlines.Add(new Run("testing") { FontWeight = FontWeights.Bold });
                    //    inlines.Add(new Run(": defined in "));

                    //    return inlines;
                }

                return null;
            }
 private List<string> getInputFiles()
 {
     var r = new List<string>();
     var s = m_InputFiles.SelectedItems;
     r.AddRange(s.OfType<string>());
     return r;
 }
        void Search(string _query)
        {
            // separate terms, dont include ''
            string[] query = _query.Split(' ').Where(t => t.Length > 0).ToArray();

            Participants = new List<Participant>();

            if (query.Length == 0)
            {
                ShowParticipants(true);
                return;
            }

            // each term must match, so start with the first term
            Participants.AddRange(FilterParticipants(query[0]));

            // todo: not reiterating over the first term
            foreach (string term in query)
            {
                List<Participant> results = FilterParticipants(term);

                List<Participant> filtered = new List<Participant>();

                foreach (Participant p in Participants)
                {
                    // only participants that match each term will be shown
                    if (results.Contains(p))
                        filtered.Add(p);
                }

                Participants = filtered;
            }

            ShowParticipants();
        }
Exemple #18
0
 public static string[] FlowDocumentToSlipPrinterFormat(FlowDocument document)
 {
     var result = new List<string>();
     if (document != null)
         result.AddRange(ReadBlocks(document.Blocks));
     return result.ToArray();
 }
        private void UnZip(List<string> cbzlist)
        {
            foreach (var fileName in cbzlist)
            {
                toolStripStatusLabel1.Content = "UnZipping...";
                var newfolder = fileName.Substring(0, fileName.Length - 4);
                if (Directory.Exists(newfolder))
                    Directory.Delete(newfolder, true);
                System.IO.Directory.CreateDirectory(newfolder);
                ZipHelp.UnZip(fileName,"", newfolder);
                List<String> picFiles = new List<String>(Directory.GetFiles(newfolder, "*.jpg", SearchOption.AllDirectories));
                picFiles.AddRange(new List<String>(Directory.GetFiles(newfolder, "*.png", SearchOption.AllDirectories)));
                int c = 0;
                foreach (var picFile in picFiles)
                {
                    switch (Path.GetExtension(picFile))
                    {
                        case ".jpg":
                            System.IO.File.Move(picFile, newfolder + @"\" + c + ".jpg");
                            break;
                        case ".png":
                            System.IO.File.Move(picFile, newfolder + @"\" + c + ".png");
                            break;
                    }
                    c++;
                }

                toolStripStatusLabel1.Content = "Done";
            }
        }
 public void Show() {
     Visibility = Visibility.Visible;
     var studies = new List<string>();
     studies.AddRange(DatabaseManager.Entities.Studia.Select(x => x.Nazwa).AsEnumerable());
     comboBox.ItemsSource = studies;
     comboBox.SelectedIndex = 0;
 }
        public WalletPicker()
        {
            InitializeComponent();

            walletPath = ConfigurationManager.AppSettings.Get("WalletPath");
            if (string.IsNullOrWhiteSpace(walletPath) || !Directory.Exists(walletPath))
            {
                walletPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            }

            string extensions = ConfigurationManager.AppSettings.Get("WalletExtensions") ?? "wallet";

            var dir = new DirectoryInfo(walletPath);
            existingWallets = new List<FileInfo>();

            foreach (var extension in extensions.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries))
            {
                existingWallets.AddRange(dir.GetFiles("*." + extension));
            }

            cbWallets.DisplayMemberPath = "Name";
            cbWallets.SelectedValuePath = "FullName";
            cbWallets.ItemsSource = existingWallets;

            if (cbWallets.Items.Count > 0)
            {
                cbWallets.SelectedIndex = 0;
                cbWallets.IsEnabled = true;
                btnOpen.IsEnabled = true;
            }

            cbWallets.Focus();
        }
        private static void OptimizePosition(FantasyTeam mockTeam, string position, int spotsAlreadyFilled)
        {
            int numberOfTotalSpots = Brain.MyDraft.RosterSpotsByPosition[position];
            int percentageBudgetForPosition = mockTeam.PercentageBudgetsByPosition[position];
            int percentageBudgetForBench = mockTeam.PercentageBudgetsByPosition["BENCH"];

            List<Player> players = new List<Player>();
            players.AddRange(Brain.MyDraft.PlayersByPosition[position]);

            while (spotsAlreadyFilled < numberOfTotalSpots)
            {
                int dollarBudgetForPosition = mockTeam.GetBudgetDollarForPosition(position);

                int numberOfSpotsAvailable = numberOfTotalSpots - spotsAlreadyFilled;
                int dollarBudgetForThisPlayer = numberOfSpotsAvailable > 1 ? (int)Math.Ceiling(dollarBudgetForPosition / 2.0) : dollarBudgetForPosition;

                Player bestPlayer = players.Where(p => p.Dollar <= dollarBudgetForThisPlayer && !mockTeam.Roster.Contains(p))
                    .OrderByDescending(s => s.Points).First();

                mockTeam.addMockPlayer(bestPlayer);

                players.Remove(bestPlayer);
                spotsAlreadyFilled++;
            }

            if (mockTeam.PercentageBudgetsByPosition[position] > 0)
            {
                var increase = mockTeam.PercentageBudgetsByPosition[position] * Brain.MyDraft.LeagueSalarayCap / 100;
                mockTeam.AdjustedCap += increase;
            }
        }
        void bwS_DoWork(object sender, DoWorkEventArgs e) {
            String kws = Convert.ToString(e.Argument);

            List<string> Dirs = new List<string>();

            foreach (String k in Settings.Default.Dirs.Split('\n')) {
                if (String.IsNullOrEmpty(k)) continue;
                if (Directory.Exists(k)) {
                    Dirs.AddRange(Directory.GetDirectories(k, "*", SearchOption.AllDirectories));
                }
            }

            foreach (String dir in Dirs) {
                foreach (var fi in new DirectoryInfo(dir).GetFiles()) {
                    String fext = fi.Extension.ToLowerInvariant();
                    if (fext == ".png" || fext == ".gif" || fext == ".ico") {
                        String fn = fi.Name;
                        if (MUt.Match(fn, kws)) {
                            wpRes.Dispatcher.Invoke((Action<String>)((fp) => {
                                var src = new BitmapImage(new Uri(fp));
                                Image i = new Image();
                                i.Width = (src.PixelWidth);
                                i.Height = (src.PixelHeight);
                                i.Stretch = Stretch.Uniform;
                                i.HorizontalAlignment = HorizontalAlignment.Center;
                                i.VerticalAlignment = VerticalAlignment.Center;
                                i.Source = src;
                                i.Tag = fp;
                                i.MaxHeight = 64;
                                i.MaxWidth = 64;
                                i.MouseDown += new MouseButtonEventHandler(i_MouseDown);
                                i.ContextMenu = FindResource("cms1") as ContextMenu;
                                Grid g = new Grid();
                                g.RowDefinitions.Add(new RowDefinition { Height = new GridLength(64) });
                                g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
                                g.Children.Add(i);
                                {
                                    TextBlock l = new TextBlock();
                                    l.Text = String.Format("{0}{1}", src.PixelWidth, fext);
                                    l.HorizontalAlignment = HorizontalAlignment.Right;
                                    l.VerticalAlignment = VerticalAlignment.Bottom;
                                    l.FontSize = 9;
                                    l.Margin = new Thickness(0, 0, 2, 0);
                                    l.Foreground = Brushes.YellowGreen;
                                    l.SetValue(Grid.RowProperty, 1);
                                    g.Children.Add(l);
                                }
                                Border b = new Border();
                                b.Width = 64;
                                b.Height = 80;
                                b.Child = g;
                                b.BorderBrush = Brushes.Aqua;
                                b.BorderThickness = new Thickness(0.25);
                                wpRes.Children.Add(b);
                            }), fi.FullName);
                        }
                    }
                }
            }
        }
Exemple #24
0
        public BookmarkEditor(Comisor.MainWindow mainWindow, string strName, string strPath, string strCurrentPath = "")
        {
            InitializeComponent();

            this.main = mainWindow;
            this.Title = Comisor.Resource.Bookmark_Editor;
            lbName.Content = Comisor.Resource.Bookmark_Name + ":";
            lbPath.Content = Comisor.Resource.Bookmark_FilePath + ":";

            List<string> nameOption = new List<string>();
            nameOption.AddRange(strPath.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries));
            nameOption.Reverse();
            nameOption.Insert(0, strName);
            ys.DataProcessor.RemoveSame(ref nameOption);
            cbName.ItemsSource = nameOption;
            cbName.SelectedIndex = 0;

            List<string> pathOption = new List<string>();
            pathOption.Add(strPath);
            if (strCurrentPath != "") pathOption.Add(strCurrentPath);
            ys.DataProcessor.RemoveSame(ref pathOption);
            cbPath.Focus();
            cbPath.ItemsSource = pathOption;
            cbPath.SelectedIndex = 0;

            ckbShortcut.Content = Comisor.Resource.Bookmark_CreatShortcut;

            btnOK.Content = mainWindow.resource.imgOK;
            btnCancel.Content = mainWindow.resource.imgCancel;

            this.PreviewKeyDown += new KeyEventHandler(InputBox_PreviewKeyDown);
        }
Exemple #25
0
        public Page()
        {
            InitializeComponent();

            //dataGrid.ItemsSource = "H e l l o W o r l d !".Split();

            //int itemsCount = 100;
            //for (int i = 0; i < itemsCount; i++)
            //{
            //    data.Add(new Data()
            //    {
            //        FirstName = "First",
            //        LastName = "Last",
            //        Age = i,
            //        Available = (i % 2 == 0)
            //    });
            //}

            List<Data> data = new List<Data>();
            Data item1 = new Data() { BoolColumn = null, EditColumn = "Edit0", ReadColumn = "Read0" };
            Data item2 = new Data() { BoolColumn = true, EditColumn = "Edit1", ReadColumn = "Read1" };
            Data item3 = new Data() { BoolColumn = false, EditColumn = "Edit2", ReadColumn = "Read2" };

            data.AddRange(new Data[] { item1,item2, item3 });
            dataGrid.ItemsSource = data;
        }
 private byte[] GetTextArray ()
 {
     List<byte> byteList = new List<byte>();
     string text = this.inputTextBox.Text;
     byteList.AddRange(Encoding.GetEncoding(1251).GetBytes(text));
     return byteList.ToArray();
 }
        public List<string> GetImageFilePathsInFolder(string folder)
        {
            List<string> images = new List<string>();

            //Recursively get images from subfolders of current folder
            foreach (string subFolder in Directory.GetDirectories(folder).OrderBy(f => f))
            {
                images.AddRange(GetImageFilePathsInFolder(System.IO.Path.Combine(folder, subFolder)));
            }

            if (isContinueLastSession)
            {
                //Only consider the image if it hasn't been processed in the previous session
                foreach (string fileName in Directory.GetFiles(folder, ImageFileSearchPattern))
                {
                    if (!File.Exists(System.IO.Path.Combine(destinationDirectory, System.IO.Path.GetFileName(fileName))))
                    { images.Add(System.IO.Path.Combine(folder, fileName)); }
                }
            }
            else
            {
                images.AddRange(Directory.GetFiles(folder, ImageFileSearchPattern));
            }

            return images;
        }
        public SignatureWindow(string signature)
        {
            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _signatureComboBox.ItemsSource = digitalSignatureCollection;

            for (int index = 0; index < Settings.Instance.Global_DigitalSignatureCollection.Count; index++)
            {
                if (Settings.Instance.Global_DigitalSignatureCollection[index].ToString() == signature)
                {
                    _signatureComboBox.SelectedIndex = index + 1;

                    break;
                }
            }
        }
Exemple #29
0
        private TaskManager()
        {
            InitializeComponent();
            AllProcesses = new List<Process>();
            AllProcesses.AddRange(Process.GetProcesses());
            var r = new Random();
            paged = r.Next(750, 860);
            nonpaged = r.Next(450, 550);
            totalMemory = r.Next(55, 65);
            totalCPU = r.Next(30, 55);
            lblPaged.Content = paged.ToString() + " MB";
            lblNonPaged.Content = nonpaged.ToString() + " MB";
            lblTotalMem.Content = totalMemory.ToString() + " %";
            lblTotalCPUu.Content = totalCPU.ToString() + " %";
            foreach (Process p in AllProcesses)
            {
                long ws = p.WorkingSet64 / 1024;
                long ramP = (ws / ram) % 100;
                int usoCPU = r.Next(1, 50);
                long usoDisco = (ramP + r.Next(1, 25)) % 100;

                lvProcess.Items.Add(new MyItem { Name = p.ProcessName, ID = p.Id, Threads = p.Threads.Count, Memory = ramP, CPU = usoCPU, Disk = usoDisco });
            }

            timer.Tick += new EventHandler(timer_Tick);
            timerDos.Tick += timerDos_Tick;
            timerDos.Interval = new TimeSpan(0, 0, 2);
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            timer.Start();
            stopwatch.Start();
            timerDos.Start();
        }
        /// <summary>
        /// Retrieves stored time zones
        /// </summary>
        /// <returns>persisted time zones</returns>
        public static List<CityTZ> ReadAllKnownTimeZones()
        {
            List<CityTZ> allTimeZones = new List<CityTZ>();
            TextReader reader = null;
            TextWriter writer = null;
            try
            {
                using (IsolatedStorageFile isoStorage =
                    IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (!isoStorage.FileExists(ConstCityZoneFileName))
                    {
                        StreamResourceInfo sri = Application.GetResourceStream(
                            new Uri("/TimeZones;component/" + ConstCityZoneFileName, UriKind.Relative));
                        reader = new StreamReader(sri.Stream);
                        XmlSerializer xs = new XmlSerializer(
                            typeof(List<CityTZ>));
                        allTimeZones.AddRange(
                            (List<CityTZ>)xs.Deserialize(reader));
                        reader.Close();
                        IsolatedStorageFileStream file =
                         isoStorage.OpenFile(
                             ConstCityZoneFileName,
                             FileMode.Create);
                        writer = new StreamWriter(file);
                        xs.Serialize(writer, allTimeZones);
                        writer.Close();
                    }
                    else
                    {
                        IsolatedStorageFileStream file =
                            isoStorage.OpenFile(
                                ConstCityZoneFileName,
                                FileMode.Open);
                        reader = new StreamReader(file);

                        XmlSerializer xs = new XmlSerializer(
                            typeof(List<CityTZ>));
                        allTimeZones.AddRange(
                            (List<CityTZ>)xs.Deserialize(reader));
                        reader.Close();
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Read from Isolated Storage Exception:" + exception.Message);
            }
            finally
            {
                if (reader != null)
                    reader.Dispose();

                if (writer != null)
                    writer.Dispose();
            }

            return allTimeZones;
        }