示例#1
0
        /// <summary>
        /// Restore a saved tab from a previous session's stored XML data. This is usually triggered by
        /// an event from the XMLDocumentHistory class during program startup, or when a history file
        /// is loaded. --Will Kraft (12/29/2019).
        /// </summary>
        /// <param name="e">Tab data (from XML) to restore.</param>
        void RestoreTab(TabRestorationEventArgs e)
        {
            Brush OutputBG        = SystemColors.HighlightBrush;
            Brush OutputSelection = SystemColors.WindowBrush;
            Brush TabTextColor    = SystemColors.ControlTextBrush;

            switch (e.Task)
            {
            default:
            case TaskType.Default:     // This isn't supposed to happen but if it ever does, default system colors are good enough.
                break;

            case TaskType.Prepare:
                TabTextColor    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1b80fa"));
                OutputBG        = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#d9edff"));
                OutputSelection = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#486394"));
                break;

            case TaskType.Strip:
                TabTextColor    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fe5000"));  // old color: #fa781b
                OutputBG        = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff3cf"));
                OutputSelection = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9c4c24"));
                break;
            }


            var n = new EditorDuo
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Name        = $"Editor{TabNumber}",
                ID          = e.TabID,
                Processed   = true,
                Task        = e.Task,
                LowerText   = e.LowerText,
                UpperText   = e.UpperText,
                Args        = e.PrepareArgs,
                LowerColor  = OutputBG,
                LowerSelect = OutputSelection,
                TabName     = e.TabName,
            };

            n.Upper.CreationDate           = e.CreationDate;
            n.Lower.ProcessedDate          = e.ProcessedDate;
            n.Lower.Task                   = e.Task;
            n.Lower.OpStatusProcessedColor = TabTextColor;
            n.Lower.Processed              = true;
            n.Lower.SetDateStamp();
            n.Upper.SetDateStamp();
            n.Lower.SetTaskType();

            var _h = new HeaderedContentControl
            {
                Header     = e.TabName,
                Foreground = TabTextColor
            };

            _h.MouseDown += OnTabHeaderClick;

            var t = new TabItem
            {
                Header  = _h,
                Content = n,
                Tag     = e.TabID
            };

            Tabs.Items.Add(t);

            Tabs.SelectedIndex = Tabs.Items.Count - 1;

            // Create a menu item for this  tab. Menu items and tabs are bound together
            // using the editor's GUID as a reference. --Will Kraft (2/16/2020).
            var _menuItem = new MenuItem
            {
                Header      = e.TabName.Replace("_", "__"),
                Tag         = e.TabID,
                Foreground  = TabTextColor,
                IsCheckable = true,
                IsChecked   = true // This corrects itself automatically as subsequent tabs are loaded, but it ensures the last                                   document is checked properly in the query list. --Will Kraft (2/16/2020).
            };

            _menuItem.Click += _menuItem_Click;

            MnuQueryList.Items.Add(_menuItem);

            TabNumber++;
            Fingerprints.Add(e.TabID);
        }
示例#2
0
 private void _xml_RegenerateTab(object sender, TabRestorationEventArgs e)
 {
     RestoreTab(e);
 }