Esempio n. 1
0
        /// <example>
        /// Document document = new Document(
        ///     new Header("Main Title"));
        ///
        ///    document.AddChild(new Section(
        ///         new Header("Section Title"),
        ///         new Paragraph(
        ///             new Span(
        ///                 new PlainText("Lorem ipsum "),
        ///                 new Strong(
        ///                     new Span(
        ///                         new PlainText("dolor sit amet, "),
        ///                         new Strikethrough("consectetur"),
        ///                         new PlainText(" adipiscing "),
        ///                         new Italic("elit"),
        ///                         new PlainText(".")
        ///                     )
        ///                 )
        ///             )
        ///         )
        /// ));
        /// </example>
        public static IDocument PureBuilder()
        {
            Document document = new Document(
                new Header("Main Title"));

            document.AddChild(new Section(
                                  new Header("Section Title"),
                                  new Paragraph(
                                      new Span(
                                          new PlainText("Lorem ipsum "),
                                          new Strong(
                                              new Span(
                                                  new PlainText("dolor sit amet, "),
                                                  new Strikethrough("consectetur"),
                                                  new PlainText(" adipiscing "),
                                                  new Italic("elit"),
                                                  new PlainText(".")
                                                  )
                                              )
                                          )
                                      )
                                  ));

            return(document);
        }
        public VectorViewModel(int id, int parentId, string name, ViewModelBase parent, Document parentDocument)
            : base(id, parentId, name, parent, parentDocument)
        {
            int markerId        = parentDocument.GetNextId();
            var markerViewModel = new MarkerViewModel(markerId, id, "marker" + markerId.ToString(), this, parentDocument);

            parentDocument.AddChild(markerViewModel);
        }
        /// <summary>
        ///     Create a "pair" document, this is a bit different from the others
        /// </summary>
        /// <returns>Document</returns>
        public static Document LogitechPairDocument()
        {
            var document = new Document
            {
                Namespace = Namespace
            };

            var element = new Element("oa");

            element.Attributes.Add("xmlns", "connect.logitech.com");
            element.Attributes.Add("mime", "vnd.logitech.connect/vnd.logitech.pair");
            element.Value = "method=pair:name=foo#iOS6.0.1#iPhone";
            document.AddChild(element);
            return(document);
        }
        /// <summary>
        ///     Create a simple document for the command
        /// </summary>
        /// <param name="command">Command to call</param>
        /// <param name="elementValue">The value of the OA element, if one is needed</param>
        /// <returns>Document</returns>
        private static Document CreateDocument(HarmonyCommands command, string elementValue = null)
        {
            var document = new Document
            {
                Namespace = Namespace
            };

            var element = CreateOaElement(command);

            if (elementValue != null)
            {
                element.Value = elementValue;
            }
            document.AddChild(element);
            return(document);
        }
