예제 #1
0
파일: FormMain.cs 프로젝트: manhg/malyst
 private void mnuDataResample_Click(object sender, EventArgs e)
 {
     //openFileDialog.Filter = UI.Properties.Settings.Default.ImageFileFilter;
     //openFileDialog.Title = "Chon anh can dua ve 100dpi";
     //openFileDialog.Multiselect = true;
     //if (openFileDialog.ShowDialog() == DialogResult.OK)
     //{
     folderBrowserDialog.ShowNewFolderButton = false;
     folderBrowserDialog.Description         = "Chọn thư mục chứa các ảnh cần đưa về 100 dpi. Các file ảnh hỗ trợ gồm *.jpg, *.bmp, *.tif";
     if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
     {
         System.Collections.Specialized.StringCollection files = new System.Collections.Specialized.StringCollection();
         string[] jpg = Directory.GetFiles(folderBrowserDialog.SelectedPath, "*.jpg");
         string[] bmp = Directory.GetFiles(folderBrowserDialog.SelectedPath, "*.bmp");
         string[] tif = Directory.GetFiles(folderBrowserDialog.SelectedPath, "*.tif");
         if (jpg != null)
         {
             files.AddRange(jpg);
         }
         if (bmp != null)
         {
             files.AddRange(bmp);
         }
         if (tif != null)
         {
             files.AddRange(tif);
         }
         StringBuilder err  = new StringBuilder();
         string        path = folderBrowserDialog.SelectedPath + "\\100dpi";
         Directory.CreateDirectory(path);
         foreach (string file in files)
         {
             try
             {
                 Image img = Image.FromFile(file);
                 Core.Utility.Resample(100, img).Save(
                     path + "\\" + Core.Utility.GetSafeFileName(file) + ".jpg",
                     System.Drawing.Imaging.ImageFormat.Jpeg);
                 img.Dispose();
             }
             catch (Exception ex) { err.AppendLine("Không chuyển được file: " + file + ". Vui lòng kiểm tra lại. \n" + ex.Message); }
         }
         if (err.Length != 0)
         {
             Core.Utility.Error(err.ToString());
         }
         Core.Utility.Msg("Đã chuyển song sang thư mục: " + path);
         System.Diagnostics.Process.Start(path);
     }
 }
예제 #2
0
        private void DropFileOutsideApplication(TreeNode node)
        {
            if (node is ArchiveFileWrapper)
            {
                Runtime.EnableDragDrop = false;

                string fullPath = Write2TempAndGetFullPath(((ArchiveFileWrapper)node).ArchiveFileInfo);

                DataObject dragObj = new DataObject();
                dragObj.SetFileDropList(new System.Collections.Specialized.StringCollection()
                {
                    fullPath
                });
                treeViewCustom1.DoDragDrop(dragObj, DragDropEffects.Copy);

                Runtime.EnableDragDrop = true;
            }
            else if (node is ArchiveFolderNodeWrapper || node is ArchiveRootNodeWrapper)
            {
                Runtime.EnableDragDrop = false;

                string[] fullPaths = Write2TempAndGetFullPath(node);

                DataObject dragObj    = new DataObject();
                var        collection = new System.Collections.Specialized.StringCollection();
                collection.AddRange(fullPaths);
                dragObj.SetFileDropList(collection);
                treeViewCustom1.DoDragDrop(dragObj, DragDropEffects.Copy);

                Runtime.EnableDragDrop = true;
            }
        }
예제 #3
0
        private void FixAdministrator()
        {
            using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForReading))
            {
                if (users.Count == 0)
                {
                    Logger.Warn("No users found, adding Administrator account with default password");

                    l.UpgradeToWriterLock();
                    UserInfo adminInfo = new UserInfo("Administrator", "ServerChecker4");
                    users.Add(adminInfo.Username, adminInfo);
                    l.DowngradeToReaderLock();
                }

                SecuritySubject me = acls[securityGuid];
                System.Collections.Specialized.StringCollection permissions = new System.Collections.Specialized.StringCollection();
                permissions.AddRange(me.GetPermissions());

                if (permissions.Count == 0)
                {
                    Logger.Warn("No permissions found for SecurityManager. Adding permission for Administrator account");

                    l.UpgradeToWriterLock();
                    me.AddPermission("Administrator");
                    l.DowngradeToReaderLock();
                }
            }
        }
예제 #4
0
        /// ---------------------------------------------------------------------------------------
        /// <summary>
        ///     指定した検索パターンに一致するファイルを最下層まで検索しすべて返します。</summary>
        /// <param name="stRootPath">
        ///     検索を開始する最上層のディレクトリへのパス。</param>
        /// <param name="stPattern">
        ///     パス内のファイル名と対応させる検索文字列。</param>
        /// <returns>
        ///     検索パターンに一致したすべてのファイルパス。</returns>
        /// ---------------------------------------------------------------------------------------
        public static string[] GetFilesMostDeep(string stRootPath, string stPattern)
        {
            System.Collections.Specialized.StringCollection hStringCollection = (
                new System.Collections.Specialized.StringCollection()
                );

            // このディレクトリ内のすべてのファイルを検索する
            foreach (string stFilePath in Directory.GetFiles(stRootPath, stPattern))
            {
                hStringCollection.Add(stFilePath);
            }

            // このディレクトリ内のすべてのサブディレクトリを検索する (再帰)
            foreach (string stDirPath in Directory.GetDirectories(stRootPath))
            {
                string[] stFilePaths = GetFilesMostDeep(stDirPath, stPattern);

                // 条件に合致したファイルがあった場合は、ArrayList に加える
                if (stFilePaths != null)
                {
                    hStringCollection.AddRange(stFilePaths);
                }
            }

            // StringCollection を 1 次元の String 配列にして返す
            string[] stReturns = new string[hStringCollection.Count];
            hStringCollection.CopyTo(stReturns, 0);

            return(stReturns);
        }
예제 #5
0
        /// <summary>
        /// 复制文件到剪贴板
        /// </summary>
        /// <param name="filePaths">文件的路径集合</param>
        /// <returns></returns>
        public static void CopyFileToClipBoard(string[] filePaths)
        {
            var strColl = new System.Collections.Specialized.StringCollection();

            strColl.AddRange(filePaths);
            Clipboard.SetFileDropList(strColl);
        }
예제 #6
0
        public override void SetClipboardFileDropList(string[] filedrops)
        {
            var stringCollection = new System.Collections.Specialized.StringCollection();

            stringCollection.AddRange(filedrops);
            System.Windows.Forms.Clipboard.SetFileDropList(stringCollection);
        }
 public static void Save <T>(
     System.Collections.Specialized.StringCollection collection,
     ConcurrentDictionary <int, T> dictionary, Func <T, string> valueSelector)
 {
     collection.Clear();
     collection.AddRange(dictionary.Select(x => WriteMapping(x, valueSelector)).ToArray());
 }
예제 #8
0
        /// ---------------------------------------------------------------------------------------
        /// <summary>
        ///     指定した検索パターンに一致するファイルを最下層まで検索しすべて返します。</summary>
        /// <param name="stRootPath">
        ///     検索を開始する最上層のディレクトリへのパス。</param>
        /// <param name="stPattern">
        ///     パス内のファイル名と対応させる検索文字列。</param>
        /// <returns>
        ///     検索パターンに一致したすべてのファイルパス。</returns>
        /// ---------------------------------------------------------------------------------------
        public static string[] GetFilesMostDeep(string stRootPath, string stPattern, string label)
        {
            System.Collections.Specialized.StringCollection hStringCollection = (
                new System.Collections.Specialized.StringCollection()
                );

            // このディレクトリ内のすべてのファイルを検索する
            foreach (string stFilePath in System.IO.Directory.GetFiles(stRootPath, stPattern))
            {
                // ファイルパスに"config","docs","oem"がある場合は検索せずにスキップする
                if (Regex.IsMatch(stFilePath, "config") || Regex.IsMatch(stFilePath, "docs") || Regex.IsMatch(stFilePath, "oem"))
                {
                    continue;
                }

                // ファイルパスが".cpio.gz_20170719_1220"で終わるフォルダは検索せずにスキップする
                if (Regex.IsMatch(stFilePath, ".cpio.gz_(\\d+)_(\\d+)"))
                {
                    continue;
                }

                if (!Regex.IsMatch(stFilePath, label))
                {
                    continue;
                }

                string stExtension = System.IO.Path.GetExtension(stFilePath);
                string dirPath     = System.IO.Path.GetDirectoryName(stFilePath);

                if (stExtension == ".gz")
                {
                    //解凍インターフェース
                    extract7zip(stFilePath, dirPath);
                }
                else if (stExtension == ".cpio" || stExtension == ".rpm")
                {
                    //解凍インターフェース
                    extract7zip(stFilePath, dirPath);
                    System.IO.File.Delete(stFilePath);
                }
                hStringCollection.Add(stFilePath);
            }

            // このディレクトリ内のすべてのサブディレクトリを検索する (再帰)
            foreach (string stDirPath in System.IO.Directory.GetDirectories(stRootPath))
            {
                string[] stFilePathes = GetFilesMostDeep(stDirPath, stPattern, label);

                // 条件に合致したファイルがあった場合は、ArrayList に加える
                if (stFilePathes != null)
                {
                    hStringCollection.AddRange(stFilePathes);
                }
            }

            // StringCollection を 1 次元の String 配列にして返す
            string[] stReturns = new string[hStringCollection.Count];
            hStringCollection.CopyTo(stReturns, 0);
            return(stReturns);
        }
