예제 #1
0
 private async void UploadVideo_Click(object sender, EventArgs e)
 {
     if (video_token == null)
     {
         wrapper.Controls.Remove(txbLink);
         string state = rbPrivate.Checked ? "private" : (rbPublic.Checked ? "public" : "unlisted");
         wrapper.Controls.Add(bar, 0, 2);
         bar.Value      = 0;
         video_token    = new CancellationTokenSource();
         btnUpload.Text = L18n.Get("OtherHelper", "Text_cancel");
         try
         {
             await YouTube.Upload(this, label.Text, state, video_token.Token);
         }
         catch (OperationCanceledException) { }
         finally
         {
             video_token = null;
             wrapper.Controls.Remove(bar);
             btnUpload.Text = L18n.Get("OtherHelper", "Text_upload");
         }
     }
     else
     {
         video_token.Cancel();
         video_token = null;
     }
 }
        public DiagnosticsWindow()
        {
            InitializeComponent();
            #region Localizing
            this.Text = L18n.Get("DiagnosticsWindow", "DiagnosticsWindow_name");
            this.Tab_SystemInfo.Text   = L18n.Get("DiagnosticsWindow", "Tab_SystemInfo");
            this.Tab_Flash_Player.Text = L18n.Get("DiagnosticsWindow", "Tab_Flash_Player");
            this.Tab_Network.Text      = L18n.Get("DiagnosticsWindow", "Tab_Network");

            this.forProcessor.Text        = L18n.Get("DiagnosticsWindow", "Label_forProcessor");
            this.forMemory.Text           = L18n.Get("DiagnosticsWindow", "Label_forMemory");
            this.forGraphics.Text         = L18n.Get("DiagnosticsWindow", "Label_forGraphics");
            this.forDriver.Text           = L18n.Get("DiagnosticsWindow", "Label_forDriver");
            this.forOS.Text               = L18n.Get("DiagnosticsWindow", "Label_forOS");
            this.forResolution.Text       = L18n.Get("DiagnosticsWindow", "Label_forResolution");
            this.forIpAddress.Text        = L18n.Get("DiagnosticsWindow", "Label_forIpAddress");
            this.btnCheckFlash.Text       = L18n.Get("DiagnosticsWindow", "Button_btnCheckFlash");
            this.btnCheckPorts.Text       = L18n.Get("DiagnosticsWindow", "Button_btnCheckPorts");
            this.btnPing.Text             = L18n.Get("DiagnosticsWindow", "Button_btnPing");
            this.btnTrace.Text            = L18n.Get("DiagnosticsWindow", "Button_btnTrace");
            this.labelNetworkResults.Text = L18n.Get("DiagnosticsWindow", "Label_labelNetworkResults");
            #endregion ;
            FillSystemInfo();
            self = this;
        }
예제 #3
0
        public Settings()
        {
            InitializeComponent();
            #region Localizing
            this.Text                 = L18n.Get("Settings", "Settings_name");
            this.btnExit.Text         = L18n.Get("Settings", "Button_btnExit");
            this.btnSetToDefault.Text = L18n.Get("Settings", "Button_btnSetToDefault");
            this.btnSaveSettings.Text = L18n.Get("Settings", "Button_btnSaveSettings");
            this.tabProgram.Text      = L18n.Get("Settings", "Tab_Program");
            this.tabClients.Text      = L18n.Get("Settings", "Tab_Clients");
            this.tabScreenshots.Text  = L18n.Get("Settings", "Tab_Screenshots");
            this.tabVideos.Text       = L18n.Get("Settings", "Tab_Videos");
            this.chbAutostart.Text    = L18n.Get("Settings", "CheckBox_chbAutostart");
            this.chbAutoupdate.Text   = L18n.Get("Settings", "CheckBox_chbAutoupdate");
            this.labelLang.Text       = L18n.Get("Settings", "Label_labelLang");

            this.labelSelectedClient.Text      = L18n.Get("Settings", "Label_labelSelectedClient");
            this.labelImageFormat.Text         = L18n.Get("Settings", "Label_labelImageFormat");
            this.labelFullScreen.Text          = L18n.Get("Settings", "Label_labelFullScreen");
            this.labelAreaScreen.Text          = L18n.Get("Settings", "Label_labelAreaScreen");
            this.chbUploadImage.Text           = L18n.Get("Settings", "CheckBox_chbUploadImage");
            this.btnChooseScreenshotsPath.Text = L18n.Get("Settings", "Button_btnChoosePath");
            this.btnChooseVideosPath.Text      = L18n.Get("Settings", "Button_btnChoosePath");
            this.groupScreenshots.Text         = L18n.Get("Settings", "GroupBox_groupScreenshots");
            this.labelFullVideo.Text           = L18n.Get("Settings", "Label_labelFullVideo");
            this.labelAreaVideo.Text           = L18n.Get("Settings", "Label_labelAreaVideo");
            this.groupVideos.Text = L18n.Get("Settings", "GroupBox_groupVideos");

            #endregion
            clients = SettingsManager.MakeClientsList();
            Init();
            current = GetCurrentGuiSettings();
            self    = this;
        }
