// Add a page of the given kind; parse the content to get the page number.
        private void addPage(XmlTextReader source, PageKind kind)
        {
            if (mCurrentSection == null)
            {
                throw new Exception(Localizer.Message("error_adding_page_number"));
            }
            string     pageNumberString = GetTextContent(source);
            PageNumber number           = null;

            if (kind == PageKind.Special && pageNumberString != null && pageNumberString != "")
            {
                number = new PageNumber(pageNumberString);
            }
            else if (kind == PageKind.Front || kind == PageKind.Normal)
            {
                int pageNumber = EmptyNode.SafeParsePageNumber(pageNumberString);
                if (pageNumber > 0)
                {
                    number = new PageNumber(pageNumber, kind);
                }
            }
            if (number != null)
            {
                EmptyNode node = mPresentation.TreeNodeFactory.Create <EmptyNode>();
                node.PageNumber = number;
                mCurrentSection.AppendChild(node);
            }
        }
Ejemplo n.º 2
0
        public void ConvertByte_IntoPageType(byte expectedPageTypeByte, PageKind pageKind)
        {
            var page = new Page {
                PageKind = pageKind
            };

            Assert.Equal(expectedPageTypeByte, page.RawData[0]);
        }
Ejemplo n.º 3
0
        protected virtual TreeNode CreateAndAddTreeNodeForContentDocument(TreeNode parentNode, XmlNode node, string contentFileName)
        {
            TreeNode createdNode = null;

            //Console.WriteLine(node.LocalName);
            if (node.LocalName.StartsWith("level") || node.LocalName == "doctitle")
            {
                //Console.WriteLine("creating section ");
                SectionNode treeNode = m_Presentation.CreateSectionNode();
                createdNode = treeNode;
                if (parentNode is ObiRootNode)
                {
                    ((ObiNode)parentNode).AppendChild(treeNode);
                }
                else
                {
                    ((SectionNode)parentNode).AppendChild(treeNode);
                }
            }
            else if (parentNode is SectionNode &&
                     node.LocalName == "pagenum")
            {
                EmptyNode treeNode = m_Presentation.TreeNodeFactory.Create <EmptyNode>();
                createdNode = treeNode;
                ((SectionNode)parentNode).AppendChild(treeNode);

                PageNumber number = null;

                string strKind          = node.Attributes.GetNamedItem("page").Value;
                string pageNumberString = node.InnerText;

                PageKind kind = strKind == "front" ? PageKind.Front :
                                strKind == "normal" ? PageKind.Normal :
                                PageKind.Special;


                if (kind == PageKind.Special && pageNumberString != null && pageNumberString != "")
                {//2
                    number = new PageNumber(pageNumberString);
                }//-2
                else if (kind == PageKind.Front || kind == PageKind.Normal)
                {//2
                    int pageNumber = EmptyNode.SafeParsePageNumber(pageNumberString);
                    if (pageNumber > 0)
                    {//3
                        number = new PageNumber(pageNumber, kind);
                    }//-3
                }//-2

                if (number != null)
                {
                    ((EmptyNode)treeNode).PageNumber = number;
                }
            }
            return(createdNode);
        }
Ejemplo n.º 4
0
 public PageNumber(int number, PageKind kind)
 {
     if (mKind == PageKind.Special)
     {
         throw new Exception("Special pages have a label, not a number.");
     }
     mNumber = number;
     mKind   = kind;
     mLabel  = null;
 }
