Example #1
0
        private void searchBtn_Click(object sender, EventArgs e)
        {
            UserObject           uobj = (UserObject)objsList.SelectedItem;
            string               l2   = uobj.ToString();
            CancelableWaitWindow cww  = null;

            if (!uobj.newObj)
            {
                if (MessageBox.Show("This will search the entire Map.wz for usages of this object. It may take a while. Proceed?", "Search", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
                {
                    return;
                }
                cww = new CancelableWaitWindow("Searching...", () => Enumerable.Concat(SearchMapWzForObj(l2), SearchEditorForObj(l2).Select(x => x + " (In Editor)")));
            }
            else
            {
                cww = new CancelableWaitWindow("Searching...", () => SearchEditorForObj(l2).Select(x => x + " (In Editor)"));
            }
            cww.ShowDialog();
            if (cww.result == null)
            {
                return;
            }
            List <string> result = ((IEnumerable <string>)cww.result).ToList();

            if (result.Count > 0)
            {
                MessageBox.Show("The object is used in the following maps:\r\n\r\n" + result.Aggregate((x, y) => x + ", " + y), "Search Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("The object is not used in any maps.", "Search Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
 public CancelableWaitWindow(string message, Func <object> action)
 {
     InitializeComponent();
     this.label1.Text = message;
     actionThread     = new Thread(new ParameterizedThreadStart(x =>
     {
         CancelableWaitWindow cww = (CancelableWaitWindow)x;
         cww.result = action();
         cww.Invoke((Action) delegate { cww.EndWait(); });
     }));
 }
Example #3
0
 private void searchBtn_Click(object sender, EventArgs e)
 {
     UserObject uobj = (UserObject)objsList.SelectedItem;
     string l2 = uobj.ToString();
     CancelableWaitWindow cww = null;
     if (!uobj.newObj)
     {
         if (MessageBox.Show("This will search the entire Map.wz for usages of this object. It may take a while. Proceed?", "Search", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
             return;
         cww = new CancelableWaitWindow("Searching...", () => Enumerable.Concat(SearchMapWzForObj(l2), SearchEditorForObj(l2).Select(x => x + " (In Editor)")));
     }
     else
     {
         cww = new CancelableWaitWindow("Searching...", () => SearchEditorForObj(l2).Select(x => x + " (In Editor)"));
     }
     cww.ShowDialog();
     if (cww.result == null)
         return;
     List<string> result = ((IEnumerable<string>)cww.result).ToList();
     if (result.Count > 0)
         MessageBox.Show("The object is used in the following maps:\r\n\r\n" + result.Aggregate((x, y) => x + ", " + y), "Search Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
     else
         MessageBox.Show("The object is not used in any maps.", "Search Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }