Beispiel #1
0
        internal static void OpenFile(Manuscript.WordType? wt)
        {
            string filter = wt == null ? "txt files (*.txt)|*.txt|xml files (*.xml)|*.xml" : "xml files (*.xml)|*.xml";

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.RestoreDirectory = true;
            ofd.Filter = filter;
            ofd.FilterIndex = 2;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (wt.HasValue)
                {
                    Manuscript.WordType _wt = wt.Value;

                    XDocument xd = XDocument.Load(ofd.FileName);

                    switch (_wt)
                    {
                        case Manuscript.WordType.Danger:
                            Working.LoadXWords(xd.Element("dangerwords"),_wt);
                            break;
                        case Manuscript.WordType.Invisible:
                        default:
                            Working.LoadXWords(xd.Element("invisiblewords"),_wt);
                            break;
                    }

                }
                else
                {
                    CurrentFile = ofd.FileName;
                    doOpen(ofd.FilterIndex);
                }
            }
        }
Beispiel #2
0
        private void GenerateWCtl(string word, string occurrences, Manuscript.WordType wt)
        {
            Button btnW = new Button();
            string strBtnText = !string.IsNullOrEmpty(occurrences) ? occurrences : "!";
            btnW.Text = strBtnText;
            btnW.AutoSize = true;
            btnW.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            List<object> listTag = new List<object>();
            listTag.Add(wt);
            listTag.Add(word);
            btnW.Tag = listTag;

            btnW.Click += new EventHandler(btnW_Click);

            toolTip1.SetToolTip(btnW, "Add To " + wt.ToString());

            flpDynCtls.Controls.Add(btnW);
        }
Beispiel #3
0
        private static void doOpen(int filter)
        {
            try
            {
                Working = new Manuscript();

                SetRecentFiles(CurrentFile);

                if (filter == 1)
                {
                    StreamReader s = File.OpenText(CurrentFile);
                    string read = s.ReadToEnd();
                    s.Close();
                    s.Dispose();

                    Working = new Manuscript(read);

                    CurrentFile = CurrentFile.Remove(CurrentFile.Length - 4) + ".xml";
                }
                else
                {
                    XDocument xd = XDocument.Load(CurrentFile);
                    Working = new Manuscript(xd);
                }
            }
            catch
            {
                MessageBox.Show("Error opening file " + CurrentFile + " Load Aborted.");
                Working = new Manuscript();
            }
        }