Inheritance: ManagerBase
Ejemplo n.º 1
0
        public ProfileWindow(ProfileItem profileItem, OutoposManager outoposManager, BufferManager bufferManager)
        {
            _profileItem = profileItem;
            _outoposManager = outoposManager;
            _bufferManager = bufferManager;

            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            _wikiTextBox.MaxLength = Wiki.MaxNameLength;
            _chatTextBox.MaxLength = Chat.MaxNameLength;

            lock (_profileItem.ThisLock)
            {
                _uploadSignature = _profileItem.UploadSignature;
                _signatureCollection.AddRange(_profileItem.TrustSignatures);
                _wikiCollection.AddRange(_profileItem.Wikis);
                _chatCollection.AddRange(_profileItem.Chats);
            }

            _signatureListView.ItemsSource = _signatureCollection;
            _wikiListView.ItemsSource = _wikiCollection;
            _chatListView.ItemsSource = _chatCollection;

            _signatureComboBox.ItemsSource = digitalSignatureCollection;

            this.Sort();
        }
        public DownloadControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewModelCollection;

            _showDownloadItemThread = new Thread(this.ShowDownloadItem);
            _showDownloadItemThread.Priority = ThreadPriority.Highest;
            _showDownloadItemThread.IsBackground = true;
            _showDownloadItemThread.Name = "DownloadControl_ShowDownloadItemThread";
            _showDownloadItemThread.Start();

            _watchThread = new Thread(this.Watch);
            _watchThread.Priority = ThreadPriority.Highest;
            _watchThread.IsBackground = true;
            _watchThread.Name = "DownloadControl_WatchThread";
            _watchThread.Start();

            _searchRowDefinition.Height = new GridLength(0);

            LanguagesManager.UsingLanguageChangedEvent += this.LanguagesManager_UsingLanguageChangedEvent;
        }
Ejemplo n.º 3
0
        public LinkControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            _trustSignatureListView.ItemsSource = _trustSignatureCollection;
            _untrustSignatureListView.ItemsSource = _untrustSignatureCollection;

            this.Sort();

            _watchThread = new Thread(this.WatchThread);
            _watchThread.Priority = ThreadPriority.Highest;
            _watchThread.IsBackground = true;
            _watchThread.Name = "LinkControl_WatchThread";
            _watchThread.Start();

            _mainWindow._tabControl.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
            {
                if (e.OriginalSource != _mainWindow._tabControl) return;

                if (_mainWindow.SelectedTab == MainWindowTabType.Link)
                {
                    this.Update();
                }
            };

            _searchRowDefinition.Height = new GridLength(0);
        }
Ejemplo n.º 4
0
        public BitmapManager(string bitmapPath, BufferManager bufferManager)
        {
            _bitmapStream = new FileStream(bitmapPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
            _bufferManager = bufferManager;

            _cacheBuffer = _bufferManager.TakeBuffer(BitmapManager.SectorSize);

            _settings = new Settings(this.ThisLock);
        }
        public OverlayNetworkManager(OutoposManager outoposManager, BufferManager bufferManager)
        {
            _outoposManager = outoposManager;
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _outoposManager.CreateCapEvent = this.CreateCap;
            _outoposManager.AcceptCapEvent = this.AcceptCap;
        }
        public OverlayNetworkManager(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            _settings = new Settings();

            _amoebaManager.CreateCapEvent = this.CreateCap;
            _amoebaManager.AcceptCapEvent = this.AcceptCap;
        }
Ejemplo n.º 7
0
        public DownloadManager(ConnectionsManager connectionsManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _connectionsManager = connectionsManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _settings = new Settings();

            _threadCount = Math.Max(1, Math.Min(System.Environment.ProcessorCount, 32) / 2);

            _cacheManager.BlockSetEvents += this.BlockSetThread;
            _cacheManager.BlockRemoveEvents += this.BlockRemoveThread;
        }
Ejemplo n.º 8
0
        public ShareControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewItemCollection;

            _showShareItemThread = new Thread(ShowShareItem);
            _showShareItemThread.Priority = ThreadPriority.Highest;
            _showShareItemThread.IsBackground = true;
            _showShareItemThread.Name = "ShareControl_ShowShareItemThread";
            _showShareItemThread.Start();
        }
