private void Used_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //allow to edit ports and save that
            InterfaceClass li = null;
            bool           removeInterfaceFromUsed = false;

            foreach (var iface in UsedInterfaces)
            {
                if (iface.ToString().Equals(LBUsed.SelectedItem.ToString()))
                {
                    li = iface;
                    if (LBUsed.SelectedItem != null)
                    {
                        BaseWindow editInterfaceWindow = new BaseWindow()
                        {
                            Owner = MyBaseWindow, MaxHeight = 75, Width = 300
                        };
                        EditInterface editInterface = new EditInterface(ref li, ref editInterfaceWindow);
                        editInterfaceWindow.ClientArea.Content = editInterface;

                        editInterfaceWindow.Closing += new CancelEventHandler(delegate(object o, System.ComponentModel.CancelEventArgs cancelEventArgs) {
                            iface.Ports             = editInterface.getPorts();
                            removeInterfaceFromUsed = !(bool)editInterface.checkBox.IsChecked;
                        });
                        editInterfaceWindow.ShowDialog();
                    }
                    break;
                }
            }
            if (removeInterfaceFromUsed && li != null)
            {
                AvaliableInterfaces.Add(li);
                UsedInterfaces.Remove(li);
            }
        }
Пример #2
0
 private void MIExtensions_Click(object sender, RoutedEventArgs e)
 {
     fileExtensionsWindow = new BaseWindow()
     {
         Owner = this
     };
     fileExtensionsWindow.ClientArea.Content = new FileExtensions(ref UsedExtensions, ref AvaliableExtensions, ref fileExtensionsWindow);
     fileExtensionsWindow.ShowDialog();
 }
Пример #3
0
        public EditInterface(ref InterfaceClass interfaceObj, ref BaseWindow MyBaseWindow)
        {
            InitializeComponent();
            this.MyBaseWindow  = MyBaseWindow;
            MyBaseWindow.Title = "Edycja portów";

            MyBaseWindow.SizeChanged += MyBaseWindow_SizeChanged;

            this.interfaceObj = interfaceObj;
            strIP.Text        = interfaceObj.Addres;
            strPort.Text      = interfaceObj.Ports;
        }
Пример #4
0
        private void MISourceInterfaces_Click(object sender, RoutedEventArgs e)
        {
            networkSettingsWindow = new BaseWindow()
            {
                Owner = this
            };
            networkSettingsWindow.ClientArea.Content = new NetworkSettings(ref UsedInterfaces, ref AvaliableInterfaces, ref networkSettingsWindow);
            //stop sniffer
            if (MISniff.IsChecked)
            {
                MISniff.IsChecked = false;
                MISniff_Click(this, e);
            }

            networkSettingsWindow.ShowDialog();
        }
Пример #5
0
        public FileExtensions(ref ObservableCollection <FileExtensionClass> UsedExtensions, ref ObservableCollection <FileExtensionClass> AvaliableExtensions, ref BaseWindow MyBaseWindow)
        {
            InitializeComponent();

            this._AvaliableExtensions = AvaliableExtensions;
            this._UsedExtensions      = UsedExtensions;

            MyBaseWindow.Title = "Rozszerzenia plików";
            this.MyBaseWindow  = MyBaseWindow;

            MyBaseWindow.SizeChanged += MyBaseWindow_SizeChanged;
            MyBaseWindow.Closing     += MyBaseWindow_Closing;

            new ListViewDragDropManager <FileExtensionClass>(LBAvaliable);
            new ListViewDragDropManager <FileExtensionClass>(LBUsed);

            this.DataContext = this;
        }
        public NetworkSettings(ref ObservableCollection <InterfaceClass> UsedInterfaces, ref ObservableCollection <InterfaceClass> AvaliableInterfaces, ref BaseWindow MyBaseWindow)
        {
            InitializeComponent();
            this._UsedInterfaces      = UsedInterfaces;
            this._AvaliableInterfaces = AvaliableInterfaces;
            this.MyBaseWindow         = MyBaseWindow;
            MyBaseWindow.Title        = "Interfejsy sieciowe";

            MyBaseWindow.SizeChanged += MyBaseWindow_SizeChanged;


            List <string> networkInterfaces = new List <string>();

            /*
             * string strIP = null;
             * IPHostEntry HosyEntry = Dns.GetHostEntry((Dns.GetHostName()));
             * if (HosyEntry.AddressList.Length > 0) {
             *  foreach (IPAddress ip in HosyEntry.AddressList) {
             *      if (ip.AddressFamily == AddressFamily.InterNetwork) {
             *          networkInterfaces.Add(strIP);
             *          if (!this.AvaliableInterfaces.Any(x => x.Addres.Equals(strIP)) && !this.UsedInterfaces.Any(x => x.Addres.Equals(strIP)))
             *              this.AvaliableInterfaces.Add(new InterfaceClass(strIP, ""));
             *      }
             *  }
             * }*/


            foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback && adapter.OperationalStatus == OperationalStatus.Up)
                {
                    foreach (UnicastIPAddressInformation ip in adapter.GetIPProperties().UnicastAddresses)
                    {
                        if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
                        {
                            networkInterfaces.Add(ip.Address.ToString());
                            if (!this.AvaliableInterfaces.Any(x => x.Addres.Equals(ip.Address.ToString())) && !this.UsedInterfaces.Any(x => x.Addres.Equals(ip.Address.ToString())))
                            {
                                this.AvaliableInterfaces.Add(new InterfaceClass(ip.Address.ToString(), ""));
                            }
                        }
                    }
                }
            }

            foreach (var interfaceObj in this.UsedInterfaces)
            {
                if (networkInterfaces.Contains(interfaceObj.Addres))
                {
                    interfaceObj.InterfaceIsUp = true;
                }
                else
                {
                    interfaceObj.InterfaceIsUp = false;
                }
            }
            foreach (var interfaceObj in this.AvaliableInterfaces)
            {
                if (networkInterfaces.Contains(interfaceObj.Addres))
                {
                    interfaceObj.InterfaceIsUp = true;
                }
                else
                {
                    interfaceObj.InterfaceIsUp = false;
                }
            }



            new ListViewDragDropManager <InterfaceClass>(LBAvaliable);
            new ListViewDragDropManager <InterfaceClass>(LBUsed);


            this.DataContext = this;
        }