コード例 #1
0
        private void btnAbout_Click(object sender, EventArgs e)
        {
            StringBuilder sbMessage = new StringBuilder();

            sbMessage.AppendLine(string.Format("{0} v{1}",
                                               Application.ProductName,
                                               AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3)));
            sbMessage.AppendLine();

            sbMessage.AppendLine(AmbLib.getAssemblyCopyright(Assembly.GetExecutingAssembly()));
            sbMessage.AppendLine();

            sbMessage.AppendLine(Program.Url);
            sbMessage.AppendLine(Properties.Resources.PRESS_CTRL_OK);

            CppUtils.CenteredMessageBox(this,
                                        sbMessage.ToString(),
                                        Application.ProductName,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);

            if (CppUtils.IsCtrlPressed())
            {
                try
                {
                    Process.Start(Program.Url);
                }
                catch (Exception ex)
                {
                    CppUtils.Alert(ex);
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ambiesoft/SendToTools
 static void ShowHelp()
 {
     CppUtils.CenteredMessageBox(GetHelpMessage(),
                                 string.Format("{0} ver{1}",
                                               Application.ProductName,
                                               AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3)),
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
 }
コード例 #3
0
        void UpdateTitle()
        {
            int    done    = GetDoneCount();
            int    all     = GetAllCount();
            string ratio   = AmbLib.GetRatioString(done, all);
            string version = AmbLib.getAssemblyVersion(System.Reflection.Assembly.GetExecutingAssembly(), 3);

            Text = string.Format("{0}{1} {2}/{3} - {4} v{5}",
                                 Running ? (string.IsNullOrEmpty(ratio) ? "0" : ratio) : string.Empty,
                                 Running ? "%" : string.Empty,
                                 done,
                                 all,
                                 Application.ProductName,
                                 version);
        }
コード例 #4
0
ファイル: FormInputUrl.cs プロジェクト: ambiesoft/printurls
        private void btnAbout_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0} ver {1}", Application.ProductName, AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3));
            sb.AppendLine();
            sb.AppendLine(Application.CompanyName);
            sb.Append(AmbLib.getAssemblyCopyright(Assembly.GetExecutingAssembly()));

            CppUtils.CenteredMessageBox(this,
                                        sb.ToString(),
                                        Application.ProductName,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
        }
コード例 #5
0
ファイル: FormMain.About.cs プロジェクト: ambiesoft/ffjoin
        private void btnAbout_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Application.ProductName).Append(" ver ");
            sb.Append(AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3));

            //sb.Append(Assembly.GetExecutingAssembly().GetName().Version.Major.ToString());
            //sb.Append(".");
            //sb.Append(Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString());
            //sb.Append(".");
            //sb.Append(Assembly.GetExecutingAssembly().GetName().Version.Build.ToString());

            Info(sb.ToString());
        }
コード例 #6
0
ファイル: FormMain.cs プロジェクト: ambiesoft/SendToTools
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Application.ProductName);
            sb.Append(" version ");
            sb.Append(AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3));
            sb.AppendLine();
            // sb.Append("Copyright 2018 Ambiesoft");
            sb.Append(AmbLib.getAssemblyCopyright(Assembly.GetExecutingAssembly()));
            CppUtils.CenteredMessageBox(this,
                                        sb.ToString(),
                                        Application.ProductName,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
        }
コード例 #7
0
ファイル: FormMain.cs プロジェクト: ambiesoft/clickchecker
        private void btnInfo_Click(object sender, EventArgs e)
        {
            var message = new StringBuilder();

            message.AppendLine(string.Format("{0} v{1}",
                                             Application.ProductName,
                                             AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3)));
            message.AppendLine();
            message.AppendLine("https://ambiesoft.github.io/webjumper/?target=clickchecker");
            message.AppendLine();

            message.AppendLine("Gitrev:");
            message.AppendLine(GitRev.GetHashMessage());

            JR.Utils.GUI.Forms.FlexibleMessageBox.Show(this,
                                                       message.ToString(),
                                                       Application.ProductName,
                                                       MessageBoxButtons.OK,
                                                       MessageBoxIcon.Information);
        }
