コード例 #1
0
 public TabButtonControl(TabButtonControl t)
 {
     InitializeComponent();
     this.Title = t.Title;
     this.ControlTabButtonClicked = t.ControlTabButtonClicked;
     this.CloseTabButtonClicked   = t.CloseTabButtonClicked;
     this.GetTextControl          = t.GetTextControl;
     this.LsLanguage          = t.LsLanguage;
     this.GetSplitTextControl = t.GetSplitTextControl;
     Button_Click(BackButton, new RoutedEventArgs());
 }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            bool             next = false;
            TabButtonControl past = new TabButtonControl();

            foreach (var item in TopPanel.Children.OfType <TabButtonControl>())
            {
                if (item.Open)
                {
                    foreach (var item2 in TopPanel.Children.OfType <TabButtonControl>())
                    {
                        if (item2.Open)
                        {
                            item2.GetTextControl      = GroopGrid.Children.OfType <TextControl>().FirstOrDefault();
                            item2.GetSplitTextControl = GroopGrid.Children.OfType <SplitTextControl>().FirstOrDefault();
                        }
                        item2.Open = false;
                    }
                    past.Open = true;
                    try { GroopGrid.Children.Remove(GroopGrid.Children.OfType <TextControl>().FirstOrDefault()); } catch { }
                    try { GroopGrid.Children.Remove(GroopGrid.Children.OfType <SplitTextControl>().FirstOrDefault()); } catch { }
                    TextControl textControl = past.GetTextControl;
                    textControl.SetValue(Grid.RowProperty, 0);
                    textControl.Margin = new Thickness(0, 1, 0, 0);
                    textControl.SetValue(Panel.ZIndexProperty, 0);
                    GroopGrid.Children.Add(past.GetTextControl);
                    SplitTextControl splitTextControl = past.GetSplitTextControl;
                    splitTextControl.SetValue(Grid.RowProperty, 1);
                    splitTextControl.Margin = new Thickness(0, 1, 0, 0);
                    splitTextControl.SetValue(Panel.ZIndexProperty, 0);
                    GroopGrid.Children.Add(past.GetSplitTextControl);
                    switch (past.IsSplit)
                    {
                    case true:
                        GroopGrid.Children[0].Visibility = Visibility.Collapsed;
                        GroopGrid.Children[1].Visibility = Visibility.Visible;
                        break;

                    case false:
                    default:
                        GroopGrid.Children[0].Visibility = Visibility.Visible;
                        GroopGrid.Children[1].Visibility = Visibility.Collapsed;
                        break;
                    }
                    break;
                }
                next      = item.Open;
                item.Open = false;
                past      = item;
            }
        }
コード例 #3
0
        public void TabAdd(string langage, Dictionary <string, MainWindow.ColorType> keyValuePairs)
        {
            TabButtonControl buttonControl = new TabButtonControl();

            buttonControl.LsLanguage = langage;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = buttonControl.languageFilter[buttonControl.GetLanguage];
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            if (openFileDialog.ShowDialog() == true)
            {
                buttonControl.splitChanged += new TabButtonControl.SplitChanged(this.SplitChanged);
                buttonControl.GetTextControl.Dictionary            = keyValuePairs;
                buttonControl.GetSplitTextControl.Left.Dictionary  = keyValuePairs;
                buttonControl.GetSplitTextControl.Right.Dictionary = keyValuePairs;
                buttonControl.GetTextControl.LsLanguage            = langage;
                buttonControl.GetSplitTextControl.Left.LsLanguage  = langage;
                buttonControl.GetSplitTextControl.Right.LsLanguage = langage;
                buttonControl.ControlTabButtonClicked += new EventHandler(this.TabButtonControl_ControlClicked);
                buttonControl.CloseTabButtonClicked   += new EventHandler(this.TabButtonClose_ControlClicked);
                buttonControl.Open = true;
                TabButtonControl_ControlClicked(buttonControl, new EventArgs());
                foreach (var item in TopPanel.Children.OfType <TabButtonControl>())
                {
                    item.Open = false;
                }
                TopPanel.Children.Insert(TopPanel.Children.Count - 1, buttonControl);

                buttonControl.Document = openFileDialog.FileName;
                buttonControl.GetTextControl.MainRichTextBox.Document.Blocks.Clear();
                buttonControl.GetTextControl.MainRichTextBox.AppendText(File.ReadAllText(buttonControl.Document));
                List <FormattedWord> formattedWords = new List <FormattedWord>();
                foreach (var item7 in ((SplitTextControl)this.GroopGrid.Children[1]).Right.Dictionary)
                {
                    formattedWords.Add(new FormattedWord(item7.Key, item7.Value.Color, item7.Value.Types));
                }
                (new RTX()
                {
                    words = formattedWords
                }).update(ref buttonControl.GetTextControl.MainRichTextBox);
                buttonControl.GetSplitTextControl.Left.MainRichTextBox.Document.Blocks.Clear();
                buttonControl.GetSplitTextControl.Left.MainRichTextBox.AppendText(File.ReadAllText(buttonControl.Document));
                buttonControl.Title = $"{buttonControl.DocumentName}{buttonControl.DocumentType}";
            }
        }
コード例 #4
0
        private void TabButtonControl_ControlClicked(object sender, EventArgs e)
        {
            #region Try 1
            TabButtonControl tab = (TabButtonControl)sender;
            foreach (var item in TopPanel.Children.OfType <TabButtonControl>())
            {
                if (item.Open)
                {
                    item.GetTextControl      = GroopGrid.Children.OfType <TextControl>().FirstOrDefault();
                    item.GetSplitTextControl = GroopGrid.Children.OfType <SplitTextControl>().FirstOrDefault();
                }
                item.Open = false;
            }
            tab = (TabButtonControl)sender;
            try { GroopGrid.Children.Remove(GroopGrid.Children.OfType <TextControl>().FirstOrDefault()); } catch { }
            try { GroopGrid.Children.Remove(GroopGrid.Children.OfType <SplitTextControl>().FirstOrDefault()); } catch { }
            TextControl textControl = tab.GetTextControl;
            textControl.SetValue(Grid.RowProperty, 0);
            textControl.Margin = new Thickness(0, 1, 0, 0);
            textControl.SetValue(Panel.ZIndexProperty, 0);
            GroopGrid.Children.Add(tab.GetTextControl);
            SplitTextControl splitTextControl = tab.GetSplitTextControl;
            splitTextControl.SetValue(Grid.RowProperty, 1);
            splitTextControl.Margin = new Thickness(0, 1, 0, 0);
            splitTextControl.SetValue(Panel.ZIndexProperty, 0);
            GroopGrid.Children.Add(tab.GetSplitTextControl);
            switch (tab.IsSplit)
            {
            case true:
                GroopGrid.Children[0].Visibility = Visibility.Collapsed;
                GroopGrid.Children[1].Visibility = Visibility.Visible;
                break;

            case false:
            default:
                GroopGrid.Children[0].Visibility = Visibility.Visible;
                GroopGrid.Children[1].Visibility = Visibility.Collapsed;
                break;
            }
            #endregion
        }