예제 #9
0
        /// <summary>
        /// 指定した検索パターンに一致するファイルを最下層まで検索し全てを返す
        /// </summary>
        /// <param name="strRootPath"></param>
        /// <param name="strPatterns"></param>
        /// <returns></returns>
        public string[] GetFilesMostDeep(string strRootPath, string[] strPatterns)
        {
            var hStringCollection = new System.Collections.Specialized.StringCollection();

            //このディレクトリ内のすべてのファイルを検索する
            foreach (string strFilePath in System.IO.Directory.GetFiles(strRootPath, "*"))
            {
                foreach (string strPattern in strPatterns)
                {
                    if ("*" + Path.GetExtension(strFilePath) == strPattern)
                    {
                        hStringCollection.Add(strFilePath);
                    }
                }
            }

            //このディレクトリ内のすべてのサブディレクトリを検索する(再帰)
            foreach (string strDirPath in Directory.GetDirectories(strRootPath))
            {
                string[] strFilePathes = GetFilesMostDeep(strDirPath, strPatterns);
                //条件に合致したファイルが有った場合は、ArrayListに加える
                if (strFilePathes != null)
                {
                    hStringCollection.AddRange(strFilePathes);
                }
            }
            //StringCollectionを1次元のString配列に変換して返す
            string[] strReturns = new string[hStringCollection.Count];
            hStringCollection.CopyTo(strReturns, 0);

            return(strReturns);
        }
예제 #10
0
        public string[] GetAllSubDirectories(string stRootPath)
        {
            System.Collections.Specialized.StringCollection hStringCollection = (
                new System.Collections.Specialized.StringCollection()
                );

            hStringCollection.Add(stRootPath);

            try
            {
                // このディレクトリ内のすべてのサブディレクトリを検索する (再帰)
                foreach (string stDirPath in System.IO.Directory.GetDirectories(stRootPath))
                {
                    string[] stFilePathes = GetAllSubDirectories(stDirPath);

                    // 条件に合致したファイルがあった場合は、ArrayList に加える
                    if (stFilePathes != null)
                    {
                        hStringCollection.AddRange(stFilePathes);
                    }
                }
            }
            catch (Exception)
            {
            }

            // StringCollection を 1 次元の String 配列にして返す
            string[] stReturns = new string[hStringCollection.Count];
            hStringCollection.CopyTo(stReturns, 0);

            return(stReturns);
        }
예제 #11
0
 /// <summary>
 /// ファイルパスをクリップボードにコピーする
 /// </summary>
 /// <param name="paths">コピーするファイルパス</param>
 static public void CopyFilesToClipboard(params string[] paths)
 {
     //コピーするファイルのパスをStringCollectionに追加する
     System.Collections.Specialized.StringCollection files = new System.Collections.Specialized.StringCollection();
     files.AddRange(paths);
     //クリップボードにコピーする
     Clipboard.SetFileDropList(files);
 }
예제 #12
0
        protected void BootstrapConfiguration()
        {
            m_skipDirs.AddRange(new string[] { "output", "obj", "debug", "ww-conchx", "bin", "cominterfaces", "generated", "templates", "modeltesting" });

            m_skipNameParts.AddRange(new string[] { "copy (", "copy of", ".user", "thumbs.db", "b4", "generated", ".suo", ".log", ".exe", ".dll", ".ncb", "dbversion" });
            m_skipNameParts.AddRange(new string[] { "cellar.cs", "featsys.cs", "langproj.cs", "ling.cs", "notebk.cs", "scripture.cs" });

            SetupConfigurationDocument();
            foreach (string path in m_skipDirs)
            {
                AddDirectoryPath(path);
            }
            foreach (string pattern in m_skipNameParts)
            {
                AddNamePart(pattern);
            }
            SaveConfiguration();
        }
예제 #13
0
        public void InvokeMethodTest()
        {
            var s = new System.Collections.Specialized.StringCollection();

            s.AddRange(new[] { "A", "B", "C" });
            var sa = new string[3];

            Assert.That(() => s.InvokeMethod("CopyTo", new[] { typeof(string[]), typeof(int) }, new object[] { sa, 0 }), Throws.Nothing);
            Assert.That(() => s.InvokeMethod("CopyTo", sa, 0), Throws.Nothing);
            Assert.That(sa[0] == "A");
            Assert.That(() => s.InvokeMethod("Clear"), Throws.Nothing);
            Assert.That(s.Count == 0);
            s.AddRange(sa);
            Assert.That(() => s.InvokeMethod("Clear", Type.EmptyTypes, null), Throws.Nothing);
            Assert.That(s.Count == 0);
            Assert.That(() => s.InvokeMethod("Clr", Type.EmptyTypes, null), Throws.ArgumentException);
            Assert.That(() => s.InvokeMethod <DateTime>("ToBinary", Type.EmptyTypes, null), Throws.ArgumentException);
        }
        public void SetValues(string path, IEnumerable <string> values)
        {
            path = path.Replace(":", "_");
            var stringCollection = new System.Collections.Specialized.StringCollection();

            stringCollection.AddRange(values.ToArray());
            Settings.Default[path] = stringCollection;
            Settings.Default.Save();
        }
예제 #15
0
 private void SaveRecentFont()
 {
     if (this == RibbonViewModel.FontFace)
     {
         var recentFonts = new System.Collections.Specialized.StringCollection();
         recentFonts.AddRange(this.FontFamilies.Where(f => f.IsRecent).Select(x => x.Name).ToArray());
         Naver.Compass.Common.Helper.GlobalData.RecentFonts = recentFonts;
     }
 }
예제 #16
0
        private Guid RegisterSubject(string name, string[] additionalOperations, string username)
        {
            Logger.Debug("Registered subject " + name);

            using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForWriting))
            {
                SecuritySubject subject;
                if (!subjects.ContainsKey(name))
                {
                    if (username == null)
                    {
                        subjects[name] = new SecuritySubject(name);
                    }
                    else
                    {
                        subjects[name] = new SecuritySubject(name, username);
                    }
                }

                subject = subjects[name];

                Guid guid = Guid.NewGuid();

                while (acls.ContainsKey(guid))
                {
                    guid = Guid.NewGuid();
                }

                acls.Add(guid, subject);

                if (additionalOperations != null)
                {
                    Logger.Debug("Additional operations " + string.Join(", ", additionalOperations));
                    System.Collections.Specialized.StringCollection operations = new System.Collections.Specialized.StringCollection();
                    operations.AddRange(additionalOperations);

                    foreach (string op in operations)
                    {
                        if (!subject.HaveOperation(op))
                        {
                            subject.AddOperation(op);
                        }
                    }
                    operations.Add(Operation.DEFAULT_OPERATION);
                    foreach (string op in subject.GetOperations())
                    {
                        if (!operations.Contains(op))
                        {
                            subject.RemoveOperation(op);
                        }
                    }
                }
                return(guid);
            }
        }
        private void btnDownload_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtLinks.Text))
            {
                var strCol = new System.Collections.Specialized.StringCollection();
                strCol.AddRange(txtLinks.Text.Split('\r'));
                var videoList = VKontakteApiWrapper.Instance.VideoGetByIds(Utils.StringUtils.GetUserAndObjectIDFromUrl(strCol));
                this.Close();

                DownloadVideo wind = new DownloadVideo(videoList);
                wind.Owner = App.Current.MainWindow;
                wind.Show();
            }
        }
예제 #18
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (lstServices.SelectedItems.Count > 0)
     {
         selectedServices = new System.Collections.Specialized.StringCollection();
         selectedServices.AddRange
         (
             (from object lstItem in lstServices.SelectedItems
              select lstItem.ToString()).ToArray()
         );
         DialogResult = DialogResult.OK;
         Close();
     }
 }
예제 #19
0
        private void BtnAdicionaListaRetirar_Click(object sender, EventArgs e)
        {
            System.Collections.Specialized.StringCollection colecao = new System.Collections.Specialized.StringCollection();
            colecao.AddRange(GetNome(TbListaRetirar.Text));
            Properties.Settings.Default.ListaRetirar = colecao;
            Properties.Settings.Default.Save();
            TbListaRetirar.Text = ArrayToString(Properties.Settings.Default.ListaRetirar);
            DialogResult result = MessageBox.Show("A lista de exclusão foi salva.");

            if (result == DialogResult.OK)
            {
                tbInputTexto.Text = RemoveLinhas(ReitarItensListados(GetNomes(tbInputTexto.Text), Properties.Settings.Default.ListaRetirar), tbInputTexto.SelectedText);
                Expandir();
            }
        }
예제 #20
0
 public static void SetPaths(IEnumerable <string> collection)
 {
     lock (_thisLock)
     {
         try
         {
             var list = new System.Collections.Specialized.StringCollection();
             list.AddRange(collection.ToArray());
             System.Windows.Clipboard.SetFileDropList(list);
         }
         catch (Exception)
         {
         }
     }
 }
예제 #21
0
        private void mnuRefreshP4_Click(object sender, System.EventArgs e)
        {
            LoadFileList();

            System.Collections.Specialized.StringCollection opened = new System.Collections.Specialized.StringCollection();
            opened.AddRange(m_p4.GetP4OpenFiles());

            foreach (ListViewItem item in m_list.Items)
            {
                if (opened.Contains((string)item.Tag))
                {
                    item.ImageIndex = 1;
                    item.ForeColor  = System.Drawing.Color.Blue;
                }
            }
        }
예제 #22
0
        private void ApplyBtn_Click(object sender, EventArgs e)
        {
            List <string> ActiveModules = new List <string>();

            for (int i = 0; i < LoadOrderList.CheckedItems.Count; i++)
            {
                string Name = LoadOrderList.CheckedItems[i].ToString().Split(new char[] { ':' }).FirstOrDefault();
                ActiveModules.Add(Name);
            }
            System.Collections.Specialized.StringCollection s = new System.Collections.Specialized.StringCollection();
            s.AddRange(ActiveModules.ToArray());
            Properties.CoreSettings.Default.LoadOrder = s;
            Properties.CoreSettings.Default.Save();

            AnimaCentral.PlugMan.SortLoadOrder();

            this.Hide();
        }
