public EditDrinksPage()
        {
            InitializeComponent();
            DataContext = App.ViewModel;

            Drink TapToAdd = new Drink() { Name = "Tap to add a drink", Size = 0, mg = 0, drinkId = 1, IsActive = false };
            Drink AddedDrinks = new Drink() { Name = "------ Added Drinks ------", Size = 0, mg = 0 };

            var drinkList = new List<Drink>(App.ViewModel.drinkList);

            int i;
            for (i = 0; i < drinkList.Count; i++)
            {
                if ((drinkList[i] as Drink).Name == "Tap to add a drink")
                {
                    var drink = (drinkList[i] as Drink);

                    if (drinkList.Contains(drink))
                        drinkList.Remove(drink);
                }
                else if ((drinkList[i] as Drink).Name == "------ Added Drinks ------")
                {
                    var drink = (drinkList[i] as Drink);

                    if (drinkList.Contains(drink))
                        drinkList.Remove(drink);
                }
            }
            drinkList.Remove(TapToAdd);

            if (drinkList.Contains(AddedDrinks))
                drinkList.Remove(AddedDrinks);

            drinksListBox.ItemsSource = drinkList;
        }
示例#2
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                t = Utils.Utils.GetTscDataByApplicationCurrentProperties();
                if (t == null)
                {
                    return;
                }
                //t.ListPlan;
                List<Schedule> ls = t.ListSchedule;
                List<int> li = new List<int>();
                foreach (Schedule s in ls)
                {
                    if (!li.Contains(s.ucId) && s.ucId != 0)
                        li.Add(s.ucId);
                }

                cbxScheduleId.ItemsSource = li;
                List<Plan> lp = t.ListPlan;
                foreach (Plan p in lp)
                {
                    if (p.ucId >= 1 && p.ucId <= 20)
                    {
                        sldPlanId.Value = p.ucId;
                        cbxScheduleId.SelectedItem = Convert.ToInt32(p.ucScheduleId);
                        ushort month = p.usMonthFlag;
                        uint day = p.ulDayFlag;
                        DateTime datetime = DateTime.Now;
                        //for (int i = 1; i <= 12; i++)
                        //{
                        //    if (((month >> i) & 0x01) == 0x01)
                        //    {
                        //        for (int j = 1; j <= 31; j++)
                        //        {
                        //            if (((day >> j) & 0x01) == 0x01)
                        //            {
                        //                try
                        //                {
                        //                    calendar.SelectedDates.Add(new DateTime(datetime.Year, i, j));
                        //                }
                        //                catch (Exception ex)
                        //                {
                        //                    continue;
                        //                }

                        //            }
                        //        }
                        //    }
                        //}
                        //break;
                    }
                }
            }
            catch(Exception ex )
            {

            }
            
        }
