Ejemplo n.º 1
0
        public static bool SelectWorksheetRange(TextBox textBox, string workbookPath)
        {
            if (worksheetNames != null)
            {
                var worksheetDialog = new SelectWorksheetDialog(workbookPath, SelectionMode.Extended);

                worksheetDialog.ItemContent = worksheetNames;

                if (worksheetNames.Count() > 1)
                {
                    worksheetDialog.SetSelectedRange(1, worksheetNames.Count());
                }

                bool?success = worksheetDialog.ShowDialog();

                if (success.HasValue && success.Value && worksheetDialog.Results != null)
                {
                    textBox.Text = worksheetDialog.Results.First();

                    if (worksheetDialog.Results.Count > 1)
                    {
                        textBox.Text += ":" + worksheetDialog.Results.Last();
                    }

                    textBox.ScrollToEnd();
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static bool SelectWorksheet(TextBox textBox, string workbookPath)
        {
            if (worksheetNames != null)
            {
                var worksheetDialog = new SelectWorksheetDialog(workbookPath, SelectionMode.Single);
                worksheetDialog.ItemContent = worksheetNames;

                bool?success = worksheetDialog.ShowDialog();

                if (success.HasValue && success.Value && worksheetDialog.Result != null)
                {
                    textBox.Text = worksheetDialog.Result;
                    textBox.ScrollToEnd();
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static bool SelectSharedWorksheets(TextBox textBox)
        {
            if (sharedWorksheets != null)
            {
                var worksheetDialog = new SelectWorksheetDialog(null, SelectionMode.Multiple);

                var list = new List <SelectWorksheetDialog.Item>();
                foreach (var item in sharedWorksheets)
                {
                    string name = item.SharedName;

                    if (!item.IsCommon)
                    {
                        name += $" ({item.SourceWorksheet})";
                    }

                    list.Add(new SelectWorksheetDialog.Item {
                        Content = name, Primary = item.IsCommon
                    });
                }

                worksheetDialog.Items = list;
                worksheetDialog.SelectAll();

                bool?success = worksheetDialog.ShowDialog();

                if (success.HasValue && success.Value && worksheetDialog.Results != null)
                {
                    string result = string.Join(',', worksheetDialog.Results);

                    textBox.Text = result;
                    textBox.ScrollToEnd();
                    return(true);
                }
            }

            return(false);
        }