예제 #23
0
        DataObject GetDataObject(ListView targetListView)
        {
            if (targetListView.SelectedItems.Count == 0)
            {
                return(null);
            }
            object data = targetListView.SelectedItems;

            System.Collections.IList items = (System.Collections.IList)data;
            var collection = items.Cast <UserData>();

            if (data != null)
            {
                DataObject obj = new DataObject();
                switch (targetListView.Name.ToLower())
                {
                case "files":
                case "folders":
                    List <string> filePaths = new List <string>();
                    foreach (UserData ud in collection)
                    {
                        filePaths.Add(new System.IO.FileInfo(ud.Data.ToString()).FullName);
                    }
                    System.Collections.Specialized.StringCollection sc = new System.Collections.Specialized.StringCollection();
                    sc.AddRange(filePaths.ToArray());
                    obj.SetFileDropList(sc);
                    break;

                case "texts":
                    string textData = "";
                    foreach (UserData ud in collection)
                    {
                        textData = textData + ud.Data;
                    }
                    obj.SetText(textData);
                    break;

                default: return(null);
                }
                return(obj);
            }
            return(null);
        }
예제 #24
0
        // Splits a string containing new lines (assumed to be \n or \r\n) and passes each
        // line to FormatSingleLineMaxChars and returns the resulting string array
        public static string[] FormatMultiLineMaxChars(int maxLen, string sLine)
        {
            System.Diagnostics.Debug.Assert(maxLen > 0, "Max must be at least 1");
            if (maxLen <= 0)
            {
                return(null);
            }

            string[] lines = sLine.Replace("\r", "").Split(new char[] { '\n' });
            System.Collections.Specialized.StringCollection formattedLines = new System.Collections.Specialized.StringCollection();

            foreach (string line in lines)
            {
                formattedLines.AddRange(FormatSingleLineMaxChars(maxLen, line));
            }

            string[] multi = new string[formattedLines.Count];
            formattedLines.CopyTo(multi, 0);
            return(multi);
        }
예제 #25
0
        protected ArrayList GetUniqueTransitionEvents(bool qualifiedEvent)
        {
            Hashtable uniqueEventNames = new Hashtable();
            ArrayList list             = new ArrayList();

            foreach (ITransitionGlyph trans in _Transitions)
            {
                System.Collections.Specialized.StringCollection eventNames = new System.Collections.Specialized.StringCollection();

                string eventNameOnly = null;
                if (qualifiedEvent)
                {
                    eventNameOnly = trans.QualifiedEvent;
                }
                else
                {
                    eventNameOnly = trans.EventSignal;
                }

                eventNames.Add(eventNameOnly);

                if (IsNotEmptyString(trans.Action))
                {
                    string[] signals = ParseActionForSignals(trans.Action);
                    eventNames.AddRange(signals);
                }

                foreach (string eventName in eventNames)
                {
                    if (!uniqueEventNames.Contains(eventName))
                    {
                        list.Add(eventName);
                        uniqueEventNames.Add(eventName, "");
                    }
                }
            }
            list.Sort();
            return(list);
        }
예제 #26
0
        public static IDataObject ToFileDropList(this IEnumerable <string> strings, bool move = false)
        {
            if (strings == null || strings.Count() == 0)
            {
                return(null);
            }

            var dropList = new System.Collections.Specialized.StringCollection();

            dropList.AddRange(strings.ToArray());

            var data = new DataObject();

            data.SetFileDropList(dropList);
            if (move)
            {
                var bytes = new byte[] { (byte)(DragDropEffects.Move), 0, 0, 0 };
                data.SetData("Preferred DropEffect", new MemoryStream(bytes));
            }

            return(data);
        }
예제 #27
0
        private void CmdApplyChanges_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TxtFullName.Text))
            {
                MessageBox.Show("Put your full name.");
                return;
            }

            /*if (RbEmail.Checked && (string.IsNullOrEmpty(TxtEmail.Text)
            || string.IsNullOrEmpty(TxtEMailPassword.Text)
            || string.IsNullOrEmpty(TxtReceivers.Text)))
            || {
            ||  MessageBox.Show("Fill out all the e-mail settings or configure the E-Mail connection.");
            ||  return;
            || }*/
            //TODO: Add TCP Check

            System.Collections.Specialized.StringCollection collection = new System.Collections.Specialized.StringCollection();
            collection.AddRange(lbItems.Items.OfType <string>().ToArray());

            Properties.Settings.Default.Purposes          = collection;
            Properties.Settings.Default.EMail             = TxtEmail.Text;
            Properties.Settings.Default.Password          = TxtEMailPassword.Text;
            Properties.Settings.Default.DestEmail         = TxtReceivers.Text;
            Properties.Settings.Default.DefaultSearch     = string.IsNullOrEmpty(TxtDefaultSearch.Text) ? "" : TxtDefaultSearch.Text;
            Properties.Settings.Default.Name              = TxtFullName.Text;
            Properties.Settings.Default.EMailServerMethod = CbHosts.SelectedIndex;
            Properties.Settings.Default.EMailDomain       = (CbHosts.SelectedIndex == 3) ? TxtEmailDomain.Text : "";
            Properties.Settings.Default.EMailPort         = (CbHosts.SelectedIndex == 3) ? int.Parse(TxtEmailDomain.Text) : 0;
            Properties.Settings.Default.EMailSSL          = CbxEmailSSL.Checked;

            /*Properties.Settings.Default.
            *  Properties.Settings.Default.*/

            Properties.Settings.Default.Save();

            this.Close();
        }
예제 #28
0
        private void lvFileBrowser_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                System.Collections.Specialized.StringCollection filePath = new System.Collections.Specialized.StringCollection();
                if (lvFileBrowser.SelectedItems.Count > 0)
                {
                    try
                    {
                        filePath.AddRange(GetSelectedFilesPathesLV().ToArray());
                        DataObject dataObject = new DataObject();

                        dataObject.SetFileDropList(filePath);
                        lvFileBrowser.DoDragDrop(dataObject, DragDropEffects.Copy);
                        DoDragDrop(lvFileBrowser.SelectedItems, DragDropEffects.Copy);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Drag mouse down pack exception : {ex.Message}");
                    }
                }
            }
        }
예제 #29
0
        public static ManagementObjectCollection QueryInstacnes(String scope, String className, String condition, String[] selectedProperties)
        {
            if (String.IsNullOrEmpty(scope))
            {
                throw new ArgumentNullException("scope");
            }
            if (String.IsNullOrEmpty(className))
            {
                throw new ArgumentNullException("className");
            }
            var query = new SelectQuery(className, condition);

            if (selectedProperties != null)
            {
                var collection = new System.Collections.Specialized.StringCollection();
                collection.AddRange(selectedProperties);
                query.SelectedProperties = collection;
            }
            using (var search = new ManagementObjectSearcher(new ManagementScope(scope), query))
            {
                try
                {
                    var result = search.Get();
                    if (result.Count == 0)
                    {
                        throw new NotImplementedException(String.Format("Can't find wmi object: namespace='{0}', class='{1}', condition='{2}'",
                                                                        scope, className, condition));
                    }
                    return(result);
                }
                catch (ManagementException e)
                {
                    throw new ManagementException(String.Format("Wmi query error: namespace='{0}', class='{1}', condition='{2}'\n",
                                                                scope, className, condition), e);
                }
            }
        }