Ejemplo n.º 9
0
        public UploadControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewItemCollection;

            _showUploadItemThread = new Thread(this.ShowUploadItem);
            _showUploadItemThread.Priority = ThreadPriority.Highest;
            _showUploadItemThread.IsBackground = true;
            _showUploadItemThread.Name = "UploadControl_ShowUploadItemThread";
            _showUploadItemThread.Start();

            LanguagesManager.UsingLanguageChangedEvent += this.LanguagesManager_UsingLanguageChangedEvent;
        }
Ejemplo n.º 10
0
        public StoreControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _amoebaManager = amoebaManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            StoreDownloadControl storeDownloadControl = new StoreDownloadControl(this, _amoebaManager, _bufferManager);
            storeDownloadControl.Height = Double.NaN;
            storeDownloadControl.Width = Double.NaN;
            _storeDownloadTabItem.Content = storeDownloadControl;

            StoreUploadControl storeUploadControl = new StoreUploadControl(this, _amoebaManager, _bufferManager);
            storeUploadControl.Height = Double.NaN;
            storeUploadControl.Width = Double.NaN;
            _storeUploadTabItem.Content = storeUploadControl;

            LibraryControl libraryControl = new LibraryControl(this, _amoebaManager, _bufferManager);
            libraryControl.Height = Double.NaN;
            libraryControl.Width = Double.NaN;
            _libraryTabItem.Content = libraryControl;
        }
        public InformationControl(AmoebaManager amoebaManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;

            InitializeComponent();

            _listView.ItemsSource = _listViewItemCollection;

            #if DEBUG
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_BufferManagerSize" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());
            #endif

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_SentByteCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_ReceivedByteCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_CreateConnectionCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_AcceptConnectionCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_BlockedConnectionCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_SurroundingNodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_RelayBlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_LockSpace" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_FreeSpace" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_UsingSpace" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_NodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_SeedCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_BlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_DownloadCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_UploadCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_ShareCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushNodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushBlockLinkCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushBlockRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushBlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushSeedRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PushSeedCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem());

            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullNodeCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullBlockLinkCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullBlockRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullBlockCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullSeedRequestCount" });
            _infomationListViewItemCollection.Add(new AmoebaInfomationListViewItem() { Id = "InformationControl_PullSeedCount" });

            _infomationListView.ItemsSource = _infomationListViewItemCollection;

            _showAmoebaInfomationThread = new Thread(this.ShowAmoebaInfomation);
            _showAmoebaInfomationThread.Priority = ThreadPriority.Highest;
            _showAmoebaInfomationThread.IsBackground = true;
            _showAmoebaInfomationThread.Name = "InformationControl_ShowAmoebaInfomationThread";
            _showAmoebaInfomationThread.Start();

            _showConnectionInfomationwThread = new Thread(this.ShowConnectionInfomation);
            _showConnectionInfomationwThread.Priority = ThreadPriority.Highest;
            _showConnectionInfomationwThread.IsBackground = true;
            _showConnectionInfomationwThread.Name = "InformationControl_ShowConnectionInfomationThread";
            _showConnectionInfomationwThread.Start();
        }
