Example #1
0
        BitGroup GetFlagFromNode(XmlNode Bit)
        {
            if (Bit.Name != standard.BitNode)
            {
                return(null);
            }
            BitGroup flag = new BitGroup();

            if (Bit.Attributes[standard.IndexAttr] == null)
            {
                return(null);
            }
            string[] indexes = Bit.Attributes[standard.IndexAttr].Value.Split(',');
            flag.bitRefs = CommonUtils.ParseStringArrayToIntArray(indexes);
            foreach (XmlNode Attribute in Bit.ChildNodes)
            {
                if (Attribute.Name == standard.DescriptionNode)
                {
                    flag.description = Attribute.InnerText;
                }
                else if (Attribute.Name == standard.OptionNode)
                {
                    try
                    {
                        flag.bitDescriptions.Add(int.Parse(Attribute.Attributes[standard.ValueNode].Value.ToString()), Attribute.InnerText);
                    } catch
                    {
                    }
                }
            }
            flag.FillDescriptions();
            return(flag);
        }
Example #2
0
        public void BitGroup_Set()
        {
            var start = new BitGroup(2, "10");
            start.SetValue(1);

            Assert.That(start, Is.EqualTo(new BitGroup(2, "11")));
        }
        public PartiallyCompleteGroup(BitGroup bitValues)
        {
            this.maxLength = 31;

            this.blackBits = bitValues.Copy();
            this.whiteBits = bitValues.Invert();
        }
Example #4
0
        public void BitGroup_Invert_InvertsTheString()
        {
            var start = new BitGroup(2, "101");
            var inverted = start.Invert();

            Assert.That(inverted, Is.EqualTo(new BitGroup(2, "010")));
        }
Example #5
0
        public void BitGroup_Invert()
        {
            var start = new BitGroup(2, "10");
            var inverted = start.Invert();
            var doubleInverted = inverted.Invert();

            Assert.That(doubleInverted, Is.EqualTo(start));
        }
        public PartiallyCompleteGroup(int maxLength, string bitValues)
        {
            if (maxLength >= 31)
            {
                throw new ArgumentException("maxLength of BitSet cannot be larger than 31");
            }

            this.maxLength = maxLength;

            this.blackBits = new BitGroup(maxLength, bitValues);
            this.whiteBits = new BitGroup(maxLength, bitValues.Replace("1", "_").Replace("0", "1"));
        }
        public PartiallyCompleteGroup(int maxLength)
        {
            if (maxLength >= 31)
            {
                throw new ArgumentException("maxLength of BitSet cannot be larger than 31");
            }

            this.maxLength = maxLength;

            this.blackBits = new BitGroup(maxLength);
            this.whiteBits = new BitGroup(maxLength);
        }
Example #8
0
        public Dictionary <string, FlagList> GetFlagLists(string filePath)
        {
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(filePath);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Dictionary <string, FlagList> list = new Dictionary <string, FlagList>();

            if (xmlDoc.ChildNodes.Count == 0)
            {
                return(list);
            }
            foreach (XmlNode Flag in xmlDoc.SelectNodes(standard.FlagGroupNode))
            {
                FlagList flagList = new FlagList();
                try // this is needed for dynamic loader to work
                {
                    flagList.name = Flag.Attributes[standard.NameAttr].Value;
                }
                catch
                {
                    return(list);
                }
                foreach (XmlNode Bit in Flag.ChildNodes)
                {
                    BitGroup flag = GetFlagFromNode(Bit);
                    if (flag == null)
                    {
                        continue;
                    }
                    flagList.flags.Add(flag.bitRefs[0], flag);
                }

                if (flagList.flags.Count > 0)
                {
                    list.Add(flagList.name, flagList);
                }
            }
            return(list);
        }
