コード例 #1
0
        public void RemoveSelectedSplit()
        {
            var selected = Selected;

            if (selected != null)
            {
                ChatColumn    column = null;
                ColumnTabPage _page  = null;

                foreach (ColumnTabPage page in tabControl.TabPages.Where(x => x is ColumnTabPage))
                {
                    foreach (var c in page.Columns)
                    {
                        if (c.Widgets.Contains(selected))
                        {
                            _page  = page;
                            column = c;
                            break;
                        }
                    }
                }

                if (column != null)
                {
                    column.RemoveWidget(selected);

                    if (column.WidgetCount == 0)
                    {
                        _page.RemoveColumn(column);
                    }
                }

                selected.Dispose();
            }
        }
コード例 #2
0
        public void LoadLayout(string path)
        {
            try
            {
                string channelNames = "";
                if (File.Exists(path))
                {
                    var doc = XDocument.Load(path);

                    doc.Root.Process(root =>
                    {
                        foreach (var tab in doc.Elements().First().Elements("tab"))
                        {
                            Console.WriteLine("tab");

                            var page = new ColumnTabPage();

                            page.CustomTitle = tab.Attribute("title")?.Value;

                            page.EnableNewMessageHighlights = (tab.Attribute("enableNewMessageHighlights")?.Value?.ToUpper() ?? "TRUE") == "TRUE";

                            page.EnableGoLiveHighlights = (tab.Attribute("enableGoLiveHighlights")?.Value?.ToUpper() ?? "TRUE") == "TRUE";

                            foreach (var col in tab.Elements("column"))
                            {
                                var column = new ChatColumn();

                                foreach (var chat in col.Elements("chat"))
                                {
                                    if (chat.Attribute("type")?.Value == "twitch")
                                    {
                                        Console.WriteLine("added chat");

                                        var channel = chat.Attribute("channel")?.Value;
                                        try {
                                            var widget         = new ChatControl();
                                            widget.ChannelName = channel;
                                            column.AddWidget(widget);
                                        }  catch (Exception e) {
                                            GuiEngine.Current.log("error loading tab " + e.Message);
                                        }
                                    }
                                }

                                if (column.WidgetCount == 0)
                                {
                                    column.AddWidget(new ChatControl());
                                }

                                page.AddColumn(column);
                            }


                            tabControl.AddTab(page);
                        }
                    });
                }
            }
            catch (Exception exc)
            {
                GuiEngine.Current.log("error loading layout " + exc.Message);
            }

            //columnLayoutControl1.ClearGrid();

            //try
            //{
            //    if (File.Exists(path))
            //    {
            //        XDocument doc = XDocument.Load(path);
            //        doc.Root.Process(root =>
            //        {
            //            root.Elements("tab").Do(tab =>
            //            {
            //                int columnIndex = 0;
            //                tab.Elements("column").Do(xD =>
            //                {
            //                    int rowIndex = 0;
            //                    xD.Elements().Do(x =>
            //                    {
            //                        switch (x.Name.LocalName)
            //                        {
            //                            case "chat":
            //                                if (x.Attribute("type").Value == "twitch")
            //                                {
            //                                    AddChannel(x.Attribute("channel").Value, columnIndex, rowIndex == 0 ? -1 : rowIndex);
            //                                }
            //                                break;
            //                        }
            //                        rowIndex++;
            //                    });
            //                    columnIndex++;
            //                });
            //            });
            //        });
            //    }
            //}
            //catch { }

            if (!tabControl.TabPages.Any())
            {
                tabControl.AddTab(new ColumnTabPage());
            }

            //if (columnLayoutControl1.Columns.Count == 0)
            //    AddChannel("fourtf");
        }