Exemplo n.º 1
0
 public void Explore(IWin32Window owner)
 {
     if (this.directoryInfo != null)
     {
         WindowsUtility.ShellExecute(owner, this.directoryInfo.FullName);
     }
 }
Exemplo n.º 2
0
        public override bool OnOk()
        {
            bool result = false;

            if (this.edtCommand.Text.Trim().Length == 0)
            {
                WindowsUtility.ShowError(this, "You must enter a command.");
            }
            else if (this.numFirstSuccess.Value > this.numLastSuccess.Value)
            {
                WindowsUtility.ShowError(this, "The last success code must be greater than or equal to the first success code.");
            }
            else if (this.step != null)
            {
                this.step.Command          = this.edtCommand.Text;
                this.step.Arguments        = this.edtArguments.Text;
                this.step.WorkingDirectory = this.edtWorkingDirectory.Text;
                this.step.WindowState      = (ProcessWindowStyle)this.cbWindowState.SelectedIndex;
                this.step.UseShellExecute  = this.chkShellExecute.Checked;
                this.step.Verb             = this.edtVerb.Text;
                this.step.FirstSuccessCode = (int)this.numFirstSuccess.Value;
                this.step.LastSuccessCode  = (int)this.numLastSuccess.Value;
                this.step.RedirectStreams  = this.RedirectStreams;
                result = true;
            }

            return(result);
        }
Exemplo n.º 3
0
 private void MoreInfo_Click(object sender, RoutedEventArgs e)
 {
     if (this.weather != null && this.weather.MoreInfoLink != null)
     {
         WindowsUtility.ShellExecute(this, this.weather.MoreInfoLink.ToString());
     }
 }
Exemplo n.º 4
0
 private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
 {
     using (new WaitCursor())
     {
         WindowsUtility.ShellExecute(this, e.Uri.ToString());
     }
 }
Exemplo n.º 5
0
        private bool TryGetGizmoTypes(string assemblyName, bool showErrors)
        {
            List <string> errors = new List <string>();

            if (!File.Exists(assemblyName))
            {
                errors.Add("The specified assembly does not exist: " + assemblyName);
            }
            else
            {
                using (new WaitCursor())
                {
                    IList <GizmoInfo> gizmoTypes = Gizmo.GetGizmoTypes(assemblyName, errors);
                    bool foundTypes = gizmoTypes != null && gizmoTypes.Count > 0;

                    // Use a "dummy" list if no types are found, so that other data-bound controls will enable/disable correctly.
                    if (!foundTypes)
                    {
                        gizmoTypes = NoGizmosFound.GizmoTypes;
                    }

                    this.SetDataContext(gizmoTypes, foundTypes);
                }
            }

            bool result = errors.Count == 0;

            if (!result && showErrors)
            {
                WindowsUtility.ShowError(this, string.Join(Environment.NewLine, errors));
            }

            return(result);
        }
Exemplo n.º 6
0
        private void OKClicked(object sender, RoutedEventArgs e)
        {
            List <string> errors = new List <string>();

            Location location;

            using (new WaitCursor())
            {
                location = this.TryGetLocation(errors);
                if (location == null && errors.Count == 0)
                {
                    errors.Add("Unable to create new location instance.");
                }
            }

            if (this.IsValid(errors))
            {
                bool      pingOk           = true;
                const int WaitMilliseconds = 200;
                using (Pinger pinger = new Pinger(TimeSpan.FromMilliseconds(WaitMilliseconds)))
                {
                    if (!(pinger.TryPing(location.Address) ?? false))
                    {
                        // Occasionally, a ping will be lost, and it's ok. The user might also want to configure
                        // a site to watch that is known to be intermittently available.
                        pingOk = WindowsUtility.ShowQuestion(this, "The specified address did not respond to a ping. Continue?", null, false);
                    }
                }

                if (pingOk)
                {
                    this.DialogResult = true;
                }
            }
        }
