static internal void DeleteFromTable(CiscoObject n)
 {
     This.BeginInvoke(() =>
     {
         lock (This.cisco_objects.Children)
         {
             for (int i = This.cisco_objects.Children.Count - 1; i >= 0; i--)
             {
                 CiscoObjectControl nc = (CiscoObjectControl)This.cisco_objects.Children[i];
                 if (nc.CiscoObject == n)
                 {
                     This.cisco_objects.Children.RemoveAt(i);
                 }
             }
         }
     });
 }
 static internal UserControl GetControl(CiscoObject co)
 {
     return((UserControl)This.Invoke(() =>
     {
         lock (This.cisco_objects.Children)
         {
             foreach (CiscoObjectControl c in This.cisco_objects.Children)
             {
                 if (c.CiscoObject == co)
                 {
                     return c.Control;
                 }
             }
             throw new Exception("No CiscoObjectControl found.");
         }
     }));
 }
        static internal void AddToTable(CiscoObject n)
        {
            This.BeginInvoke(() =>
            {
                CiscoObjectControl nc = new CiscoObjectControl(n);
                lock (This.cisco_objects.Children)
                {
                    nc.HorizontalAlignment = HorizontalAlignment.Stretch;
                    This.set_visibility(nc);

                    int i = 0;
                    for (; i < This.cisco_objects.Children.Count; i++)
                    {
                        if (((CiscoObjectControl)This.cisco_objects.Children[i]).CiscoObject.CreateTime < n.CreateTime)
                        {
                            break;
                        }
                    }
                    This.cisco_objects.Children.Insert(i, nc);
                }
            });
        }
Ejemplo n.º 4
0
        internal CiscoObjectControl(CiscoObject n)
        {
            InitializeComponent();

            CiscoObject = n;

            xml.Text       = CiscoObject.Xml;
            xml.Visibility = Visibility.Collapsed;

            if (n is Info)
            {
                type.Content = "Info";
                back_color   = Colors.Beige;
                Control      = new CiscoObjectInfoControl((Info)n);
            }
            else if (n is Alert)
            {
                type.Content = "Alert";
                back_color   = Colors.OrangeRed;
                Control      = new CiscoObjectAlertControl((Alert)n);
            }
            else if (n is Execute)
            {
                type.Content = "Execute";
                back_color   = Colors.LightGreen;
                Control      = new CiscoObjectExecuteControl((Execute)n);
            }
            else
            {
                throw new Exception("Unknown type: " + n.GetType());
            }

            Background = new SolidColorBrush(back_color);
            Control.HorizontalAlignment = HorizontalAlignment.Stretch;
            Control.VerticalAlignment   = VerticalAlignment.Top;
            Grid.SetColumn(Control, 1);
            grid.Children.Add(Control);

            delete.Click += (object sender, RoutedEventArgs e) =>
            {
                n.Delete();
                e.Handled = true;
            };

            show_xml.Click += (object sender, RoutedEventArgs e) =>
            {
                e.Handled = true;
            };

            show_xml.Checked += (object sender, RoutedEventArgs e) =>
            {
                e.Handled          = true;
                Control.Visibility = Visibility.Collapsed;
                xml.Visibility     = Visibility.Visible;
            };

            show_xml.Unchecked += (object sender, RoutedEventArgs e) =>
            {
                e.Handled          = true;
                Control.Visibility = Visibility.Visible;
                xml.Visibility     = Visibility.Collapsed;
            };

            activate.Click += (object sender, RoutedEventArgs e) =>
            {
                e.Handled = true;
                CiscoObject.Activate();
            };

            MouseDown += (object sender, MouseButtonEventArgs e) =>
            {
                checkBox.IsChecked = !checkBox.IsChecked;
            };

            checkBox.Checked += (object sender, RoutedEventArgs e) =>
            {
                Color c = Color.FromArgb(255, (byte)(back_color.R * .6), (byte)(back_color.G * .6), (byte)(back_color.B * .6));
                Background = new SolidColorBrush(c);
            };

            checkBox.Unchecked += (object sender, RoutedEventArgs e) =>
            {
                Background = new SolidColorBrush(back_color);
            };

            time.Content = n.CreateTime.ToString("yy-MM-dd HH:mm:ss");
        }
        CiscoObjectsWindow()
        {
            InitializeComponent();

            Icon = WindowRoutines.GetAppIcon();

            //ShowInTaskbar = false;

            IsVisibleChanged += (object sender, DependencyPropertyChangedEventArgs e) =>
            {
                if (Visibility != Visibility.Visible)
                {
                    return;
                }
                show(true);
            };

            Closing += (object sender, System.ComponentModel.CancelEventArgs e) =>
            {
                e.Cancel = true;
                //This.Hide();
                show(false);
            };

            //Closed += (object sender, EventArgs e) =>
            //{
            //    This = null;
            //};

            restore.IsEnabled = false;

            select_all.Click += delegate
            {
                lock (this.cisco_objects.Children)
                {
                    foreach (CiscoObjectControl nc in this.cisco_objects.Children)
                    {
                        nc.checkBox.IsChecked = true;
                    }
                }
            };

            clear_selection.Click += delegate
            {
                lock (this.cisco_objects.Children)
                {
                    foreach (CiscoObjectControl nc in this.cisco_objects.Children)
                    {
                        nc.checkBox.IsChecked = false;
                    }
                }
            };

            delete_selected.Click += delegate
            {
                List <CiscoObject> ns = new List <CiscoObject>();
                lock (this.cisco_objects.Children)
                {
                    foreach (CiscoObjectControl nc in this.cisco_objects.Children)
                    {
                        if (nc.checkBox.IsChecked ?? true)
                        {
                            ns.Add(nc.CiscoObject);
                        }
                    }
                }
                foreach (CiscoObject n in ns)
                {
                    n.Delete();
                }
            };

            restore.Click += delegate
            {
                CiscoObject.RestoreLastDeleted();
            };

            show_infos.Click += delegate
            {
                set_visibility();
            };

            show_alerts.Click += delegate
            {
                set_visibility();
            };

            show_executes.Click += delegate
            {
                set_visibility();
            };

            rtp_records.Click += delegate
            {
                if (string.IsNullOrWhiteSpace(Settings.Default.RtpStreamStorageFolder))
                {
                    return;
                }
                System.Diagnostics.Process.Start(Settings.Default.RtpStreamStorageFolder);
            };
        }