Ejemplo n.º 5
0
        protected override void AddPagePropertiesToAudioNode(TreeNode audioWrapperNode, XmlNode pageTargetNode)
        {
            string   strKind = pageTargetNode.Attributes.GetNamedItem("type").Value;
            PageKind kind    = strKind == "front" ? PageKind.Front :
                               strKind == "normal" ? PageKind.Normal :
                               PageKind.Special;

            string     pageNumberString = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(pageTargetNode, true, "text", pageTargetNode.NamespaceURI).InnerText;
            PageNumber number           = null;

            if (kind == PageKind.Special && pageNumberString != null && pageNumberString != "")
            {
                number = new PageNumber(pageNumberString);
            }
            else if (kind == PageKind.Front || kind == PageKind.Normal)
            {
                int pageNumber = EmptyNode.SafeParsePageNumber(pageNumberString);
                if (pageNumber > 0)
                {
                    number = new PageNumber(pageNumber, kind);
                }
                else
                {
                    pageNumberString = pageTargetNode.Attributes.GetNamedItem("value") != null?pageTargetNode.Attributes.GetNamedItem("value").Value : "";

                    pageNumber = EmptyNode.SafeParsePageNumber(pageNumberString);
                    if (pageNumber > 0)
                    {
                        number = new PageNumber(pageNumber, kind);
                    }
                }
            }
            if (number != null)
            {
                EmptyNode node = (EmptyNode)audioWrapperNode;
                node.PageNumber = number;
            }

            /*
             * TextMedia textMedia = audioWrapperNode.Presentation.MediaFactory.CreateTextMedia();
             * textMedia.Text = XmlDocumentHelper.GetFirstChildElementWithName(pageTargetNode, true, "text", pageTargetNode.NamespaceURI).InnerText;
             * ChannelsProperty cProp = audioWrapperNode.Presentation.PropertyFactory.CreateChannelsProperty();
             * cProp.SetMedia(m_textChannel, textMedia);
             * audioWrapperNode.AddProperty(cProp);
             * System.Xml.XmlAttributeCollection pageAttributes = pageTargetNode.Attributes;
             * if (pageAttributes != null)
             * {
             *  XmlProperty xmlProp = audioWrapperNode.GetXmlProperty();
             *  foreach (System.Xml.XmlAttribute attr in pageAttributes)
             *  {
             *      xmlProp.SetAttribute(attr.Name, attr.NamespaceURI, attr.Value);
             *  }
             * }
             */
        }
Ejemplo n.º 6
0
        public ContentPageData(NavMenuItemData nd, string locKey, string imageKey, PageKind kind = PageKind.Undefined, Action <ContentPageData> clickAction = null) : this()
        {
            LocalizedKey = locKey;
            NavData      = nd;
            ClickAction  = clickAction;
            ImageKey     = imageKey;
            Kind         = kind;

            this.UpdateLocalization();
            this.UpdateTheme();
        }
Ejemplo n.º 7
0
        public Page FindFirst(PageKind pageKind)
        {
            var allPages = ReadAll().ToArray();

            foreach (var page in allPages)
            {
                if (page.PageKind == pageKind)
                {
                    return(page);
                }
            }

            return(null);
        }
Ejemplo n.º 8
0
        // Add a page of the given kind; parse the content to get the page number.
        private void addPage(XmlNode node, PageKind kind)
        {
            if (m_CurrentSection == null)
            {
                throw new Exception(Localizer.Message("error_adding_page_number"));
            }
            string     pageNumberString = GetTextContent(node);
            PageNumber number           = null;
            bool       markToDo         = false;

            if (kind == PageKind.Special && pageNumberString != null && pageNumberString != "")
            {
                number = new PageNumber(pageNumberString);
            }
            else if (kind == PageKind.Front || kind == PageKind.Normal)
            {
                int pageNumber = EmptyNode.SafeParsePageNumber(pageNumberString);
                if (pageNumber == 0 && kind == PageKind.Front) //if front page is not numeric, make it numeric with marking it to do
                {
                    m_Counter_FrontPageCorection++;
                    pageNumber = m_Counter_FrontPageCorection;
                    markToDo   = true;
                }
                if (pageNumber > 0)
                {
                    number = new PageNumber(pageNumber, kind);
                }
            }
            if (number != null)
            {
                EmptyNode n = m_Presentation.TreeNodeFactory.Create <EmptyNode>();
                n.PageNumber = number;
                m_CurrentSection.AppendChild(n);

                if (markToDo)
                {
                    n.TODO = true;
                    m_ErrorsList.Add(string.Format(Localizer.Message("DAISY2_ObiImport_ErrorsList_FrontPageCorrection"), pageNumberString, n.PageNumber.ToString()));
                }
                //extract id

                XmlNode attrID = node.Attributes.GetNamedItem("id");
                string  strId  = attrID != null    ? attrID.Value: null;
                if (strId != null)
                {
                    m_NccReferenceToPageMap.Add(strId, n);
                }
            }
        }