示例#3
0
         private void ComboBox_Loaded(object sender, RoutedEventArgs e)
         {
             List<string> maat = new List<string>();
 
             try
             {
                 //maat comboboxiin, ei lisätä duplikaatteja      
                 foreach (XElement maa in xe.Descendants("maa"))
                 {
                     if (!maat.Contains(maa.Value))
                     {
                         maat.Add(maa.Value);
                     }
                 }
 
                 // ... Get the ComboBox reference.
                 var comboBoxMaa = sender as ComboBox;
 
                 // ... Assign the ItemsSource to the List.
                 comboBoxMaa.ItemsSource = maat;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
 private void convert(int i)
 {
     List<int> listy = new List<int>();
     int t = 0;
     while (t < i)
     {
         int a = f();
         if (listy.Contains(a))
         {
             a = f();
             listy.Add(a);
         }
         else
         {
             listy.Add(a);
         }
         t++;
     }
     StringBuilder builder = new StringBuilder();
     foreach (int list in listy)
     {
         builder.Append(list).Append(" ");
     }
     string result = builder.ToString();
     label.Content = result;
 }
示例#5
0
        private void InitMyStuff()
        {
            try
            {
                cities = new List<string>();
                /*cities.Add("Jyväskylä");
                cities.Add("Helsinki");
                cities.Add("New York");*/
                string kaupunki = "";
                foreach (DataRow item in table.Rows)
                {
                    kaupunki = item[3].ToString();
                    if (!cities.Contains(kaupunki))
                    {
                        cities.Add(kaupunki);
                    }
                    
                }
                // VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn datatableen, huom ei kaikille datatablella
             //   var result = (from c in table select c.City).Distinct();
                // databindaus
                cbCities.ItemsSource = cities;

                            
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#6
0
        public string CreateMeasurementsJson(string fileName, string resourceid)
        {
            XDocument doc = XDocument.Load(fileName);
              var str = new StringBuilder();

              var res2 = (from measure in doc.Root.Elements("resource").Elements("measurements").Elements("measurement")
                      where
                          measure.Attribute("resource_id").Value.Equals(resourceid, StringComparison.OrdinalIgnoreCase)
                      select measure).ToList();

              str.Append("[");
              var elemsList = new List<string>();
              foreach (var el in res2)
              {
              var basicInfo = new List<string> { "resource_id", "resource_name", "measurement_id", "measurement_time" };
              var tmp = new StringBuilder();
              tmp.Append("{");
              tmp.Append(string.Format("\"{0}\":\"{1}\"", "measurement_id", el.Attribute("measurement_id").Value));
              tmp.Append(",");
              tmp.Append(string.Join(",", (from att in el.Attributes() where !basicInfo.Contains(att.Name.ToString()) select string.Format("\"{0}\":\"{1}\"", "measurement_name", att.Name)).ToArray()));
              tmp.Append("}");

              elemsList.Add(tmp.ToString());
              }
              str.Append(string.Join(",", elemsList));
              str.Append("]");

              return (!str.ToString().Equals("[]")) ? str.ToString() : string.Empty;
        }
示例#7
0
        private void IniMyStuff()
        {
            cities = new List<string>();
            //cities.Add("Jyväskylä");
            //cities.Add("Helsinki");
            //cities.Add("New York");
            // VE2 käydään loopilla DataTable läpi
            string kaupunki = "";
            foreach (DataRow item in dt.Rows)
            {
                kaupunki = item[3].ToString();
                if (!cities.Contains(kaupunki))
                {
                    cities.Add(kaupunki);
                }
                
            }
            // VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn DataTableen, huom ei kaikille DataTableille
            // joten ei toimi tässä
            // databindaus
            // var result = (from c in dt select c.City).Distinct();

            // databindaus
            cbCities.ItemsSource = cities;
        }
        private void HaeMaat()
        {
            List<string> maalista = new List<string>();

        // Loading from a file, you can also load from a stream       
        // Z:\Github\IIO13200_NET_15S\Tehtävä4\Viinit1.xml
         var xml = XDocument.Load(@"Z:\Github\IIO13200_NET_15S\Tehtävä4\Viinit1.xml");

            var result = from r in xml.Descendants("wine")
                            select new
                            {
                                Maa = r.Element("maa").Value
                            };

            foreach (var r in result)
            {
                string uusi = r.Maa;
                if (!maalista.Contains(uusi))
                    {
                    maalista.Add(uusi);
                    } 
            }

            cbMaat.ItemsSource = maalista;
            cbMaat.SelectedIndex = 0;

        }
示例#9
0
        private void IniMyStuff()
        {
            // Asetetaan kaupunkien nimet ComboBoxiin.
            cities = new List<string>();
            // VE1 kaupungin nimet "kovakoodattuna".
            //cities.Add("Jyväskylä");
            //cities.Add("Helsinki");
            //cities.Add("New York");

            // VE2 käydään loopittamalla DataTable läpi.
            string kaupunki = "";

            foreach (DataRow item in dt.Rows)
            {
                kaupunki = item[3].ToString();

                // Lisätään kaupunki vain kerran listaan.
                if(!cities.Contains(kaupunki))
                    cities.Add(item[3].ToString());
            }

            // VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn DataTableen, huom. ei kaikille DataTableille.
            // var result = (from c in dt select c.City).Distinct();

            // Databindaus.
            cbCities.ItemsSource = cities;
        }
示例#10
0
        private bool CheckRoomFree()
        {
            bool check = false;
            ClassSchedule = new List<string>();
            ClassSchedule = database.getAllweekPlan();
            tempSplitArray = new string[6];
            roomClassSetup.Clear();
            List<string> tempList = new List<string>();
            foreach (var item in ClassSchedule)
            {
                tempSplitArray = item.Split(';');

                if (!roomClassSetup.Contains(tempSplitArray[3]))
                    roomClassSetup.Add(tempSplitArray[3]);

                if (dayOfWeekID.ToString() == tempSplitArray[0] && periodID.ToString() == tempSplitArray[1])
                {
                    if (tempSplitArray[3] != null && !tempList.Contains(tempSplitArray[3]))
                    {
                        tempList.Add(tempSplitArray[3]);
                        check = true;
                    }
                }
            }
            roomClassSetup = roomClassSetup.Except(tempList).ToList();
            return check;
        }
        private void AllProductProvinceGroupings_Loaded(LoadOperation<ProductProvinceGrouping> result)
        {
            List<int> alreadySetProducts = new List<int>();
            if (Utils.LoadOperation_Error_Handled(result.Error, "SmartMap"))
                foreach (ProductProvinceGrouping ppg in result.Entities)
                    alreadySetProducts.Add(ppg.ProductMapID);

            List<string> productNames = new List<string>();
            foreach (ProductMap pm in DBUtils.GetAllProducts())
            {
                if (productNames.Contains(pm.CD_BrandDIName) || pm.CD_BrandDIName == null || pm.CD_BrandDIName.Trim() == "")
                    continue;
                productNames.Add(pm.CD_BrandDIName);
                SolidColorBrush foreground = new SolidColorBrush(Colors.Black);
                if (alreadySetProducts.Contains(pm.ProductMapID))
                    foreground = new SolidColorBrush(Colors.Gray);
            
                
                if (_selectedProductMapIds != null && _selectedProductMapIds.Contains(pm.ProductMapID))
                    SelectedProductsList.Items.Add(new ListBoxItem() { Content = pm.CD_BrandDIName, Tag = pm.ProductMapID, Foreground = foreground });
                else
                    ProductsList.Items.Add(new ListBoxItem() { Content = pm.CD_BrandDIName, Tag = pm.ProductMapID, Foreground = foreground });
            }
            if (ProductsLoading != null)
                ProductsLoading.Visibility = System.Windows.Visibility.Collapsed;
            else
                _hideLoading = true;
        }
示例#12
0
        private void ProvincesList_Loaded(object sender, RoutedEventArgs e)
        {
            ProvincesList = (sender as ListBox);
            List<string> names = new List<string>();
            foreach (RegionMap rm in DBUtils.GetAllDatRegions())
            {
                if (!Utils.String_Trim_ToLower_Equals(rm.GroupName, C.PROVINCE_DB_REGIONGROUP))
                    continue;
                if (_groupRegionMapIds != null)
                {
                    bool var = false;
                    foreach (ProvinceGroupRegionMap pgrm in _groupRegionMapIds)
                        if (pgrm.RegionMapID == rm.RegionMapID)
                        {
                            var = true;
                            break;
                        }
                    if (var)
                        continue;
                }
                if (names.Contains(rm.DAT_EnREGIONNAME.Trim().ToLower()))
                    continue;
                names.Add(rm.DAT_EnREGIONNAME.Trim().ToLower());
                ProvincesList.Items.Add(rm);
            }
            if (_groups != null)
            {

            }
        }
示例#13
0
        public Behaviors(World world)
        {
            this.world = world;

            BehaviorList = new Dictionary<int, string>();

            ranGen = new Random();

            moveMod = 1;

            turnMod = 0.04;

            energyMod = 0.5;

            blacklistMethods = new List<String>();
            createMethodBlacklist();

            int index = 0;
            //Constructing the dictionary of possible actions
            foreach (var method in GetType().GetMethods())
            {
                //Ignore operations that aren't related to an organism.
                if (!blacklistMethods.Contains(method.Name))
                {
                    BehaviorList.Add(index, method.Name);
                    index++;
                }
            }
        }
 private void IniMyStuff()
 {
   //asetetaan kaupunkien nimet ComboBoxiin
   cities = new List<string>();
   //VE1 kaupungin nimet "kovakoodattu"
   //cities.Add("Jyväskylä");
   //cities.Add("Helsinki");
   //cities.Add("New York");
   //VE2 käydään loopittamalla DataTable läpi
   string kaupunki = "";
   foreach (DataRow item in dt.Rows)
   {
     kaupunki = item["City"].ToString();
     //tai
     kaupunki = item[3].ToString();
     //lisätään kukin kaupunki vain kerran listaan
     if (!cities.Contains(kaupunki))
       cities.Add(kaupunki);
   }
   //VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn DataTableen, huom ei kaikille DataTablella
   //joten ei toimi tässä
   //var result = (from c in dt
   //              select c.City).Distinct();
   //databindaus
   cbCities.ItemsSource = cities;
 }
示例#15
0
        public int[] Started()
        {
            List<int> ar;
            List<int> buf_ar;
            do
            {
                ar = new List<int>();
                Random rand = new Random();
                int buf = rand.Next(0, 16);
                buf_ar = new List<int>(new int[16] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 });
                while (buf_ar.Count != 0)
                {

                    if (!buf_ar.Contains(buf))
                    {
                        buf = rand.Next(0, 16);
                    }
                    else
                    {
                        ar.Add(buf);
                        buf_ar.Remove(buf);
                    }

                }

            } while (!IDA.DoHaveResolve(ar.ToArray()));
            return ar.ToArray();
        }
示例#16
0
 public void Test()
 {
     Thread t = new Thread(() =>
     {
         List<int> nums = new List<int>();
         Random random = new Random();
         int num = -1;
         string[] colorStr = new string[] { "0","1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
         for (int i = 0; i < DownloadViewModel.GetInstance().PointCount; i++)
         {
             while (num == -1 || nums.Contains(num))
             {
                 num = random.Next(0, DownloadViewModel.GetInstance().PointCount);
             }
             string color = "#";
             for (int n = 0; n < 6; n++)
             {
                 color += colorStr[random.Next(0, colorStr.Count())];
             }
             DownloadViewModel.GetInstance().UpdatePointByIndex(num, color);
             Thread.Sleep(50);
             nums.Add(num);
         }
     });
     t.IsBackground = true;
     t.Start();
 }
 internal void SetModeInvestigationView()
 {
     var hiddenColumns = new List<string> {"When", "Total Credit", "My Profit", "My Profit %", "Sell Price", "Station"};
     foreach (var dataGridColumn in dataGridTransactions.Columns)
     {
         if(hiddenColumns.Contains((string)dataGridColumn.Header))
             dataGridColumn.Visibility = Visibility.Hidden;
     }
 }
        private void AddToSearchHistory(ref List<string> history, string newSearch)
        {
            if (history.Contains(newSearch))
                history.Remove(newSearch);

            if (history.Count == 100)
                history.RemoveAt(99);

            history.Insert(0, newSearch);
        }
示例#19
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            // Query the registry to find out where sample photos are stored.
            const string shellKey =
                @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell Folders";

            string imagesPath =
                (string)Microsoft.Win32.Registry.GetValue(shellKey, "CommonPictures", null) + @"\Sample Pictures";

            try
            {
                // Get a list of all .jpg files.
                string[] imageNames = System.IO.Directory.GetFiles(imagesPath, "*.jpg");

                // Make sure that there are some images to select.
                if (imageNames.Length > 0)
                {
                    Random randomIndex = new Random();
                    // This list tracks which images have been added to buttons 
                    // so that no two buttons have the same image.
                    List<int> selected = new List<int>();

                    foreach (UIElement element in MainGrid.Children)
                    {
                        SurfaceButton button = element as SurfaceButton;
                        if (button != null)
                        {
                            // Track the number of tries. 
                            // This item is to prevent an endless loop if there
                            // are fewer images to choose from than buttons.
                            int tryCount = 0;
                            int index = randomIndex.Next(imageNames.Length);
                            while (selected.Contains(index) && tryCount < 8)
                            {
                                index = randomIndex.Next(imageNames.Length);
                                tryCount++;
                            }
                            // Create the image and assign it to the button content.
                            BitmapImage bitmap = new BitmapImage(new Uri(imageNames[index]));
                            Image image = new Image();
                            image.Source = bitmap;
                            button.Content = image;
                            // Track that this index has been used.
                            selected.Add(index);
                        }
                    }
                }
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                // Handle exceptions as needed.
            }
        }
示例#20
0
        public LogTypeSelection(List<Core.Data.LogType> available, List<Core.Data.LogType> selection)
        {
            InitializeComponent();

            _availableTypes = new ObservableCollection<CheckedListItem<Core.Data.LogType>>();
            foreach (var c in available)
            {
                _availableTypes.Add(new CheckedListItem<Core.Data.LogType>(c, selection != null && selection.Contains(c)));
            }

            DataContext = this;
        }
示例#21
0
        private bool isKeyOk(Key key)
        {
            List<Key> keys = new List<Key>();
            if (forbiddenKeys.Contains(key)) return false;

            if (state != "Up") keys.Add(Profiles.Current.KeyUp);
            if (state != "Left") keys.Add(Profiles.Current.KeyLeft);
            if (state != "Right") keys.Add(Profiles.Current.KeyRight);
            if (state != "Stop") keys.Add(Profiles.Current.KeyStop);

            return !keys.Contains(key);
        }
        public GeocacheContainerSelection(List<Core.Data.GeocacheContainer> available, List<Core.Data.GeocacheContainer> selection)
        {
            InitializeComponent();

            _availableTypes = new List<CheckedListItem<Core.Data.GeocacheContainer>>();
            foreach (var c in available)
            {
                _availableTypes.Add(new CheckedListItem<Core.Data.GeocacheContainer>(c, selection != null && selection.Contains(c)));
            }

            DataContext = this;
        }
        private void ButtonImport_OnClick(object sender, RoutedEventArgs e)
        {
            List<int> SelectedGroups = new List<int>();
            for (int i = 0; i < AvailableGroups.Count; i++)
            {
                foreach (var selectedItem in ListGroups.SelectedItems)
                    if ((string)selectedItem == AvailableGroups[i])
                        SelectedGroups.Add(i);
            }

            using (Stream SessionStream = File.OpenRead(SessionPath))
            {
                XPathDocument Doc = new XPathDocument(SessionStream);
                XPathNavigator Reader = Doc.CreateNavigator();
                Reader.MoveToRoot();

                int iGroup = 0;
                foreach (XPathNavigator groupNav in Reader.Select("//PointGroups/Group"))
                {
                    if (SelectedGroups.Contains(iGroup))
                    {
                        PointGroup NewGroup = new PointGroup
                        {
                            Name = XMLHelper.LoadAttribute(groupNav, "Name", "Group " + (MainWindow.Options.Membrane.PointGroups.Count + 1)),
                            Size = XMLHelper.LoadAttribute(groupNav, "Size", 10),
                            Color = ColorHelper.LoadAttribute(groupNav, "Color", ColorHelper.SpectrumColor(MainWindow.Options.Membrane.PointGroups.Count, 0.3f))
                        };
                        NewGroup.PointCloud.GLContext = MainWindow.Options.Viewport.GetControl();

                        foreach (XPathNavigator pointNav in groupNav.SelectChildren("Point", ""))
                        {
                            int TriangleID = XMLHelper.LoadAttribute(pointNav, "ID", 0);
                            SurfacePoint NewPoint = new SurfacePoint(OpenGLHelper.LoadAttribute(pointNav, "Position", new Vector3(0)),
                                                                     MainWindow.Options.Membrane.SurfaceMesh.Triangles[TriangleID < MainWindow.Options.Membrane.SurfaceMesh.Triangles.Count ? TriangleID : 0],
                                                                     OpenGLHelper.LoadAttribute(pointNav, "Barycentric", new Vector3(0)),
                                                                     XMLHelper.LoadAttribute(pointNav, "Offset", 0f),
                                                                     OpenGLHelper.LoadAttribute(pointNav, "Orientation", new Vector3(0)).X);
                            NewGroup.Points.Add(NewPoint);
                        }

                        MainWindow.Options.Membrane.PointGroups.Add(NewGroup);
                        NewGroup.IsVisible = XMLHelper.LoadAttribute(groupNav, "IsVisible", true);
                    }

                    iGroup++;
                }
            }

            if (SelectedGroups.Count > 0)
                MainWindow.Options.Viewport.Redraw();

            Close();
        }
        public SelectMediaTypeForm(List<MediaType> mediaTypes)
        {
            InitializeComponent();

            // Display the provided media types
            foreach (MediaType item in Enum.GetValues(typeof(MediaType)))
                if (mediaTypes.Contains(item))
                    this.cbMediaType.Items.Add(item);

            if (this.cbMediaType.Items.Count > 0)
                this.cbMediaType.SelectedIndex = 0;
        }
示例#25
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                if (runUnitTests)
                {
                    UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings();

                    if (null != Deployment.Current)
                    {
                        var parts = Deployment.Current.Parts;
                        var assembliesToLoad = new List<string> { "UnitTest_S3", "UnitTest_SimpleDB", "UnitTest_SQS" }; //ADD THE NAME OF THE ASSEMBLY TO TEST HERE AND LOAD IT.
                        int count = 0;

                        //Clear all the test-assemblies.
                        settings.TestAssemblies.Clear();

                        //Algorithm.
                        //0.NOTE: ADD THE NAME OF THE ASSEMBLIES TO TEST MANUALLY.
                        //1.Assembly.Load() cannot load assemblies as it would do in a normal .NET applications.
                        //Hence, the only way to do is to make a explicit reference to them from this main executing assembly(.exe, a Windows Phone Application).
                        //Reason, to enable loading assemblies dynamically, they need to be signed by Windows Market.

                        //2. Specify the assemblies that need to be tested explicitly to the testing runtime=> UnitTestSettings.TestAssemblies() method.
                        foreach (var part in parts)
                        {
                            var assemblyName = part.Source.Replace(".dll", string.Empty);
                            if (!assembliesToLoad.Contains(assemblyName)) continue;

                            var assembly = Assembly.Load(assemblyName);
                            count++;

                            settings.TestAssemblies.Add(assembly);
                            if (count >= assembliesToLoad.Count)
                                break;
                        }

                        UserControl content = UnitTestSystem.CreateTestPage(settings) as UserControl;
                        (Application.Current.RootVisual as PhoneApplicationFrame).Content = content;
                        (Application.Current.RootVisual as PhoneApplicationFrame).Padding = new Thickness(-50);

                        IMobileTestPage imtp = (Application.Current.RootVisual as PhoneApplicationFrame).Content as IMobileTestPage;

                        if (imtp != null)
                        {
                            BackKeyPress += (x, xe) => xe.Cancel = imtp.NavigateBack();
                        }
                    }
                }
            };
        }
示例#26
0
        /// <summary>
        /// Returns the list of unique source ui-elements from the specified touch points
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static List<UIElement> GetUIElements(this List<TouchPoint2> self)
        {
            List<UIElement> list = new List<UIElement>();
            foreach (var touchPoint in self)
            {
                if (!list.Contains(touchPoint.Source))
                {
                    list.Add(touchPoint.Source);
                }
            }

            return list;
        }
示例#27
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="active">whether or not the effects are active</param>
        /// <param name="effects">effect list</param>
        public AttributeSet(string prefix, List<IEffect> effects)
        {
            // Get which effects to use aliases for
            List<String> keys = new List<String>();
            List<String> ids = new List<String>();
            foreach (IEffect effect in effects) {
                string id = effect.GetKey() + ";" + effect.GetTarget();
                if (ids.Contains(id)) continue;
                else ids.Add(id);
                if (keys.Contains(effect.GetKey())) {
                    aliasedKeys.Add(effect.GetKey());
                }
                else keys.Add(effect.GetKey());
            }

            // Get the list of attributes
            List<Attribute> unaliased = new List<Attribute>();
            keys.Clear();
            foreach (IEffect effect in effects) {
                effect.GetAttributes(unaliased);

                // Apply prefixes and aliases
                foreach (Attribute attribute in unaliased) {
                    string key = attribute.Key;
                    if (aliasedKeys.Contains(effect.GetKey())) {
                        key = effect.GetTarget() + " " + key;
                    }
                    key = prefix + key;

                    // Prevent duplicates
                    if (keys.Contains(key)) continue;
                    else keys.Add(key);

                    attributes.Add(new Attribute(key, attribute.Initial, attribute.Scale));
                }

                unaliased.Clear();
            }
        }
示例#28
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            string s = "";
            //string fn = @"C:\Windows\Temp\user.txt";
            string path = Directory.GetCurrentDirectory();
            string file = path + @"account.txt";

            List<string> user = new List<string>();
            List<string> pass = new List<string>();
            try
            {
                using (StreamReader sr = new StreamReader(file, true))
                {
                    while (sr.EndOfStream == false)
                    {
                        s = sr.ReadLine();
                        string[] ss = s.Split(',');
                        user.Add(ss[0]);
                        pass.Add(ss[1]);
                    }
                }
            }
            catch (System.IO.DirectoryNotFoundException ex)
            {
                File.Create(file);
            }
            if(user.Contains(Username.Text))
            {
                for (int i = 0; i < user.Count; i++)
                {
                    if (Username.Text == user.ElementAt(i))
                    {
                        if (Password.Text == pass.ElementAt(i))
                        {
                            this.Hide();
                            Properties.Settings.Default.Save();
                            System.Windows.MessageBox.Show("Login Successful");
                            this.Show();
                        }
                        else
                        {
                            MessageBlock.Text = "Sorry wrong Password";
                        }
                    }
                }
            }
            else
            {
                MessageBlock.Text = "Sorry wrong Username";
            }
        }
 public NewRelationWindow(List<int> instrumentIds,string code, Action<AdjustRelationViewModel> editSuccess)
 {
     InitializeComponent();
     this.SourceInstrument.ItemsSource = VmQuotationManager.Instance.Instruments;
     this._AddNewSuccess = editSuccess;
     this.RelationCode.Text = code;
     foreach (VmInstrument item in VmQuotationManager.Instance.Instruments)
     {
         if (instrumentIds.Contains(item.Id))
         {
             this.SourceInstrument.SelectedItems.Add(item);
         }
     }
 }