Ejemplo n.º 12
0
        //#endif
        public ConnectionsManager(ClientManager clientManager, ServerManager serverManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _clientManager = clientManager;
            _serverManager = serverManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _routeTable = new Kademlia<Node>(512, 20);

            _connectionManagers = new LockedList<ConnectionManager>();

            _messagesManager = new MessagesManager();
            _messagesManager.GetLockNodesEvent = (object sender) =>
            {
                lock (this.ThisLock)
                {
                    return _connectionManagers.Select(n => n.Node).ToArray();
                }
            };

            _creatingNodes = new LockedList<Node>();

            _waitingNodes = new VolatileHashSet<Node>(new TimeSpan(0, 0, 30));
            _cuttingNodes = new VolatileHashSet<Node>(new TimeSpan(0, 10, 0));
            _removeNodes = new VolatileHashSet<Node>(new TimeSpan(0, 30, 0));

            _succeededUris = new VolatileHashSet<string>(new TimeSpan(1, 0, 0));

            _downloadBlocks = new VolatileHashSet<Key>(new TimeSpan(0, 30, 0));
            _pushBroadcastSignaturesRequestList = new VolatileHashSet<string>(new TimeSpan(0, 3, 0));
            _pushUnicastSignaturesRequestList = new VolatileHashSet<string>(new TimeSpan(0, 3, 0));
            _pushMulticastWikisRequestList = new VolatileHashSet<Wiki>(new TimeSpan(0, 3, 0));
            _pushMulticastChatsRequestList = new VolatileHashSet<Chat>(new TimeSpan(0, 3, 0));

            _relayBlocks = new VolatileHashSet<Key>(new TimeSpan(0, 30, 0));

            _refreshTimer = new WatchTimer(this.RefreshTimer, new TimeSpan(0, 0, 5));
        }
