Beispiel #1
0
        public async Task <long> GetObjectIdAsync(TableControl tableControl, int rowIdx)
        {
            var oid = await tableControl.GetObjectIdAsync(rowIdx);

            ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($@"rowIdx:  {rowIdx} has OID: {oid}");
            return(oid);
        }
Beispiel #2
0
        /// <summary>
        /// Execute placement for TableControl
        /// </summary>
        /// <param name="control">TableControl</param>
        /// <param name="dx">horizontal placement value</param>
        /// <param name="dy">vertical placement value</param>
        protected void ExecuteTableControlPlacement(TableControl control, int dx, int dy, Rectangle rect)
        {
            if (!IsTableInColumnCreation(control))
            {
                int prevWidth = 0;
#if !PocketPC //tmp
                bool containerRightToLeft = control.Parent.RightToLeft == RightToLeft.Yes;
#else
                bool containerRightToLeft = false;
#endif

                //negative width and height becomes 0 in setBounds, so get the actual height from the saved data.
                Rectangle?savedRect = GetSavedBounds(control);
                if (savedRect != null)
                {
                    rect.Height = ((Rectangle)savedRect).Height;
                }
                rect.Height += dy;

                prevWidth = rect.Width;
                // compute allowed width placement depending on columns placement
                dx          = GetTablePlacementManager(control).computeWidthPlacement(dx, GetTableColumns(control));
                rect.Width += dx;
                if (containerRightToLeft)
                {
                    rect.X -= dx;
                }

                // update columns on table placement
                ExecuteTablePlacement(control, prevWidth, dx, rect);
            }
        }
        private static IEnumerable <FormatViewDefinition> ViewsOf_System_Management_Automation_PSTraceSource()
        {
            yield return(new FormatViewDefinition("System.Management.Automation.PSTraceSource",
                                                  TableControl.Create()
                                                  .AddHeader(width: 8)
                                                  .AddHeader(width: 20)
                                                  .AddHeader(width: 20)
                                                  .AddHeader()
                                                  .StartRowDefinition()
                                                  .AddPropertyColumn("Options")
                                                  .AddPropertyColumn("Name")
                                                  .AddPropertyColumn("Listeners")
                                                  .AddPropertyColumn("Description")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("System.Management.Automation.PSTraceSource",
                                                  ListControl.Create()
                                                  .StartEntry()
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty(@"Description")
                                                  .AddItemProperty(@"Options")
                                                  .AddItemProperty(@"Listeners")
                                                  .AddItemProperty(@"Attributes")
                                                  .AddItemProperty(@"Switch")
                                                  .EndEntry()
                                                  .EndList()));
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="tableControl"></param>
 /// <param name="mgControl"></param>
 /// <param name="children"></param>
 /// <param name="columnsCount"></param>
 /// <param name="style"></param>
 internal TableManagerLimitedItems(TableControl tableControl, GuiMgControl mgControl, List <GuiMgControl> children,
                                   int columnsCount, int style)
     : base(tableControl, mgControl, children, columnsCount, style)
 {
     // must be inited to zero. If font of table not refreshed intitally, rollback this change.
     _rowsInPage = 0;
 }
Beispiel #5
0
        public List <int> CreateOnTable(string modelId, int x, int y, bool persist, int quantity)
        {
            var result = new List <int>();

            Guid modelGuid;

            if (!Guid.TryParse(modelId, out modelGuid))
            {
                return(result); // e.g. modelId may be null if the cloned card is face down.
            }
            _engine.Invoke(() =>
            {
                CardModel model = Database.GetCardById(modelGuid);
                if (model == null)
                {
                }
                else
                {
                    var ids    = new int[quantity];
                    var keys   = new ulong[quantity];
                    var models = new Guid[quantity];
                    int[] xs   = new int[quantity], ys = new int[quantity];

                    CardDef def = Program.Game.Definition.CardDefinition;

                    if (Player.LocalPlayer.InvertedTable)
                    {
                        x -= def.Width;
                        y -= def.Height;
                    }
                    var offset = (int)(Math.Min(def.Width, def.Height) * 0.2);
                    if (Program.GameSettings.UseTwoSidedTable && TableControl.IsInInvertedZone(y))
                    {
                        offset = -offset;
                    }

                    for (int i = 0; i < quantity; ++i)
                    {
                        ulong key = ((ulong)Crypto.PositiveRandom()) << 32 | model.Id.Condense();
                        int id    = Program.Game.GenerateCardId();

                        new CreateCard(Player.LocalPlayer, id, key, true, model, x, y, !persist).Do();

                        ids[i]    = id;
                        keys[i]   = key;
                        models[i] = model.Id;
                        xs[i]     = x;
                        ys[i]     = y;
                        result.Add(id);

                        x += offset;
                        y += offset;
                    }

                    Program.Client.Rpc.CreateCardAt(ids, keys, models, xs, ys, true, persist);
                }
            });

            return(result);
        }
        protected bool _realIncludesFirst;      // this is includeFirst that was sent from
        // the  server includefirst member may be updated here, because of listview limitations

        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="tableControl"></param>
        /// <param name="mgControl"></param>
        /// <param name="children"></param>
        /// <param name="columnsCount"></param>
        /// <param name="style"></param>
        internal TableManagerUnlimitedItems(TableControl tableControl, GuiMgControl mgControl, List <GuiMgControl> children,
                                            int columnsCount, int style)
            : base(tableControl, mgControl, children, columnsCount, style)
        {
            _realIncludesFirst = _includesFirst = false;
            _includesLast      = false;
        }
Beispiel #7
0
        /// <summary>
        /// adds handler for Table control
        /// </summary>
        /// <param name="table"></param>
        internal void addHandler(TableControl table)
        {
            table.MouseMove += MouseMoveHandler;
            table.MouseDown += MouseDownHandler;
#if !PocketPC
            table.MouseLeave   += MouseLeaveHandler;
            table.Layout       += LayoutHandler;
            table.MouseWheel   += MouseWheelHandler;
            table.DragOver     += DragOverHandler;
            table.DragDrop     += DragDropHandler;
            table.GiveFeedback += GiveFeedBackHandler;
#endif
            table.Scroll  += ScrollHandler;
            table.Reorder += ReorderHandler;
            table.MouseUp += MouseUpHandler;
            table.Resize  += ResizeHandler;

            table.PaintItem += PaintItemHandler;
            //table.EraseItem += EraseItemHandler;
            table.ItemDisposed += DisposedItemHandler;
            table.Disposed     += DisposedHandler;
            table.ReorderEnded += ReorderEndedHandler;
            table.NCMouseDown  += NCMouseDownHandler;
            table.HorizontalScrollVisibilityChanged += HorizontalScrollVisibilityChangedHandler;
            table.KeyPress       += KeyPressHandler;
            table.KeyDown        += KeyDownHandler;
            table.PreviewKeyDown += PreviewKeyDownHandler;
        }
Beispiel #8
0
 public ThreeDRaisedStyleRenderer(TableControl tableControl)
     : base(tableControl)
 {
     ColumnDividerRenderer = new ThreeDRaisedStyleColumnDividerRenderer();
     RowDividerRenderer    = new ThreeDRaiseStyleRowDividerRenderer();
     BorderRenderer        = new ThreeDRaisedBorderRenderer();
 }
Beispiel #9
0
        private void TableControlClick(object sender, RoutedEventArgs e)
        {
            TableControl tableControl = new TableControl();

            tableControl.Show();
            Application.Current.Windows[0].Visibility = Visibility.Hidden;
        }
        public void Render(Graphics graphics, TableControl tableControl, Pen dividerPen, int left, int top, int bottom)
        {
            int offset = tableControl.RightToLeftLayout ? 0 : DIVIDER_OFFSET;

            left += offset;
            graphics.DrawLine(dividerPen, left, top, left, bottom);
        }
Beispiel #11
0
        public static int MARGIN = 4; // #define COL_DIVIDER 4 (win.h)

        /// <summary>
        /// Renderer for two-d table
        /// </summary>
        public TwoDTableStyleRenderer(TableControl tableControl)
            : base(tableControl)
        {
            ColumnDividerRenderer = new TwoDStyleColumnDividerRenderer();
            RowDividerRenderer    = new TwoDStyleRowDividerRenderer();
            BorderRenderer        = new TwoDStyleBorderRenderer();
        }
Beispiel #12
0
        private void LoadData()
        {
            TableBLL tableBLL = new TableBLL();

            this.ListOrderedTables   = tableBLL.ListOrderedTables();
            this.ListAvailableTables = tableBLL.ListAvailableTables();

            foreach (DAL.Table table in this.Tables)
            {
                TableControl tableControl = new TableControl(table, false);
                tableControl.MouseDown += new MouseEventHandler(this.tableControl1_MouseDown);
                this.flowLayoutPanel1.Controls.Add(tableControl);
            }

            foreach (DAL.Table table in this.ListAvailableTables)
            {
                TableControl tableControl = new TableControl(table, false);
                tableControl.MouseDown += new MouseEventHandler(this.tableControl1_MouseDown);
                this.flowLayoutPanel2.Controls.Add(tableControl);
            }

            foreach (DAL.Table table in this.ListOrderedTables)
            {
                DAL.Table tt = this.Tables.Find(t => t.ID == table.ID);
                if (tt != null)
                {
                    continue;
                }

                TableControl tableControl = new TableControl(table, false);
                tableControl.MouseDown += new MouseEventHandler(this.tableControl1_MouseDown);
                this.flowLayoutPanel3.Controls.Add(tableControl);
            }
        }
Beispiel #13
0
 public WindowsThreeDStyleRenderer(TableControl tableControl)
     : base(tableControl)
 {
     RowDividerRenderer    = new WindowsStyleRowDividerRenderer();
     ColumnDividerRenderer = new WindowsThreeDColumnDividerRenderer();
     BorderRenderer        = new WindowsThreeDBorderRenderer();
 }
Beispiel #14
0
        private static IEnumerable <FormatViewDefinition> ViewsOf_FileSystemTypes(CustomControl[] sharedControls)
        {
            const string LengthScriptBlock =
                @"if ($_ -is [System.IO.DirectoryInfo]) { return '' }
if ($_.Attributes -band [System.IO.FileAttributes]::Offline)
{
    return '({0})' -f $_.Length
}
return $_.Length";

            yield return(new FormatViewDefinition("children",
                                                  TableControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddHeader(Alignment.Left, label: "Mode", width: 7)
                                                  .AddHeader(Alignment.Right, label: "LastWriteTime", width: 25)
                                                  .AddHeader(Alignment.Right, label: "Length", width: 14)
                                                  .AddHeader()
                                                  .StartRowDefinition(wrap: true)
                                                  .AddPropertyColumn("Mode")
                                                  .AddScriptBlockColumn(@"
                                    [String]::Format(""{0,10} {1,8}"", $_.LastWriteTime.ToString(""d""), $_.LastWriteTime.ToString(""t""))
                                ")
                                                  .AddScriptBlockColumn(LengthScriptBlock)
                                                  .AddPropertyColumn("Name")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("children",
                                                  ListControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .StartEntry(entrySelectedByType: new[] { "System.IO.FileInfo" })
                                                  .AddItemProperty(@"Name")
                                                  .AddItemScriptBlock(LengthScriptBlock, label: "Length")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .AddItemProperty(@"VersionInfo")
                                                  .EndEntry()
                                                  .StartEntry()
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .EndEntry()
                                                  .EndList()));

            yield return(new FormatViewDefinition("children",
                                                  WideControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddPropertyEntry("Name")
                                                  .AddPropertyEntry("Name", format: "[{0}]", entrySelectedByType: new[] { "System.IO.DirectoryInfo" })
                                                  .EndWideControl()));
        }
Beispiel #15
0
        /// <summary>
        /// Filter Table Name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtFilterTable_KeyUp(object sender, KeyEventArgs e)
        {
            XmlControl.CreateCorrespondingXmlWhenNotExist();
            Dictionary <string, string> dic = XmlControl.ReadXml();

            dgvDataTables.DataSource          = TableControl.GetTables(dic, txtFilterTable.Text.Trim().ToLower(), dbType);
            dgvDataTables.AutoGenerateColumns = false;
        }
Beispiel #16
0
        private void tableControl1_MouseDown(object sender, MouseEventArgs e)
        {
            TableControl tableControl = (TableControl)sender;

            tableControl.Select();
            DataObject data = new DataObject(DataFormats.Serializable, tableControl.Table);

            tableControl.DoDragDrop(data, DragDropEffects.Copy);
        }
Beispiel #17
0
    private void Confirm()
    {
        tableList.Clear();
        List <string> level = new List <string>();

        foreach (var item in levelTree.nodeData[0].Children)
        {
            if (item.Check)
            {
                level.Add(item.Title);
                //Debug.Log(item.Title);
            }
        }


        Dictionary <string, List <string> > resultsList = new Dictionary <string, List <string> >();
        List <string> result = new List <string>();

        foreach (UTreeNodeData node1 in compoentTree.nodeData)
        {
            foreach (UTreeNodeData node2 in node1.Children)
            {
                foreach (UTreeNodeData node3 in node2.Children)
                {
                    if (node3.Check)
                    {
                        string codeNum = node3.Title;
                        result.Add(codeNum);
                    }
                    //foreach (UTreeNodeData node4 in node3.Children)
                    //{
                    //    if (node4.Check)
                    //    {
                    //        string codeNum = node4.Title;
                    //        resultsList.Add(codeNum, new List<string>());
                    //        resultsList[codeNum].AddRange(_elementList[codeNum]);
                    //    }
                    //}
                }
            }
        }

        Debug.Log(_path);

        Debug.Log(level.Count);
        Debug.Log(result);
        //this.transform.gameObject.SetActive(false);

        countPanel.gameObject.SetActive(true);
        SelectFloorNum(level, result);
        TableControl tControl = countPanel.GetComponent <TableControl>();

        tControl.Load(tableList);
        // tControl.test(level, resultsList, _path);
        //触发事件
        //CallBack(resultsList);
    }
Beispiel #18
0
        public void CanCreateTableControl()
        {
            //Act
            tc = new TableControl();

            //Assert
            Assert.IsNotNull(tc);
            Assert.IsInstanceOfType(tc, typeof(TableControl));
        }
        private void ListviewMarkdownHtml_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RenderingSettingsItemContent.Children.Clear();

            var item = (RenderModel)((ListView)sender).SelectedItem;

            switch (item)
            {
            case CoreRenderModel coreRenderModel:
                var coreControl = new CoreControl();
                coreControl.Init(coreRenderModel);
                RenderingSettingsItemContent.Children.Add(coreControl);
                break;

            case EmphasisExtraRenderModel emphasisExtraModel:
                var emphasisExtraControl = new EmphasisExtraControl();
                emphasisExtraControl.Init(emphasisExtraModel);
                RenderingSettingsItemContent.Children.Add(emphasisExtraControl);
                break;

            case TableRenderModel tableModel:
                var tableControl = new TableControl();
                tableControl.Init(tableModel);
                RenderingSettingsItemContent.Children.Add(tableControl);
                break;

            case ListRenderModel listModel:
                var listControl = new ListControl();
                listControl.Init(listModel);
                RenderingSettingsItemContent.Children.Add(listControl);
                break;

            case MathRenderModel mathModel:
                var mathControl = new MathControl();
                mathControl.Init(mathModel);
                RenderingSettingsItemContent.Children.Add(mathControl);
                break;

            case SyntaxHighlightingRenderModel syntaxHighlightingModel:
                var syntaxHighlightingControl = new SyntaxHighlightingControl();
                syntaxHighlightingControl.Init(syntaxHighlightingModel);
                RenderingSettingsItemContent.Children.Add(syntaxHighlightingControl);
                break;

            case DiagramRenderModel diagramModel:
                var diagramControl = new DiagramControl();
                diagramControl.Init(diagramModel);
                RenderingSettingsItemContent.Children.Add(diagramControl);
                break;

            default:
                // TODO Error UI model does not exist
                // TODO Analytics
                break;
            }
        }
Beispiel #20
0
        private void tableControl_OnEdit(TableControl sender)
        {
            TableEditDialog tableEditDialog = new TableEditDialog(sender.Table);
            DialogResult    dr = tableEditDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                sender.Table = tableEditDialog.table;
            }
        }
Beispiel #21
0
        public TableViewModel(string key, string label, string required, TableControl control)
            : base(key, label, required, control)
        {
            _control = control;

            _isEditable = _control.Editable.GetValueOrDefault();

            AddCommand    = new DelegateCommand(AddRow, () => true);
            RemoveCommand = new DelegateCommand(RemoveRow, () => SelectedRow != null);
        }
 public override void ClearSearch()
 {
     if (TableControl != null)
     {
         TableControl.SetFilter(SearchFilterKey, null);
     }
     else
     {
         System.Diagnostics.Debug.Fail("Attempting to clear before initializing ErrorListWindow");
     }
 }
Beispiel #23
0
        /// <summary>
        /// Get TablePlacementManager object
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        protected TablePlacementManagerBase GetTablePlacementManager(TableControl control)
        {
            ITableManager tableManager = GetTableManager(control);

            if (tableManager != null)
            {
                return(tableManager.TablePlacementManager);
            }

            return(null);
        }
 private static IEnumerable <FormatViewDefinition> ViewsOf_Microsoft_PowerShell_Commands_GetCounter_PerformanceCounterSampleSet()
 {
     yield return(new FormatViewDefinition("Counter",
                                           TableControl.Create()
                                           .AddHeader(Alignment.Left, label: "Timestamp", width: 25)
                                           .AddHeader(Alignment.Left, label: "CounterSamples", width: 100)
                                           .StartRowDefinition(wrap: true)
                                           .AddPropertyColumn("Timestamp")
                                           .AddPropertyColumn("Readings")
                                           .EndRowDefinition()
                                           .EndTable()));
 }
 private static IEnumerable <FormatViewDefinition> ViewsOf_Microsoft_WSMan_Management_WSManConfigLeafElement_InitParams()
 {
     yield return(new FormatViewDefinition("Microsoft.WSMan.Management.WSManConfigLeafElement#InitParams",
                                           TableControl.Create()
                                           .GroupByProperty("PSParentPath", label: "WSManConfig")
                                           .AddHeader(label: "ParamName", width: 30)
                                           .AddHeader(label: "ParamValue", width: 20)
                                           .StartRowDefinition()
                                           .AddPropertyColumn("Name")
                                           .AddPropertyColumn("Value")
                                           .EndRowDefinition()
                                           .EndTable()));
 }
 private static IEnumerable <FormatViewDefinition> ViewsOf_Microsoft_WSMan_Management_WSManConfigContainerElement_ComputerLevel()
 {
     yield return(new FormatViewDefinition("Microsoft.WSMan.Management.WSManConfigContainerElement#ComputerLevel",
                                           TableControl.Create()
                                           .GroupByProperty("PSParentPath", label: "WSManConfig")
                                           .AddHeader(label: "ComputerName", width: 45)
                                           .AddHeader(label: "Type", width: 20)
                                           .StartRowDefinition()
                                           .AddPropertyColumn("Name")
                                           .AddPropertyColumn("TypeNameOfElement")
                                           .EndRowDefinition()
                                           .EndTable()));
 }
Beispiel #27
0
 private static IEnumerable <FormatViewDefinition> ViewsOf_System_Security_Cryptography_X509Certificates_X509CertificateEx()
 {
     yield return(new FormatViewDefinition("System.Security.Cryptography.X509Certificates.X509CertificateEx",
                                           TableControl.Create()
                                           .GroupByProperty("PSParentPath")
                                           .AddHeader(width: 41)
                                           .AddHeader()
                                           .StartRowDefinition()
                                           .AddPropertyColumn("Thumbprint")
                                           .AddPropertyColumn("Subject")
                                           .EndRowDefinition()
                                           .EndTable()));
 }
Beispiel #28
0
 private static IEnumerable <FormatViewDefinition> ViewsOf_Microsoft_PowerShell_Commands_AlternateStreamData()
 {
     yield return(new FormatViewDefinition("FileSystemStream",
                                           TableControl.Create()
                                           .GroupByProperty("Filename")
                                           .AddHeader(Alignment.Left, width: 20)
                                           .AddHeader(Alignment.Right, width: 10)
                                           .StartRowDefinition()
                                           .AddPropertyColumn("Stream")
                                           .AddPropertyColumn("Length")
                                           .EndRowDefinition()
                                           .EndTable()));
 }
 private static IEnumerable <FormatViewDefinition> ViewsOf_Microsoft_PowerShell_Commands_GetCounter_CounterFileInfo()
 {
     yield return(new FormatViewDefinition("Counter",
                                           TableControl.Create()
                                           .AddHeader(Alignment.Left, width: 30)
                                           .AddHeader(Alignment.Left, width: 30)
                                           .AddHeader(Alignment.Left, width: 30)
                                           .StartRowDefinition(wrap: true)
                                           .AddPropertyColumn("OldestRecord")
                                           .AddPropertyColumn("NewestRecord")
                                           .AddPropertyColumn("SampleCount")
                                           .EndRowDefinition()
                                           .EndTable()));
 }
            public override Control CreateControl()
            {
                TableControl control = new TableControl();

                control.SetId(this._id, "DataGridPreprocessorDialog");

                control.SetConfigurationFromText(
                    this._configuration,
                    this.Preprocessor.GraphicsInfo.Size,
                    this.Preprocessor.DataProvider.XmlDocument
                    );

                return(control);
            }
Beispiel #31
0
        public PlayWindow()
            : base()
        {
            GameSettings = Program.GameSettings;
            IsHost = Program.IsHost;
            if (Program.GameEngine.Spectator)
            {
                CanChat = Program.GameSettings.MuteSpectators == false;
            }
            else
            {
                CanChat = true;
            }
            GameMessages = new ObservableCollection<IGameMessage>();
            _gameMessageReader = new GameMessageDispatcherReader(Program.GameMess);
            var isLocal = Program.GameEngine.IsLocal;
            //GameLogWindow.Show();
            //GameLogWindow.Visibility = Visibility.Hidden;
            Program.Dispatcher = Dispatcher;
            DataContext = Program.GameEngine;
            InitializeComponent();

            _isLocal = isLocal;
            //Application.Current.MainWindow = this;
            Version oversion = Assembly.GetExecutingAssembly().GetName().Version;
            Title = "Octgn  version : " + oversion + " : " + Program.GameEngine.Definition.Name;
            Program.GameEngine.ComposeParts(this);
            this.Loaded += OnLoaded;
            this.chat.MouseEnter += ChatOnMouseEnter;
            this.chat.MouseLeave += ChatOnMouseLeave;
            this.playerTabs.MouseEnter += PlayerTabsOnMouseEnter;
            this.playerTabs.MouseLeave += PlayerTabsOnMouseLeave;
            this.PreGameLobby.OnClose += delegate
            {
                if (this.PreGameLobby.StartingGame)
                {
                    PreGameLobby.Visibility = Visibility.Collapsed;
                    if (Player.LocalPlayer.Spectator == false)
                        Program.GameEngine.ScriptEngine.SetupEngine(false);


                    table = new TableControl { DataContext = Program.GameEngine.Table, IsTabStop = true };
                    KeyboardNavigation.SetIsTabStop(table, true);
                    TableHolder.Child = table;

                    table.UpdateSided();
                    Keyboard.Focus(table);

					Dispatcher.BeginInvoke(new Action(Program.GameEngine.Ready), DispatcherPriority.ContextIdle);
                    
                    //Program.GameEngine.Ready();
                    if (Program.DeveloperMode && Player.LocalPlayer.Spectator == false)
                    {
                        MenuConsole.Visibility = Visibility.Visible;
                        var wnd = new DeveloperWindow() { Owner = this };
                        wnd.Show();
                    }
                    Program.GameSettings.PropertyChanged += (sender, args) =>
                        {
                            if (Program.GameEngine.Spectator)
                            {
                                CanChat = Program.GameSettings.MuteSpectators == false;
                            }
                            if (Program.IsHost)
                            {
                                Program.Client.Rpc.Settings(Program.GameSettings.UseTwoSidedTable,
                                                            Program.GameSettings.AllowSpectators,
                                                            Program.GameSettings.MuteSpectators);
                            }
                        };
                    // Select proper player tab
                    if (Player.LocalPlayer.Spectator)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                            {
                                playerTabs.SelectedIndex = 0;
                            }));
                    }
                }
                else
                {
                    IsRealClosing = true;
                    this.TryClose();
                }
            };

            this.Loaded += delegate
            {
                Program.OnOptionsChanged += ProgramOnOnOptionsChanged;
                _gameMessageReader.Start(
                    x =>
                    {
                        Dispatcher.Invoke(new Action(
                            () =>
                            {
                                bool gotOne = false;
                                foreach (var m in x)
                                {
                                    var b = Octgn.Play.Gui.ChatControl.GameMessageToBlock(m);
                                    if (b == null) continue;

                                    if (m is NotifyBarMessage)
                                    {
                                        GameMessages.Insert(0, m);
                                        gotOne = true;
                                        while (GameMessages.Count > 60)
                                        {
                                            GameMessages.Remove(GameMessages.Last());
                                        }
                                    }
                                }
                                if (!gotOne) return;

                                if (_showBottomBar != null && _showBottomBar.GetCurrentProgress(BottomBar) > 0)
                                {
                                    _showBottomBar.Seek(BottomBar, TimeSpan.FromMilliseconds(500), TimeSeekOrigin.BeginTime);
                                }
                                else
                                {
                                    if (_showBottomBar == null)
                                    {
                                        _showBottomBar = BottomBar.Resources["ShowBottomBar"] as Storyboard;
                                    }
                                    _showBottomBar.Begin(BottomBar, HandoffBehavior.Compose, true);
                                }
                                if (this.IsActive == false)
                                {
                                    this.FlashWindow();
                                }
                                if (this.IsActive == false && Prefs.EnableGameSound && DateTime.Now > lastMessageSoundTime.AddSeconds(10))
                                {
                                    Octgn.Utils.Sounds.PlayGameMessageSound();
                                    lastMessageSoundTime = DateTime.Now;
                                }
                            }));
                    });
            };
            this.Activated += delegate
            {
                this.StopFlashingWindow();
            };
            this.Unloaded += delegate
            {
                Program.OnOptionsChanged -= ProgramOnOnOptionsChanged;
                _gameMessageReader.Stop();
            };

            
            //this.chat.NewMessage = x =>
            //{
            //    GameMessages.Insert(0, x);
            //};
        }