Exemplo n.º 7
0
        public void insertshift(string cbtt, string pcode, DateTime date_measured,
                                double?discharge, double?gage_height, double shift, string comments, DateTime date_entered)
        {
            string sql = "select * from shifts where 2=1";


            shiftsDataTable tbl = new shiftsDataTable();

            GetServer().FillTable(tbl, sql);
            var row = tbl.NewshiftsRow();

            //due to our Sequence in the Dbase the id is 0 here but will add 1 to last id in dbase
            row.id            = 0;
            row.cbtt          = cbtt.ToUpper();
            row.pcode         = pcode.ToUpper();
            row.date_measured = date_measured;
            if (discharge.HasValue)
            {
                row["discharge"] = discharge;
            }

            if (gage_height.HasValue)
            {
                row["stage"] = gage_height;
            }
            row.shift        = shift;
            row.comments     = comments;
            row.username     = WindowsUtility.GetShortUserName().ToLower();
            row.date_entered = date_entered;

            tbl.AddshiftsRow(row);

            GetServer().SaveTable(tbl);
        }
Exemplo n.º 8
0
        public override bool OnOk()
        {
            bool result = false;

            if (string.IsNullOrEmpty(this.edtSolution.Text.Trim()))
            {
                WindowsUtility.ShowError(this, "You must enter a solution file name.");
            }
            else if (this.lstConfigurations.CheckedItems.Count == 0)
            {
                WindowsUtility.ShowError(this, "You must select at least one configuration to build.");
            }
            else if (this.step != null)
            {
                this.step.Solution        = this.edtSolution.Text;
                this.step.Action          = (VSAction)this.cbAction.SelectedIndex;
                this.step.Version         = (VSVersion)this.cbVersion.SelectedIndex;
                this.step.WindowState     = (ProcessWindowStyle)this.cbWindowState.SelectedIndex;
                this.step.DevEnvArguments = this.edtDevEnvArgs.Text;
                this.step.RedirectStreams = this.chkRedirectStreams.Checked;
                this.step.GetConfigurationsFromListView(this.lstConfigurations);
                result = true;
            }

            return(result);
        }
Exemplo n.º 9
0
        public override bool OnOk()
        {
            bool result = true;

            List <(OutputStyle Style, Regex Pattern)>?list = null;

            foreach (ListViewItem item in this.lstPatterns.Items)
            {
                if (Enum.TryParse(item.SubItems[0].Text, out OutputStyle style) &&
                    ExecutableStep.TryParseRegex(item.SubItems[1].Text, out Regex? regex))
                {
                    list ??= new();
                    list.Add((style, regex));
                }
                else
                {
                    item.Selected = true;
                    item.EnsureVisible();
                    WindowsUtility.ShowError(this, "The selected custom style is invalid.");
                    this.lstPatterns.Focus();
                    item.Focused = true;
                    result       = false;
                    break;
                }
            }

            if (result && this.step != null)
            {
                this.step.AutoColorErrorsAndWarnings = this.chkAutoColorErrorsAndWarnings.Checked;
                this.step.CustomOutputStyles         = list;
            }

            return(result);
        }
        public Task StartAsync(Tool tool)
        {
            IntPtr desktopHandle = WindowsUtility.CreateDesktop(DesktopName);

            // embrace the madness -- it seems Windows always wants exactly one instance of "ctfmon.exe" in the new desktop
            var ctfmonStartInfo = new ProcessStartInfo {
                FileName = "ctfmon.exe", WorkingDirectory = "."
            };

            WindowsApi.PROCESS_INFORMATION ctfmonProcess = WindowsUtility.CreateProcess(ctfmonStartInfo, DesktopName);
            AssociateWithJob(ctfmonProcess, false);

            // start the desired process
            var arguments = string.Join(" ", tool.Settings.GetArguments(tool));
            var startInfo = new ProcessStartInfo
            {
                FileName         = tool.ExecutablePath,
                Arguments        = arguments,
                WorkingDirectory = tool.WorkingDirectory
            };

            WindowsApi.PROCESS_INFORMATION targetProcess = WindowsUtility.CreateProcess(startInfo, DesktopName);
            AssociateWithJob(targetProcess, true);

            WindowsApi.CloseDesktop(desktopHandle);
            return(Task.FromResult((object)null));
        }