Esempio n. 5
0
        /// <summary>
        /// 登录成功事件
        /// </summary>
        /// <param name="sender"></param>
        public void XmppCon_OnLogin(object sender)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new CSS.IM.XMPP.ObjectHandler(XmppCon_OnLogin), new object[] { sender });
                return;
            }

            Program.UserName = XmppCon.Username;
            Program.LocalHostIP = IPAddress.Parse(XmppCon.ClientSocket.LocalHostIP);//设置本地IP地址
            VcardIq viq = new VcardIq(IqType.get, null, new Jid(XmppCon.MyJID.User));
            XmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
            Program.UserName = XmppCon.MyJID.User;//保存登录的用户名

            notifyIcon_MessageQueue.Visible = true;
            waiting.Close();

            XmppCon.Show = ShowType.NONE;
            XmppCon.SendMyPresence();

            DiscoServer();//获取各种服务器

            this.NikeName = XmppCon.Username;
            this.ShowInTaskbar = false;
            this.Show();
            this.WindowState = FormWindowState.Normal;
            listView_fd.XmppConnection = XmppCon;

            listView_fd.AddGroup("我的联系人");
            listView_fd.UpdateLayout(3, 0);

            this.TopMost = true;
            this.Show();
            this.Activate();
            this.TopMost = false;

            #region 设置最后一次登录的用户
            Document hl_doc = new Document();
            Settings.HistoryLogin doc_HLlgin;
            if (!System.IO.File.Exists(CSS.IM.UI.Util.Path.HistoryFilename))
            {
                doc_HLlgin = new Settings.HistoryLogin();
                doc_HLlgin.LoginName = Program.UserName;
            }
            else
            {
                hl_doc.LoadFile(CSS.IM.UI.Util.Path.HistoryFilename);
                doc_HLlgin = hl_doc.RootElement as Settings.HistoryLogin;
                doc_HLlgin.LoginName = Program.UserName;
                hl_doc.RemoveAllChildNodes();

            }
            hl_doc.AddChild(doc_HLlgin);
            FileInfo file = new FileInfo(CSS.IM.UI.Util.Path.HistoryFilename);
            if (!File.Exists(file.DirectoryName))
            {
                Directory.CreateDirectory(file.DirectoryName);
            }
            hl_doc.Save(CSS.IM.UI.Util.Path.HistoryFilename);
            #endregion

            #region 创建服务配置文件
            Document vy_doc = new Document();
            Settings.Verify vy_doc_settings = new Settings.Verify();
            Settings.Login vy_doc_login = null;
            Settings.ServerInfo vy_doc_serverInfo = null;

            if (System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.SettingsFilename,Program.UserName)))
            {
                vy_doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName));

                vy_doc_login = vy_doc.RootElement.SelectSingleElement(typeof(Settings.Login)) as Settings.Login;
                vy_doc_serverInfo = vy_doc.RootElement.SelectSingleElement(typeof(Settings.ServerInfo)) as Settings.ServerInfo;
                vy_doc.RemoveAllChildNodes();
            }
            else
            {
                vy_doc_login = new Settings.Login();
                vy_doc_serverInfo = new Settings.ServerInfo();
                vy_doc_login.InitIal = true;//设置开机自动启动,默认为启动
            }

            vy_doc_login.Auto = login_user.Auto;
            vy_doc_login.Save = login_user.Save;
            vy_doc_login.Jid = new Jid(login_user.UserName);
            vy_doc_login.Password = login_user.PassWord;

            vy_doc_serverInfo.ServerIP = Program.ServerIP;
            vy_doc_serverInfo.ServerPort = Program.Port;

            vy_doc_settings.ServerInfo = vy_doc_serverInfo;
            vy_doc_settings.Login = vy_doc_login;

            vy_doc.ChildNodes.Add(vy_doc_settings);
            vy_doc.Save(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName));
            CSS.IM.UI.Util.Path.Initial = vy_doc_login.InitIal;//设置开机自动启动
            #endregion

            #region 创建个人配置文件
            if (!System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.ConfigFilename,Program.UserName)))
            {
                Document doc = new Document();
                Settings.Settings config = new Settings.Settings();
                CSS.IM.App.Settings.Paths path = new Settings.Paths();
                path.MsgPath = CSS.IM.UI.Util.Path.MsgPath;
                path.SelectSingleElement("MsgPath").SetAttribute("Enable", true);
                path.SystemPath = CSS.IM.UI.Util.Path.SystemPath;
                path.SelectSingleElement("SystemPath").SetAttribute("Enable", true);
                path.CallPath = CSS.IM.UI.Util.Path.CallPath;
                path.SelectSingleElement("CallPath").SetAttribute("Enable", true);
                path.FolderPath = CSS.IM.UI.Util.Path.FolderPath;
                path.SelectSingleElement("FolderPath").SetAttribute("Enable", true);
                path.GlobalPath = CSS.IM.UI.Util.Path.GlobalPath;
                path.SelectSingleElement("GlobalPath").SetAttribute("Enable", true);
                path.InputAlertPath = CSS.IM.UI.Util.Path.InputAlertPath;
                path.SelectSingleElement("InputAlertPath").SetAttribute("Enable", true);
                path.ReveiveSystemNotification = true;
                path.ChatOpen = true;
                path.SendKeyType = CSS.IM.UI.Util.Path.SendKeyType;//创建消息发送快捷键类型 默认为enter发送
                path.GetOutMsgKeyTYpe = "W+ Control+ Alt";//默认获取消息快捷按键
                path.ScreenKeyTYpe = "S+ Control+ Alt";//默认截图快捷按键
                path.FriendContainerType = true;//保存是大头像还是小头像 默认为小头像

                path.DefaultURL = "http://10.0.0.207:8080/bgtoa/eblueplugins/eblueim/forwardUrl.do?url=cmVkaXJlY3Q6L2luZGV4LmRv";//毛奇使用

                path.EmailURL = "http://10.0.0.207:8080/bgtoa/eblueplugins/eblueim/forwardUrl.do?url=cmVkaXJlY3Q6L2luZGV4LmRv";//毛奇使用

                config.Paths = path;

                CSS.IM.UI.Util.Path.DefaultURL = path.DefaultURL;

                BasicTextBox txt_temp = new BasicTextBox();

                CSS.IM.App.Settings.SFont font = new Settings.SFont();
                font.Name = txt_temp.Font.Name;
                font.Size = txt_temp.Font.Size;
                font.Bold = txt_temp.Font.Bold;
                font.Italic = txt_temp.Font.Italic;
                font.Strikeout = txt_temp.Font.Strikeout;
                config.Font = font;

                CSS.IM.App.Settings.SColor color = new Settings.SColor();
                Color top_cl = txt_temp.ForeColor;
                byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                color.CA = top_cby[0];
                color.CR = top_cby[1];
                color.CG = top_cby[2];
                color.CB = top_cby[3];
                config.Color = color;

                doc.ChildNodes.Add(config);
                doc.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName));

                txt_temp.Dispose();
            }

            #endregion
        }
        public static void ImportFromExistingDirectoryDialog(Document document)
        {
            var dialog = new FolderBrowserDialog
            {
                RootFolder = Environment.SpecialFolder.Desktop,
                ShowNewFolderButton = false,
                SelectedPath = Settings.Default.LastFolderBrowsed
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.LastFolderBrowsed = dialog.SelectedPath;
                Settings.Default.Save();

                var rootFolder = ImportFromFolder(dialog.SelectedPath);
                document.AddChild(rootFolder);
            }
        }