Example #9
0
        int GetFlagIntWithModifedFlagFromCell(DataGridViewCell cell, int i32, BitGroup flag)
        {
            int value;

            if (cell is DataGridViewComboBoxCell)
            {
                string optionName = cell.Value.ToString();
                value = selectedFlagList.GetParsedFlagOptions(flag)[optionName];
                return(flag.GetModifiedValue(i32, value));
            }
            if (cell is DataGridViewTextBoxCell)
            {
                value = int.Parse(cell.Value.ToString());
                return(flag.GetModifiedValue(i32, value));
            }
            return(0);
        }
Example #10
0
 public void Dispose()
 {
     MarketWindowValue        = null;
     _1ItemlistLabelValue     = null;
     CloseButtonValue         = null;
     BuyButtonValue           = null;
     ItemlistGroupValue       = null;
     ItemListValue            = null;
     ItemGroupValue           = null;
     ItemnameLabelValue       = null;
     ItempriceLabelValue      = null;
     ItemimagePictureValue    = null;
     DescriptionGroupValue    = null;
     DescriptionTextareaValue = null;
     DescriptionLabelValue    = null;
     PriceLabelValue          = null;
     NameLabelValue           = null;
 }
Example #11
0
        void dataGridView_OnTextChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == (int)Column.CurrentOptionColumnIndex || e.ColumnIndex == (int)Column.ValueColumnIndex)
            {
                DataGridViewCell cell = dataGridView[e.ColumnIndex, e.RowIndex];
                int bitID;
                try
                {
                    bitID = int.Parse(dataGridView.Rows[cell.RowIndex].Cells[(int)Column.IDColumnIndex].Value.ToString());
                }
                catch
                {
                    return;
                }
                BitGroup flag = selectedFlagList.flags[bitID];
                if ((Column)e.ColumnIndex == Column.ValueColumnIndex)
                {
                    try
                    {
                        cell.Value = CommonUtils.Clamp(int.Parse(cell.Value.ToString()), 0, flag.GetMaxSize());
                    }
                    catch
                    {
                        cell.Value = 0;
                    }
                }
                int i32 = GetValueFromTextBox();
                txtBoxBits.Text = GetFlagIntWithModifedFlagFromCell(cell, i32, flag).ToString();
                txtBoxBits.Refresh();

                if (e.ColumnIndex == (int)Column.CurrentOptionColumnIndex)
                {
                    RefreshValueInDataGridView(e.RowIndex);
                }
                if (e.ColumnIndex == (int)Column.ValueColumnIndex)
                {
                    RefreshCurrentOptionInDataGridView(e.RowIndex);
                }

                BitButtons.RefreshAll();
                SetColorsInDataGridView();
            }
        }
 public bool GroupMatchesKnownSquares(BitGroup group)
 {
     return group.MatchBlacks(this.blackBits) && group.MatchWhites(this.whiteBits);
 }
 public PartiallyCompleteGroup(BitGroup blacks, BitGroup whites)
 {
     this.maxLength = 31;
     this.blackBits = blacks;
     this.whiteBits = whites;
 }
Example #14
0
    public void Start()
    {
        _tag = new Dictionary <BitButton, int>();

        Component[] windows = gameObject.GetComponents(typeof(BitWindow));
        BitWindow   window  = null;

        for (int i = 0; i < windows.Length; i++)
        {
            if (windows[i].name == "calculator_window")
            {
                window = (BitWindow)windows[i];
            }
        }

        if (window == null)
        {
            Debug.LogError("Main window not found.");
            return;
        }

        _result      = window.FindControl <BitLabel>("Result");
        _resultLabel = window.FindControl <BitLabel>("ResultLabel");
        _group       = window.FindControl <BitGroup>("Group");

        BitButton b;

        for (int i = 0; i < 10; i++)
        {
            b = _group.FindControl <BitButton>(i.ToString());

            _tag.Add(b, i);
            b.MouseClick += NumericClick;
        }
        b             = _group.FindControl <BitButton>(".");
        b.MouseClick += DotClick;

        b = _group.FindControl <BitButton>("+");
        _tag.Add(b, (int)Operations.Plus);
        b.MouseClick += OperationClick;

        b = _group.FindControl <BitButton>("-");
        _tag.Add(b, (int)Operations.Minus);
        b.MouseClick += OperationClick;

        b = _group.FindControl <BitButton>("*");
        //b.Tag = Operations.Multiplication;
        _tag.Add(b, (int)Operations.Multiplication);
        b.MouseClick += OperationClick;

        b = _group.FindControl <BitButton>("/");
        _tag.Add(b, (int)Operations.Division);
        b.MouseClick += OperationClick;

        b             = _group.FindControl <BitButton>("=");
        b.MouseClick += EqualsClick;

        b             = _group.FindControl <BitButton>("C");
        b.MouseClick += ClearClick;

        b             = _group.FindControl <BitButton>("Bk");
        b.MouseClick += BackClick;

        Reset();
    }