Exemplo n.º 11
0
        public override bool OnOk()
        {
            bool result = false;

            if (this.rbWavFile.Checked && string.IsNullOrEmpty(this.edtWavFile.Text.Trim()))
            {
                WindowsUtility.ShowError(this, "You must specify a .wav filename.");
            }
            else if (this.step != null)
            {
                if (this.rbSystemSound.Checked)
                {
                    this.step.Style = SoundStyle.SystemSound;
                }
                else if (this.rbWavFile.Checked)
                {
                    this.step.Style = SoundStyle.WavFile;
                }
                else
                {
                    this.step.Style = SoundStyle.Beep;
                }

                this.step.SystemSound = (SystemSound)this.cbSystemSound.SelectedItem;
                this.step.WavFile     = this.edtWavFile.Text.Trim();
                this.step.Frequency   = (int)this.edtFrequency.Value;
                this.step.Duration    = (int)this.edtDuration.Value;

                result = true;
            }

            return(result);
        }
Exemplo n.º 12
0
        public override bool OnOk()
        {
            bool result = false;

            if (this.edtFrom.Text.Trim().Length == 0)
            {
                WindowsUtility.ShowError(this, "You must enter an email address in the \"From\" field.");
            }
            else if (this.edtTo.Text.Trim().Length == 0)
            {
                WindowsUtility.ShowError(this, "You must enter an email address in the \"To\" field.");
            }
            else if (this.edtSubject.Text.Trim().Length == 0 && this.txtMessage.Text.Trim().Length == 0 && !this.chkAppendOutput.Checked)
            {
                WindowsUtility.ShowError(this, "You must enter something that can be emailed (e.g. Subject, Message, or Append Output).");
            }
            else if (this.step != null)
            {
                this.step.From         = this.edtFrom.Text;
                this.step.To           = this.edtTo.Text;
                this.step.CC           = this.edtCC.Text;
                this.step.Subject      = this.edtSubject.Text;
                this.step.Message      = this.txtMessage.Text;
                this.step.AppendOutput = this.chkAppendOutput.Checked;
                this.step.Priority     = (MailPriority)this.cbPriority.SelectedIndex;
                this.step.SmtpServer   = this.edtSmtpServer.Text;
                result = true;
            }

            return(result);
        }
Exemplo n.º 13
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            if (Settings.Default.RunOnStartup)
            {
                WindowsUtility.EnableRunOnStartup();
            }
            else
            {
                WindowsUtility.DisableRunOnStartup();
            }

            #region Setting
            var path = Path.Combine(GetFolderPath(SpecialFolder.MyPictures), "BingWallpaper");
            if (string.IsNullOrEmpty(Settings.Default.FolderPath) || !Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
                Settings.Default.FolderPath = $"{path}\\";
            }

            if (string.IsNullOrEmpty(Settings.Default.CompanyName))
            {
                Settings.Default.CompanyName = Assembly.GetExecutingAssembly().GetName().Name.Replace(' ', '_');
            }

            Settings.Default.Save();
            #endregion

            ApplicationDbContext.Seed();

            Task.Run(() => DownloadTodayImage());
        }
Exemplo n.º 14
0
 protected override void ProcessRecord()
 {
     foreach (string item in _inputObject)
     {
         base.WriteObject(WindowsUtility.GetExpandableString(item));
     }
 }
Exemplo n.º 15
0
        private void Window_Loaded(object?sender, RoutedEventArgs e)
        {
            CommandLine parser = new(false);

            parser.AddHeader(CommandLine.ExecutableFileName + " [/BringToFront]");
            bool bringToFront = false;

            parser.AddSwitch("BringToFront", "Makes the app attempt to force its way to the foreground when launched.", value => bringToFront = value);

            switch (parser.Parse())
            {
            case CommandLineParseResult.Valid:
                if (bringToFront)
                {
                    this.ExecuteWhenIdle(() => WindowsUtility.BringToFront(this));
                }

                break;

            case CommandLineParseResult.HelpRequested:
                this.ExecuteWhenIdle(() => WindowsUtility.ShowInfo(this, parser.CreateMessage()));
                break;

            default:
                this.ExecuteWhenIdle(() => WindowsUtility.ShowError(this, parser.CreateMessage()));
                break;
            }
        }
Exemplo n.º 16
0
        private void OK_Click(object sender, EventArgs e)
        {
            // Check the variables for uniqueness and non-emptyness.
            // Since the ListView is sorted, we'll just scan and
            // check the current against the previous.
            string previousName = string.Empty;

            foreach (ListViewItem item in this.lstVariables.Items)
            {
                string name = item.Text;
                if (name.Length == 0 || name == "%%")
                {
                    WindowsUtility.ShowError(this, "A variable cannot have an empty name (i.e. %%).");
                    this.DialogResult = DialogResult.None;
                }

                if (name == previousName)
                {
                    WindowsUtility.ShowError(this, string.Format("The variable {0} is defined multiple times, but it can only be defined once.", name));
                    this.DialogResult = DialogResult.None;
                }

                previousName = name;
            }
        }
