Example #1
0
        public void TestSettingsInThread()
        {
            DateTime now = DateTime.Now;

            SyncItem syncItem;

            System.Action saveAnchor = () =>
            {
                SyncSettingsBase settings = OutlookSyncSettings.Default;
                syncItem = OutlookSyncSettings.Default.CalendarSyncItem;
                syncItem.LastAnchorTime = now;
                settings.Save();
            };

            IAsyncResult result = saveAnchor.BeginInvoke(null, null);

            saveAnchor.EndInvoke(result);

            System.Threading.Thread.Sleep(100);
            OutlookSyncSettings.Default.Reload();
            Assert.AreEqual(now, OutlookSyncSettings.Default.CalendarSyncItem.LastAnchorTime);

            now = DateTime.Now;
            IAsyncResult result2 = saveAnchor.BeginInvoke(null, null);

            saveAnchor.EndInvoke(result2);

            System.Threading.Thread.Sleep(100);
            OutlookSyncSettings.Default.Reload();
            Assert.AreEqual(now, OutlookSyncSettings.Default.CalendarSyncItem.LastAnchorTime);
        }
Example #2
0
        /// <summary>
        /// Create a mainform as a component of client codes.
        /// Client codes should give an assembly with an ILocalDataSource class.
        /// </summary>
        public UcSync(SyncItem syncItem, SyncSettingsBase syncSettings)
            : this()
        {
            if (syncItem == null)
            {
                throw new ArgumentNullException("syncItem");
            }
            if (syncSettings == null)
            {
                throw new ArgumentNullException("syncSettings");
            }

            this.syncItem     = syncItem;
            this.syncSettings = syncSettings;

            ShowLastSyncInfo();
            ButtonLabel = syncItem.DisplayName;
        }
Example #3
0
        /// <summary>
        /// Create a form for application containing UcMultiSyncMain.
        /// And this form can remember its own location in multiscreen.
        /// </summary>
        /// <returns></returns>
        public static Form CreateMainForm(SyncSettingsBase settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings", "How could settings be null?");
            }
            CommonForm form = new CommonForm();

            form.ShowInTaskbar = true;
            //  form.AutoSize = true;/// Because this form is used as main form.
            // AutoSize can not work properly probably the autosize takes effects
            // before UcMultiSyncMain is loaded.
            //   form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            form.Icon  = Properties.Resources.syncIcon;
            form.Load += delegate(object sender, EventArgs e)
            {
                try
                {
                    UcMultiSyncMain uc = new UcMultiSyncMain(settings);
                    form.AddControl(uc, ProgramSettings.Default.ProductName);
                    // form.AutoSize = true;//not working either
                }
                catch (System.Configuration.ConfigurationErrorsException exception)
                {
                    MessageBox.Show("Configuration has problem: " + e.ToString() + "~" + exception.Message);
                }
            };

            MultiScreenHelper.RefineLocation(form, ProgramSettings.Default.Location, ProgramSettings.Default.ScreenDeviceName);
            form.FormClosing += delegate(object sender, System.Windows.Forms.FormClosingEventArgs e)
            {
                ProgramSettings.Default.Location         = form.Location;
                ProgramSettings.Default.ScreenDeviceName = System.Windows.Forms.Screen.FromControl(form).DeviceName;
                ProgramSettings.Default.Save();
            };
            return(form);
        }
Example #4
0
 internal UcMultiSyncMain(SyncSettingsBase settings)
     : this()
 {
     this.settings = settings;
 }