Example #15
0
 // Use this for initialization
 void Start()
 {
     BitGroupComponent = this.GetComponent <BitGroup>();
 }
Example #16
0
        public void MatchWhites(string bitsToCheck, string knownWhiteSquares, bool shouldMatch)
        {
            var result = new BitGroup(4, bitsToCheck).MatchWhites(new BitGroup(4, knownWhiteSquares));

            Assert.That(result, Is.EqualTo(shouldMatch));
        }
 public SolvedSquaresResult(BitGroup knownGroup)
 {
     this.knownGroup = knownGroup;
 }
Example #18
0
	void Awake(){
		root = GetComponent<BitStage>();
		
		gameControlWindow = root.FindControl<BitWindow>("EGameControlWindow");
		conversation = gameControlWindow.FindControl<BitBox>("ConversationBox");
		BitGroup headGroup = gameControlWindow.FindControl<BitGroup>("HeadGroup");
		
		helpButton = headGroup.FindControl<BitButton>("help");
		exitButton = headGroup.FindControl<BitButton>("exit");
		progressBar = headGroup.FindControl<BitGroup>("progress_bg").FindControl<BitHorizontalProgressBar>();
		tickCounter = gameControlWindow.FindControl<BitGroup>("TickCounter_bg").FindControl<BitVerticalProgressBar>();
		centerGroup = gameControlWindow.FindControl<BitGroup>("CenterGroup");
		skipDemoBtn = centerGroup.FindControl<BitButton>("SkipDemoBtn");
		playDemoBtn = centerGroup.FindControl<BitButton>("PlayDemoBtn");
		startButton = centerGroup.FindControl<BitButton>("start");
		
		gameHelpWindow = root.FindControl<BitWindow>("EGameHelpWindow");
		hPictureRender = gameHelpWindow.FindControl<BitPicture>();
		hPreBtn = gameHelpWindow.FindControl<BitButton>("help_btn_prev");
		hNextBtn = gameHelpWindow.FindControl<BitButton>("help_btn_next");
		hCloseBtn = gameHelpWindow.FindControl<BitButton>("close");
		hAlwaysShowHelp = gameHelpWindow.FindControl<BitToggle>();
		
		gameWindow = root.FindControl<BitWindow>("GameWindow");
	}
