예제 #1
0
        private void SetTumblers(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Tumblers.Count == _ViewModel.Watch.Count)
            {
                return;
            }
            if (_ViewModel.FreezeWatch)
            {
                return;
            }
            while (Tumblers.Count != _ViewModel.Watch.Count)
            {
                if (Tumblers.Count < _ViewModel.Watch.Count)
                {
                    Tumbler T = new Tumbler();
                    SetTriggerToTumbler(T, "Checked", "SetWach", Tumblers.Count);
                    SetTriggerToTumbler(T, "Unchecked", "SetWach", Tumblers.Count);

                    T.SetBinding(Tumbler.IsCheckedProperty, $"Watch[{Tumblers.Count}]");
                    WachingRigsSP.Children.Add(T);
                    Tumblers.Add(T);
                }
                else
                {
                    WachingRigsSP.Children.RemoveAt(WachingRigsSP.Children.Count - 1);
                    Tumblers.RemoveAt(Tumblers.Count - 1);
                }
            }
        }
예제 #2
0
    public void LoadXML(string ID)
    {
        if (xmlLevelFile != null)
        {
            XmlDocument root = new XmlDocument();
            root.LoadXml(xmlLevelFile.text);
            XmlElement elem = root.GetElementById(ID);

            levelData       = new LevelData();
            levelData.star1 = float.Parse(elem.Attributes["star1"].Value);
            levelData.star2 = float.Parse(elem.Attributes["star2"].Value);
            levelData.star3 = float.Parse(elem.Attributes["star3"].Value);
            foreach (XmlNode k in elem.ChildNodes)
            {
                Tumbler t = new Tumbler();
                t.ID    = k.Attributes["ID"].Value;
                t.x     = float.Parse(k.Attributes["x"].Value);
                t.slotY = float.Parse(k.FirstChild.Attributes["y"].Value);
                XmlNode c = k.LastChild;
                t.bottomY      = float.Parse(c.PreviousSibling.Attributes["y"].Value);
                t.bottomScale  = int.Parse(c.PreviousSibling.Attributes["scale"].Value);
                t.bottomWeight = int.Parse(c.PreviousSibling.Attributes["weight"].Value);
                t.topY         = float.Parse(c.Attributes["y"].Value);
                t.topFall      = int.Parse(c.Attributes["fall"].Value);

                levelData.tumblers.Add(t);
            }

            foreach (string l in f1)
            {
                if (ID == "L_" + l)
                {
                    chamberColor        = new Color32(59, 174, 218, 255);
                    levelSelectExitCode = 0;
                }
            }
            foreach (string l in f2)
            {
                if (ID == "L_" + l)
                {
                    chamberColor        = new Color32(40, 185, 94, 255);
                    levelSelectExitCode = 1;
                }
            }
            foreach (string l in f3)
            {
                if (ID == "L_" + l)
                {
                    chamberColor        = new Color32(232, 121, 0, 255);
                    levelSelectExitCode = 2;
                }
            }
            levelData.ID = ID;
            SceneManager.LoadScene("Arena");
        }
    }
예제 #3
0
        private void SetTriggerToTumbler(Tumbler T, string EventName, string Command, object Parametr)
        {
            var invokeCommandAction = new InvokeCommandAction {
                CommandParameter = Parametr
            };
            var binding = new Binding {
                Path = new PropertyPath(Command)
            };

            BindingOperations.SetBinding(invokeCommandAction, InvokeCommandAction.CommandProperty, binding);

            var eventTrigger = new Microsoft.Xaml.Behaviors.EventTrigger {
                EventName = EventName
            };

            eventTrigger.Actions.Add(invokeCommandAction);

            var triggers = Interaction.GetTriggers(T);

            triggers.Add(eventTrigger);
        }
예제 #4
0
        private void PoolsSets_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            PoolsSeletorsSP.Children.Clear();
            PoolsNamesSP.Children.Clear();
            PoolsTypesSP.Children.Clear();
            PoolsCoinsSP.Children.Clear();
            PoolsWalletsSP.Children.Clear();
            PoolsWachSP.Children.Clear();

            while (PoolsSeletorsSP.Children.Count < _ViewModel.PoolsSets.Count)
            {
                int i  = PoolsSeletorsSP.Children.Count;
                var ps = _ViewModel.PoolsSets[i];

                var sel = new Selector
                {
                    index             = i,
                    IsChecked         = _ViewModel.Selection[i],
                    Height            = 26,
                    VerticalAlignment = VerticalAlignment.Center
                };
                sel.Checked   += Sel_Checked;
                sel.Unchecked += Sel_Checked;
                PoolsSeletorsSP.Children.Add(sel);

                var nameTb = new TextBox
                {
                    Name   = $"nameTb{i}",
                    Text   = ps.Name,
                    Height = 26,
                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    FontSize = 18
                };
                nameTb.TextChanged += NameTb_TextChanged;
                PoolsNamesSP.Children.Add(nameTb);

                var pooltypeTb = new ComboBox
                {
                    Name   = $"pooltypeTb{i}",
                    Height = 26,
                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    FontSize     = 16,
                    ItemsSource  = PoolsWacher.PoolTypes,
                    SelectedItem = ps.Pool
                };
                pooltypeTb.SelectionChanged += PooltypeTb_SelectionChanged;
                PoolsTypesSP.Children.Add(pooltypeTb);

                CoinType[] Coins = null;
                if (ps.Pool != null)
                {
                    Coins = PoolsWacher.Coins[ps.Pool.Value];
                }
                var cointypeTb = new ComboBox
                {
                    Name   = $"cointypeTb{i}",
                    Height = 26,
                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    FontSize     = 16,
                    ItemsSource  = Coins,
                    SelectedItem = ps.Coin
                };
                cointypeTb.SelectionChanged += CointypeTb_SelectionChanged;
                PoolsCoinsSP.Children.Add(cointypeTb);

                var walletTb = new TextBox
                {
                    Name   = $"walletTb{i}",
                    Text   = ps.Wallet,
                    Height = 26,
                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    FontSize = 18
                };
                walletTb.TextChanged += WalletTb_TextChanged;
                PoolsWalletsSP.Children.Add(walletTb);

                var wachTb = new Tumbler
                {
                    index             = i,
                    IsChecked         = ps.Wach,
                    Height            = 26,
                    VerticalAlignment = VerticalAlignment.Center
                };
                wachTb.Checked   += WachTb_Checked;
                wachTb.Unchecked += WachTb_Checked;
                PoolsWachSP.Children.Add(wachTb);
            }
        }