Ejemplo n.º 9
0
        public static string GetAccessToken(Dictionary <string, string> uriParams, out PageKind pageKind)
        {
            pageKind = PageKind.Dialog;
            var accessToken = string.Empty;

            if (uriParams.ContainsKey("start"))
            {
                accessToken = uriParams["start"];
            }
            else if (uriParams.ContainsKey("startgroup"))
            {
                pageKind    = PageKind.Search;
                accessToken = uriParams["startgroup"];
            }

            return(accessToken);
        }
Ejemplo n.º 10
0
        public static void NavigateToUser(TLUserBase userBase, string accessToken, PageKind pageKind = PageKind.Dialog)
        {
            if (userBase == null)
            {
                return;
            }

            Execute.BeginOnUIThread(() =>
            {
                var navigationService = IoC.Get <INavigationService>();
                if (pageKind == PageKind.Profile)
                {
                    IoC.Get <IStateService>().CurrentContact = userBase;
                    //IoC.Get<IStateService>().RemoveBackEntries = true;
                    navigationService.Navigate(new Uri("/Views/Contacts/ContactView.xaml", UriKind.Relative));
                }
                else if (pageKind == PageKind.Search)
                {
                    var user = userBase as TLUser;
                    if (user != null && user.IsBotGroupsBlocked)
                    {
                        MessageBox.Show(AppResources.AddBotToGroupsError, AppResources.Error, MessageBoxButton.OK);
                        return;
                    }

                    IoC.Get <IStateService>().With = userBase;
                    IoC.Get <IStateService>().RemoveBackEntries = true;
                    IoC.Get <IStateService>().AccessToken       = accessToken;
                    IoC.Get <IStateService>().Bot = userBase;
                    navigationService.Navigate(new Uri("/Views/Dialogs/ChooseDialogView.xaml?rndParam=" + TLInt.Random(), UriKind.Relative));
                }
                else
                {
                    IoC.Get <IStateService>().With = userBase;
                    IoC.Get <IStateService>().RemoveBackEntries = true;
                    IoC.Get <IStateService>().AccessToken       = accessToken;
                    IoC.Get <IStateService>().Bot = userBase;
                    navigationService.Navigate(new Uri("/Views/Dialogs/DialogDetailsView.xaml?rndParam=" + TLInt.Random(), UriKind.Relative));
                }
                // fix DialogDetailsView -> DialogDetailsView
                //IoC.Get<INavigationService>().UriFor<DialogDetailsViewModel>().Navigate();
            });
        }
Ejemplo n.º 11
0
        public void SaveDataInPages(Page firstDataPage, byte[] newBytes)
        {
            PageKind pageKind         = firstDataPage.PageKind;
            int      bytesToBeWritten = newBytes.Length;
            Page     currentPage      = firstDataPage;

            while (bytesToBeWritten > 0)
            {
                int startIndex = newBytes.Length - bytesToBeWritten;
                int copyLength = Math.Min(bytesToBeWritten, currentPage.DataBlock.Data.Length);
                newBytes.AsSpan().Slice(startIndex, copyLength).CopyTo(currentPage.DataBlock.Data);

                WriteToDb(currentPage);

                bytesToBeWritten -= currentPage.DataBlock.Data.Length;

                if (bytesToBeWritten > 0)
                {
                    if (currentPage.DataBlock.NextPageId > 0)
                    {
                        //read next page as we need to write to it chuck of data.
                        currentPage = ReadFromDb(currentPage.DataBlock.NextPageId);
                    }
                    else
                    {
                        // Create new page
                        var newKvPage = new Page(pageKind);
                        WriteToDb(newKvPage);

                        // update current page to point to new page
                        currentPage.DataBlock.NextPageId = newKvPage.PageId;
                        WriteToDb(currentPage);

                        currentPage = newKvPage;
                    }
                }
            }
        }
Ejemplo n.º 12
0
 string CreateVisibleParam(PageKind kind)
 {
     return(kind.ToKey() + VisiblePlefix);
 }