コード例 #8
0
ファイル: FormMain.cs プロジェクト: ambiesoft/CPUNotify
 private void btnAbout_Click(object sender, EventArgs e)
 {
     CppUtils.Info(string.Format("{0} {1}",
                                 Application.ProductName,
                                 AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3)));
 }
コード例 #9
0
ファイル: FormMain.cs プロジェクト: ambiesoft/CPUNotify
        public FormMain(string[] args)
        {
            InitializeComponent();

            this.Text = Application.ProductName;

            // read ini
            HashIni ini = Profile.ReadAll(IniPath);

            AmbLib.LoadFormXYWH(this, SECTION_LOCATION, ini);

            int intval;

            if (Profile.GetInt(SECTION_OPTION, KEY_CHECKDURATION, 0, out intval, ini))
            {
                _checkDuration = intval;
            }
            float fval;

            if (Profile.GetFloat(SECTION_OPTION, KEY_MIN_CPUUSAGE, 0, out fval, ini))
            {
                _minCPUUsage = fval;
            }
            if (Profile.GetFloat(SECTION_OPTION, KEY_MAX_CPUUSAGE, 0, out fval, ini))
            {
                _maxCPUUsage = fval;
            }

            bool bval;

            if (Profile.GetBool(SECTION_OPTION, KEY_IS_AVERAGE, false, out bval, ini))
            {
                _isAverage = bval;
            }

            try
            {
                bool start = false;
                var  p     = new OptionSet();
                p.Add("v|version", "Show Version", dummy =>
                {
                    MessageBox.Show("ver");
                    Environment.Exit(0);
                });
                p.Add("max=", "Max cpu usage", max =>
                {
                    _maxCPUUsage = float.Parse(max);
                });
                p.Add("min=", "Min cpu usage", max =>
                {
                    _minCPUUsage = float.Parse(max);
                });
                p.Add("d=|duration=", "Duration of checking", duration =>
                {
                    _checkDuration = int.Parse(duration);
                });
                p.Add("a|average", "Use average", dummy =>
                {
                    _isAverage = true;
                });
                p.Add("h|H|help|?", "Show Help", dummy =>
                {
                    var stream = new MemoryStream();
                    var to     = new StreamWriter(stream);
                    p.WriteOptionDescriptions(to);
                    to.Flush();
                    stream.Position = 0;
                    var reader      = new StreamReader(stream);
                    string message  = reader.ReadToEnd();

                    MessageBox.Show(message,
                                    Application.ProductName + " v" + AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    Environment.Exit(0);
                });
                p.Add("start", "Start without showing the dialog", dummy =>
                {
                    start = true;
                });

                List <string> mainArgs = p.Parse(args);
                _start = start;
                if (mainArgs.Count != 0)
                {
                    FatalExit("Uknown Option:" + string.Join(" ", mainArgs.ToArray()));
                }
            }
            catch (Exception ex)
            {
                FatalExit(ex.Message);
            }
        }
コード例 #10
0
 private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Ambiesoft.CppUtils.Info(string.Format("{0} ver{1}",
                                           Application.ProductName, AmbLib.getAssemblyVersion(System.Reflection.Assembly.GetExecutingAssembly(), 3)));
 }