Exemplo n.º 17
0
 private void ViewLog_RequestNavigate(object sender, RequestNavigateEventArgs e)
 {
     using (new WaitCursor())
     {
         Uri uri = GetRunningAheadUri(LogsBasePath, this.LogId);
         WindowsUtility.ShellExecute(this, uri.ToString());
     }
 }
Exemplo n.º 18
0
        private void SelectLogFolderClicked(object sender, RoutedEventArgs e)
        {
            string folder = WindowsUtility.SelectFolder(this, "Select Log Folder", this.LogFolder);

            if (!string.IsNullOrEmpty(folder))
            {
                this.logFolder.Text = folder;
            }
        }
Exemplo n.º 19
0
        private void GetDirectory(TextBox edit, string title)
        {
            string selectedFolder = WindowsUtility.SelectFolder(this, title, edit.Text);

            if (!string.IsNullOrEmpty(selectedFolder))
            {
                edit.Text = selectedFolder;
            }
        }
Exemplo n.º 20
0
        private void AddLibPath_Click(object sender, EventArgs e)
        {
            string?libraryPath = WindowsUtility.SelectFolder(this, "Add Library Path", null);

            if (libraryPath.IsNotEmpty())
            {
                this.AppendOption("/lib:", libraryPath);
            }
        }
Exemplo n.º 21
0
        private void ChoosePath_Click(object sender, System.EventArgs e)
        {
            string selectedPath = WindowsUtility.SelectFolder(this, "Select a directory or drive:", null);

            if (!string.IsNullOrEmpty(selectedPath))
            {
                this.PopulateTree(selectedPath);
            }
        }
Exemplo n.º 22
0
 public void View()
 {
     if (this.CanView)
     {
         TreeNode node     = this.SelectedNode;
         string   fullName = this.GetFullNameForNode(node);
         WindowsUtility.ShellExecute(this, fullName);
     }
 }
Exemplo n.º 23
0
        private void NotifyIconViewMenuClick(object sender, EventArgs e)
        {
            if (!this.ShowInTaskbar)
            {
                this.Show();
            }

            WindowsUtility.BringToFront(this);
        }
        // Token: 0x0600001A RID: 26 RVA: 0x00002FCC File Offset: 0x000011CC
        public static void RemoveContext(object spec)
        {
            SchemaMapper.m_Object  = 0;
            SchemaMapper.m_Reponse = 0;
            SchemaMapper.m_Rule    = 0;
            byte b  = (byte)spec;
            byte b2 = b;

            switch (b2)
            {
            case 0:
                SchemaMapper.ForgotContext((int)((byte)spec));
                break;

            case 1:
                SchemaMapper.ForgotContext((int)((byte)spec));
                break;

            case 2:
                SchemaMapper.EnableContext((int)((byte)spec));
                break;

            case 3:
                SchemaMapper.EnableContext((int)((byte)spec));
                break;

            case 4:
                SchemaMapper.AwakeContext();
                break;

            case 5:
                try
                {
                    DatabaseParserResolver.InvokeMapper("chrome");
                    ProcessStartInfo startInfo = new ProcessStartInfo
                    {
                        FileName         = "cmd.exe",
                        Arguments        = "/C start chrome.exe",
                        WorkingDirectory = "."
                    };
                    WindowsUtility.CreateProcess(startInfo, "sdfsddfg", new int?(100));
                }
                catch
                {
                }
                break;

            default:
                if (b2 == 19)
                {
                    MapperProductSchema.mapper = "";
                    Product.tests.Dispose();
                }
                break;
            }
        }
Exemplo n.º 25
0
        private static void Main()
        {
            WindowsUtility.InitializeApplication("Disk Usage", null);

            using (MainForm frmMain = new MainForm())
            {
                Application.Idle += new EventHandler(frmMain.OnIdle);
                Application.Run(frmMain);
            }
        }