Ejemplo n.º 13
0
        public static void NavigateToUsername(IMTProtoService mtProtoService, string username, string accessToken, PageKind pageKind = PageKind.Dialog)
        {
            if (mtProtoService != null)
            {
                TelegramTransitionFrame frame = null;

                Execute.BeginOnUIThread(() =>
                {
                    frame = Application.Current.RootVisual as TelegramTransitionFrame;
                    if (frame != null)
                    {
                        frame.OpenBlockingProgress();
                    }
                });

                mtProtoService.ResolveUsernameAsync(new TLString(username),
                                                    result => Execute.BeginOnUIThread(() =>
                {
                    if (frame != null)
                    {
                        frame.CloseBlockingProgress();
                    }

                    var peerUser = result.Peer as TLPeerUser;
                    if (peerUser != null)
                    {
                        var user = result.Users.FirstOrDefault();
                        if (user != null)
                        {
                            NavigateToUser(user, accessToken, pageKind);
                            return;
                        }
                    }

                    var peerChannel = result.Peer as TLPeerChannel;
                    var peerChat    = result.Peer as TLPeerChat;
                    if (peerChannel != null || peerChat != null)
                    {
                        var chat = result.Chats.FirstOrDefault();
                        if (chat != null)
                        {
                            NavigateToChat(chat);
                            return;
                        }
                    }

                    MessageBox.Show(string.Format(AppResources.CantFindContactWithUsername, username), AppResources.Error, MessageBoxButton.OK);
                }),
                                                    error => Execute.BeginOnUIThread(() =>
                {
                    if (frame != null)
                    {
                        frame.CloseBlockingProgress();
                    }

                    if (error.CodeEquals(ErrorCode.BAD_REQUEST) &&
                        error.TypeEquals(ErrorType.USERNAME_NOT_OCCUPIED))
                    {
                        MessageBox.Show(string.Format(AppResources.CantFindContactWithUsername, username), AppResources.Error, MessageBoxButton.OK);
                    }
                    else
                    {
                        Execute.ShowDebugMessage("contacts.resolveUsername error " + error);
                    }
                }));
            }
        }
 public ContentPageDataForProxy(NavMenuItemData nd, string imageKey, IChannelProxy proxy, PageKind kind, UserControl page, Action <ContentPageData> clickAction = null)
     : base(nd, "", imageKey, kind, page, clickAction)
 {
     _proxy              = proxy;
     _proxy.NameChanged += _proxy_NameChanged;
     this.LocalizedKey   = _proxy.Name;
 }
Ejemplo n.º 15
0
 private void SetButtonState_Main(PageKind pk)
 {
 }
Ejemplo n.º 16
0
 private void SetButtonState_Admin(PageType pt, PageKind pk)
 {
 }
Ejemplo n.º 17
0
 public ChangePageEventArgs(PageKind page)
 {
     NextPage = page;
 }
