Ejemplo n.º 1
0
 public GoogleSpreadsheetBrowser(string sAppName, string sClientId, string sGoogleAccessToken, bool bRequireSheetSelect)
 {
     m_bRequireSheetSelect = bRequireSheetSelect;
     InitializeComponent();
     listViewSheets.Visible = m_bRequireSheetSelect;
     lblSheets.Visible      = m_bRequireSheetSelect;
     m_zSpreadsheetsService = GoogleSpreadsheet.GetSpreadsheetsService(sAppName, sClientId, sGoogleAccessToken);
 }
Ejemplo n.º 2
0
        private void listViewSpreadsheets_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!m_bRequireSheetSelect)
            {
                return;
            }

            if (listViewSpreadsheets.SelectedItems.Count == 1)
            {
                new Thread(() =>
                {
                    Func <ListViewItem> getCurrentSelectedtem = () =>
                                                                listViewSpreadsheets.SelectedItems.Count == 1 ? listViewSpreadsheets.SelectedItems[0] : null;


                    var zLvi = listViewSpreadsheets.InvokeFunc(getCurrentSelectedtem);

                    AtomEntryCollection zSheetAtomCollection = getAtomEntryCollection(
                        () => GoogleSpreadsheet.GetSheetNames(m_zSpreadsheetsService, ((AtomEntry)zLvi.Tag)),
                        () => listViewSheets.InvokeAction(() => listViewSheets.Clear()));

                    if (null == zSheetAtomCollection)
                    {
                        return;
                    }

                    var listNewItems = new List <ListViewItem>();
                    foreach (var entry in zSheetAtomCollection)
                    {
                        var zNewLvi = new ListViewItem(entry.Title.Text)
                        {
                            Tag = entry
                        };
                        listNewItems.Add(zNewLvi);
                    }
                    if (listViewSpreadsheets.InvokeFunc(getCurrentSelectedtem) == zLvi)
                    {
                        listViewSheets.InvokeAction(() =>
                        {
                            listViewSheets.Items.Clear();
                            listViewSheets.Items.AddRange(listNewItems.ToArray());
                            listViewSpreadsheets.Sort();
                        });
                    }
                }).Start();
            }
            else
            {
                listViewSheets.Items.Clear();
            }
        }
Ejemplo n.º 3
0
        private void GoogleSpreadsheetBrowser_Load(object sender, EventArgs e)
        {
            var zWait = new WaitDialog(1,
                                       () =>
            {
                AtomEntryCollection zSheetAtomCollection = getAtomEntryCollection(
                    () => GoogleSpreadsheet.GetSpreadsheetList(m_zSpreadsheetsService),
                    () => listViewSpreadsheets.InvokeAction(() => listViewSpreadsheets.Clear()));

                if (null == zSheetAtomCollection)
                {
                    this.InvokeAction(
                        () => MessageBox.Show(this, "Failed to access Google Spreadsheets", "Access Failed", MessageBoxButtons.OK, MessageBoxIcon.Error));
                    this.InvokeAction(Close);
                    WaitDialog.Instance.CloseWaitDialog();
                    return;
                }

                m_zAllEntries    = zSheetAtomCollection;
                var listNewItems = new List <ListViewItem>();
                foreach (var entry in zSheetAtomCollection)
                {
                    var zLvi = new ListViewItem(entry.Title.Text)
                    {
                        Tag = entry
                    };
                    listNewItems.Add(zLvi);
                }
                listViewSpreadsheets.InvokeAction(() =>
                {
                    listViewSpreadsheets.Items.AddRange(listNewItems.ToArray());
                });
                WaitDialog.Instance.CloseWaitDialog();
            },
                                       "Getting Google Spreadsheets...",
                                       null,
                                       400);

            zWait.ShowDialog(this);
        }