예제 #30
0
        private void buttonOK_Click(object sender, System.EventArgs e)
        {
            _selectedfont.Clear();
            switch (this.tabControlSchema.SelectedIndex)
            {
            case 0:
                for (int i = 0; i < this.fontListBoxSystem.SelectedIndices.Count; i++)
                {
                    _selectedfont.Add((string)this.fontListBoxSystem.SelectedItems[i]);
                }
                break;

            case 1:
                for (int i = 0; i < this.fontListBoxWeb.SelectedIndices.Count; i++)
                {
                    _selectedfont.Add((string)this.fontListBoxWeb.SelectedItems[i]);
                }
                break;

            case 2:
                for (int i = 0; i < this.fontListBoxGeneric.SelectedIndices.Count; i++)
                {
                    _selectedfont.Add((string)this.fontListBoxGeneric.SelectedItems[i]);
                }
                break;

            case 3:
                if (this.textBoxFreeFont.TextLength > 1)
                {
                    string[] lines = this.textBoxFreeFont.Text.Split(new char[] { '\n' });
                    _selectedfont.AddRange(lines);
                }
                break;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
예제 #31
0
 private void G_I_listView_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         System.Collections.Specialized.StringCollection filePath = new
                                                                    System.Collections.Specialized.StringCollection();
         if (G_I_listView.SelectedItems.Count > 0)
         {
             List <string> buf = new List <string>();
             try
             {
                 buf.Add(G_I_listView.SelectedItems[0].ImageKey);
                 filePath.AddRange(buf.ToArray());
                 DataObject dataObject = new DataObject();
                 dataObject.SetFileDropList(filePath);
                 G_I_listView.DoDragDrop(dataObject, DragDropEffects.Copy);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
예제 #32
0
        /// <summary>
        /// リストリフレッシュ
        /// </summary>
        private void Refresh()
        {
            (CollectionViewSource.GetDefaultView(LauncherItems) as ICollectionView).Refresh();

            var collection = new System.Collections.Specialized.StringCollection();
            collection.AddRange(LauncherItems.Select(a => a.FullPath).ToArray());
            Properties.Settings.Default.RegisterdItems = collection;
            Properties.Settings.Default.Save();
        }
예제 #33
0
 /// <summary>
 /// Set files note
 /// </summary>
 /// <param name="files">files note</param>
 /// <returns>return true if success</returns>
 public static bool SetClipboardFiles(string[] files)
 {
     try
     {
         System.Collections.Specialized.StringCollection coll = new System.Collections.Specialized.StringCollection();
         coll.AddRange(files);
         FORMS.Clipboard.SetFileDropList(coll);
         return true;
     }
     catch
     {
         return false;
     }
 }
예제 #34
0
        // Splits a string containing new lines (assumed to be \n or \r\n) and passes each
        // line to FormatSingleLineMaxChars and returns the resulting string array
        public static string[] FormatMultiLineMaxChars( int maxLen, string sLine )
        {
            System.Diagnostics.Debug.Assert( maxLen > 0, "Max must be at least 1" );
              if(  maxLen <= 0 ) return null;

              string[] lines = sLine.Replace( "\r", "" ).Split( new char[]{'\n'} );
              System.Collections.Specialized.StringCollection formattedLines = new System.Collections.Specialized.StringCollection();

              foreach( string line in lines )
            formattedLines.AddRange( FormatSingleLineMaxChars( maxLen, line ) );

              string[] multi = new string[ formattedLines.Count ];
              formattedLines.CopyTo( multi, 0 );
              return multi;
        }
 public override System.Collections.Specialized.StringCollection GetFunctionsIceIds()
 {
     System.Collections.Specialized.StringCollection _functionsIceIds =
     new System.Collections.Specialized.StringCollection();
     _functionsIceIds.AddRange(
         this.iceBoxModulePrx.getFunctionsIceIds());
     return _functionsIceIds;
 }
예제 #36
0
        private void FixAdministrator()
        {
            using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForReading))
            {
                if (users.Count == 0)
                {
                    Logger.Warn("No users found, adding Administrator account with default password");

                    l.UpgradeToWriterLock();
                    UserInfo adminInfo = new UserInfo("Administrator", "ServerChecker4");
                    users.Add(adminInfo.Username, adminInfo);
                    l.DowngradeToReaderLock();
                }

                SecuritySubject me = acls[securityGuid];
                System.Collections.Specialized.StringCollection permissions = new System.Collections.Specialized.StringCollection();
                permissions.AddRange(me.GetPermissions());

                if (permissions.Count == 0)
                {
                    Logger.Warn("No permissions found for SecurityManager. Adding permission for Administrator account");

                    l.UpgradeToWriterLock();
                    me.AddPermission("Administrator");
                    l.DowngradeToReaderLock();
                }
            }
        }
예제 #37
0
        private Guid RegisterSubject(string name, string[] additionalOperations, string username)
        {
            Logger.Debug("Registered subject " + name);

            using (SC.Utility.Lock l = new SC.Utility.Lock(secLock, SC.Utility.Lock.LockType.ForWriting))
            {
                SecuritySubject subject;
                if (!subjects.ContainsKey(name))
                {
                    if (username == null)
                        subjects[name] = new SecuritySubject(name);
                    else
                        subjects[name] = new SecuritySubject(name, username);
                }

                subject = subjects[name];

                Guid guid = Guid.NewGuid();

                while (acls.ContainsKey(guid))
                    guid = Guid.NewGuid();

                acls.Add(guid, subject);

                if (additionalOperations != null)
                {
                    Logger.Debug("Additional operations " + string.Join(", ", additionalOperations));
                    System.Collections.Specialized.StringCollection operations = new System.Collections.Specialized.StringCollection();
                    operations.AddRange(additionalOperations);

                    foreach (string op in operations)
                    {
                        if (!subject.HaveOperation(op))
                            subject.AddOperation(op);
                    }
                    operations.Add(Operation.DEFAULT_OPERATION);
                    foreach (string op in subject.GetOperations())
                    {
                        if (!operations.Contains(op))
                            subject.RemoveOperation(op);
                    }
                }
                return guid;
            }
        }
        protected ArrayList GetUniqueTransitionEvents(bool qualifiedEvent)
        {
            Hashtable uniqueEventNames = new Hashtable ();
            ArrayList list = new ArrayList ();
            foreach (ITransitionGlyph trans in _Transitions)
            {
                System.Collections.Specialized.StringCollection eventNames = new System.Collections.Specialized.StringCollection ();

                string eventNameOnly = null;
                if (qualifiedEvent)
                {
                    eventNameOnly = trans.QualifiedEvent;
                }
                else
                {
                    eventNameOnly = trans.EventSignal;
                }

                eventNames.Add (eventNameOnly);

                if (IsNotEmptyString (trans.Action))
                {
                    string[] signals = ParseActionForSignals (trans.Action);
                    eventNames.AddRange (signals);
                }

                foreach (string eventName in eventNames)
                {
                    if (!uniqueEventNames.Contains (eventName))
                    {
                        list.Add (eventName);
                        uniqueEventNames.Add (eventName, "");
                    }
                }
            }
            list.Sort ();
            return list;
        }
        /// <summary>
        /// Inner method used to implement the setup operation.  
        /// </summary>
        protected void InnerSetup(Config config)
        {
            // if needed, clear the prior state.
            if (setupPerformed)
                Clear();

            // record the given configuration
            this.config = config;
            excludedFileSet = new System.Collections.Specialized.StringCollection();
            excludedFileSet.AddRange(config.excludeFileNamesSet.ToArray());

            string dirPath = config.dirPath;

            // try to add a DirectoryEntryInfo record for each of the files that are in the directory
            try
            {
                DirectoryEntryInfo basePathInfo = new DirectoryEntryInfo(dirPath);

                if (basePathInfo.Exists)
                {
                    if (basePathInfo.IsFile)
                        throw new SetupFailureException(Utils.Fcns.CheckedFormat("target path '{0}' does not specify a directory.", dirPath));
                }
                else
                {
                    if (config.createDirectoryIfNeeded)
                        System.IO.Directory.CreateDirectory(dirPath);
                    else
                        throw new SetupFailureException(Utils.Fcns.CheckedFormat("target path '{0}' does not exist.", dirPath));
                }

                // directory exists or has been created - now scan it and record each of the entries that are found therein
                DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
                FileSystemInfo [] directoryFSIArray = dirInfo.GetFileSystemInfos();

                foreach (FileSystemInfo fsi in directoryFSIArray)
                {
                    string path = fsi.FullName;
                    string name = fsi.Name;

                    if (!excludedFileSet.Contains(name) && !excludedFileSet.Contains(path))
                        AddDirEntry(path, true);
                }

                if (numBadDirEntries != 0)
                    logger.Error.Emit("Setup Failure: There are bad directory entries in dir '{0}'", dirPath);
            }
            catch (SetupFailureException sfe)
            {
                SetSetupFaultCode(sfe.Message);
            }
            catch (System.Exception ex)
            {
                SetSetupFaultCode(Utils.Fcns.CheckedFormat("Setup Failure: encountered unexpected exception '{0}' while processing dir '{1}'", ex.Message, dirPath));
            }

            if (!SetupFailed)
            {
                // perform an additional set of tests
                if (string.IsNullOrEmpty(config.fileNamePrefix) || string.IsNullOrEmpty(config.fileNameSuffix))
                    SetSetupFaultCode("Setup Failure: Invalid file name fields in configuration");
                else if (config.advanceRules.fileAgeLimitInSec < 0.0)
                    SetSetupFaultCode("Setup Failure: Config: advanceRules.fileAgeLimitInSec is negative");
                else if (config.purgeRules.dirNumFilesLimit > 0 && config.purgeRules.dirNumFilesLimit < ConfigPurgeNumFilesMinValue)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.dirNumFilesLimit is too small");
                else if (config.purgeRules.dirNumFilesLimit > 0 && config.purgeRules.dirNumFilesLimit > ConfigPurgeNumFilesMaxValue)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.dirNumFilesLimit is too large");
                else if (config.purgeRules.dirTotalSizeLimit < 0)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.dirTotalSizeLimit is negative");
                else if (config.purgeRules.fileAgeLimitInSec < 0.0)
                    SetSetupFaultCode("Setup Failure: Config: purgeRules.maxFileAgeLimitInSec is negative");
            }

            DirectoryEntryInfo activeFileInfo = new DirectoryEntryInfo();

            if (!SetupFailed)
            {
                switch (config.fileNamePattern)
                {
                case FileNamePattern.ByDate:				numFileNumberDigits = 0; break;
                case FileNamePattern.Numeric2DecimalDigits:	numFileNumberDigits = 2; maxFileNumber = 100; break;
                case FileNamePattern.Numeric3DecimalDigits:	numFileNumberDigits = 3; maxFileNumber = 1000; break;
                case FileNamePattern.Numeric4DecimalDigits:	numFileNumberDigits = 4; maxFileNumber = 10000; break;
                default: SetSetupFaultCode("Setup Failure: Invalid file name pattern in configuration"); break;
                }

                // go through the directory file info entries (acquired above) from newest to oldest
                //	and retain the newest valid file that matches the name pattern for this content
                //	manager.  This file will become the initial active file.

                activeFileEntryID = DirEntryID_Invalid;
                activeFileNumber = 0;
                bool matchFound = false;

                IList<Int64> itemKeys = dirEntryIDListSortedByCreatedFTimeUtc.Keys;
                IList<List<int>> itemValues = dirEntryIDListSortedByCreatedFTimeUtc.Values;

                for (int idx = dirEntryIDListSortedByCreatedFTimeUtc.Count - 1; !matchFound && idx >= 0; idx--)
                {
                    Int64 itemFTime = itemKeys[idx];
                    List<int> itemEntryIDList = itemValues[idx];

                    foreach (int itemEntryID in itemEntryIDList)
                    {
                        activeFileEntryID = itemEntryID;

                        if (IsDirEntryIDValid(activeFileEntryID))
                            activeFileInfo = dirEntryList[activeFileEntryID];
                        else
                        {
                            activeFileInfo.Clear();
                            Utils.Asserts.TakeBreakpointAfterFault("Setup: entry ID in ListSortedByCreated is not valid");
                            continue;
                        }

                        // verify that the entry is a file
                        if (!activeFileInfo.IsFile)
                        {
                            Utils.Asserts.TakeBreakpointAfterFault("Setup: entry ID in ListSortedByCreated is not a file");
                            continue;
                        }

                        // divide the name into prefix, middle and suffix fields

                        string fileName = activeFileInfo.Name;
                        bool fileNameIsValidMatch = true;

                        int fileNamePrefixLen = config.fileNamePrefix.Length;
                        int fileNameSuffixLen = config.fileNameSuffix.Length;

                        int split1Idx = Math.Min(fileNamePrefixLen, fileName.Length);   // prevent attempting to call Substring with a second arg that is beyond the end of the string.
                        string prefix = fileName.Substring(0, split1Idx);
                        string rest = fileName.Substring(split1Idx);
                        int restLen = rest.Length;

                        string middle = string.Empty, suffix = string.Empty;

                        if (restLen >= fileNameSuffixLen)
                        {
                            int splitPoint = restLen - fileNameSuffixLen;

                            middle = rest.Substring(0, splitPoint);
                            suffix = rest.Substring(splitPoint);
                        }
                        else
                        {
                            // this file name does not match requirements - exclude from search for current active file
                            fileNameIsValidMatch = false;
                        }

                        // test if the prefix and suffix's match
                        if (prefix != config.fileNamePrefix || suffix != config.fileNameSuffix)
                            fileNameIsValidMatch = false;

                        // test if the middle is valid
                        if (numFileNumberDigits > 0)
                        {
                            int testFileNumber = -1;
                            bool match = int.TryParse(middle, out testFileNumber);

                            if (testFileNumber >= 0 && middle.Length == numFileNumberDigits && match)
                                activeFileNumber = testFileNumber;
                            else
                                fileNameIsValidMatch = false;
                        }
                        else
                        {
                            // for FileNamePattern.ByDate files, we assume that the middle is valid if it is not empty
                            if (middle.Length == 0)
                                fileNameIsValidMatch = false;
                        }

                        matchFound = fileNameIsValidMatch;
                        if (matchFound)
                            break;
                    }
                }

                if (!matchFound && dirEntryIDListSortedByCreatedFTimeUtc.Count != 0)
                    logger.Warning.Emit("Setup Warning: no valid active file found in non-empty directory '{0}'", dirPath);
            }

            if (!SetupFailed && config.enableAutomaticCleanup)
            {
                for (int limit = 0; IsDirectoryCleanupNeeded && (limit < config.maxAutoCleanupDeletes); limit++)
                    PerformIncrementalCleanup();
            }

            if (SetupFailed)
            {
                logger.Error.Emit("Directory is not usable: path:'{0}' fault:'{1}'", dirPath, setupFaultCode);
            }
            else
            {
                logger.Debug.Emit("Directory is usable: path:'{0}' number of files:{1} active file:'{2}'",
                                            dirPath, dirEntryIDListSortedByName.Count, activeFileInfo.Name);
            }

            setupPerformed = true;
        }
예제 #40
0
        private void miVidImport_Click(object sender, RoutedEventArgs e)
        {
            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "Yuv-Videos (.yuv)|*.yuv|All files (*.*)|*.*"; // Filter files by extension
            dlg.Multiselect = true;

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                System.Collections.Specialized.StringCollection sc = new System.Collections.Specialized.StringCollection();
                sc.AddRange(dlg.FileNames);
                // Open document
                this.vM_ProjectExplorer.importVideos(sc);
            }
        }
예제 #41
0
		private void Initializing_pagevariables()
		{
			available_elements = new System.Collections.Specialized.StringCollection();
			available_elements.AddRange(new string[] {"themecolour", "pagetitle", "pagetagline", "mda", "leftnav", "leftnav_page", "introduction", "headline", "required_sentence", "bandedheader", "content", "button", "divider"});
			
			try
			{
				Hashtable h_params = new Hashtable();
						
				page_id_from_session = Session["page_id"].ToString();
				if(Request.QueryString["element"] != null)
				{
					string rqst_element = Request.QueryString["element"].ToString();
					element_to_edit = rqst_element;

					if (!available_elements.Contains(rqst_element))
					{
						Response.Redirect("index.aspx");
					}
				}
				else
				{
					if (Request.QueryString["id"] != null)
					{
						element_id = Request.QueryString["id"].ToString();

						h_params.Add("page_id", page_id_from_session);
						h_params.Add("element_id", element_id);

						element_db = DB.execProc("select_page_variableelements", h_params);

						switch (element_db.Rows[0][1].ToString())
						{
							case "bh": element_to_edit = "bandedheader";
								break;
                            case "di": element_to_edit = "divider";
                                break;
							case "cc": element_to_edit = "content";
								break;
                            case "rh": element_to_edit = "headline";
                                break;
							default: Response.Redirect("index.aspx", true);
								break;
						}
					}
					else
					{
						Response.Redirect("index.aspx", true);
					}
				}

				h_params.Clear();

				h_params = new Hashtable();
				h_params.Add("page_id", page_id_from_session);
				h_params.Add("page_type", "1"); 

				page_type = DB.execProc("select_page_fixedelements", h_params).Rows[0][0].ToString();				

				Session["page_type"] = page_type;
			}
			catch
			{
				Response.Redirect("index.aspx", true);
			}
		}
        /// <summary>
        /// Load the addins to the FrontEnd
        /// </summary>
        /// <param name="ownerOfAddIn">Who will own this addin</param>
        /// <param name="objectAdapter">Some ice stuff</param>
        /// <param name="modulesManager">Modules Manager</param>
        /// <param name="displayer">Displayer of the properties (if an Add-in has a property)</param>
        private static void loadAddIns(IOwnerOfAddIn ownerOfAddIn,
            Ice.ObjectAdapter objectAdapter,
            Ferda.ModulesManager.ModulesManager modulesManager, Properties.IOtherObjectDisplayer displayer)
        {
            System.Collections.Specialized.StringCollection proxies
                = new System.Collections.Specialized.StringCollection();

            foreach(string file in System.IO.Directory.GetFiles("AddIns"))
            {
                if(System.IO.Path.GetExtension(file) == ".dll")
                {
                    string path = "Ferda.FrontEnd.AddIns." +
                        System.IO.Path.GetFileNameWithoutExtension(file) +
                        ".Main";

                    //tohle se nezvladne
                    Assembly asembly =
                        System.Reflection.Assembly.LoadFile(System.IO.Path.GetFullPath(file));

                    IAddInMain addInMain = (IAddInMain)asembly.CreateInstance(path);

                    //adding the properties displayer if it is a addin capable of
                    //displaying properties
                    if (addInMain is Properties.IPropertyProvider)
                    {
                        Properties.IPropertyProvider prov = addInMain as
                            Properties.IPropertyProvider;

                        prov.Displayer = displayer;
                    }

                    addInMain.OwnerOfAddIn = ownerOfAddIn;
                    addInMain.ObjectAdapter = objectAdapter;
                    proxies.AddRange(addInMain.ObjectProxiesToAdd);
                    addIns.Add(addInMain);
                }
            }
            int count = proxies.Count;
            string[] newServices = new string[count];
            if(count > 0)
            {
                proxies.CopyTo(newServices, 0);
            }
            modulesManager.AddModuleServices(newServices);
        }
예제 #43
0
파일: Program.cs 프로젝트: abenori/TeX2img
        // CUIモード
        static int CUIExec(bool q, List<string> files) {
            IOutputController Output = new CUIOutput(q);
            if (files.Count == 0) {
                Console.WriteLine(Properties.Resources.NOINPUTFILE);
                return -5;
            }
            try {
                Directory.CreateDirectory(Path.GetTempPath());
            }
            catch (Exception) {
                Console.WriteLine(String.Format(Properties.Resources.FAIL_TMPFOLDER, Path.GetTempPath()));
                return -7;
            }

            int failnum = 0;

            var outFiles = new System.Collections.Specialized.StringCollection();
            for (int i = 0; i < files.Count / 2; ++i) {
                string file = Path.GetFullPath(files[2 * i]);
                string dir;
                if (Properties.Settings.Default.workingDirectory == "file") dir = Path.GetDirectoryName(file);
                else if (Properties.Settings.Default.workingDirectory == "current") dir = Directory.GetCurrentDirectory();
                else dir = Path.GetTempPath();
                string tmpTeXFileName = TempFilesDeleter.GetTempFileName(Path.GetExtension(file), dir);
                if (tmpTeXFileName == null) {
                    Console.WriteLine(String.Format(Properties.Resources.FAIL_TMPFILE, Path.GetTempPath()));
                    return -6;
                }
                tmpTeXFileName = Path.Combine(dir, tmpTeXFileName);
                // 一時フォルダにコピー
                File.Copy(file, tmpTeXFileName, true);
                (new FileInfo(tmpTeXFileName)).Attributes = FileAttributes.Normal;
                var output = Path.GetFullPath(files[2 * i + 1]);
                // 変換!
                try {
                    using (var converter = new Converter(Output, tmpTeXFileName, output)) {
                        converter.AddInputPath(Path.GetDirectoryName(file));
                        if (!converter.Convert()) ++failnum;
                        else outFiles.AddRange(converter.OutputFileNames.ToArray());
                    }
                    if (Properties.Settings.Default.setFileToClipBoard) Clipboard.SetFileDropList(outFiles);
                }
                catch (Exception e) { Console.WriteLine(e.Message); }
            }
            return failnum;
        }
        private static void CreateAContentType()
        {
            SPList listFields;
            SPWeb myWeb;
            SPSite myDemoSite = new SPSite("http://abcuniversity");

            Console.WriteLine("Talking to SharePoint, Don't Go Anywhere.");

            myWeb = myDemoSite.OpenWeb();
            listFields = myWeb.Lists.TryGetList("CustomizableList");

            List<SPField> fieldsForContentType = new List<SPField>();
            string[] fieldsIWantToAdd = {"AnnualSalary", "SportType", "CurrentStatus"};
            foreach(SPField field in listFields.Fields)
            {
                //Console.WriteLine("Field name: {0}, \nField ID: {1}\nField Group: {2}\n",
                    //field.StaticName, field.Id.ToString(),field.Group);

                //3 differencet ways of adding fields
                //-1- Adding field directly to list using ADD()
                string newFieldA = null, newFieldB = null, newFieldC = null;
                if(listFields.Fields.ContainsField("CurrentTeam") == false)
                {
                    Console.WriteLine("Adding CurrentTeam...");
                    newFieldA = listFields.Fields.Add("CurrentTeam", SPFieldType.Text, false);
                    Console.WriteLine("Added CurrentTeam column to list");
                }
                else
                {
                    Console.WriteLine("Added CurrentTeam column to list.");
                }

                //-and2- Adding the same field to site columns ausing SPField object and target list.
                if (listFields.Fields.ContainsField("PlayerPosition") == false)
                {
                    SPField addANewField = listFields.Fields.CreateNewField("Text", "PlayerPosition");
                    addANewField.Description = "This position, will vary by sport.";

                    //Add it to the Web first... We should probably do the duplication here, too...
                    myWeb.Fields.Add(addANewField);
                    newFieldB = listFields.Fields.Add(addANewField);
                    Console.WriteLine("PlayerPosition column added to the list...");

                }
                else
                {
                    Console.WriteLine("Added PlayerPosition column to list.");
                }
                
                //-and3!- //Using System.Collections to create and add choice field
                if(listFields.Fields.ContainsField("MyPeronalField") == false)
                {
                    System.Collections.Specialized.StringCollection choices = new System.Collections.Specialized.StringCollection();
                    choices.AddRange(new string[] {"Healthy","Out","Likely","Probable"});
                    //Add("DisplayName",FieldType,Required,CompactName,choicelist
                    newFieldC = listFields.Fields.Add("MyPeronalField", SPFieldType.Choice, false, false, choices);
                    Console.WriteLine("MyPeronalField field added to the list...");

                }
                else
                {
                    Console.WriteLine("MyPeronalField not added, already part of the list...");
                }



                /*//If its one of the fields we're interested in, add it to our collection
                if(fieldsIWantToAdd.Contains(field.StaticName))
                {
                    fieldsForContentType.Add(field);
                }*/



            }//end foreach

            SPContentTypeCollection allMyContent = myWeb.ContentTypes;
            SPContentType newContentType = new SPContentType(
                    allMyContent["item"], allMyContent, "TestContentType");
            allMyContent.Add(newContentType);

            string newField1 = myWeb.Fields.Add("AnnualSalary", SPFieldType.Number, false);
            SPFieldLink newField1Link = new SPFieldLink(myWeb.Fields.GetField(newField1));
            newContentType.FieldLinks.Add(newField1Link);

            string newField2 = myWeb.Fields.Add("CurrentStatus", SPFieldType.Text, false);
            SPFieldLink newField2Link = new SPFieldLink(myWeb.Fields.GetField(newField2));
            newContentType.FieldLinks.Add(newField2Link);

            string newField3 = myWeb.Fields.Add("SportType", SPFieldType.Text, false);
            SPFieldLink newField3Link = new SPFieldLink(myWeb.Fields.GetField(newField3));
            newContentType.FieldLinks.Add(newField3Link);

            //newContentType.Update();

        }
예제 #45
0
파일: Form1.cs 프로젝트: sillsdev/WorldPad
		private void mnuRefreshP4_Click(object sender, System.EventArgs e)
		{
			LoadFileList();

			System.Collections.Specialized.StringCollection opened = new System.Collections.Specialized.StringCollection();
			opened.AddRange(m_p4.GetP4OpenFiles ());

			foreach(ListViewItem item in m_list.Items)
			{
				if(opened.Contains( (string)item.Tag))
				{
					item.ImageIndex = 1;
					item.ForeColor = System.Drawing.Color.Blue;
				}
			}
		}
 /// <summary>
 /// Says if some creator has function with specified ice identifier
 /// </summary>
 /// <param name="iceId">Ice identifier</param>
 /// <param name="creator">Proxy of box module factory creator</param>
 /// <returns></returns>
 public bool IsWithIceId(string iceId, BoxModuleFactoryCreatorPrx creator)
 {
     System.Collections.Specialized.StringCollection _functionsIceIds =
     new System.Collections.Specialized.StringCollection();
     _functionsIceIds.AddRange(
         creator.getBoxModuleFunctionsIceIds());
     return _functionsIceIds.Contains(iceId);
 }
		/// <summary>
		/// Construct the line counter user interface and
		/// the countable file type mappings (to icons and
		/// counting algorithms).
		/// </summary>
		public LineCounterBrowser()
		{
			InitializeComponent();
			
			#if IMPR1
			projectImageListHelper = new ImageListHelper(imgProjectTypes);
			fileImageListHelper    = new ImageListHelper(imgFileTypes);
			#endif

			// Map project types to icons for use in the projects list
			m_projIconMappings = new Dictionary<string, int>();
			m_projIconMappings.Add("{00000000-0000-0000-0000-000000000000}", 0);
			m_projIconMappings.Add("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", 1); // C#
			m_projIconMappings.Add("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", 2); // VB
			m_projIconMappings.Add("{00000001-0000-0000-0000-000000000000}", 5);

			// List all the countable file types (so we don't try to count .dll's,
			// images, executables, etc.
			
			m_countableTypes = new System.Collections.Specialized.StringCollection();
			#if IMPR2
			countingAlgorithms = AddInTree.BuildItems<CountingAlgorithmDescriptor>
				("/AddIns/LineCounter/CountingAlgorithms", this);
			// Iterate through algorithms to fill list of known countable types
			foreach (CountingAlgorithmDescriptor desc in countingAlgorithms) {
				m_countableTypes.AddRange(desc.extensions);
			}
			#else
			m_countableTypes.Add("*");
			m_countableTypes.Add(".cs");
			m_countableTypes.Add(".vb");
			m_countableTypes.Add(".vj");
			m_countableTypes.Add(".cpp");
			m_countableTypes.Add(".cc");
			m_countableTypes.Add(".cxx");
			m_countableTypes.Add(".c");
			m_countableTypes.Add(".hpp");
			m_countableTypes.Add(".hh");
			m_countableTypes.Add(".hxx");
			m_countableTypes.Add(".h");
			m_countableTypes.Add(".js");
			m_countableTypes.Add(".cd");
			m_countableTypes.Add(".resx");
			m_countableTypes.Add(".res");
			m_countableTypes.Add(".css");
			m_countableTypes.Add(".htm");
			m_countableTypes.Add(".html");
			m_countableTypes.Add(".xml");
			m_countableTypes.Add(".xsl");
			m_countableTypes.Add(".xslt");
			m_countableTypes.Add(".xsd");
			m_countableTypes.Add(".config");
			m_countableTypes.Add(".asax");
			m_countableTypes.Add(".ascx");
			m_countableTypes.Add(".asmx");
			m_countableTypes.Add(".aspx");
			m_countableTypes.Add(".ashx");
			m_countableTypes.Add(".idl");
			m_countableTypes.Add(".odl");
			m_countableTypes.Add(".txt");
			m_countableTypes.Add(".sql");
			#endif

			// Map file extensions to icons for use in the file list
			m_fileIconMappings = new Dictionary<string, int>(33);
			m_fileIconMappings.Add("*", 0);
			m_fileIconMappings.Add(".cs", 1);
			m_fileIconMappings.Add(".vb", 2);
			m_fileIconMappings.Add(".vj", 3);
			m_fileIconMappings.Add(".cpp", 4);
			m_fileIconMappings.Add(".cc", 4);
			m_fileIconMappings.Add(".cxx", 4);
			m_fileIconMappings.Add(".c", 5);
			m_fileIconMappings.Add(".hpp", 6);
			m_fileIconMappings.Add(".hh", 6);
			m_fileIconMappings.Add(".hxx", 6);
			m_fileIconMappings.Add(".h", 6);
			m_fileIconMappings.Add(".js", 7);
			m_fileIconMappings.Add(".cd", 8);
			m_fileIconMappings.Add(".resx", 9);
			m_fileIconMappings.Add(".res", 9);
			m_fileIconMappings.Add(".css", 10);
			m_fileIconMappings.Add(".htm", 11);
			m_fileIconMappings.Add(".html", 11);
			m_fileIconMappings.Add(".xml", 12);
			m_fileIconMappings.Add(".xsl", 13);
			m_fileIconMappings.Add(".xslt", 13);
			m_fileIconMappings.Add(".xsd", 14);
			m_fileIconMappings.Add(".config", 15);
			m_fileIconMappings.Add(".asax", 16);
			m_fileIconMappings.Add(".ascx", 17);
			m_fileIconMappings.Add(".asmx", 18);
			m_fileIconMappings.Add(".aspx", 19);
			m_fileIconMappings.Add(".ashx", 0);
			m_fileIconMappings.Add(".idl", 0);
			m_fileIconMappings.Add(".odl", 0);
			m_fileIconMappings.Add(".txt", 0);
			m_fileIconMappings.Add(".sql", 0);

			// Prepare counting algorithm mappings
			CountLines countLinesGeneric = new CountLines(CountLinesGeneric);
			CountLines countLinesCStyle = new CountLines(CountLinesCStyle);
			CountLines countLinesVBStyle = new CountLines(CountLinesVBStyle);
			CountLines countLinesXMLStyle = new CountLines(CountLinesXMLStyle);

			m_countAlgorithms = new Dictionary<string, CountLines>(33);
			m_countAlgorithms.Add("*", countLinesGeneric);
			m_countAlgorithms.Add(".cs", countLinesCStyle);
			m_countAlgorithms.Add(".vb", countLinesVBStyle);
			m_countAlgorithms.Add(".vj", countLinesCStyle);
			m_countAlgorithms.Add(".js", countLinesCStyle);
			m_countAlgorithms.Add(".cpp", countLinesCStyle);
			m_countAlgorithms.Add(".cc", countLinesCStyle);
			m_countAlgorithms.Add(".cxx", countLinesCStyle);
			m_countAlgorithms.Add(".c", countLinesCStyle);
			m_countAlgorithms.Add(".hpp", countLinesCStyle);
			m_countAlgorithms.Add(".hh", countLinesCStyle);
			m_countAlgorithms.Add(".hxx", countLinesCStyle);
			m_countAlgorithms.Add(".h", countLinesCStyle);
			m_countAlgorithms.Add(".idl", countLinesCStyle);
			m_countAlgorithms.Add(".odl", countLinesCStyle);
			m_countAlgorithms.Add(".txt", countLinesGeneric);
			m_countAlgorithms.Add(".xml", countLinesXMLStyle);
			m_countAlgorithms.Add(".xsl", countLinesXMLStyle);
			m_countAlgorithms.Add(".xslt", countLinesXMLStyle);
			m_countAlgorithms.Add(".xsd", countLinesXMLStyle);
			m_countAlgorithms.Add(".config", countLinesXMLStyle);
			m_countAlgorithms.Add(".res", countLinesGeneric);
			m_countAlgorithms.Add(".resx", countLinesXMLStyle);
			m_countAlgorithms.Add(".aspx", countLinesXMLStyle);
			m_countAlgorithms.Add(".ascx", countLinesXMLStyle);
			m_countAlgorithms.Add(".ashx", countLinesXMLStyle);
			m_countAlgorithms.Add(".asmx", countLinesXMLStyle);
			m_countAlgorithms.Add(".asax", countLinesXMLStyle);
			m_countAlgorithms.Add(".htm", countLinesXMLStyle);
			m_countAlgorithms.Add(".html", countLinesXMLStyle);
			m_countAlgorithms.Add(".css", countLinesCStyle);
			m_countAlgorithms.Add(".sql", countLinesGeneric);
			m_countAlgorithms.Add(".cd", countLinesGeneric);
		}
 public static ManagementObjectCollection QueryInstacnes(String scope, String className, String condition, String[] selectedProperties)
 {
     if (String.IsNullOrEmpty(scope))
     {
         throw new ArgumentNullException("scope");
     }
     if (String.IsNullOrEmpty(className))
     {
         throw new ArgumentNullException("className");
     }
     var query = new SelectQuery(className, condition);
     if(selectedProperties != null)
     {
         var collection = new System.Collections.Specialized.StringCollection();
         collection.AddRange(selectedProperties);
         query.SelectedProperties = collection;
     }
     using (var search = new ManagementObjectSearcher(new ManagementScope(scope), query))
     {
         try
         {
             var result = search.Get();
             if (result.Count == 0)
             {
                 throw new NotImplementedException(String.Format("Can't find wmi object: namespace='{0}', class='{1}', condition='{2}'",
                                                                     scope, className, condition));
             }
             return result;
         }
         catch (ManagementException e)
         {
             throw new ManagementException(String.Format("Wmi query error: namespace='{0}', class='{1}', condition='{2}'\n",
                                                             scope, className, condition), e);
         }
     }
 }
예제 #49
0
        /// <summary>
        /// Prevents a default instance of the <see cref="CLAutoThumbnailer"/> class from being created.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        /// <param name="baseDir">If created via command file the directory of the command file,
        /// otherwise <c>null</c>.</param>
        /// <exception cref="NDesk.Options.OptionException">Thrown when option error occurs.</exception>
        CLAutoThumbnailer(string[] args, string baseDir)
        {
            InitializeThumbnailSettings ();
            InitializeVideoRE ();

            System.Collections.Specialized.StringCollection fixedArgs =
                new System.Collections.Specialized.StringCollection ();
            foreach (string arg in args)
                {
                if (arg.EndsWith("\""))
                    {
                    fixedArgs.Add(arg.Remove(arg.Length-1));
                    }
                else
                    fixedArgs.Add(arg);
                }

            String[] fixedArgsArray = new String[fixedArgs.Count];
            fixedArgs.CopyTo(fixedArgsArray, 0);
            double doubleInterval = -1;

            _oset = new NDesk.Options.OptionSet () {
                { "d|directory=",
                  "{DIRECTORY} to process. Generate thumbnails for\n" +
                   "files with the following extensions:\n" +
                   _videoExtensions,
                  v => _directoryArg = v },
                { "exts=",
                  "add/remove video {EXTENSIONS} " +
                  "(\"[+]ext1, -ext2\")",
                    v =>
                    {
                    string[] exts = _commaRE.Split(v);
                    foreach (string ext in exts)
                        {
                        string s = ext.Trim().ToLower();
                        bool addExt = true;
                        if (s[0] == '-')
                            {
                            s = s.Substring(1);
                            addExt = false;
                            }
                        else if (s[0] == '+')
                            {
                            s = s.Substring (1);
                            }
                        if (addExt)
                            {
                            if (_videoExts.Contains (s))
                                THelper.Error ("Error: '{0}' is already in valid video extensions list.", s);
                            else
                                {
                                THelper.Information ("'{0}' added to valid video extensions list.", s);
                                _videoExts.Add (s);
                                _videoExtsChanged = true;
                                }
                            }
                        else
                            {
                            if (!_videoExts.Contains (s))
                                THelper.Error ("Error: '{0}' isn't in valid video extensions list.", s);
                            else
                                {
                                THelper.Information ("'{0}' removed from valid video extensions list.", s);
                                _videoExts.Remove (s);
                                _videoExtsChanged = true;
                                }
                            }
                        }
                    if (_videoExtsChanged)
                        {
                        System.Collections.ArrayList temp = System.Collections.ArrayList.Adapter(_videoExts);
                        temp.Sort ();
                        _videoExts = new System.Collections.Specialized.StringCollection ();
                        _videoExts.AddRange ((String[]) temp.ToArray(typeof(string)));
                        }
                    } },

                { "minsize=",
                   String.Format("Minimum {{FILESIZE}} of video files (0 to disable) [{0} ({1})]",
                                  _minFileSize, ThumbnailCreator.GetFileSizeString(_minFileSize)),
                    (long v) =>
                        {
                        if (v < 0)
                            v = 0;
                        _minFileSize = v;
                        } },

                { "m|cmddir=",
                   "create initial command file for {DIRECTORY}",
                   v => _cmdDirectory = v },

                { "s|start=",
                  String.Format(@"start {{TIME}} in h:mm:ss [{0}]",
                                _tnSettings.Start.ToString(@"h\:mm\:ss")),
                  (TimeSpan v) => _tnSettings.Start = v },
                { "e|end=",
                  String.Format(@"end {{TIME}} in h:mm:ss [{0}{1}]",
                                _tnSettings.End.TotalSeconds < 0 ? "-" : "",
                                _tnSettings.End.ToString(@"h\:mm\:ss")),
                  (TimeSpan v) => _tnSettings.End = v },

                { "v|overview",
                  String.Format("create Overview page (-v- disables) [{0}]",
                                _createOverview),
                  v => _createOverview = v != null },
                { "n=",
                  String.Format("Overview page desired # of {{ROWS or COLUMNS}} [{0}]",
                                _tnSettings.OverviewThumbs),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.OverviewThumbs = v;
                      } },
                { "c|columns=",
                  String.Format("Overview page actual # of {{COLUMNS}} [{0}]",
                                _tnSettings.OverviewColumns),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.OverviewColumns = v;
                      } },
                { "r|rows=",
                  String.Format("Overview page actual # of {{ROWS}} [{0}]",
                                _tnSettings.OverviewRows),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.OverviewRows = v;
                      } },

                { "i|interval=",
                   String.Format("Detail page thumbnail interval {{SECONDS}} [{0:F2}]",
                                 _tnSettings.Interval.TotalSeconds),
                    (double v) =>
                        {
                        if (v != 0.0 && v < 1.0 / 30.0)
                            v = 1.0 / 30.0;
                        doubleInterval = v;
                        } },
                { "autointerval",
                   String.Format("use automatic interval based on duration [{0}]",
                                 _autoInterval),
                   v => _autoInterval = v != null },
                { "autointervals=",
                   String.Format("automatic interval {{SPECIFICATION}}\n" +
                                 "( <min1=secs1, <min2=secs2, <min3=secs3, secs4 )\n" +
                                 "[ {0} ]",
                                 _intervalsStr),
                   v => {
                        _intervalsStr = v;
                        InitializeAutoIntervals (_intervalsStr);
                        } },

                { "N=",
                  String.Format("Detail page desired # of {{ROWS or COLUMNS}} [{0}]",
                                _tnSettings.DetailThumbs),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.DetailThumbs = v;
                      } },
                { "C|Columns=",
                  String.Format("Detail page actual # of {{COLUMNS}} [{0}]",
                                _tnSettings.DetailColumns),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.DetailColumns = v;
                      } },
                { "R|Rows=",
                  String.Format("Detail page actual # of {{ROWS}} [{0}]",
                                _tnSettings.DetailRows),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.DetailRows = v;
                      } },
                { "dfts",
                  String.Format("add Detail page filename timestamps\n" +
                                "(--dfts- disables) [{0}]",
                                _tnSettings.DetailFileTimestamps),
                  v => _tnSettings.DetailFileTimestamps = v != null },

                { "y|layout=",
                  String.Format("layout {{MODE}}\n(0=Auto,1=Actual,2=Row Priority,3=Column Priority) [{0}]",
                  _tnSettings.LayoutMode),
                  (int v) =>
                      {
                      if (v < 0 || v > 3)
                          v = 0;
                      _tnSettings.LayoutMode = (ThumbnailSettings.LayoutModes) v;
                      } },
                { "othres=",
                  String.Format("video aspect ratio {{THRESHOLD}} for\n" +
                                "Auto Layout of Overview Page [{0:F2}]",
                                _tnSettings.OverviewThreshold),
                  (double v) =>
                      {
                      if (v != 0.0 && v < 0.2)
                          v = 0.2;
                      if (v > 4.0)
                          v = 4.0;

                      _tnSettings.OverviewThreshold = v;
                      } },
                { "dthres=",
                  String.Format("video aspect ratio {{THRESHOLD}} for\n" +
                                "Auto Layout of Detail Pages [{0:F2}]",
                                _tnSettings.DetailThreshold),
                  (double v) =>
                      {
                      if (v != 0.0 && v < 0.2)
                          if (v < 0.2)
                          v = 0.2;
                      if (v > 4.0)
                          v = 4.0;

                      _tnSettings.DetailThreshold = v;
                      } },
                { "rcopt",
                  String.Format("do row/column optimizations\n" +
                                "(--rcopt- disables) [{0}]",
                  _tnSettings.RCOptimization),
                  v => _tnSettings.RCOptimization = v != null },
                { "maxoptsteps=",
                  String.Format("max # of row/column optimization {{STEPS}}\n" +
                                "(0=unlimited) [{0}]",
                  _tnSettings.MaxOptimizationSteps),
                  (int v) =>
                      {
                      if (v < 0)
                          v = 0;
                      _tnSettings.MaxOptimizationSteps = v;
                      } },
                { "wthres=",
                  String.Format("width {{THRESHOLD}} for adding columns (0.1 - 1.0) [{0:F2}]",
                                _tnSettings.WidthThreshold),
                  (double v) =>
                      {
                      if (v < 0.1)
                          v = 0.1;
                      if (v > 1.0)
                          v = 1.0;

                      _tnSettings.WidthThreshold = v;
                      } },
                { "hthres=",
                  String.Format("height {{THRESHOLD}} for adding rows (0.1 - 1.0)\n[{0:F2}]",
                                _tnSettings.HeightThreshold),
                  (double v) =>
                      {
                      if (v < 0.1)
                          v = 0.1;
                      if (v > 1.0)
                          v = 1.0;

                      _tnSettings.HeightThreshold = v;
                      } },
                { "mincols=",
                  String.Format("minimum # of {{COLUMNS}} [{0}]",
                                _tnSettings.MinColumns),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.MinColumns = v;
                      } },
                { "minrows=",
                  String.Format("minimum # of {{ROWS}} [{0}]",
                                _tnSettings.MinRows),
                  (int v) =>
                      {
                      if (v < 1)
                          v = 1;
                      _tnSettings.MinRows = v;
                      } },

                { "p|crop=", "crop {ASPECT RATIO}",
                    (double v) =>
                        {
                        if (v < 0.2)
                            v = 0.2;
                        if (v > 4.0)
                            v = 4.0;
                        _cropAspect = v;
                        } },
                { "rect=", "source {RECTANGLE} ( X,Y+WxH )",
                    v =>
                    {
                    System.Text.RegularExpressions.Match m = _rectRE.Match (v);
                    if (!m.Success)
                        throw new NDesk.Options.OptionException (
                            "Need to specify X,Y+WxH for --rect option.",
                            "--rect");
                    _srcRect = new System.Drawing.Rectangle (Int32.Parse (m.Groups["x"].Value),
                                                             Int32.Parse (m.Groups["y"].Value),
                                                             Int32.Parse (m.Groups["w"].Value),
                                                             Int32.Parse (m.Groups["h"].Value));
                    } },

                { "t|stretch=", "stretch {ASPECT RATIO}",
                    (double v) =>
                        {
                        if (v < 0.2)
                            v = 0.2;
                        if (v > 4.0)
                            v = 4.0;
                        _stretchAspect = v;
                        } },
                { "aar",
                  String.Format("do auto aspect ratio adjustment\n" +
                                "(--aar- disables) [{0}]",
                                _autoAspectRatio),
                  v => _autoAspectRatio = v != null },

                { "o|outdir=",  "Output {DIRECTORY}",
                    v => _outputDirectory = v },
                { "subdir=",
                  String.Format("Output sub-directory {{NAME}} [\"{0}\"]",
                                _tnSettings.SubDirectory),
                    v =>
                        {
                        if (v=="" || !_subdirRE.IsMatch(v))
                            throw new NDesk.Options.OptionException (
                                "Subdirectory name can only contain alphanumerics, '_', and '-'.",
                                "--subdir");
                        _tnSettings.SubDirectory = v;
                        } },
                { "name=",  "Display {NAME}",
                    v => _displayFilename = v },

                { "l|label=",
                  String.Format("timestamp label {{POSITION}}\n(0=Off,1=LR,2=LL,3=UR,4=UL) [{0}]",
                  _tnSettings.LabelPosition),
                  (int v) =>
                      {
                      if (v < 0 || v > 4)
                          v = 1;
                      _tnSettings.LabelPosition = (ThumbnailSettings.LabelPositions) v;
                      } },
                { "ms",
                  String.Format("show non-zero millisecond display in timestamps [{0}]",
                                _tnSettings.AlwaysShowMilliseconds),
                  v => _tnSettings.AlwaysShowMilliseconds = v != null },

                { "f|scalefactor=",
                  String.Format("page {{SCALE FACTOR}} [{0:F2}]",
                  _tnSettings.ScaleFactor),
                  (double v) =>
                      {
                      if (v < 0.25)
                          v = 0.25;
                      if (v > 3.0)
                          v = 3.0;
                      _tnSettings.ScaleFactor = v;
                      } },
                { "w|width=",
                  String.Format("page width {{PIXELS}} [{0}]",
                  _tnSettings.Width),
                  (int v) =>
                      {
                      if (v < 100)
                          v = 100;

                      _tnSettings.Width = v;
                      } },
                { "h|height=",
                  String.Format("page height {{PIXELS}} [{0}]",
                  _tnSettings.Height),
                  (int v) =>
                      {
                      if (v < 100)
                          v = 100;

                      _tnSettings.Height = v;
                      } },
                { "margin=",
                  String.Format("margin between thumbnails {{PIXELS}} [{0}]",
                  _tnSettings.Margin),
                  (int v) =>
                      {
                      if (v < 0)
                          v = 0;
                      _tnSettings.Margin = v;
                      } },
                { "border=",
                  String.Format("thumbnail border width {{PIXELS}} [{0}]",
                  _tnSettings.Border),
                  (int v) =>
                      {
                      if (v < 0)
                          v = 0;
                      _tnSettings.Border = v;
                      } },

                { "save", "save current settings as defaults",
                   v => _saveSettings = v != null },
                { "reset", "reset settings to initial defaults",
                   v => _resetSettings = v != null },

                { "dumpcr:", "dump # columns/rows diagnostic plot to {FILE}",
                   v =>
                       {
                       _dumpCRs = true;
                       if (v != null)
                           {
                           _dumpFilename = v;
                           if (_dumpFilename.Contains ("|"))
                               {
                               string[] parts = _dumpFilename.Split (new char[] { '|' }, 2);
                               _dumpFilename = parts[1];
                               string flag = parts[0].Trim ().ToLower ();
                               if (flag.StartsWith ("nothr"))
                                   _dumpThresholds = false;
                               }
                           }
                       } },

                { "debug:",
                   String.Format("show debugging information"),
                   v =>
                       {
                       if (v == null)
                           _debug = DebugModes.ShowDebuggingMessages;
                       else
                           {
                           int debug = Int32.Parse (v);
                           if (debug < 0)
                               {
                               debug = -debug;
                               THelper.SetLoggerLevel("mainlogger",
                                                      System.Diagnostics.SourceLevels.Information);
                               }
                           else
                               {
                               THelper.SetConsoleLevel (System.Diagnostics.SourceLevels.Verbose);
                               }
                           _debug = (DebugModes) debug;
                           }
                       } },

                { "?|help",  "show this message and exit",
                    v => _show_help = v != null },
                { "version",  "show version and exit",
                    v => _show_version = v != null },

            #if false
                { "x|maxmulti=", "max # of multi-page {ROWS}",
                    (int v) => _tnSettings.MaxMultiRows = v },
                { "n|minoverview=", "minimum # of overview {ROWS}",
                    (int v) => _tnSettings.MinOverviewRows = v },
               NDesk.Options.Option rectOption = _oset.Add(
                    );
            #endif
                };

            List<string> extra;
            extra = _oset.Parse (fixedArgsArray);
            if (_show_help && baseDir != null)
                {
                ShowHelp (_oset);
                return;
                }

            if (_debug == DebugModes.ShowDebuggingMessages && baseDir != null)
                {
                THelper.Information ("Displaying debugging information.");
                }

            if (extra.Count > 0)
                {
                _filename = extra[0];
                }

            if (_filename != null)
                {
                if (baseDir != null)
                    {
                    if (!System.IO.Path.IsPathRooted (_filename))
                        _filename = System.IO.Path.Combine (baseDir, _filename);
                    }

                _fileList = CreateFileList (_filename);
                if (_fileList == null)
                    {
                    THelper.Critical ("\"" + _filename + "\" doesn't exist.");
                    _filename = null;
                    return;
                    }
                if (_fileList.Count == 0)
                    {
                    THelper.Critical ("\"" + _filename + "\" doesn't match any files.");
                    _filename = null;
                    _fileList = null;
                    return;
                    }
                }

            if (_directoryArg != null)
                {
                if (baseDir != null)
                    {
                    if (!System.IO.Path.IsPathRooted(_directoryArg))
                        _directoryArg = System.IO.Path.Combine(baseDir, _directoryArg);
                    }

                if (!System.IO.Directory.Exists(_directoryArg))
                    {
                    _directoryArg = null;
                    THelper.Critical ("\"" + _directoryArg + "\" doesn't exist.");
                    return;
                    }
                }

            if (doubleInterval != -1)
                {
                int intervalSeconds = (int) Math.Truncate (doubleInterval);
                int intervalMilliseconds = 0;
                double fractSeconds = Math.Abs (doubleInterval - (double) intervalSeconds);
                if (fractSeconds >= 0.001)
                    intervalMilliseconds = (int) (1000 * fractSeconds);

                _tnSettings.Interval = new TimeSpan (0, 0, 0,
                                                    intervalSeconds, intervalMilliseconds);
                }

            if (_tnSettings.OverviewThreshold == 0.0)
                _tnSettings.OverviewThreshold = _tnSettings.AspectRatio * _tnSettings.LayoutThresholdAdjustment;
            if (_tnSettings.DetailThreshold == 0.0)
                _tnSettings.DetailThreshold = _tnSettings.AspectRatio * _tnSettings.LayoutThresholdAdjustment;
        }