예제 #4
0
        private void OpenLink_click(object sender, EventArgs e)
        {
            string link = (sender as LinkLabel).Links[0].Name;

            statusStrip1.Items[0].Text = $"{L18n.Get("MediaHistory", "Status_openlink")} {link}...";
            System.Diagnostics.Process.Start(link);
        }
        private async void btnTrace_Click(object sender, EventArgs e)
        {
            txbNetworkResults.Text = L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_tracing");
            var trace = await Network.Trace();

            var    lost    = trace.Where(x => x.status == Network.TraceStatus.PacketsLoss);
            var    badping = trace.Where(x => x.status == Network.TraceStatus.BadPing);
            string res     = "";

            txbNetworkResults.Text = "";
            if (lost.Count() == 0 || lost.Count() == 0)
            {
                res = L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_noproblem");
            }
            else
            {
                if (lost.Count() > 0)
                {
                    res += "\n" + L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_packetsloss");
                    foreach (var item in lost)
                    {
                        res += "\n" + item.ToString();
                    }
                }
                if (badping.Count() > 0)
                {
                    res += "\n" + L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_badping");
                    foreach (var item in badping)
                    {
                        res += "\n" + item.ToStringWithPing();
                    }
                }
            }
            txbNetworkResults.Lines = res.Split('\n');
        }
예제 #6
0
        private void OpenFile_click(object sender, EventArgs e)
        {
            string path = (sender as LinkLabel).Links[0].Name;

            statusStrip1.Items[0].Text = $"{L18n.Get("MediaHistory", "Status_openfile")} {Path.GetFileName(path)}...";
            System.Diagnostics.Process.Start(path);
        }
예제 #7
0
        private void CopyLink_click(object sender, EventArgs e)
        {
            string link = (sender as LinkLabel).Links[0].Name;

            Clipboard.SetText(link);
            statusStrip1.Items[0].Text = $"{L18n.Get("MediaHistory", "Label_link2")} {link} {L18n.Get("MediaHistory", "Status_copylink")}";
        }
        private async void btnCheckFlash_Click(object sender, EventArgs e)
        {
            labelCheckFlashInfo.Text = L18n.Get("DiagnosticsWindow", "Label_labelCheckFlashInfo_prepare");
            string ppapi, npapi, activex;

            string[] urls =
            {
                @"http://fpdownload.macromedia.com/get/flashplayer/update/current/xml/version_en_win_ax.xml",
                @"http://fpdownload.macromedia.com/get/flashplayer/update/current/xml/version_en_win_pep.xml",
                @"http://fpdownload.macromedia.com/get/flashplayer/update/current/xml/version_en_win_pl.xml"
            };
            try
            {
                using (WebClient c = new WebClient())
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(await c.DownloadStringTaskAsync(urls[0]));
                    activex = doc.GetElementsByTagName("update")[0].Attributes["version"].Value.Replace(",", ".");
                    doc.LoadXml(await c.DownloadStringTaskAsync(urls[1]));
                    ppapi = doc.GetElementsByTagName("update")[0].Attributes["version"].Value.Replace(",", ".");
                    doc.LoadXml(await c.DownloadStringTaskAsync(urls[2]));
                    npapi = doc.GetElementsByTagName("update")[0].Attributes["version"].Value.Replace(",", ".");
                }
                string query = $@"http://217.71.139.74/~user119/Povshedny_test/test.html?latest_ppapi={ppapi}&latest_npapi={npapi}&latest_activex={activex}";
                labelCheckFlashInfo.Text = L18n.Get("DiagnosticsWindow", "Label_labelCheckFlashInfo_opening");
                System.Diagnostics.Process.Start(query);
            }
            catch (Exception)
            {
                labelCheckFlashInfo.Text = L18n.Get("DiagnosticsWindow", "Label_labelCheckFlashInfo_error");
                return;
            }
        }