Ejemplo n.º 13
0
        public OptionsWindow(AmoebaManager amoebaManager, ConnectionSettingManager connectionSettingManager, OverlayNetworkManager overlayNetworkManager, TransfarLimitManager transfarLimitManager, BufferManager bufferManager)
        {
            _bufferManager = bufferManager;
            _amoebaManager = amoebaManager;
            _connectionSettingManager = connectionSettingManager;
            _overlayNetworkManager = overlayNetworkManager;
            _transferLimitManager = transfarLimitManager;

            InitializeComponent();

            _baseNodeTextBox.MaxLength = UriCollection.MaxUriLength;

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            {
                foreach (var item in Enum.GetValues(typeof(ConnectionType)).Cast<ConnectionType>())
                {
                    _clientFiltersConnectionTypeComboBox.Items.Add(item);
                }

                foreach (var item in Enum.GetValues(typeof(TransferLimitType)).Cast<TransferLimitType>())
                {
                    _transferLimitTypeComboBox.Items.Add(item);
                }

                foreach (var u in new string[] { "Byte", "KB", "MB", "GB", "TB" })
                {
                    _dataCacheSizeComboBox.Items.Add(u);
                }

                _dataCacheSizeComboBox.SelectedItem = Settings.Instance.OptionsWindow_DataCacheSize_Unit;

                foreach (var u in new string[] { "Byte", "KB", "MB", "GB", })
                {
                    _bandwidthLimitComboBox.Items.Add(u);
                }

                _bandwidthLimitComboBox.SelectedItem = Settings.Instance.OptionsWindow_BandwidthLimit_Unit;

                foreach (var u in new string[] { "Byte", "KB", "MB", "GB", })
                {
                    _transferLimitSizeComboBox.Items.Add(u);
                }

                _transferLimitSizeComboBox.SelectedItem = Settings.Instance.OptionsWindow_TransferLimit_Unit;
            }

            {
                lock (_amoebaManager.ThisLock)
                {
                    var baseNode = _amoebaManager.BaseNode;

                    _baseNode_Id = baseNode.Id;
                    _baseNode_Uris.AddRange(baseNode.Uris);
                    _otherNodes.AddRange(_amoebaManager.OtherNodes);
                    _clientFilters.AddRange(_amoebaManager.Filters);
                    _serverListenUris.AddRange(_amoebaManager.ListenUris);

                    try
                    {
                        _dataCacheSizeTextBox.Text = NetworkConverter.ToSizeString(_amoebaManager.Size, Settings.Instance.OptionsWindow_DataCacheSize_Unit);
                    }
                    catch (Exception)
                    {
                        _dataCacheSizeTextBox.Text = "";
                    }

                    _dataDownloadDirectoryTextBox.Text = _amoebaManager.DownloadDirectory;

                    _bandwidthConnectionCountTextBox.Text = _amoebaManager.ConnectionCountLimit.ToString();

                    try
                    {
                        _bandwidthLimitTextBox.Text = NetworkConverter.ToSizeString(_amoebaManager.BandwidthLimit, Settings.Instance.OptionsWindow_BandwidthLimit_Unit);
                    }
                    catch (Exception)
                    {
                        _bandwidthLimitTextBox.Text = "";
                    }
                }

                _baseNodeUrisListView.ItemsSource = _baseNode_Uris;
                _baseNodeUpdate();

                _otherNodesListView.ItemsSource = _otherNodes;
                _otherNodesUpdate();

                _clientFiltersListView.ItemsSource = _clientFilters;
                _clientFiltersListViewUpdate();

                _serverListenUrisListView.ItemsSource = _serverListenUris;
                _serverListenUrisUpdate();
            }

            {
                lock (_transferLimitManager.TransferLimit.ThisLock)
                {
                    _transferLimitTypeComboBox.SelectedItem = _transferLimitManager.TransferLimit.Type;
                    _transferLimitSpanTextBox.Text = _transferLimitManager.TransferLimit.Span.ToString();

                    try
                    {
                        _transferLimitSizeTextBox.Text = NetworkConverter.ToSizeString(_transferLimitManager.TransferLimit.Size, Settings.Instance.OptionsWindow_TransferLimit_Unit);
                    }
                    catch (Exception)
                    {
                        _transferLimitSizeTextBox.Text = "";
                    }
                }

                {
                    var uploadSize = _transferLimitManager.TotalUploadSize;
                    var downloadSize = _transferLimitManager.TotalDownloadSize;

                    _transferInfoUploadedLabel.Content = NetworkConverter.ToSizeString(uploadSize);
                    _transferInfoDownloadedLabel.Content = NetworkConverter.ToSizeString(downloadSize);
                    _transferInfoTotalLabel.Content = NetworkConverter.ToSizeString(uploadSize + downloadSize);
                }
            }

            {
                _eventOpenPortAndGetIpAddressCheckBox.IsChecked = Settings.Instance.Global_ConnectionSetting_IsEnabled;
                _eventUseI2pCheckBox.IsChecked = Settings.Instance.Global_I2p_SamBridge_IsEnabled;

                {
                    _eventSamBridgeUriTextBox.Text = _overlayNetworkManager.SamBridgeUri;
                }
            }

            {
                _updateUrlTextBox.Text = Settings.Instance.Global_Update_Url;
                _updateProxyUriTextBox.Text = Settings.Instance.Global_Update_ProxyUri;
                _updateSignatureTextBox.Text = Settings.Instance.Global_Update_Signature;

                if (Settings.Instance.Global_Update_Option == UpdateOption.None)
                {
                    _updateOptionNoneRadioButton.IsChecked = true;
                }
                else if (Settings.Instance.Global_Update_Option == UpdateOption.Check)
                {
                    _updateOptionAutoCheckRadioButton.IsChecked = true;
                }
                else if (Settings.Instance.Global_Update_Option == UpdateOption.Update)
                {
                    _updateOptionAutoUpdateRadioButton.IsChecked = true;
                }
            }

            {
                _signatureListViewItemCollection.AddRange(Settings.Instance.Global_DigitalSignatures.Select(n => new SignatureListViewItem(n)));
                _signatureListView.ItemsSource = _signatureListViewItemCollection;
                _signatureListViewUpdate();
            }

            {
                _keywordCollection.AddRange(Settings.Instance.Global_SearchKeywords);
                _keywordListView.ItemsSource = _keywordCollection;
                _keywordListViewUpdate();
            }

            {
                try
                {
                    string extension = ".box";
                    string commandline = "\"" + Path.GetFullPath(Path.Combine(_serviceManager.Paths["Core"], "Amoeba.exe")) + "\" \"%1\"";
                    string fileType = "Amoeba";
                    string verb = "open";

                    using (var regkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(extension))
                    {
                        if (fileType != (string)regkey.GetValue("")) throw new Exception();
                    }

                    using (var shellkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(fileType))
                    {
                        using (var shellkey2 = shellkey.OpenSubKey("shell\\" + verb))
                        {
                            using (var shellkey3 = shellkey2.OpenSubKey("command"))
                            {
                                if (commandline != (string)shellkey3.GetValue("")) throw new Exception();
                            }
                        }
                    }

                    Settings.Instance.Global_RelateBoxFile_IsEnabled = true;
                    _boxRelateFileCheckBox.IsChecked = true;
                }
                catch
                {
                    Settings.Instance.Global_RelateBoxFile_IsEnabled = false;
                    _boxRelateFileCheckBox.IsChecked = false;
                }

                _boxOpenCheckBox.IsChecked = Settings.Instance.Global_OpenBox_IsEnabled;
                _boxExtractToTextBox.Text = Settings.Instance.Global_BoxExtractTo_Path;
            }

            {
                _MiningTimeTextBox.Text = Settings.Instance.Global_MiningTime.TotalMinutes.ToString();
            }

            {
                _fontMessageFontFamilyComboBoxItemCollection.AddRange(Fonts.SystemFontFamilies.Select(n => n.ToString()));
                _fontMessageFontFamilyComboBoxItemCollection.Sort();
                _fontMessageFontFamilyComboBox.ItemsSource = _fontMessageFontFamilyComboBoxItemCollection;
                _fontMessageFontFamilyComboBox.SelectedItem = Settings.Instance.Global_Fonts_Message_FontFamily;

                _fontMessageFontSizeTextBox.Text = Settings.Instance.Global_Fonts_Message_FontSize.ToString();
            }
        }
