public int UpdateCustom(string custom) { // validate the string provided if (!CsUtilities.ValidateStringChars(custom, RvtIdentifiers.INVALID_NAME_CHARS_ARRAY)) { // invalid - return -1 return(-1); } // get the index for the current custom item // get -1 if not found int idx = FindCode((int)CustomType.ITEM); if (!string.IsNullOrWhiteSpace(custom)) { // got a valid custom string // save custom this.Custom = custom; // create the box item ShNamePartItem bi = new ShNamePartItem("[" + custom + "]", (int)Type * 100 + CUSTOMSET); // update the list of box items based on // wheather the current custom value is found if (idx > -1) { // current custom item found - // remove the current and replace // with the updated valie Collection.RemoveAt(idx); Collection.Insert(idx, bi); } else { // custom item not found // add a new Collection.Add(bi); idx = Collection.Count - 1; } } else { // custom string is blank // if current exists - remove // else do nothing if (idx > -1) { Collection.RemoveAt(idx); } idx = -2; } OnPropertyChanged("Title"); return(idx); }
// method to add a pushbutton to the ribbon public static bool AddPushButton(RibbonPanel Panel, string ButtonName, string ButtonText, string Image16, string Image32, string dllPath, string dllClass, string ToolTip) { try { PushButtonData m_pdData = new PushButtonData(ButtonName, ButtonText, dllPath, dllClass); // if we have a path for a small image, try to load the image if (Image16.Length != 0) { try { // load the image m_pdData.Image = CsUtilities.GetBitmapImage(Image16, NAMESPACE_PREFIX); } catch { // could not locate the image } } // if have a path for a large image, try to load the image if (Image32.Length != 0) { try { // load the image m_pdData.LargeImage = CsUtilities.GetBitmapImage(Image32, NAMESPACE_PREFIX); } catch { // could not locate the image } } // set the tooltip m_pdData.ToolTip = ToolTip; // add it to the panel PushButton m_pb = Panel.AddItem(m_pdData) as PushButton; return(true); } catch { return(false); } }
private void GetUserList() { userProfilesPath = KnownFolders.UserProfiles.Path; currentUserProfilePath = KnownFolders.Profile.Path; appDataSubFolders = KnownFolders.RoamingAppData.Path.Substring(CurrentUserProfilePath.Length); // Debug.WriteLine("common desktop| " // + Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory)); // Debug.WriteLine("User Profiles Path | " + UserProfilesPath); // Debug.WriteLine("Current User Profile Path | " + CurrentUserProfilePath); // Debug.WriteLine("AppData sub-folder path | " + AppDataSubFolders); SelectQuery query = new SelectQuery("Win32_UserAccount"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); foreach (ManagementObject envVar in searcher.Get()) { bool local = (bool)envVar["LocalAccount"]; string status = (string)envVar["Status"]; string name = (string)envVar["Name"]; if (!local || !status.Equals("OK") || name.Equals("Administrator")) { continue; } // Debug.WriteLine( // "Username | {0} | is local | {1} | status | {2} | type | {3} | caption | {4} | domain | {5}", // envVar["Name"], // ((bool) envVar["LocalAccount"]), // envVar["Status"], // envVar["SIDType"], // envVar["Caption"], // envVar["Domain"] // ); string path = UserProfilesPath + FilePathUtil.PATH_SEPARATOR + name + AppDataSubFolders + ConfigFileSupport.USER_STORAGE_FOLDER; Debug.WriteLine("user classification files path | " + path); Debug.WriteLine("create setting path | " + UserSettings.Path.CreateSettingPath()); Debug.WriteLine("created sub-folders | " + CsUtilities.SubFolder( UserSettings.Path.SubFolders.Length - 2, "", UserSettings.Path.SubFolders)); userList.AddUser(name, path); } }
protected string GetVersionFromFile(string elementName) => CsUtilities.ScanXmlForElementValue(SettingPathAndFile, elementName);