예제 #9
0
        static public string GetClientLocalizedName(Clients client)
        {
            switch (client)
            {
            case Clients.Chrome: return(L18n.Get("Browsers", "Chrome"));

            case Clients.Edge: return(L18n.Get("Browsers", "Edge"));

            case Clients.Firefox: return(L18n.Get("Browsers", "Firefox"));

            case Clients.IE: return(L18n.Get("Browsers", "IE"));

            case Clients.OfficialClient: return(L18n.Get("Browsers", "OfficialClient"));

            case Clients.Opera: return(L18n.Get("Browsers", "Opera"));

            case Clients.Yandex: return(L18n.Get("Browsers", "Yandex"));

            case Clients.SAFP: return(L18n.Get("Browsers", "SAFP"));

            case Clients.OtherBrowser: return(L18n.Get("Browsers", "OtherBrowser"));

            case Clients.ThirdPartyClient: return(L18n.Get("Browsers", "ThirdPartyClient"));

            default: return("");
            }
        }
예제 #10
0
        private async void UploadScreenshot_Click(object sender, EventArgs e)
        {
            btnUpload.Text   = L18n.Get("OtherHelper", "Text_cancel");
            btnUpload.Click -= UploadScreenshot_Click;
            btnUpload.Click += UploadScreenshotCanceled;
            txbLink.Text     = "";
            txbLink.Enabled  = false;
            try
            {
                var filename = Path.GetFileName(label.Text);
                txbLink.Text = await Screenshot.UploadScreenshot(label.Text);

                MediaHistoryManager.AddLinkToEntry(filename, txbLink.Text, MediaHistoryManager.MediaType.Screenshot);
                label.Text        = L18n.Get("OtherHelper", "Text_uploaded");
                label.ForeColor   = Color.Green;
                txbLink.Enabled   = true;
                btnUpload.Enabled = false;
            }
            catch (OperationCanceledException) { }
            finally
            {
                btnUpload.Click -= UploadScreenshotCanceled;
                btnUpload.Click += UploadScreenshot_Click;
                btnUpload.Text   = L18n.Get("OtherHelper", "Text_upload");
            }
        }
예제 #11
0
        private static Dictionary <string, string> BuildSystemInfo()
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("CPU", GetCpuInfo()["Name"] + " " + GetCpuInfo()["Freq"]);
            dict.Add("RAM", Util.BytesToString(GetMemoryInfo()));
            dict.Add("OS", GetOsInfo()["Version"] + " " + GetOsInfo()["Bits"]);
            dict.Add("Resolution", GetResolutionInfo()["Width"] + "x" + GetResolutionInfo()["Height"]);

            string gpu  = string.Empty;
            string drv  = string.Empty;
            var    list = GetGpuInfo();

            if (list.Count == 1)
            {
                gpu = list[0]["Model"] + " " + Util.BytesToString(list[0]["Memory"]);
                drv = list[0]["DriverVersion"];
            }
            else
            {
                for (int i = 0; i < list.Count; i++)
                {
                    var t = list[i];
                    gpu += L18n.Get("SystemInfo", "Text_adapter") + i + ": " + t["Model"] + " " + Util.BytesToString(t["Memory"]) + "\n";
                    drv += L18n.Get("SystemInfo", "Text_adapter") + i + ": " + t["DriverVersion"] + "\n";
                }
            }
            dict.Add("GPU", gpu);
            dict.Add("Drivers", drv);
            return(dict);
        }
예제 #12
0
 public OtherWindow()
 {
     InitializeComponent();
     this.Text = L18n.Get("OtherWindow", "OtherWindow_name");
     this.btnUploadScreenshot.Text = L18n.Get("OtherWindow", "Button_btnUploadScreenshot");
     this.btnUploadVideo.Text      = L18n.Get("OtherWindow", "Button_btnUploadVideo");
     this.btnOpenMediaHistory.Text = L18n.Get("OtherWindow", "Button_btnOpenMediaHistory");
     self = this;
 }