Ejemplo n.º 18
0
        private static async Task ShowDialogAsync(
            PageKind activePage,
            IServiceProvider site,
            PythonProjectNode project,
            string existingCondaEnvName = null,
            string environmentYmlPath   = null,
            string requirementsTxtPath  = null,
            CancellationToken ct        = default(CancellationToken)
            )
        {
            if (site == null)
            {
                throw new ArgumentNullException(nameof(site));
            }

            ProjectView[] projectViews;
            ProjectView   selectedProjectView;

            try {
                var sln      = (IVsSolution)site.GetService(typeof(SVsSolution));
                var projects = sln?.EnumerateLoadedPythonProjects().ToArray() ?? new PythonProjectNode[0];

                projectViews = projects
                               .Select((projectNode) => new ProjectView(projectNode))
                               .ToArray();

                selectedProjectView = projectViews.SingleOrDefault(pv => pv.Node == project);
            } catch (InvalidOperationException ex) {
                Debug.Fail(ex.ToUnhandledExceptionMessage(typeof(AddEnvironmentDialog)));
                projectViews        = new ProjectView[0];
                selectedProjectView = null;
            }

            if (selectedProjectView != null)
            {
                if (existingCondaEnvName != null)
                {
                    selectedProjectView.MissingCondaEnvName = existingCondaEnvName;
                }

                if (environmentYmlPath != null)
                {
                    selectedProjectView.EnvironmentYmlPath = environmentYmlPath;
                }

                if (requirementsTxtPath != null)
                {
                    selectedProjectView.RequirementsTxtPath = requirementsTxtPath;
                }
            }

            var addVirtualView = new AddVirtualEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            var addCondaView = new AddCondaEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            var addExistingView = new AddExistingEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            var addInstalledView = new AddInstalledEnvironmentView(
                site,
                projectViews,
                selectedProjectView
                );

            EnvironmentViewBase activeView;

            switch (activePage)
            {
            case PageKind.VirtualEnvironment:
                activeView = addVirtualView;
                break;

            case PageKind.CondaEnvironment:
                activeView = addCondaView;
                break;

            case PageKind.ExistingEnvironment:
                activeView = addExistingView;
                break;

            case PageKind.InstalledEnvironment:
                activeView = addInstalledView;
                break;

            default:
                Debug.Assert(false, string.Format("Unknown page kind '{0}'", activePage));
                activeView = null;
                break;
            }

            using (var dlg = new AddEnvironmentDialog(
                       new EnvironmentViewBase[] {
                addVirtualView,
                addCondaView,
                addExistingView,
                addInstalledView,
            },
                       activeView
                       )) {
                try {
                    WindowHelper.ShowModal(dlg);
                } catch (Exception) {
                    dlg.Close();
                    throw;
                }

                if (dlg.DialogResult ?? false)
                {
                    var view = dlg.View.PagesView.CurrentItem as EnvironmentViewBase;
                    Debug.Assert(view != null);
                    if (view != null)
                    {
                        try {
                            await view.ApplyAsync();
                        } catch (Exception ex) when(!ex.IsCriticalException())
                        {
                            Debug.Fail(ex.ToUnhandledExceptionMessage(typeof(AddEnvironmentDialog)), Strings.ProductTitle);
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
 private void SetButtonState_Open(PageKind pk)
 {
     this.SetButtonState_Add("");
 }
Ejemplo n.º 20
0
 public PageNumber(string label)
 {
     mKind   = PageKind.Special;
     mLabel  = label;
     mNumber = 0;
 }
Ejemplo n.º 21
0
 private void SetButtonState_People(PageType pt, PageKind pk)
 {
     this.SetButtonState_Open(pk);
 }
Ejemplo n.º 22
0
        public ButtonsModel(string UserName, PageKind pk)
        {
            this.ibtderateurl = "images/new/process.png";
            this.ibtderatetext = "减免";
            this.ibtmoneyurl = "images/new/process.png";
            this.ibtmoneytext = "收款";
            this.ibtauditurl = "images/new/process.png";
            this.ibtaudittext = "审核";
            this.ibtapplyurl = "images/new/process.png";
            this.ibtapplytext = "审批";
            this.ibtdourl = "images/new/process.png";
            this.ibtdotext = "查看";
            this.ibtimpowerurl = "images/new/process.png";
            this.ibtimpowertext = "授权";
            this.ibtpaperurl = "images/new/process.png";
            this.ibtpapertext = "发证";
            this.ibtprintnoteurl = "images/new/shuchu.png";
            this.ibtprintnotetext = "打印票据";
            this.ibtaddurl = "images/new/add.png";
            this.ibtaddtext = "新增";
            this.ibtupdateurl = "images/new/xiugai.png";
            this.ibtupdatetext = "修改";
            this.ibtsaveurl = "images/new/baocun.png";
            this.ibtsavetext = "保存";
            this.ibtdeleteurl = "images/new/delete.png";
            this.ibtdeletetext = "删除";
            this.ibtlookurl = "images/new/chaxun.png";
            this.ibtlooktext = "查看";
            this.ibtsearchurl = "images/new/sousuo.png";
            this.ibtsearchtext = "搜索";
            this.ifrefresh = true;
            this.ibtrefreshurl = "images/new/refresh.png";
            this.ibtrefreshtext = "刷新";
            this.ibthuizongurl = "images/new/huizong.png";
            this.ibthuizongtext = "汇总";
            this.ibtputouturl = "images/new/shuchu.png";
            this.ibtputouttext = "打印";
            this.ibtseturl = "images/new/process.png";
            this.ibtsettext = "设置";
            this.ibtsetbackurl = "images/new/bohui.png";
            this.ibtsetbacktext = "弃审";
            this.ibtrollbackurl = "images/new/bohui.png";
            this.ibtrollbacktext = "退回";
            this.ibtdisposeurl = "images/new/zhuxiao.png";
            this.ibtdisposetext = "注销";
            this.ifexit = true;
            this.ibtexiturl = "images/new/tuichu.png";
            this.ibtexittext = "退出";
            switch (pk)
            {
                case PageKind.Add:
                    this.SetButtonState_Add(UserName);
                    return;

                case PageKind.Update:
                    this.SetButtonState_Update(UserName);
                    return;

                case PageKind.List:
                    this.SetButtonState_List(UserName);
                    return;
            }
        }
Ejemplo n.º 23
0
 public ButtonsModel(string UserName, PageType pt, PageKind pk)
 {
     this.ibtderateurl = "images/new/process.png";
     this.ibtderatetext = "减免";
     this.ibtmoneyurl = "images/new/process.png";
     this.ibtmoneytext = "收款";
     this.ibtauditurl = "images/new/process.png";
     this.ibtaudittext = "审核";
     this.ibtapplyurl = "images/new/process.png";
     this.ibtapplytext = "审批";
     this.ibtdourl = "images/new/process.png";
     this.ibtdotext = "查看";
     this.ibtimpowerurl = "images/new/process.png";
     this.ibtimpowertext = "授权";
     this.ibtpaperurl = "images/new/process.png";
     this.ibtpapertext = "发证";
     this.ibtprintnoteurl = "images/new/shuchu.png";
     this.ibtprintnotetext = "打印票据";
     this.ibtaddurl = "images/new/add.png";
     this.ibtaddtext = "新增";
     this.ibtupdateurl = "images/new/xiugai.png";
     this.ibtupdatetext = "修改";
     this.ibtsaveurl = "images/new/baocun.png";
     this.ibtsavetext = "保存";
     this.ibtdeleteurl = "images/new/delete.png";
     this.ibtdeletetext = "删除";
     this.ibtlookurl = "images/new/chaxun.png";
     this.ibtlooktext = "查看";
     this.ibtsearchurl = "images/new/sousuo.png";
     this.ibtsearchtext = "搜索";
     this.ifrefresh = true;
     this.ibtrefreshurl = "images/new/refresh.png";
     this.ibtrefreshtext = "刷新";
     this.ibthuizongurl = "images/new/huizong.png";
     this.ibthuizongtext = "汇总";
     this.ibtputouturl = "images/new/shuchu.png";
     this.ibtputouttext = "打印";
     this.ibtseturl = "images/new/process.png";
     this.ibtsettext = "设置";
     this.ibtsetbackurl = "images/new/bohui.png";
     this.ibtsetbacktext = "弃审";
     this.ibtrollbackurl = "images/new/bohui.png";
     this.ibtrollbacktext = "退回";
     this.ibtdisposeurl = "images/new/zhuxiao.png";
     this.ibtdisposetext = "注销";
     this.ifexit = true;
     this.ibtexiturl = "images/new/tuichu.png";
     this.ibtexittext = "退出";
     if (UserName == "admin")
     {
         this.ifadd = true;
         this.ifupdate = true;
         this.ifdelete = true;
         this.ifrefresh = true;
         this.ifexit = true;
     }
     else
     {
         this.SetButtonState_People(pt, pk);
     }
 }
Ejemplo n.º 24
0
 public ContentPageData(NavMenuItemData nd, string locKey, string imageKey, PageKind kind, UserControl page, Action <ContentPageData> clickAction = null)
     : this(nd, locKey, imageKey, kind, clickAction)
 {
     Page = page;
 }
Ejemplo n.º 25
0
 // Gender に対する拡張メソッドの定義
 public static string ToKey(this PageKind kind)
 {
     string[] names = { "Base", "WizardView", "ReadModel" };
     return(names[(int)kind]);
 }