示例#30
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            newItem = GlobalVars.item;
            GlobalVars.item = null;
            Item item = Database_Functions.GetItem(newItem.Item_ID);
            this.item_name.Text = item.Title;
            this.textBlock_description.Text = item.Description;
            textBlock_total.Text = Database_Functions.GetItemCost(item.ID).ToString("c");
            IList<Transaction> transactions = Database_Functions.GetItemTransactions(item.ID);
            IList<TextBlock> names = new List<TextBlock>();
            IList<TextBlock> amounts = new List<TextBlock>();
            IList<string> names_only = new List<string>();
            IList<Decimal> amounts_only = new List<Decimal>();
            int index = -1;

            foreach (Transaction t in transactions)
            {
                TextBlock name = new TextBlock();
                name.FontSize = 20;
                name.Margin = new Thickness(9, 64, 0, 0);
                name.Text = Database_Functions.GetMember((int)t.MemberID).Name;
                TextBlock amount = new TextBlock();
                amount.FontSize = 28;
                amount.Margin = new Thickness(9, 0, 0, 0);
                amounts_only.Add(t.Amount);
                if (t.Amount < 0)
                    amount.Text = "-" + (t.Amount * -1).ToString("c");
                else
                    amount.Text = t.Amount.ToString("c");
                if (!names_only.Contains(name.Text))
                {
                    names_only.Add(name.Text);
                    names.Add(name);
                    ContentPanel.Children.Add(name);
                    amounts.Add(amount);
                    ContentPanel.Children.Add(amount);
                }
                else
                {
                    index = names_only.IndexOf(name.Text);
                    Decimal temp = amounts_only[index] + t.Amount;
                    if (temp < 0)
                        amounts[index].Text = "-" + (temp * -1).ToString("c");
                    else
                        amounts[index].Text = temp.ToString("c");
                }
            }
        }