Ejemplo n.º 14
0
        public MainWindow()
        {
            try
            {
                var sw = new Stopwatch();
                sw.Start();

                _bufferManager = BufferManager.Instance;

                _configrationDirectoryPaths.Add("Settings", Path.Combine(_serviceManager.Paths["Configuration"], @"Settings"));
                _configrationDirectoryPaths.Add("AmoebaManager", Path.Combine(_serviceManager.Paths["Configuration"], @"AmoebaManager"));
                _configrationDirectoryPaths.Add("ConnectionSettingManager", Path.Combine(_serviceManager.Paths["Configuration"], @"ConnectionSettingManager"));
                _configrationDirectoryPaths.Add("OverlayNetworkManager", Path.Combine(_serviceManager.Paths["Configuration"], @"OverlayNetworkManager"));
                _configrationDirectoryPaths.Add("TransfarLimitManager", Path.Combine(_serviceManager.Paths["Configuration"], @"TransfarLimitManager"));
                _configrationDirectoryPaths.Add("CatharsisManager", Path.Combine(_serviceManager.Paths["Configuration"], @"CatharsisManager"));

                Settings.Instance.Load(_configrationDirectoryPaths["Settings"]);

                InitializeComponent();

                this.Setting_Log();

                this.Title = string.Format("Amoeba {0}", _serviceManager.AmoebaVersion);

                {
                    var icon = new BitmapImage();

                    icon.BeginInit();
                    icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    icon.EndInit();
                    if (icon.CanFreeze) icon.Freeze();

                    this.Icon = icon;
                }

                var myIcon = new System.Drawing.Icon(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"));
                _notifyIcon.Icon = new System.Drawing.Icon(myIcon, new System.Drawing.Size(16, 16));
                _notifyIcon.Visible = true;

                this.Setting_Init();
                this.Setting_Languages();

                _notifyIcon.Visible = false;
                _notifyIcon.Click += (object sender2, EventArgs e2) =>
                {
                    if (_closed) return;

                    try
                    {
                        this.Show();
                        this.Activate();
                        this.WindowState = _windowState;

                        _notifyIcon.Visible = false;
                    }
                    catch (Exception)
                    {

                    }
                };

                _timerThread = new Thread(this.TimerThread);
                _timerThread.Priority = ThreadPriority.Lowest;
                _timerThread.Name = "MainWindow_TimerThread";
                _timerThread.Start();

                _statusBarThread = new Thread(this.StatusBarThread);
                _statusBarThread.Priority = ThreadPriority.Highest;
                _statusBarThread.Name = "MainWindow_StatusBarThread";
                _statusBarThread.Start();

                _trafficMonitorThread = new Thread(this.TrafficMonitorThread);
                _trafficMonitorThread.Priority = ThreadPriority.Highest;
                _trafficMonitorThread.Name = "MainWindow_TrafficMonitorThread";
                _trafficMonitorThread.Start();

                _transferLimitManager.StartEvent += _transferLimitManager_StartEvent;
                _transferLimitManager.StopEvent += _transferLimitManager_StopEvent;

            #if !DEBUG
                _logRowDefinition.Height = new GridLength(0);
            #endif

                sw.Stop();
                Debug.WriteLine("StartUp {0}", sw.ElapsedMilliseconds);
            }
            catch (Exception e)
            {
                Log.Error(e);

                throw;
            }
        }
Ejemplo n.º 15
0
        public MainWindow()
        {
            try
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                _bufferManager = BufferManager.Instance;

                this.Setting_Log();

                _configrationDirectoryPaths.Add("MainWindow", Path.Combine(App.DirectoryPaths["Configuration"], @"Outopos/Properties/Settings"));
                _configrationDirectoryPaths.Add("OutoposManager", Path.Combine(App.DirectoryPaths["Configuration"], @"Library/Net/Outopos/OutoposManager"));
                _configrationDirectoryPaths.Add("AutoBaseNodeSettingManager", Path.Combine(App.DirectoryPaths["Configuration"], @"Outopos/AutoBaseNodeSettingManager"));
                _configrationDirectoryPaths.Add("OverlayNetworkManager", Path.Combine(App.DirectoryPaths["Configuration"], @"Outopos/OverlayNetworkManager"));
                _configrationDirectoryPaths.Add("TransfarLimitManager", Path.Combine(App.DirectoryPaths["Configuration"], @"Outopos/TransfarLimitManager"));
                _configrationDirectoryPaths.Add("CatharsisManager", Path.Combine(App.DirectoryPaths["Configuration"], @"Outopos/CatharsisManager"));

                Settings.Instance.Load(_configrationDirectoryPaths["MainWindow"]);

                InitializeComponent();

                this.Title = string.Format("Outopos {0}", App.OutoposVersion);

                {
                    var icon = new BitmapImage();

                    icon.BeginInit();
                    icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Outopos.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    icon.EndInit();
                    if (icon.CanFreeze) icon.Freeze();

                    this.Icon = icon;
                }

                // World
                {
                    var bitmap = new BitmapImage();

                    bitmap.BeginInit();
                    bitmap.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], @"Tabs\World.png"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    bitmap.EndInit();
                    if (bitmap.CanFreeze) bitmap.Freeze();

                    _worldRadioButton.Content = new Image() { Source = bitmap, Height = 32, Width = 32 };
                }

                // Wiki
                {
                    var bitmap = new BitmapImage();

                    bitmap.BeginInit();
                    bitmap.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], @"Tabs\Wiki.png"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    bitmap.EndInit();
                    if (bitmap.CanFreeze) bitmap.Freeze();

                    _wikiRadioButton.Content = new Image() { Source = bitmap, Height = 32, Width = 32 };
                }

                // Chat
                {
                    var bitmap = new BitmapImage();

                    bitmap.BeginInit();
                    bitmap.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], @"Tabs\Chat.png"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    bitmap.EndInit();
                    if (bitmap.CanFreeze) bitmap.Freeze();

                    _chatRadioButton.Content = new Image() { Source = bitmap, Height = 32, Width = 32 };
                }

                // Mail
                {
                    var bitmap = new BitmapImage();

                    bitmap.BeginInit();
                    bitmap.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], @"Tabs\Mail.png"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    bitmap.EndInit();
                    if (bitmap.CanFreeze) bitmap.Freeze();

                    _mailRadioButton.Content = new Image() { Source = bitmap, Height = 32, Width = 32 };
                }

                // Profile
                {
                    var bitmap = new BitmapImage();

                    bitmap.BeginInit();
                    bitmap.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], @"Tabs\Profile.png"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    bitmap.EndInit();
                    if (bitmap.CanFreeze) bitmap.Freeze();

                    _profileButton.Content = new Image() { Source = bitmap, Height = 32, Width = 32 };
                }

                // Options
                {
                    var bitmap = new BitmapImage();

                    bitmap.BeginInit();
                    bitmap.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], @"Tabs\Options.png"), FileMode.Open, FileAccess.Read, FileShare.Read);
                    bitmap.EndInit();
                    if (bitmap.CanFreeze) bitmap.Freeze();

                    _optionsButton.Content = new Image() { Source = bitmap, Height = 32, Width = 32 };
                }

                System.Drawing.Icon myIcon = new System.Drawing.Icon(Path.Combine(App.DirectoryPaths["Icons"], "Outopos.ico"));
                _notifyIcon.Icon = new System.Drawing.Icon(myIcon, new System.Drawing.Size(16, 16));
                _notifyIcon.Visible = true;

                this.Setting_Init();

                _notifyIcon.Visible = false;
                _notifyIcon.Click += (object sender2, EventArgs e2) =>
                {
                    if (_closed) return;

                    try
                    {
                        this.Show();
                        this.Activate();
                        this.WindowState = _windowState;

                        _notifyIcon.Visible = false;
                    }
                    catch (Exception)
                    {

                    }
                };

                _timerThread = new Thread(this.TimerThread);
                _timerThread.Priority = ThreadPriority.Lowest;
                _timerThread.Name = "MainWindow_TimerThread";
                _timerThread.Start();

                _statusBarThread = new Thread(this.StatusBarThread);
                _statusBarThread.Priority = ThreadPriority.Highest;
                _statusBarThread.Name = "MainWindow_StatusBarThread";
                _statusBarThread.Start();

                _trafficMonitorThread = new Thread(this.TrafficMonitorThread);
                _trafficMonitorThread.Priority = ThreadPriority.Highest;
                _trafficMonitorThread.Name = "MainWindow_TrafficMonitorThread";
                _trafficMonitorThread.Start();

                Debug.WriteLineIf(System.Runtime.GCSettings.IsServerGC, "GCSettings.IsServerGC");

                sw.Stop();
                Debug.WriteLine("StartUp {0}", sw.ElapsedMilliseconds);
            }
            catch (Exception e)
            {
                Log.Error(e);

                throw;
            }
        }
