Пример #1
0
        /// <summary>
        /// Funambol SyncML server does not seem to like multiple log-on SyncML message
        /// at almost the same time, and occasionally send back status code 400.
        /// So I have to serialize these.
        /// </summary>
        void SyncAll()
        {
            foreach (Control control in panel1.Controls)
            {
                UcSync syncUc = control as UcSync;
                //Debug.Assert(syncUc != null, "What, not syncUc?");
                if (syncUc == null) //could be the status box
                {
                    continue;
                }

                IAsyncResult r = syncUc.Sync();
                while (!r.IsCompleted)
                {
                    System.Threading.Thread.Sleep(200);
                }
            }
        }
Пример #2
0
        private void LoadSyncPanels()
        {
            //   IList<SyncItem> syncItems = settings.GetSyncItems();
            IList <string> syncItemNames = settings.GetSyncItemNames();

            if (syncItemNames.Count == 0)
            {
                MessageBox.Show("The user configuration has no SyncItems defined. Please check.");
                return;
            }

            TextBox statusBox = new TextBox();

            Trace.Assert(panel1 != null, "panel1 null");
            Trace.Assert(btnSync != null, "btuSync null");
            Trace.Assert(syncItemNames.Count > 0, "syncItemNames empty.");
            int i = 0;

            if (syncItemNames.Count == 1)
            {//Hide the Sync All button.
                i = 1;
                string   syncItemPropertyName = syncItemNames[0];
                SyncItem syncItem             = settings[syncItemPropertyName] as SyncItem;
                if (syncItem.Enabled)
                {
                    UcSync syncUc = new UcSync(syncItem, settings);
                    syncUc.Dock          = DockStyle.None;
                    syncUc.Location      = new Point(0, 0);
                    syncUc.Width         = ClientSize.Width;
                    syncUc.Anchor        = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                    syncUc.TextBoxStatus = statusBox;
                    panel1.Controls.Add(syncUc);

                    syncUc.ButtonLabel = "Sync";
                    syncUc.SetButtonIcon(Properties.Resources.sync);
                    btnSync.Visible             = false;
                    toolStripSeparator1.Visible = false;
                    panel1.Height = syncUc.Height;
                }
            }
            else
            {
                int y = 0;
                foreach (string itemName in syncItemNames)
                {
                    SyncItem item = settings[itemName] as SyncItem;
                    if (item.Enabled)
                    {
                        UcSync syncUc = new UcSync(item, settings);
                        syncUc.Dock          = DockStyle.None;
                        syncUc.Location      = new Point(0, y);
                        syncUc.Width         = ClientSize.Width;
                        syncUc.Anchor        = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        syncUc.TextBoxStatus = statusBox;
                        panel1.Controls.Add(syncUc);

                        i++;
                        y += syncUc.Height + 1; // add one to leave a line between
                    }
                }
            }

            const int ucPanelHeight = 71;  //UcSync's default height
            const int ucPanelWidth  = 372; //UcSync's default Width

            Height = (ucPanelHeight + 1) * i + toolStrip1.Height;
            Width  = ucPanelWidth;

            //initialize the statusBox
            statusBox.Multiline  = true;
            statusBox.ScrollBars = ScrollBars.Vertical;
            statusBox.Location   = new Point(4, (ucPanelHeight + 1) * i + 4);
            const int statusBoxHeight = 125;

            statusBox.Size   = new Size(ucPanelWidth - 8, statusBoxHeight);
            statusBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            panel1.Controls.Add(statusBox);
            Height += statusBoxHeight + 8;

            ParentForm.ClientSize = new Size(ParentForm.ClientSize.Width, Height);
        }