Beispiel #1
0
        /// <summary>
        /// this function change clue of current password
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_Change_Clue(object sender, RoutedEventArgs e)
        {
            int j = CB.SelectedIndex;
            int l = int.Parse(CB.Text);

            TrackClueList.Index[j] = TrackClueList.NextIndex(TrackClueList.Index[j], Cluelist[j].Count);
            var textBox = new TextBox
            {
                IsReadOnly   = true,
                Text         = (l).ToString() + "." + Cluelist[j][TrackClueList.Index[j]] + "(" + PasswordList[j].Count() + ")",
                Name         = "TB" + (j).ToString(),
                TextWrapping = TextWrapping.Wrap
            };

            if (PasswordList[0] != " ")
            {
                textBox.Text = (j + 1).ToString() + "." + Cluelist[j][TrackClueList.Index[j]] + "(" + PasswordList[j].Count() + ")";
            }
            if (TrackClueList.Check[j])
            {
                textBox.TextDecorations = TextDecorations.Strikethrough;
            }
            ListBoxWithClues.Items[j] = textBox;
        }
Beispiel #2
0
        /// <summary>
        /// constructor set CbItems, ListPasswordYouTriedEnter
        /// </summary>
        /// <param name="passwordList">set PasswordList</param>
        /// <param name="tblist">set TBList</param>
        /// <param name="startxylist">set StsrtXYList can be null for crossword in only across passwords</param>
        /// <param name="endxylist">set EndXYList can be null for crossword in only across passwords</param>
        /// <param name="trackcluelist">set TrackClueList can be null for crossword in only across passwords</param>
        public CrosswordWindow(List <String> passwordList, List <List <TextBox> > tblist, List <List <int> > startxylist = null, List <List <int> > endxylist = null, TrackClueList trackcluelist = null)
        {
#if DEBUG
            System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
#endif
            InitializeComponent();
            DataContext   = this;
            PasswordList  = passwordList;
            StartXYList   = startxylist;
            EndXYList     = endxylist;
            TexBoxList    = tblist;
            TrackClueList = trackcluelist;
            if (TrackClueList == null)
            {
                TrackClueList = new TrackClueList
                {
                    Check = new List <bool>(),
                    Index = new List <int>()
                };
                for (int i = 0; i < PasswordList.Count; i++)
                {
                    TrackClueList.Check.Add(false);
                    TrackClueList.Index.Add(0);
                }
            }
            CbItems = new ObservableCollection <ComboBoxItem>();
            ListPasswordYouTriedEnter = new List <string>();
            foreach (var record in PasswordList)
            {
                ListPasswordYouTriedEnter.Add("");
                var subcluelist = SubClueList(record.Length, record);
                Cluelist.Add(subcluelist);
            }
            int j = 0;
            for (int i = 0; i < PasswordList.Count; i++)
            {
                var cbItem = new ComboBoxItem
                {
                    Content = "" + (j).ToString(),
                    Name    = "CBI" + (i + 1).ToString()
                };
                var spTextBox = new TextBox
                {
                    IsReadOnly   = true,
                    Text         = (j).ToString() + "." + Cluelist[i][0] + "(" + PasswordList[i].Count() + ")",
                    Name         = "TB" + i.ToString(),
                    TextWrapping = TextWrapping.Wrap
                };
                if (TrackClueList.Check[j] == true)
                {
                    spTextBox.TextDecorations = TextDecorations.Strikethrough;
                }
                if (PasswordList[0] != " ")
                {
                    cbItem.Content = "" + (j + 1).ToString();
                    spTextBox.Text = (j + 1).ToString() + "." + Cluelist[i][0] + "(" + PasswordList[i].Count() + ")";
                }
                if (PasswordList[i] == " ")
                {
                    cbItem.Content   = "Across";
                    cbItem.IsEnabled = false;
                    spTextBox.Text   = "Across";
                }
                if (PasswordList[i] == "  ")
                {
                    cbItem.Content   = "Down";
                    cbItem.IsEnabled = false;
                    spTextBox.Text   = "Down";
                    j = 0;
                }
                if (TrackClueList.Check[i] == true)
                {
                    if (StartXYList != null)
                    {
                        int x  = StartXYList[i][0];
                        int y  = StartXYList[i][1];
                        int x2 = EndXYList[i][0];
                        int y2 = EndXYList[i][1];
                        if (x == x2)
                        {
                            for (int k = 0; k < PasswordList[i].Length; k++)
                            {
                                TexBoxList[x][y + k].Text = PasswordList[i][k].ToString();
                            }
                        }
                        if (y == y2)
                        {
                            for (int k = 0; k < PasswordList[i].Length; k++)
                            {
                                TexBoxList[x + k][y].Text = PasswordList[i][k].ToString();
                            }
                        }
                    }
                }
                j += 1;
                SelectedcbItem = cbItem;
                ListBoxWithClues.Items.Add(spTextBox);
                CbItems.Add(cbItem);
            }
        }