示例#1
0
        public void Test()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IDataProvider <CountryInfoEx> provider = new MockDataProviderEx();

            IReadOnlyList <CountryInfoEx> data = provider.GetCountryData();

            Form form = new Form();

            form.Width  = 800;
            form.Height = 600;

            IView view = new GlobalView(data);

            TabControl tabControl = new TabControl();

            tabControl.Controls.Add(view.GetPage());

            form.Controls.Add(tabControl);
            tabControl.Dock = DockStyle.Fill;

            Application.Run(form);
        }
        /// <summary>
        /// Thread body
        /// </summary>
        /// <param name="state"></param>
        private void StartWork(object state)
        {
            GlobalView globalView  = state as GlobalView;
            myGlob     savedGlobal = null;
            myGlob     theGlobal   = new myGlob();

            globalView.Merge(theGlobal, editMode);

            // Save to backend
            AutoResetEvent nextOneAutoResetEvent            = new AutoResetEvent(false);
            EventHandler <save_MyGlobCompletedEventArgs> h1 = (s, e) =>
            {
                // TODO: handle error from server side
                savedGlobal = e.Result;
                nextOneAutoResetEvent.Set();
            };

            Globals.WSClient.save_MyGlobCompleted += h1;
            Globals.WSClient.save_MyGlobAsync(theGlobal);
            nextOneAutoResetEvent.WaitOne();
            Globals.WSClient.save_MyGlobCompleted -= h1;

            // Check return result. If failure, savedCategory will be null
            if (savedGlobal != null)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    globalView.Restore(new GlobalView(savedGlobal));
                });
            }
            else
            {
                // Show error message
                ShopproHelper.ShowMessageWindow(this, "Error", "Fail to save this entry.", false);

                // Back to readonly mode
                this.Dispatcher.BeginInvoke(delegate()
                {
                    // Restore cached UI data
                    globalView.CancelEdit();
                    this.itemDataForm.CancelEdit();
                });
            }

            ShopproHelper.HideBusyIndicator(this);

            // No unsaved item
            this.editMode = DataFormMode.ReadOnly;
        }
    void Awake()
    {
        if (instance != null && instance != this) {
            isSetToDestroy = true;
            Destroy(gameObject);
        } else {
            instance = this;
        }

        eventRegistery = GetComponentInChildren<EventRegistery>();
        saveFile = GetComponentInChildren<SaveFile>();
        systemFile = GetComponentInChildren<SystemFile>();
        dataFile = GetComponentInChildren<DataFile>();
        transitionery = GetComponentInChildren<TransitionManager>();
        view = GetComponentInChildren<GlobalView>();
    }
示例#4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var provider = new SQLiteDataProvider();

            var cacheSystem = new DatabaseCache();

            cacheSystem.Attach(provider);
            cacheSystem.CheckUpdate();    //check if the data is fresh (yesterday is present in the db)

            var data = provider.GetCountryData();

            MapView     mapView     = new MapView(data);
            IView       globalView  = new GlobalView(data);
            CountryView countryView = new CountryView(data);

            mapView.Subscribe(countryView);

            Application.Run(new MainForm(new List <IView> {
                mapView, globalView, countryView
            }));
        }