示例#1
0
        private void contextMenuStrip1_Opened(object sender, EventArgs e)
        {
            programItem pi = item_LV.SelectedItems[0] as programItem;

            folder_MI.Visible = runas_MI.Visible = !pi.isUrl && !pi.isDirectory;
            folder_MI.Visible = !pi.isUrl;
            folder_MI.Text    = pi.isDirectory ? "フォルダーの場所を開く" : "ファイルの場所を開く";
        }
示例#2
0
        private void mdown_MI_Click(object sender, EventArgs e)
        {
            var row   = dataGridView1.SelectedRows[0];
            var item  = new programItem(row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString(), row.Cells[4].Value.ToString(), -1, (bool)row.Cells[5].Value);
            int index = row.Index;

            programItemBindingSource.RemoveAt(index);
            programItemBindingSource.Add(item);
        }
示例#3
0
        private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = item_LV.SelectedItems.Count < 1;
            if (e.Cancel)
            {
                return;
            }
            programItem txt = (programItem)item_LV.SelectedItems[0];

            e.Cancel |= txt.path.Contains("add");
            e.Cancel |= txt.path.Contains("conf");
            e.Cancel |= txt.path.Contains("cfg");
            e.Cancel |= txt.path.Contains("end");
        }
示例#4
0
        private void addRow(params string[] rows)
        {
            if (rows.Length < 2)
            {
                return;
            }
            opening = true;
            bool isUrl = false, isDirectory = false;

            try {
                if (Directory.Exists(rows[1]))
                {
                    isDirectory = true;
                }
                else
                {
                    try {
                        using (var client = new HttpClient()) {
                            var response = client.GetAsync(rows[1]).Result;
                            if (response.StatusCode == System.Net.HttpStatusCode.OK)
                            {
                                isUrl = true;
                            }
                        }
                    }
                    catch { }
                }

                if (rows.Length > 4)
                {
                    var pitem = new programItem(rows[0].Trim(), rows[1].Trim(), rows[2].Trim(), rows[3].Trim(), rows[4].Trim(), -1, rows[rows.Length - 1] == "\a", isUrl, isDirectory);
                    programItemBindingSource.Add(pitem);
                }

                else if (rows.Length > 2)
                {
                    var pitem = new programItem(rows[0].Trim(), rows[1].Trim(), rows[2].Trim(), _imageindex: -1, _admin: rows[rows.Length - 1] == "\a", _isUrl: isUrl, _isDirectory: isDirectory);
                    programItemBindingSource.Add(pitem);
                }

                else if (rows.Length > 1)
                {
                    var pitem = new programItem(rows[0].Trim(), rows[1].Trim(), "", _imageindex: -1, _admin: rows[rows.Length - 1] == "\a", _isUrl: isUrl, _isDirectory: isDirectory);
                    programItemBindingSource.Add(pitem);
                }
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.Message);
            }
            opening = false;

            //if(rows.Length < 2) return;
            //try {
            //	if(rows.Length > 4) {
            //		var pitem = new programItem(rows[0].Trim(),rows[1].Trim(),rows[2].Trim(),rows[3].Trim(),rows[4].Trim(),-1,rows[rows.Length - 1] == "\a");
            //		programItemBindingSource.Add(pitem);
            //	}
            //	else if(rows.Length > 2) {
            //		var pitem = new programItem(rows[0].Trim(),rows[1].Trim(),rows[2].Trim(),_imageindex: -1,_admin: rows[rows.Length - 1] == "\a");
            //		programItemBindingSource.Add(pitem);
            //	}

            //	else if(rows.Length > 1) {
            //		var pitem = new programItem(rows[0].Trim(),rows[1].Trim(),"",_imageindex: -1,_admin: rows[rows.Length - 1] == "\a");
            //		programItemBindingSource.Add(pitem);
            //	}

            //}
            //catch(Exception ex) {
            //	Debug.WriteLine(ex.Message);
            //}
        }
示例#5
0
        private void addRow(int idx, params string[] rows)
        {
            if (rows.Length < 2)
            {
                return;
            }
            opening = true;
            int  imgnum = idx;
            bool isUrl = false, isDirectory = false;

            try {
                if (File.Exists(rows[1]))
                {
                    using (var ico = Icon.ExtractAssociatedIcon(rows[1])) {
                        s_IL.Images.Add($"{imgnum}", ico.ToBitmap());
                    }
                }
                else if (Directory.Exists(rows[1]))
                {
                    imgnum      = 3;
                    isDirectory = true;
                }
                else if (Regex.IsMatch(rows[1], @"^s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+$"))
                {
                    var bmp = Resources.web;
                    isUrl = true;
                    Task.Run(() => {
                        try {
                            using (var client = new HttpClient()) {
                                try {
                                    var response = client.GetAsync(rows[1]).Result;
                                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                                    {
                                        try {
                                            var uri = new Uri(rows[1]);
                                            using (var icon = client.GetStreamAsync($"{uri.GetLeftPart(UriPartial.Authority)}/favicon.ico")) {
                                                icon.Wait(5000);
                                                if (icon != null)
                                                {
                                                    bmp = new Bitmap(icon.Result);
                                                }
                                            }
                                        }
                                        catch {
                                        }
                                    }
                                    else
                                    {
                                        bmp = Resources.none;
                                    }
                                }
                                catch {
                                    bmp = Resources.none;
                                }
                            }

                            if (!IsDisposed)
                            {
                                if ((bool)item_LV?.InvokeRequired)
                                {
                                    item_LV?.Invoke((Action)(() => {
                                        s_IL?.Images?.Add($"{imgnum}", bmp);
                                    }));
                                }
                                else
                                {
                                    s_IL?.Images?.Add($"{imgnum}", bmp);
                                }
                            }

                            bmp?.Dispose();
                            bmp = null;
                        }
                        catch (Exception ex) {
                            Debug.WriteLine(ex.Message);
                        }
                    });
                }
                else
                {
                    s_IL.Images.Add($"{imgnum}", Resources.none);
                }

                programItem pitem;

                if (rows.Length > 4)
                {
                    pitem = new programItem(rows[0].Trim(), rows[1].Trim(), rows[2].Trim(), rows[3].Trim(), rows[4].Trim(), imgnum, rows[rows.Length - 1] == "\a", isUrl, isDirectory);
                }
                else if (rows.Length > 2)
                {
                    pitem = new programItem(rows[0].Trim(), rows[1].Trim(), rows[2].Trim(), _imageindex: imgnum, _admin: rows[rows.Length - 1] == "\a", _isUrl: isUrl, _isDirectory: isDirectory);
                }
                else if (rows.Length > 1)
                {
                    pitem = new programItem(rows[0].Trim(), rows[1].Trim(), "", _imageindex: imgnum, _admin: rows[rows.Length - 1] == "\a", _isUrl: isUrl, _isDirectory: isDirectory);
                }
                else
                {
                    opening = false;
                    return;
                }

                item_LV.Items.Add(pitem);
                if (Width < item_LV.Items[item_LV.Items.Count - 1].Bounds.Width + item_LV.Margin.Horizontal + SystemInformation.VerticalScrollBarWidth + 2)
                {
                    Width = item_LV.Items[item_LV.Items.Count - 1].Bounds.Width + item_LV.Margin.Horizontal + SystemInformation.VerticalScrollBarWidth + 2;
                }
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.Message);
            }
            opening = false;
        }