Beispiel #1
0
        /// <summary>
        /// 获取用户使用痕迹
        /// </summary>
        /// <param name="path"></param>
        public static Stack <string> getUserTrack()
        {
            Stack <string> userIDStack = new Stack <string>();

            try
            {
                StreamReader trackReader = new StreamReader(PATH_USER_TRACK, Encoding.Default);
                string       line;
                string       userName;
                while ((line = trackReader.ReadLine()) != null)
                {
                    userName = CodeAnalysis.getValueString(line)[0];
                    if (!userIDStack.Contains(userName))
                    {
                        userIDStack.Push(userName);
                    }
                }
                trackReader.Close();
            }
            catch (Exception e)
            {
                Reporter.reportBug(e.ToString());
            }
            return(userIDStack);
        }
Beispiel #2
0
        /// <summary>
        /// 获取小文件图标
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, Image> getSmallFileIconDictionary()
        {
            Dictionary <string, Image> iconDict = new Dictionary <string, Image>();

            //if (!Directory.Exists(LARGE_ICON_PATH)) return null;
            if (!Directory.Exists(SMALL_ICON_PATH))
            {
                return(null);
            }
            if (!File.Exists(ICON_CONF_PATH))
            {
                return(null);
            }
            StreamReader confReader = new StreamReader(ICON_CONF_PATH, Encoding.Default);
            string       line;

            while ((line = confReader.ReadLine()) != null)
            {
                iconDict.Add(Path.GetExtension(CodeAnalysis.getCommandString(line)),
                             Image.FromFile(SMALL_ICON_PATH + "/" + CodeAnalysis.getValueString(line)[0]));
            }
            confReader.Close();
            return(iconDict);
        }
Beispiel #3
0
        void btn_Click_Event(object obj, EventArgs ea)
        {
            if (obj.Equals(pictureBox_buttonClose))
            {
                this.Close();
            }
            if (obj.Equals(pictureBox_buttonMinimize))
            {
                this.WindowState = FormWindowState.Minimized;
            }
            if (obj.Equals(button_confirm))
            {
                /* 可能不合法的配置 */
                string sync_ip = settingSyncForm.ServerAddress;
                //string a = "";

                /*
                 * if (!CodeAnalysis.IsValidIP(sync_ip))
                 * {
                 *  label_error.Visible = true;
                 *  label_error.Text = "服务器地址不合法";
                 *  return;
                 * }
                 */
                string sync_port_str = settingSyncForm.Port;
                if (!CodeAnalysis.IsInteger(sync_port_str))
                {
                    label_error.Visible = true;
                    label_error.Text    = "端口不合法";
                    return;
                }
                /* 保存配置 */
                MyConfig.ConfigFile configFile;
                if (File.Exists(MyConfig.CONFIG_FILE_PATH))
                {
                    configFile = MyConfig.readConfig(MyConfig.CONFIG_FILE_PATH);
                }
                else
                {
                    configFile = new MyConfig.ConfigFile();
                }
                if (configFile == null)
                {
                    return;
                }

                /* 保存服务器地址 */
                configFile.createOrModifyItem(MyConfig.ConfigFile.TABLE_NAME_SYNC,
                                              MyConfig.ConfigFile.Sync.KEY_SERVER_URI, sync_ip);
                /* 保存端口 */
                configFile.createOrModifyItem(MyConfig.ConfigFile.TABLE_NAME_SYNC,
                                              MyConfig.ConfigFile.Sync.KEY_SERVER_PORT, int.Parse(sync_port_str));
                /* 是否自动启动 */
                configFile.createOrModifyItem(MyConfig.ConfigFile.TABLE_NAME_PRIMARY,
                                              MyConfig.ConfigFile.Primary.KEY_AUTO_START, settingPrimaryForm.isAutoStart);
                /* 是否自动同步 */
                configFile.createOrModifyItem(MyConfig.ConfigFile.TABLE_NAME_SYNC,
                                              MyConfig.ConfigFile.Sync.KEY_AUTO_SYNC, settingSyncForm.isAutoSync);

                /* 保存外观 */
                /* 大图标大小 */
                configFile.createOrModifyItem(MyConfig.ConfigFile.TABLE_NAME_SKIN,
                                              MyConfig.ConfigFile.Skin.KEY_LARGE_ICON_SIZE, settingSkinForm.SizeLargeIcon);
                /* 小图标大小 */
                configFile.createOrModifyItem(MyConfig.ConfigFile.TABLE_NAME_SKIN,
                                              MyConfig.ConfigFile.Skin.KEY_SMALL_ICON_SIZE, settingSkinForm.SizeSmallIcon);

                MyConfig.saveConfig(MyConfig.CONFIG_FILE_PATH, configFile);



                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            if (obj.Equals(button_cancel))
            {
                this.Close();
            }
        }