Ejemplo n.º 16
0
 internal SafeBuffer(BufferManager bufferManager, byte[] value)
 {
     _bufferManager = bufferManager;
     _value = value;
 }
Ejemplo n.º 17
0
        public OptionsWindow(OutoposManager outoposManager, AutoBaseNodeSettingManager autoBaseNodeSettingManager, OverlayNetworkManager overlayNetworkManager, BufferManager bufferManager)
        {
            _outoposManager = outoposManager;
            _autoBaseNodeSettingManager = autoBaseNodeSettingManager;
            _overlayNetworkManager = overlayNetworkManager;
            _bufferManager = bufferManager;

            InitializeComponent();

            _baseNodeTextBox.MaxLength = UriCollection.MaxUriLength;

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Outopos.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            foreach (var item in Enum.GetValues(typeof(ConnectionType)).Cast<ConnectionType>())
            {
                _clientFiltersConnectionTypeComboBox.Items.Add(item);
            }

            foreach (var u in new string[] { "Byte", "KB", "MB", "GB", "TB" })
            {
                _dataCacheSizeComboBox.Items.Add(u);
            }

            _dataCacheSizeComboBox.SelectedItem = Settings.Instance.OptionsWindow_DataCacheSize_Unit;

            foreach (var u in new string[] { "Byte", "KB", "MB", "GB", })
            {
                _bandwidthLimitComboBox.Items.Add(u);
            }

            _bandwidthLimitComboBox.SelectedItem = Settings.Instance.OptionsWindow_BandwidthLimit_Unit;

            lock (_outoposManager.ThisLock)
            {
                var baseNode = _outoposManager.BaseNode;

                _baseNode_Id = baseNode.Id;
                _baseNode_Uris = new ObservableCollectionEx<string>(baseNode.Uris);
                _otherNodes = new ObservableCollectionEx<Node>(_outoposManager.OtherNodes);
                _clientFilters = new ObservableCollectionEx<ConnectionFilter>(_outoposManager.Filters.Select(n => n.Clone()));
                _serverListenUris = new ObservableCollectionEx<string>(_outoposManager.ListenUris);

                try
                {
                    _dataCacheSizeTextBox.Text = NetworkConverter.ToSizeString(_outoposManager.Size, Settings.Instance.OptionsWindow_DataCacheSize_Unit);
                }
                catch (Exception)
                {
                    _dataCacheSizeTextBox.Text = "";
                }

                _bandwidthConnectionCountTextBox.Text = _outoposManager.ConnectionCountLimit.ToString();

                try
                {
                    _bandwidthLimitTextBox.Text = NetworkConverter.ToSizeString(_outoposManager.BandwidthLimit, Settings.Instance.OptionsWindow_BandwidthLimit_Unit);
                }
                catch (Exception)
                {
                    _bandwidthLimitTextBox.Text = "";
                }
            }

            _baseNodeUrisListView.ItemsSource = _baseNode_Uris;
            _otherNodesListView.ItemsSource = _otherNodes;
            _clientFiltersListView.ItemsSource = _clientFilters;
            _serverListenUrisListView.ItemsSource = _serverListenUris;

            _baseNodeUpdate();
            _otherNodesUpdate();
            _clientFiltersListViewUpdate();
            _serverListenUrisUpdate();

            _eventOpenPortAndGetIpAddressCheckBox.IsChecked = Settings.Instance.Global_AutoBaseNodeSetting_IsEnabled;
            _eventUseI2pCheckBox.IsChecked = Settings.Instance.Global_I2p_SamBridge_IsEnabled;

            lock (_overlayNetworkManager.ThisLock)
            {
                _eventSamBridgeUriTextBox.Text = _overlayNetworkManager.SamBridgeUri;
            }

            _updateUrlTextBox.Text = Settings.Instance.Global_Update_Url;
            _updateProxyUriTextBox.Text = Settings.Instance.Global_Update_ProxyUri;
            _updateSignatureTextBox.Text = Settings.Instance.Global_Update_Signature;

            if (Settings.Instance.Global_Update_Option == UpdateOption.None)
            {
                _updateOptionNoneRadioButton.IsChecked = true;
            }
            else if (Settings.Instance.Global_Update_Option == UpdateOption.AutoCheck)
            {
                _updateOptionAutoCheckRadioButton.IsChecked = true;
            }
            else if (Settings.Instance.Global_Update_Option == UpdateOption.AutoUpdate)
            {
                _updateOptionAutoUpdateRadioButton.IsChecked = true;
            }

            _languageComboBoxItemCollection = new ObservableCollectionEx<LanguageComboBoxItem>(LanguagesManager.Instance.Languages.Select(n => new LanguageComboBoxItem(n)));
            _languageComboBox.ItemsSource = _languageComboBoxItemCollection;
            _languagesComboBoxUpdate();

            _signatureListViewItemCollection = new ObservableCollectionEx<SignatureListViewItem>(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new SignatureListViewItem(n)));
            _signatureListView.ItemsSource = _signatureListViewItemCollection;
            _signatureListViewUpdate();

            _fontMessageFontFamilyComboBoxItemCollection.AddRange(Fonts.SystemFontFamilies.Select(n => n.ToString()));
            _fontMessageFontFamilyComboBox.ItemsSource = _fontMessageFontFamilyComboBoxItemCollection;
            _fontMessageFontFamilyComboBox.SelectedItem = Settings.Instance.Global_Fonts_MessageFontFamily;

            _fontMessageFontSizeTextBox.Text = Settings.Instance.Global_Fonts_MessageFontSize.ToString();

            _amoebaPathTextBox.Text = Settings.Instance.Global_Amoeba_Path;
        }