Example #19
0
    private void Start()
    {
        _form = gameObject.GetComponent <BitEditorStage>();
        if (_form == null)
        {
            Debug.LogError("Form not found");
            return;
        }


        _window = _form.FindControl <BitWindow>("main_window");
        if (_window == null)
        {
            Debug.LogError("'main_window' not found");
            return;
        }

        _simpleButton = _window.FindControl <BitButton>("SimpleButton");

        if (_simpleButton == null)
        {
            Debug.LogWarning("'SimpleButton' not found!");
        }
        else
        {
            _simpleButton.MouseClick += SimpleButton_MouseClick;
        }

        _repeatButton = _window.FindControl <BitRepeatButton>("RepeatButton");
        if (_repeatButton == null)
        {
            Debug.LogWarning("'RepeatButton' not found!");
        }
        else
        {
            _repeatButton.MouseHold += RepeatButtonMouseHold;
        }

        _textGroup = _window.FindControl <BitGroup>("TextGroup");
        if (_textGroup == null)
        {
            Debug.Log("'TextGroup' not fount!");
        }

        _toggle = _window.FindControl <BitToggle>("Toggle");
        if (_toggle == null)
        {
            Debug.LogWarning("'Toggle' not found!");
        }
        else
        {
            _toggle.ValueChanged += Toggle_ValueChanged;
            if (_textGroup != null)
            {
                _textGroup.Enabled = false;
            }
        }

        if (_textGroup != null)
        {
            _textField = _textGroup.FindControl <BitTextField>("TextField");
            if (_textField == null)
            {
                Debug.LogWarning("'TextField' not found!");
            }
            else
            {
                _textField.TextChanged += TextChanged;
            }

            _textArea = _textGroup.FindControl <BitTextArea>("TextArea");
            if (_textArea == null)
            {
                Debug.LogWarning("'TextArea' not found!");
            }
            else
            {
                _textArea.TextChanged += TextChanged;
            }

            _passwordField = _textGroup.FindControl <BitPasswordField>("PasswordField");
            if (_passwordField == null)
            {
                Debug.LogWarning("'PasswordField' not found!");
            }
            else
            {
                _passwordField.TextChanged += TextChanged;
            }
        }

        _textureGroup = _window.FindControl <BitGroup>("TextureGroup");
        if (_textureGroup == null)
        {
            Debug.LogWarning("'TextureGroup' not found!");
        }
        else
        {
//			_texture = _textureGroup.FindControl<BitDrawTexture>("Texture");
//			if (_texture == null)
//			{
//				Debug.LogWarning("'Texture' not found!");
//			}
        }

        _hsLabel = _window.FindControl <BitLabel>("HorizontalSlider Label");
        if (_hsLabel == null)
        {
            Debug.LogWarning("'HorizontalSlider Label' not found!");
        }

        _horizontalSlider = _window.FindControl <BitHorizontalSlider>("HorizontalSlider");
        if (_horizontalSlider == null)
        {
            Debug.LogWarning("'HorizontalSlider' not found!");
        }
        else
        {
            _horizontalSlider.ValueChanged += HorizontalSlider_ValueChanged;
        }

        _vsLabel = _window.FindControl <BitLabel>("VerticalSlider Label");
        if (_vsLabel == null)
        {
            Debug.LogWarning("'VerticalSlider Label' not found!");
        }

        _verticalSlider = _window.FindControl <BitVerticalSlider>("VerticalSlider");
        if (_verticalSlider == null)
        {
            Debug.LogWarning("'HorizontalSlider' not found!");
        }
        else
        {
            _verticalSlider.ValueChanged += VerticalSlider_ValueChanged;
        }

        _gridList = _window.FindControl <BitGridList>("GridList");
        if (_gridList == null)
        {
            Debug.LogWarning("'GridList' not found!");
        }
        else
        {
            _gridList.Populator = new DefaultBitListPopulator();
        }

        _multiselectionToggle = _window.FindControl <BitToggle>("MultiSelection Toggle");
        if (_multiselectionToggle == null)
        {
            Debug.LogWarning("'MultiSelection Toggle' not found!");
        }
        else
        {
            _multiselectionToggle.ValueChanged += MultiselectionToggle_ValueChanged;
        }

        _list = _window.FindControl <BitList>("List");
        if (_list == null)
        {
            Debug.LogWarning("'List' not found!");
        }
        else
        {
            _list.Populator         = new MyListPopulator();
            _list.SelectionChanged += List_SelectionChanged;
        }

        _listSelectionLabel = _window.FindControl <BitLabel>("ListSelection Label");
        if (_listSelectionLabel == null)
        {
            Debug.LogWarning("'ListSelection Label' not found!");
        }

        _labelWithPopup = _window.FindControl <BitLabel>("Label With Popup");
        if (_labelWithPopup == null)
        {
            Debug.LogWarning("'Label With Popup' not found!");
        }

        PopulateDropDown();

        PopulateContextMenu();
    }