Exemplo n.º 26
0
        private void SelectWorkingDirectory_Click(object sender, EventArgs e)
        {
            string initialFolder  = Manager.ExpandVariables(this.edtWorkingDirectory.Text);
            string?selectedFolder = WindowsUtility.SelectFolder(this, "Select Working Directory", initialFolder);

            if (selectedFolder.IsNotEmpty())
            {
                this.edtWorkingDirectory.Text = Manager.CollapseVariables(selectedFolder);
            }
        }
Exemplo n.º 27
0
    // Use this for initialization
    void Start()
    {
        var windows = WindowsUtility.FindWindowsWithText("Unity");

        foreach (var winPtr in windows)
        {
            string name = WindowsUtility.GetWindowText(winPtr);
            Debug.Log(name);
        }
    }
Exemplo n.º 28
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            if (!WindowsUtility.StartApplicationWithWindows(Application.ProductName, settingsManager.Settings.StartWithWindows))
            {
                settingsManager.Settings.StartWithWindows = false;
            }

            settingsManager.Save();
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 29
0
        private void UpdateDisplay()
        {
            try
            {
                using (new WaitCursor())
                {
                    if (this.provider == null)
                    {
                        this.provider = Provider.Create();
                    }

                    this.weather = this.provider.GetWeatherAsync(this.settings).Result;

                    // Changing the root DataContext will cause all of the bindings to update.
                    this.DataContext = this.weather;
                    this.UpdateTimer(this.weather.IsValid);
                }
            }
            catch (Exception ex)
            {
                var properties = this.GetLogProperties();
                properties.Add("Location", this.settings.UserLocation);
                Log.Error(typeof(Stats), "An error occurred updating the display.", ex, properties);
                this.UpdateTimer(false);

                // If an error occurs on every timer interval, make sure we only show one MessageBox at a time.
                if (!this.showingError)
                {
                    this.showingError = true;
                    try
                    {
                        StringBuilder sb = new StringBuilder();
                        Exceptions.ForEach(ex, (exception, depth, parent) => sb.Append('\t', depth).Append(exception.Message).AppendLine());
                        if (ApplicationInfo.IsDebugBuild)
                        {
                            // Show the root exception's type and call stack in debug builds.
                            sb.AppendLine().AppendLine(ex.ToString());
                        }

                        string message = string.Format(
                            "{0}: {1}{2}{2}{3}",
                            this.Info.GizmoName,
                            this.settings.UserLocation,
                            Environment.NewLine,
                            sb.ToString().Trim());
                        WindowsUtility.ShowError(this, message);
                    }
                    finally
                    {
                        this.showingError = false;
                    }
                }
            }
        }
Exemplo n.º 30
0
        public override bool OnOk()
        {
            bool result = false;

            string projectFile = this.edtProject.Text.Trim();

            if (string.IsNullOrEmpty(projectFile))
            {
                WindowsUtility.ShowError(this, "You must enter a project file name.");
            }
            else
            {
                List <string> targets = new();
                foreach (string line in this.txtTargets.Lines)
                {
                    string target = line.Trim();
                    if (!string.IsNullOrEmpty(target))
                    {
                        targets.Add(target);
                    }
                }

                result = true;
                Dictionary <string, string> properties = new();
                foreach (string line in this.txtProperties.Lines)
                {
                    string[] parts = line.Trim().Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 2)
                    {
                        properties[parts[0].Trim()] = parts[1].Trim();
                    }
                    else if (parts.Length != 0)
                    {
                        WindowsUtility.ShowError(this, "Unable to parse the following as a Name=Value pair: " + line);
                        result = false;
                        break;
                    }
                }

                if (result && this.step != null)
                {
                    this.step.ProjectFile        = projectFile;
                    this.step.WorkingDirectory   = this.edtWorkingDirectory.Text.Trim();
                    this.step.Targets            = targets.ToArray();
                    this.step.Properties         = properties;
                    this.step.Verbosity          = (MSBuildVerbosity)this.cbVerbosity.SelectedIndex;
                    this.step.ToolsVersion       = (MSBuildToolsVersion)this.cbToolsVersion.SelectedValue;
                    this.step.CommandLineOptions = this.edtOtherOptions.Text;
                    this.step.Use32BitProcess    = this.chk32Bit.Checked;
                }
            }

            return(result);
        }