예제 #13
0
        private void CopyFile_click(object sender, EventArgs e)
        {
            string[] path = new string[1] {
                (sender as LinkLabel).Links[0].Name
            };
            DataObject obj = new DataObject();

            obj.SetData(DataFormats.FileDrop, true, path);
            Clipboard.SetDataObject(obj, true);
            statusStrip1.Items[0].Text = $"{L18n.Get("MediaHistory", "Label_file2")} {Path.GetFileName(path[0])} {L18n.Get("MediaHistory", "Status_copyfile")}";
        }
예제 #14
0
 private void btnResetNetworkThrottling_Click(object sender, EventArgs e)
 {
     try
     {
         Network.SetNetworkThrottling(false);
         MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_done"), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception)
     {
         MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_adminerror"),
             "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #15
0
        static void videosInsertRequest_ProgressChanged(IUploadProgress progress)
        {
            switch (progress.Status)
            {
            case UploadStatus.Uploading:
                sender.ChangeProgressBar(Convert.ToInt32((float)progress.BytesSent / file_length * 100));
                break;

            case UploadStatus.Failed:
                MessageBox.Show(L18n.Get("Video", "Text_videouploaderror"), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
        }
예제 #16
0
 private void btnIncreaseCache_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_areyousure"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             Browsers.IncreaseCacheSize(Browsers.GetClientByString(SettingsManager.client_name));
             MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_cacheincreased"), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception)
     {
         MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_increaseerror"), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #17
0
        public OtherHelper()
        {
            InitializeComponent();
            #region Init
            this.StartPosition   = FormStartPosition.CenterParent;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;

            OpenFileDialog.CheckFileExists = true;
            OpenFileDialog.CheckPathExists = true;
            wrapper.Dock        = DockStyle.Fill;
            wrapper.RowCount    = 0;
            wrapper.ColumnCount = 0;
            wrapper.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 70F));
            wrapper.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F));
            label.Text        = L18n.Get("OtherHelper", "Text_nofile");
            label.Anchor      = AnchorStyles.None;
            label.AutoSize    = true;
            btnChoose.Text    = L18n.Get("OtherHelper", "Text_choosefile");
            btnChoose.Anchor  = AnchorStyles.None;
            btnChoose.Click  += Choose_Click;
            btnUpload.Text    = L18n.Get("OtherHelper", "Text_upload");
            btnUpload.Anchor  = AnchorStyles.None;
            btnUpload.Enabled = false;
            txbLink.ReadOnly  = true;
            txbLink.Anchor    = AnchorStyles.None;
            //txbLink.AutoSize = true;
            txbLink.Size        = new Size(200, 23);
            txbLink.Enabled     = false;
            txbLink.Click      += link_Click;
            group.Text          = L18n.Get("OtherHelper", "Text_videoaccess");
            group.Dock          = DockStyle.Fill;
            rbPublic.Checked    = true;
            rbPrivate.Text      = L18n.Get("OtherHelper", "Text_private");
            rbPublic.Text       = L18n.Get("OtherHelper", "Text_public");
            rbUnlisted.Text     = L18n.Get("OtherHelper", "Text_unlisted");
            rbPrivate.Location  = new Point(215, 15);
            rbPublic.Location   = new Point(5, 15);
            rbUnlisted.Location = new Point(110, 15);
            group.Controls.Add(rbPrivate);
            group.Controls.Add(rbPublic);
            group.Controls.Add(rbUnlisted);
            bar.Anchor = AnchorStyles.Left;
            bar.Size   = new Size(208, 23);
            #endregion
            self = this;
        }
        private void btnCheckPorts_Click(object sender, EventArgs e)
        {
            txbNetworkResults.Text = string.Empty;
            var closed = Network.GetPortsStatus().Where(x => x.isOpen == false);

            if (closed.Count() > 0)
            {
                txbNetworkResults.Text      = $"{L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_portsclosed1")} {string.Join(", ",closed.Select(x => x.port))}. {L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_portsclosed2")}";
                txbNetworkResults.ForeColor = Color.Red;
            }
            else
            {
                txbNetworkResults.Text      = L18n.Get("DiagnosticsWindow", "TextBox_txbNetworkResults_portsopen");
                txbNetworkResults.ForeColor = Color.Green;
            }
        }
예제 #19
0
        public MediaHistory()
        {
            InitializeComponent();
            this.Text = L18n.Get("MediaHistory", "MediaHistory_name");
            TableLayoutPanel Wrapper = new TableLayoutPanel();

            Wrapper.AutoScroll = true;
            Wrapper.AutoSize   = true;
            Wrapper.Dock       = DockStyle.Top;
            Wrapper.Controls.Clear();
            Wrapper.RowCount        = 0;
            Wrapper.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
            Wrapper.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            PanelWrapper.Controls.Add(Wrapper);
            AddEntries(Wrapper, MediaHistoryManager.GetHistoryFromFile());
            self = this;
        }
 private void FillSystemInfo()
 {
     Label_Processor.Text  = SystemInfo.Info["CPU"];
     Label_Memory.Text     = SystemInfo.Info["RAM"];
     Label_Graphics.Text   = SystemInfo.Info["GPU"];
     Label_Driver.Text     = SystemInfo.Info["Drivers"];
     Label_OS.Text         = SystemInfo.Info["OS"];
     Label_Resolution.Text = SystemInfo.Info["Resolution"];
     try
     {
         Label_IpAddress.Text = Network.GetMyIpAddress();
     }
     catch (Exception)
     {
         Label_IpAddress.Text = L18n.Get("DiagnosticsWindow", "Label_IpAddress_error");
     }
 }
예제 #21
0
        public static void StartRec(CaptureTypes type)
        {
            if (_isRecording == false)
            {
                SetScreenArea(type);
                _isRecording = true;
                now          = DateTime.Now;
                name         = $"{now.ToString().Replace(" ", "_").Replace(".", "_").Replace(":", "_") }.avi";
                path         = Path.Combine(SettingsManager.videos_path, name);

                _writer.Open(path, _width, _height, fps, codec, bitrate);
                _streamVideo           = new ScreenCaptureStream(_screenArea);
                _streamVideo.NewFrame += new NewFrameEventHandler(video_NewFrame);
                _streamVideo.Start();
                MainWindow.TrayApp.ShowBalloonTip(2000, "TankiTools", $"{L18n.Get("TrayApp", "Balloon_VideoStarted")}", ToolTipIcon.None);
            }
        }
예제 #22
0
 private void btnOpenPorts_Click(object sender, EventArgs e)
 {
     try
     {
         if (Network.OpenPorts(Network.GetPortsStatus()))
         {
             MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_done"), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_nochange"), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception)
     {
         MessageBox.Show(L18n.Get("TroubleshootingWindow", "Text_openportserror"), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #23
0
        private static void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            if (_isRecording)
            {
                Bitmap     frame    = eventArgs.Frame;
                Graphics   graphics = Graphics.FromImage(frame);
                CURSORINFO pci;
                pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));

                if (GetCursorInfo(out pci))
                {
                    if (pci.flags == CURSOR_SHOWING)
                    {
                        int x = pci.ptScreenPos.x - screenLeft;
                        int y = pci.ptScreenPos.y - screenTop;
                        DrawIcon(graphics.GetHdc(), x, y, pci.hCursor);
                        graphics.ReleaseHdc();
                    }
                }
                if (useArea)
                {
                    var destRect = new Rectangle(Convert.ToInt32((_width - frame.Width) / 2),
                                                 Convert.ToInt32((_height - frame.Height) / 2), frame.Width, frame.Height);
                    var destImage = new Bitmap(_width, _height);
                    destImage.SetResolution(frame.HorizontalResolution, frame.VerticalResolution);

                    graphics = Graphics.FromImage(destImage);
                    graphics.DrawImage(frame, destRect, 0, 0, frame.Width, frame.Height, GraphicsUnit.Pixel, null);
                    frame = destImage;
                }

                _writer.WriteVideoFrame(frame);
            }
            else
            {
                _streamVideo.SignalToStop();
                Thread.Sleep(500);
                _writer.Close();
                Save();
                MainWindow.TrayApp.ShowBalloonTip(2000, "TankiTools", $"{L18n.Get("TrayApp", "Balloon_VideoEnded")}", ToolTipIcon.None);
            }
        }
예제 #24
0
 public void UploadVideoCompleted(string id, string filename)
 {
     if (InvokeRequired)
     {
         this.Invoke(new UploadVideoCompletedDelegate(UploadVideoCompleted), new object[] { id, filename });
         return;
     }
     try
     {
         wrapper.Controls.Remove(bar);
         wrapper.Controls.Remove(txbLink);
     }
     catch (Exception) { }
     label.Text      = L18n.Get("OtherHelper", "Text_uploaded");
     label.ForeColor = Color.Green;
     txbLink.Text    = $@"https://youtu.be/{id}";
     MediaHistoryManager.AddLinkToEntry(filename, txbLink.Text, MediaHistoryManager.MediaType.Video);
     txbLink.Enabled = true;
     wrapper.Controls.Add(txbLink, 0, 2);
     btnUpload.Enabled = false;
 }
예제 #25
0
        public static bool RegisterHotkeys(CaptureTypes type, string combo, bool save = true, bool suppress = false)
        {
            IntPtr hWnd     = Util.Main.Handle;
            int    modifier = NOMOD;
            int    key      = 0;
            int    id       = 0;

            foreach (string _key in combo.Split('+'))
            {
                if (_key == "Shift")
                {
                    modifier += SHIFT;
                }
                if (_key == "Alt")
                {
                    modifier += ALT;
                }
                if (_key == "Ctrl")
                {
                    modifier += CTRL;
                }
                else
                {
                    key = (int)GetKey(_key);
                }
            }
            id = modifier ^ key ^ hWnd.ToInt32() + combo.GetHashCode();
            bool result = RegisterHotKey(hWnd, id, modifier, key);

            if (result && save)
            {
                HotkeyIds[type] = id;
            }
            if (!suppress && !result)
            {
                MessageBox.Show($"{L18n.Get("Settings", "Text_cannotregister")} {combo}",
                                "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }
예제 #26
0
        public static async Task Save(Bitmap img, string prefix)
        {
            ImageFormat       format;
            ImageCodecInfo    encoder;
            EncoderParameters encParams;
            DateTime          now  = DateTime.Now;
            string            name = $"{prefix}{now.ToString().Replace(" ", "_").Replace(".", "_").Replace(":", "_")}.{SettingsManager.screenshots_format}";
            string            path = Path.Combine(SettingsManager.screenshots_path, name);

            if (SettingsManager.screenshots_format == "jpg" || SettingsManager.screenshots_format == "jpeg")
            {
                format    = ImageFormat.Jpeg;
                encoder   = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Jpeg.Guid);
                encParams = new EncoderParameters()
                {
                    Param = new[] { new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 90L) }
                };
            }
            else
            {
                format    = ImageFormat.Png;
                encoder   = ImageCodecInfo.GetImageEncoders().First(c => c.FormatID == ImageFormat.Png.Guid);
                encParams = new EncoderParameters()
                {
                    Param = new[] { new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L) }
                };
            }
            string link = string.Empty;

            img.Save(path, encoder, encParams);
            if (SettingsManager.screenshots_upload)
            {
                link = await UploadScreenshot(img);

                Clipboard.SetText(link);
                MainWindow.TrayApp.ShowBalloonTip(2000, "TankiTools", $"{L18n.Get("TrayApp", "Balloon_screenshot1")} {link}\n{L18n.Get("TrayApp", "Balloon_screenshot2")}", ToolTipIcon.None);
            }
            MediaHistoryManager.SaveEntryToHistory(new MediaHistoryManager.HistoryEntry(
                                                       MediaHistoryManager.MediaType.Screenshot, link, name, now));
        }
예제 #27
0
        public void CreateForm(OtherType type)
        {
            switch (type)
            {
            case OtherType.UploadScreenshot:
                #region UploadScreenshot
                this.Size = new Size(257, 129);
                OpenFileDialog.InitialDirectory = SettingsManager.screenshots_path;
                OpenFileDialog.Filter           = L18n.Get("OtherHelper", "Text_imgexts");
                wrapper.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
                wrapper.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
                btnUpload.Click += UploadScreenshot_Click;
                wrapper.Controls.Add(label, 0, 0);
                wrapper.Controls.Add(btnChoose, 1, 0);
                wrapper.Controls.Add(txbLink, 0, 1);
                wrapper.Controls.Add(btnUpload, 1, 1);
                this.Controls.Add(wrapper);
                #endregion
                break;

            case OtherType.UploadVideo:
                #region UploadVideo
                this.Size = new Size(322, 144);
                OpenFileDialog.InitialDirectory = SettingsManager.videos_path;
                OpenFileDialog.Filter           = L18n.Get("OtherHelper", "Text_videoexts");
                wrapper.RowStyles.Add(new RowStyle(SizeType.Percent, 30F));
                wrapper.RowStyles.Add(new RowStyle(SizeType.Percent, 40F));
                wrapper.RowStyles.Add(new RowStyle(SizeType.Percent, 30F));
                btnUpload.Click += UploadVideo_Click;
                wrapper.Controls.Add(label, 0, 0);
                wrapper.Controls.Add(btnChoose, 1, 0);
                wrapper.Controls.Add(group, 0, 1);
                wrapper.SetColumnSpan(group, 3);
                wrapper.Controls.Add(btnUpload, 1, 2);
                this.Controls.Add(wrapper);
                #endregion
                break;
            }
        }
예제 #28
0
 public TroubleshootingWindow()
 {
     InitializeComponent();
     #region Localizing
     this.Text = L18n.Get("TroubleshootingWindow", "Troubleshooting_name");
     this.groupClients.Text = L18n.Get("TroubleshootingWindow", "GroupBox_groupClients");
     this.groupNetwork.Text = L18n.Get("TroubleshootingWindow", "GroupBox_groupNetwork");
     this.labelWarning.Text = L18n.Get("TroubleshootingWindow", "Label_labelWarning");
     this.btnClearCache.Text = L18n.Get("TroubleshootingWindow", "Button_btnClearCache");
     this.btnClearShared.Text = L18n.Get("TroubleshootingWindow", "Button_btnClearShared");
     this.btnIncreaseCache.Text = L18n.Get("TroubleshootingWindow", "Button_btnIncreaseCache");
     this.btnOpenPorts.Text = L18n.Get("TroubleshootingWindow", "Button_btnOpenPorts");
     this.btnSetNetworkThrottling.Text = L18n.Get("TroubleshootingWindow", "Button_btnSet");
     this.btnSetTcpAck.Text = L18n.Get("TroubleshootingWindow", "Button_btnSet");
     this.btnResetNetworkThrottling.Text = L18n.Get("TroubleshootingWindow", "Button_btnReset");
     this.btnResetTcpAck.Text = L18n.Get("TroubleshootingWindow", "Button_btnReset");
     this.labelTcpAck.Text = L18n.Get("TroubleshootingWindow", "Label_labelTcpAck");
     this.labelNetworkThrottling.Text = L18n.Get("TroubleshootingWindow", "Label_labelNetworkThrottling");
     #endregion
     if (Browsers.GetClientByString(SettingsManager.client_name) != Clients.Firefox 
     || Browsers.GetClientByString(SettingsManager.client_name) != Clients.IE)
     {
         btnIncreaseCache.Visible = false;
     }
     labelWarning.Text += Browsers.GetClientLocalizedName(Browsers.GetClientByString(SettingsManager.client_name));
     toolTipForTcp.SetToolTip(this.labelTcpAck, L18n.Get("TroubleshootingWindow", "Tooltip_TcpAck"));
     toolTipForThrottling.SetToolTip(this.labelNetworkThrottling, L18n.Get("TroubleshootingWindow", "Tooltip_NetworkThrottling"));
     if(SettingsManager.lang == "ru")
     {
         linkToWikiArticle.LinkClicked += (o, e) =>
             System.Diagnostics.Process.Start(@"https://ru.tankiwiki.com/Экспериментальное_решение_проблем_с_лагами_и_дисконнектами");
     }
     else
     {
         linkToWikiArticle.Visible = false;
     }
     self = this;
 }
예제 #29
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            List <string> combos = new List <string>();
            string        t;

            t = GetKeysCombo(CaptureTypes.ScreenArea);
            if (SettingsManager.RegisterHotkeys(CaptureTypes.ScreenArea, t, false, true))
            {
                combos.Add(t);
            }
            t = GetKeysCombo(CaptureTypes.ScreenFull);
            if (SettingsManager.RegisterHotkeys(CaptureTypes.ScreenFull, t, false, true))
            {
                combos.Add(t);
            }
            t = GetKeysCombo(CaptureTypes.VideoArea);
            if (SettingsManager.RegisterHotkeys(CaptureTypes.VideoArea, t, false, true))
            {
                combos.Add(t);
            }
            t = GetKeysCombo(CaptureTypes.VideoFull);
            if (SettingsManager.RegisterHotkeys(CaptureTypes.VideoFull, t, false, true))
            {
                combos.Add(t);
            }
            if (combos.Count > 0)
            {
                MessageBox.Show($"{L18n.Get("Settings", "Text_cannotregister")} {string.Join(", ", combos)}",
                                "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            SettingsManager.SetSettingsFromGui(GetCurrentGuiSettings());
            SettingsManager.SetAutostart(SettingsManager.autostart);
            SettingsManager.SaveSettingsToFile();
            SettingsManager.SetGlobalHotkeys(true);
            this.Close();
        }
예제 #30
0
 public MainWindow()
 {
     InitializeComponent();
     #region Localizing
     this.Button_Diagnostics.Text     = L18n.Get("MainWindow", "Button_Diagnostics");
     this.Button_Troubleshooting.Text = L18n.Get("MainWindow", "Button_Troubleshooting");
     this.Button_Settings.Text        = L18n.Get("MainWindow", "Button_Settings");
     this.Button_Other.Text           = L18n.Get("MainWindow", "Button_Other");
     this.Button_Exit.Text            = L18n.Get("MainWindow", "Button_Exit");
     #endregion
     #region TrayApp
     TrayApp.BalloonTipIcon  = ToolTipIcon.None;
     TrayApp.Icon            = Properties.Resources.TankiToolsIcon;
     TrayApp.Text            = "TankiTools";
     TrayApp.Visible         = true;
     TrayApp.BalloonTipTitle = "TankiTools";
     var menu = new ContextMenuStrip();
     menu.Items.Add("TankiTools", Properties.Resources.TankiToolsIcon.ToBitmap(), (o, ea) =>
     {
         if (this.WindowState == FormWindowState.Minimized)
         {
             this.WindowState = FormWindowState.Normal;
         }
         else
         {
             this.Show();
         }
     });
     menu.Items.Add(L18n.Get("TrayApp", "ItemSettings"), Properties.Resources.Settings_small, Button_Settings_Click);
     menu.Items.Add(L18n.Get("TrayApp", "ItemHistory"), Properties.Resources.Mediahistory_small, OpenMediaHistory);
     menu.Items.Add($"[{SettingsManager.screenshots_fullKeys}] {L18n.Get("TrayApp", "ItemScreenshotFull")}", null, (o, ea) => Screenshot.CaptureFullScreen());
     menu.Items.Add($"[{SettingsManager.screenshots_areaKeys}] {L18n.Get("TrayApp", "ItemScreenshotArea")}", null, (o, ea) => new SelectableScreenshotArea());
     menu.Items.Add($"[{SettingsManager.videos_fullKeys}] {L18n.Get("TrayApp", "ItemVideoFull")}", null, (o, ea) =>
     {
         if (!VideoRecorder1._isRecording)
         {
             VideoRecorder1.StartRec(CaptureTypes.VideoFull);
         }
         else
         {
             VideoRecorder1._isRecording = false;
         }
     });
     menu.Items.Add($"[{SettingsManager.videos_areaKeys}] {L18n.Get("TrayApp", "ItemVideoArea")}", null, (o, ea) =>
     {
         if (!VideoRecorder1._isRecording)
         {
             VideoRecorder1.StartRec(CaptureTypes.VideoArea);
         }
         else
         {
             VideoRecorder1._isRecording = false;
         }
     });
     menu.Items.Add(L18n.Get("TrayApp", "ItemExit"), Properties.Resources.Exit_small, (o, ea) =>
     {
         SettingsManager.UnsetGlobalHotkeys();
         Program.Shutdown();
     });
     TrayApp.ContextMenuStrip = menu;
     #endregion
     Util.Main = this;
 }