コード例 #11
0
        static bool processArgs(string[] args, out string inputFile)
        {
            inputFile = string.Empty;

            // first get lang from command line and set culture
            {
                string lang             = string.Empty;
                var    optionSetForLang = new OptionSet()
                {
                    {
                        "lang=",
                        Properties.Resources.STR_COMMANDLINEHELP_LANG,
                        v =>
                        {
                            lang = v;
                        }
                    },
                };
                optionSetForLang.SafeParse(args);
                if (!string.IsNullOrEmpty(lang))
                {
                    try
                    {
                        CultureInfo ci = new CultureInfo(lang);
                        System.Threading.Thread.CurrentThread.CurrentCulture   = ci;
                        System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Application.ProductName,
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }

            bool   showHelp    = false;
            bool   showVersion = false;
            string dummy;
            var    optionSet = new OptionSet()
            {
                {
                    "lang=",
                    Properties.Resources.STR_COMMANDLINEHELP_LANG,
                    v =>
                    {
                        dummy = v;
                    }
                },
                {
                    "h|help|?",
                    Properties.Resources.STR_SHOWHELP,
                    v =>
                    {
                        showHelp = true;
                    }
                },
                {
                    "v|version",
                    Properties.Resources.STR_SHOWHELP,
                    v =>
                    {
                        showVersion = true;
                    }
                }
            };
            List <string> extra = optionSet.SafeParse(args);

            if (showHelp)
            {
                StringBuilder sb = new StringBuilder();
                using (StringWriter sw = new StringWriter(sb))
                    optionSet.WriteOptionDescriptions(sw);
                MessageBox.Show(sb.ToString(), Application.ProductName,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (showVersion)
            {
                MessageBox.Show(
                    string.Format("{0} v{1}",
                                  Application.ProductName, AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3)),
                    Application.ProductName,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return(false);
            }
            if (extra.Count > 1)
            {
                foreach (string arg in extra)
                {
                    if (!File.Exists(arg) && !Directory.Exists(arg))
                    {
                        CppUtils.Fatal(string.Format(Properties.Resources.INTPUFILE_NOT_FOUND, arg));
                        continue;
                    }

                    try
                    {
                        Process.Start(Application.ExecutablePath, AmbLib.doubleQuoteIfSpace(arg));
                    }
                    catch (Exception ex)
                    {
                        CppUtils.Alert(ex);
                        continue;
                    }
                }
                return(false);
            }
            else if (extra.Count == 1)
            {
                inputFile = extra[0];
            }
            return(true);
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: ambiesoft/ClipimageToFile
        static void Main(string[] args)
        {
            Ambiesoft.CppUtils.AmbSetProcessDPIAware();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool          isFileClipboard = false;
            SaveImageType sit             = SaveImageType.PNG;

            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (arg == "/c")
                {
                    isFileClipboard = true;
                }
                else if (arg == "/v" || arg == "-v" ||
                         arg == "/h" || arg == "-h" || arg == "/?" || arg == "--help")
                {
                    StringBuilder sbMessage = new StringBuilder();

                    sbMessage.AppendFormat("{0} - {1}",
                                           Application.ProductName,
                                           "Save an image on the clipboard to a file");
                    sbMessage.AppendLine();
                    sbMessage.AppendLine();
                    sbMessage.AppendLine("Usage:");
                    sbMessage.AppendFormat("{0} {1}",
                                           Path.GetFileNameWithoutExtension(Application.ExecutablePath),
                                           "[/c] [/t [png|jpg]] [/h]");
                    sbMessage.AppendLine();
                    sbMessage.AppendLine();

                    string optionformat = "{0}\t{1}";

                    sbMessage.AppendFormat(optionformat,
                                           "-h", Properties.Resources.ID_SHOW_HELP);
                    sbMessage.AppendLine();

                    sbMessage.AppendFormat(optionformat,
                                           "/c", Properties.Resources.ID_C_HELP);
                    sbMessage.AppendLine();

                    sbMessage.AppendFormat(optionformat,
                                           "/t", Properties.Resources.ID_T_HELP);
                    sbMessage.AppendLine();

                    sbMessage.AppendLine();
                    sbMessage.AppendLine("Copyright 2019 Ambiesoft");
                    sbMessage.AppendLine("https://ambiesoft.github.io/webjumper/?target=ClipimageToFile");

                    JR.Utils.GUI.Forms.FlexibleMessageBox.Show(
                        sbMessage.ToString(),
                        string.Format("{0} version {1}",
                                      Application.ProductName,
                                      AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3)),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    return;
                }
                else if (arg == "/t")
                {
                    if ((i + 1) != args.Length)
                    {
                        ++i;
                        arg = args[i];
                        arg = arg.ToLower();
                        if (arg == "bmp")
                        {
                            sit = SaveImageType.BMP;
                        }
                        else if (arg == "jpg" || arg == "jpeg")
                        {
                            sit = SaveImageType.JPG;
                        }
                        else if (arg == "png")
                        {
                            sit = SaveImageType.PNG;
                        }
                        else
                        {
                            MessageBox.Show(Properties.Resources.INVALID_IMAGE_TYPE + " \"" + arg + "\"",
                                            Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(
                        string.Format(Properties.Resources.ID_UNKNOW_OPTION, arg),
                        Application.ProductName,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }

            Object o = Clipboard.GetData(DataFormats.Bitmap);

            if (!(o is Bitmap))
            {
                MessageBox.Show(Properties.Resources.NO_IMAGE_ON_CLIPBOARD,
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                Bitmap b = (Bitmap)o;

                if (isFileClipboard)
                {
                    string      clipfileext = null;
                    ImageFormat clipimagef  = null;
                    switch (sit)
                    {
                    case SaveImageType.BMP:
                        clipfileext = ".bmp";
                        clipimagef  = ImageFormat.Bmp;
                        break;

                    case SaveImageType.JPG:
                        clipfileext = ".jpg";
                        clipimagef  = ImageFormat.Jpeg;
                        break;

                    case SaveImageType.PNG:
                        clipfileext = ".png";
                        clipimagef  = ImageFormat.Png;
                        break;
                    }

                    string tempfile;
                    while (true)
                    {
                        DateTime now      = DateTime.Now;
                        string   datetime = "clipshot " + getDTString(now);
                        tempfile = System.IO.Path.GetTempPath() + datetime + clipfileext;
                        if (File.Exists(tempfile))
                        {
                            System.Threading.Thread.Sleep(1000);
                            continue;
                        }
                        break;
                    }

                    b.Save(tempfile, clipimagef);

                    // file to be cut on clipboard
                    string[] fileNames = { tempfile };
                    // DataObject will be holding data
                    DataObject data = new DataObject(DataFormats.FileDrop, fileNames);

                    // DragDropEffects.Move
                    byte[] bs = new byte[] { (byte)DragDropEffects.Move, 0, 0, 0 };
                    System.IO.MemoryStream ms = new System.IO.MemoryStream(bs);
                    data.SetData("Preferred DropEffect", ms);
                    data.SetText(tempfile);

                    // cut onto clipbard
                    Clipboard.Clear();
                    Clipboard.SetDataObject(data, true);

                    Application.DoEvents();

                    showBalloon(Properties.Resources.IMAGE_HAS_SET_ON_CLIPBOARD);
                }
                else
                {
                    CustomControls.FormSaveFileDialog ofd = new CustomControls.FormSaveFileDialog();
                    ofd.pbxPreview.Image    = (Bitmap)b.Clone();
                    ofd.lblColorsValue.Text = ofd.GetColorsCountFromImage(ofd.pbxPreview.Image);
                    ofd.lblFormatValue.Text = ofd.GetFormatFromImage(ofd.pbxPreview.Image);

                    ofd.OpenDialog.Title        = b.Width + "x" + b.Height + " - " + Application.ProductName;
                    ofd.OpenDialog.AddExtension = true;

                    System.Collections.ArrayList arFilers = new System.Collections.ArrayList();
                    string           filter = string.Empty;
                    ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
                    int filtin = 0;
                    int i      = 0;
                    foreach (ImageCodecInfo codec in codecs)
                    {
                        if ((codec.Flags & ImageCodecFlags.Encoder) != 0)
                        {
                            if (ImageFormat.Gif.Guid != codec.FormatID)
                            {
                                string ext = codec.FilenameExtension;
                                ext     = ext.Split(';')[0];
                                ext     = ext.ToLower();
                                filter += codec.FormatDescription + " (" + ext + ")|" + ext + "|";

                                if (isEqualCodec(codec.FormatDescription.ToLower(), sit))
                                {
                                    filtin = i;
                                }

                                arFilers.Add(codec);
                                ++i;
                            }
                        }
                    }
                    ofd.OpenDialog.Filter      = filter.TrimEnd('|');
                    ofd.OpenDialog.FilterIndex = filtin + 1;
                    if (DialogResult.OK != ofd.ShowDialog())
                    {
                        return;
                    }

                    ImageCodecInfo ici = (ImageCodecInfo)arFilers[ofd.OpenDialog.FilterIndex - 1];

                    EncoderParameters encoderParameters = new EncoderParameters(1);
                    encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
                    b.Save(ofd.OpenDialog.FileName, ici, encoderParameters);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                Application.ProductName,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }