Пример #1
0
        private void RedrawClientSettings()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action(() => { RedrawClientSettings(); }));
                return;
            }

            if (selectedClient == null)
            {
                selectedClient = GetlocalhostInfo();
                if (selectedClient == null)
                {
                    return;
                }
            }

            if (selectedClient.ClientId == Guid.Empty)
            {
                SendClientFileButton.Hide();
            }
            else
            {
                SendClientFileButton.Show();
            }

            ClientSettingsClientNameLabel.Text = selectedClient.ClientName;
            if (selectedClient.Key == null)
            {
                ClientHotkeyButton.Text = "None";
            }
            else
            {
                ClientHotkeyButton.Text = selectedClient.Key.ToString();
            }

            FillComboBoxWithClients(LeftClientListBox, selectedClient, selectedClient.LeftClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.LeftClient);
            FillComboBoxWithClients(RightClientListBox, selectedClient, selectedClient.RightClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.RightClient);
            FillComboBoxWithClients(BelowClientListBox, selectedClient, selectedClient.BelowClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.BelowClient);
            FillComboBoxWithClients(AboveClientListBox, selectedClient, selectedClient.AboveClient == ConnectedClientInfo.None ? ConnectedClientInfo.None : selectedClient.AboveClient);
        }
Пример #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.KeyPreview              = true;
            this.KeyDown                += MainForm_KeyDown;
            ConsoleTextBox.BackColor     = SystemColors.ControlLightLight;
            this.MaximizeBox             = false;
            ISLogger.MessageOut         += ISLogger_MessageOut;
            server.ClientConnected      += Server_ClientConnected;
            server.ClientDisconnected   += Server_ClientDisconnected;
            server.InputClientSwitched  += Server_InputClientSwitched;
            server.ServerStopped        += Server_ServerStopped;
            server.DisplayConfigChanged += Server_DisplayConfigChanged;
            ClientListBox.MouseClick    += ClientListBox_MouseClick;
            LeftClientListBox.SelectionChangeCommitted  += LeftClientListBox_SelectionChangeCommitted;
            RightClientListBox.SelectionChangeCommitted += RightClientListBox_SelectionChangeCommitted;
            AboveClientListBox.SelectionChangeCommitted += AboveClientListBox_SelectionChangeCommitted;
            BelowClientListBox.SelectionChangeCommitted += BelowClientListBox_SelectionChangeCommitted;

            ClientListBox.Hide();
            ClientSettingsPanel.Hide();
            SendClientFileButton.Hide();

            trayIcon = new NotifyIcon();

            try
            {
                trayIcon.Icon = new Icon("TrayIcon.ico");
            }catch (Exception ex)
            {
                ISLogger.Write($"Failed to open TrayIcon.ico");
                ISLogger.Write(ex.Message);
            }

            trayIcon.Visible = true;
            trayIcon.Click  += TrayIcon_Click;
        }
Пример #3
0
        private async void ConfirmCopy_Click(object sender, RoutedEventArgs e)
        {
            // todo: quality: transfer file in chunks with progress bar & cancel option
            ClientFileTextBox.IsEnabled    = false;
            ServerFileTextBox.IsEnabled    = false;
            SendClientFileButton.IsEnabled = false;
            GetServerFileButton.IsEnabled  = false;
            ConfirmTransferFlyout.Hide();
            TranferRing.IsActive = true;
            Stopwatch s = new Stopwatch();

            try
            {
                s.Start();

                if (sending)
                {
                    bool isFile = true;
                    try
                    {
                        await StorageFile.GetFileFromPathAsync(Environment.ExpandEnvironmentVariables(ClientFileTextBox.Text));
                    }
                    catch (Exception)
                    {
                        isFile = false;
                    }

                    if (isFile)
                    {
                        await Client.SendFileToDevice(ClientFileTextBox.Text, ServerFileTextBox.Text, (bool)ContainerCheckBox.IsChecked);
                    }
                    else
                    {
                        await Client.SendDirectoryToDevice(ClientFileTextBox.Text, ServerFileTextBox.Text, (bool)ContainerCheckBox.IsChecked);
                    }
                }
                else
                {
                    try
                    {
                        await Client.GetFileFromDevice(ServerFileTextBox.Text, ClientFileTextBox.Text, (bool)ContainerCheckBox.IsChecked);
                    }
                    catch (FileNotFoundException)
                    {
                        await Client.GetDirectoryFromDevice(ServerFileTextBox.Text, ClientFileTextBox.Text, (bool)ContainerCheckBox.IsChecked);
                    }
                }

                s.Stop();

                ContentDialog errorDialog = new ContentDialog
                {
                    Title           = "Transfer Succeeded!",
                    Content         = $"Transfer completed in {s.Elapsed}",
                    CloseButtonText = "Ok"
                };

                _ = await errorDialog.ShowAsync();
            }
            catch (Exception ex)
            {
                ContentDialog errorDialog = new ContentDialog
                {
                    Title           = "Transfer Error!",
                    Content         = $"{ex.Message}",
                    CloseButtonText = "Ok"
                };

                _ = await errorDialog.ShowAsync();
            }

            ClientFileTextBox.IsEnabled    = true;
            ServerFileTextBox.IsEnabled    = true;
            SendClientFileButton.IsEnabled = true;
            GetServerFileButton.IsEnabled  = true;
            TranferRing.IsActive           = false;
            _ = sending ? SendClientFileButton.Focus(FocusState.Programmatic) : GetServerFileButton.Focus(FocusState.Programmatic);
        }