Пример #1
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     if (time.newDay || needUpdate)
     {
         needUpdate = false;
         foreach (GameObject uiGO in f_syncUI)
         {
             SyncUI s_ui = uiGO.GetComponent <SyncUI>();
             s_ui.callback.Invoke();
         }
     }
 }
Пример #2
0
        private void tabMain_SelectedIndexChanged(object sender, EventArgs e)
        {
            int lastIndex = tabMain.TabPages.Count - 1;

            if (tabMain.SelectedIndex == lastIndex)
            {
                var merge = new MergeDefinition();
                _solution.Merges.Add(merge);

                var tab = new TabPage($"merge {tabMain.TabPages.Count}");
                var ui  = new SyncUI()
                {
                    Dock = DockStyle.Fill, Document = merge
                };
                tab.Controls.Add(ui);
                tabMain.TabPages.Insert(lastIndex, tab);
                tabMain.SelectedIndex = lastIndex;
            }
        }
Пример #3
0
        private async Task LoadSolutionAsync(string visualStudioSolution)
        {
            SaveCurrentSolution();

            string fileName = Solution.GetFilename(visualStudioSolution);

            tabMain.TabIndexChanged -= tabMain_SelectedIndexChanged;
            SuspendLayout();

            try
            {
                Solution result = (File.Exists(fileName)) ?
                                  JsonFile.Load <Solution>(fileName) :
                                  Solution.Create();

                string solutionPath = Path.GetDirectoryName(visualStudioSolution);

                int index = 0;
                foreach (var merge in result.Merges)
                {
                    var tab = new MergeDefinitionTab(fileName, merge.Title ?? $"merge {index}")
                    {
                        ImageKey  = GetTabImage(merge.SourceType),
                        BackColor = merge.BackgroundColor
                    };

                    var ui = new SyncUI()
                    {
                        Dock         = DockStyle.Fill,
                        Document     = merge,
                        SolutionPath = solutionPath,
                        SqlDialect   = new SqlServerDialect()
                    };
                    ui.OperationStarted    += StartOperation;
                    ui.OperationComplete   += CompleteOperation;
                    ui.ScriptGenerated     += ScriptGenerated;
                    ui.ScriptModified      += delegate(object sender, EventArgs e) { tslStatus.Text = "SQL is manually edited"; };
                    ui.GetConnection        = (text) => new SqlConnection(text);
                    ui.GetSharedExclusions += (name) => (_sharedExclusions.Actions?.ContainsKey(name) ?? false) ? _sharedExclusions.Actions[name] : Enumerable.Empty <ExcludeAction>();
                    ui.AddSharedExclusion  += (name, action) =>
                    {
                        if (_sharedExclusions.Actions == null)
                        {
                            _sharedExclusions.Actions = new Dictionary <string, HashSet <ExcludeAction> >();
                        }
                        if (!_sharedExclusions.Actions.ContainsKey(name))
                        {
                            _sharedExclusions.Actions.Add(name, new HashSet <ExcludeAction>());
                        }
                        _sharedExclusions.Actions[name].Add(action);
                    };
                    ui.RemoveSharedExclusion += (name, action) =>
                    {
                        if (_sharedExclusions.Actions == null)
                        {
                            _sharedExclusions.Actions = new Dictionary <string, HashSet <ExcludeAction> >();
                        }
                        if (!_sharedExclusions.Actions.ContainsKey(name))
                        {
                            _sharedExclusions.Actions.Add(name, new HashSet <ExcludeAction>());
                        }
                        _sharedExclusions.Actions[name].Remove(action);
                    };
                    await ui.LoadSuggestionsAsync();

                    tab.Controls.Add(ui);
                    tabMain.TabPages.Insert(index, tab);
                    index++;
                }

                // remove tab pages from the prior solution
                List <TabPage> removePages = new List <TabPage>();
                foreach (var tab in tabMain.TabPages)
                {
                    var mergeTab = tab as MergeDefinitionTab;
                    if (mergeTab != null && !mergeTab.SolutionFile.Equals(fileName))
                    {
                        removePages.Add(mergeTab);
                    }
                }
                foreach (var tab in removePages)
                {
                    tabMain.TabPages.Remove(tab);
                }

                SolutionFile      = fileName;
                _solution         = result;
                _sharedExclusions = LoadSharedExcludeActions(visualStudioSolution);

                tabMain.SelectedIndex = 0;
                var firstMerge = tabMain.TabPages[0].Controls[0] as SyncUI;
                await firstMerge.GenerateScriptAsync();
            }
            finally
            {
                tabMain.TabIndexChanged += tabMain_SelectedIndexChanged;
                ResumeLayout();
            }
        }