Exemplo n.º 1
0
        static public void InitializeGeometry()
        {
            /*
             * CDocument doc = new CDocument(device, "box.dae");
             * M = doc.Geometries["Box001"];
             */

            CDocument doc = new CDocument(device, "plane.dae");

            M = doc.Geometries["Plane001"];


            CDocument docL = new CDocument(device, "ball.dae");

            L = docL.Geometries["GeoSphere001"];

            Camera = new SDXCamera();
            phi    = 0; theta = 0; radius = M.BSphere.Radius * 3;
            Camera.SetPositionSpherical(phi, theta, radius);
            Camera.Target = M.BSphere.Center;
            Camera.Up     = new Vector3(0, 1, 0);

            Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, (float)MainWindow.ClientSize.Width / (float)MainWindow.ClientSize.Height, 0.01f, M.BSphere.Radius * 10);

            //LightPosition = new Vector3(M.BSphere.Radius * 2, 0, 0);
            LightPosition = new Vector3(M.BSphere.Radius * 2, 0, M.BSphere.Radius * 2);
        }
Exemplo n.º 2
0
        private void btnSegment_Click(object sender, EventArgs e)
        {
            CDocument OCRDoc = new CDocument(tbInput.Text);

            OCRDoc.Segment();
            OCRDoc.Save(tbOutput.Text);
        }
Exemplo n.º 3
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 유저 권한 레벨에 따라 버튼 상태 변경
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void SetChangeButtonStatus(CDocument objDocument, Control.ControlCollection collection)
        {
            do
            {
                // 현재 폼 내에 생성된 컨트롤 리스트를 뽑음
                Control.ControlCollection objCollection = collection;
                // 그 중에서 Button & ImageButton만 사용할 예정
                List <Control> objButtonList = new List <Control>();
                // Button or ImageButton Type인 놈만 List에 저장
                for (int iLoopCollection = 0; iLoopCollection < objCollection.Count; iLoopCollection++)
                {
                    // Button Type
                    if (objCollection[iLoopCollection].GetType().Name == (new Button()).GetType().Name)
                    {
                        objButtonList.Add(objCollection[iLoopCollection] as Button);
                    }
                }
                // 현재 유저 정보 받음
                CUserInformation objUserInformation = objDocument.GetUserInformation();
                // 현재 유저 권한 레벨이 폼 Write 레벨보다 낮으면 버튼 막음
                CFormView objFormView = objDocument.GetMainFrame().GetFormView() as CFormView;
                if (null == objFormView)
                {
                    break;
                }
                // 처음 생성 시 튕김
                if (CDefine.FormView.FORM_VIEW_FINAL == objFormView.GetCurrentForm())
                {
                    break;
                }

                if (( int )objUserInformation.m_eAuthorityLevel < ( int )objDocument.m_objAuthorityParameter.m_objLevelForm[( int )objFormView.GetCurrentForm()].eLevelWrite)
                {
                    for (int iLoopButton = 0; iLoopButton < objButtonList.Count; iLoopButton++)
                    {
                        if (true == objButtonList[iLoopButton].Enabled)
                        {
                            objButtonList[iLoopButton].Enabled = false;
                        }
                    }
                }
                // 아니면 버튼 살림
                else
                {
                    for (int iLoopButton = 0; iLoopButton < objButtonList.Count; iLoopButton++)
                    {
                        if (false == objButtonList[iLoopButton].Enabled)
                        {
                            objButtonList[iLoopButton].Enabled = true;
                        }
                    }
                }
            } while(false);
        }
Exemplo n.º 4
0
        public void SetOCRDoc(CDocument OCRObj)
        {
            _ocr = OCRObj;

            foreach (CColumn curColumn in _ocr.Columns)
            {
                RichTextBox rtbToAdd = new RichTextBox();
                this.Controls.Add(rtbToAdd);
                Rectangle rect = Utils.FixRect(curColumn.X, curColumn.Y, curColumn.Width, curColumn.Height, _docheight);
                rtbToAdd.Left = rect.X;
                rtbToAdd.Top = rect.Y;
                rtbToAdd.Width = rect.Width;
                rtbToAdd.Height = rect.Height;
                rtbToAdd.BorderStyle = BorderStyle.None;
                foreach (CParagraph curParagraph in curColumn.Paragraphs)
                {
                    rtbToAdd.Text += (curParagraph.Text + "\r\n");
                }
            }

            UpdateScaleFactor();
        }
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //생성 :
 //추가 :
 //목적 : 생성자
 //설명 :
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public CFormTeachOutputBufferStage(CDocument objDocument)
 {
     // 도큐먼트 포인트 받음
     m_objDocument = objDocument;
     InitializeComponent();
 }
Exemplo n.º 6
0
        public async Task <PageAttributes> DownloadDeviceContent(string UID, bool push, bool onlymobile = true, bool recursive = true)
        {
            PageAttributes mobilepage = null;
            bool           download   = false;
            IComosWeb      m_ComosWeb = Services.XServices.Instance.GetService <IComosWeb>();

            ViewModels.ProjectData projectdata = Services.XServices.Instance.GetService <ViewModels.ProjectData>();
            Services.XDatabase     db          = Services.XServices.Instance.GetService <Services.XDatabase>();


            List <CSpecification> Specifications;

            try
            {
                Specifications = await m_ComosWeb.GetObjectSpecification(
                    projectdata.SelectedDB.Key,
                    projectdata.SelectedProject.UID,
                    projectdata.SelectedLayer.UID,
                    projectdata.SelectedLanguage.LCID,
                    UID);
            }
            catch (TaskCanceledException) { return(null); } // If there is a Logout Request
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Error al obtener atributos: " + e.Message, Services.TranslateExtension.TranslateText("OK"));

                return(null);
            }

            if (Specifications == null || Specifications.Count == 0)
            {
                return(null);
            }

            foreach (var item in Specifications)
            {
                //TO DO DOWNLOAD EVERYTHING???

                if (item.Name.Equals(Constants.MobileTabName) || !onlymobile)
                {
                    download = true;
                }

                if (download)
                {
                    CSystemObject sysobj;
                    try
                    {
                        sysobj = await m_ComosWeb.GetObject(projectdata.SelectedLayer, UID, projectdata.SelectedLanguage.LCID);
                    }
                    catch (TaskCanceledException) { return(null); } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar objetos de Comos Web: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return(null);
                    }

                    if (sysobj == null)
                    {
                        return(null);
                    }

                    CObject o = new CObject()
                    {
                        ClassType       = sysobj.SystemType,
                        Description     = sysobj.Description,
                        IsClientPicture = sysobj.IsClientPicture,
                        Name            = sysobj.Name,
                        UID             = sysobj.UID,
                        OverlayUID      = projectdata.SelectedLayer.UID,
                        Picture         = sysobj.Picture,
                        ProjectUID      = projectdata.SelectedProject.UID,
                        SystemFullName  = sysobj.Name,
                    };

                    //check if its download only

                    PageAttributes page = null;
                    if (!push)
                    {
                        page = new PageAttributes();
                        await page.Init(projectdata.SelectedDB.Key, projectdata.SelectedLanguage.LCID, item, o);
                    }
                    else
                    {
                        page = new PageAttributes(projectdata.SelectedDB.Key, projectdata.SelectedLanguage.LCID, item, o);
                    }

                    //download all documents if not pushing to page
                    if (!push)
                    {
                        List <string> uids_docs = await page.DownloadDocuments();

                        foreach (var doc in uids_docs)
                        {
                            // string[] filename_mime = await DownloadDocument(doc, false);
                            CDocument filename_mime = await DownloadDocument(doc, false);

                            if (filename_mime != null && filename_mime.FileName != null)
                            {
                                db.CacheDocumentFilePath(filename_mime.FileName, filename_mime.MimeType, doc, projectdata.SelectedProject.UID, projectdata.SelectedLayer.UID, filename_mime.Name, filename_mime.Description, filename_mime.Picture);
                            }
                            else
                            {
                                if (recursive)
                                {
                                    await DownloadDeviceContent(doc, false, true, false);
                                }
                            }
                        }
                    }

                    if (item.Name.Equals(Constants.MobileTabName))
                    {
                        mobilepage = page;
                    }

                    download = false;
                }
            }

            return(mobilepage);
        }
Exemplo n.º 7
0
        public async Task <CDocument> DownloadDocument(string UID, bool open)
        {
            IComosWeb m_ComosWeb = Services.XServices.Instance.GetService <ComosWebSDK.IComosWeb>();

            ViewModels.ProjectData ProjectData = Services.XServices.Instance.GetService <ViewModels.ProjectData>();

            // Need to Lock to wait big files (on sleep will logout comosweb)
            m_ComosWeb.Lock();
            CSystemObject o;

            try
            {
                o = await m_ComosWeb.GetObject(
                    ProjectData.SelectedDB.Key,
                    ProjectData.SelectedProject.UID,
                    ProjectData.SelectedLayer.UID,
                    UID, ProjectData.SelectedLanguage.LCID);
            }
            catch (TaskCanceledException) { return(await Task.FromResult <CDocument>(null)); } // If there is a Logout Request
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Error al descargar documento: " + e.Message, Services.TranslateExtension.TranslateText("OK"));

                return(await Task.FromResult <CDocument>(null));
            }

            if (o == null)
            {
                return(await Task.FromResult <CDocument>(null));
            }
            if (o.DocumentType != null)
            {
                bool exportpdf = string.Compare(o.DocumentType.Name, "ComosReport", StringComparison.CurrentCultureIgnoreCase) == 0;
                if (!exportpdf)
                {
                    exportpdf = string.Compare(o.DocumentType.Name, "ComosIReport", StringComparison.CurrentCultureIgnoreCase) == 0;
                }
                // Is a comos report.
                CDocument result = await Task.Run <CDocument>(async() =>
                {
                    HttpResponseMessage response;
                    try
                    {
                        response = await m_ComosWeb.ComosWeb.GetDocumentStream(
                            ProjectData.SelectedDB.Key,
                            ProjectData.SelectedProject.UID,
                            ProjectData.SelectedLayer.UID,
                            UID, exportpdf);
                    }
                    catch (TaskCanceledException) { return(null); } // If there is a Logout Request
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar documento: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));
                        return(null);
                    }

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        string filename = response.Content.Headers.ContentDisposition.FileName;
                        System.Diagnostics.Debug.WriteLine(response.Content.Headers.ContentDisposition.DispositionType);
                        filename              = filename.Trim(new char[] { '"' });
                        filename              = filename.Replace("/", "-");
                        var stream            = await response.Content.ReadAsStreamAsync();
                        var platform          = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
                        string filename_saved = await platform.SaveAndOpenDocument(filename, stream, response.Content.Headers.ContentType.MediaType, open);
                        return(new CDocument()
                        {
                            Description = o.Description,
                            Name = o.Name,
                            UID = o.UID,
                            FileName = filename_saved,
                            Picture = o.Picture,
                            MimeType = response.Content.Headers.ContentType.MediaType
                        });
                    }
                    else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        return(await Task.FromResult <CDocument>(null));
                    }
                    else
                    {
                        var platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
                        platform.ShowToast("Error:" + response.ReasonPhrase);
                        return(await Task.FromResult <CDocument>(null));
                        //throw new Exception(response.ReasonPhrase);
                    }
                });

                return(result);
            }

            m_ComosWeb.UnLock();

            return(await Task.FromResult <CDocument>(null));
        }
Exemplo n.º 8
0
        private async void m_List_ItemTapped(object sender, EventArgs e)
        {
            StackLayout viewcell = (StackLayout)sender;
            ResultItem  item     = (ResultItem)viewcell.BindingContext;

            await viewcell.ScaleTo(1.2, 50, Easing.Linear);

            await viewcell.ScaleTo(1, 50, Easing.Linear);


            if ((bool)docconverter.Convert(item.UID, null, null, null))
            {
                if (plataform.IsOnline)
                {
                    plataform.ShowProgressMessage(Services.TranslateExtension.TranslateText("downloading_documents"), true);
                    CheckAndDownloadAditionalContent downloader = new CheckAndDownloadAditionalContent();
                    CDocument filename_andtype = await downloader.DownloadDocument(item.UID, true);

                    if (filename_andtype != null && filename_andtype.FileName != "")
                    {
                        cachedb.CacheDocumentFilePath(filename_andtype.FileName, filename_andtype.MimeType, item.UID, m_ProjectData.SelectedProject.UID, m_ProjectData.SelectedLayer.UID, filename_andtype.Name, filename_andtype.Description, filename_andtype.Picture);
                    }
                    if (filename_andtype == null)
                    {
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("document_not_found"));
                    }

                    plataform.HideProgressMessage();
                }
            }
            else if ((bool)devconverter.Convert(item.UID, null, null, null))
            {
                CSystemObject sysobj;
                try
                {
                    sysobj = await m_ComosWeb.GetObject(m_ProjectData.SelectedLayer, item.UID, m_ProjectData.SelectedLanguage.LCID);
                }
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Error al buscar: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                    return;
                }

                if (sysobj == null)
                {
                    return;
                }

                CObject o = new CObject()
                {
                    ClassType       = sysobj.SystemType,
                    Description     = sysobj.Description,
                    IsClientPicture = sysobj.IsClientPicture,
                    Name            = sysobj.Name,
                    UID             = sysobj.UID,
                    OverlayUID      = m_ProjectData.SelectedLayer.UID,
                    Picture         = sysobj.Picture,
                    ProjectUID      = m_ProjectData.SelectedProject.ProjectUID,
                    SystemFullName  = sysobj.Name,
                };
                PageSpecifications page = new PageSpecifications(m_ProjectData.SelectedDB.Key, o, m_ProjectData.SelectedLanguage.LCID);
                await this.Navigation.PushAsync(page);
            }
        }
Exemplo n.º 9
0
        private async void ViewCell_DocumentTapped(object sender, EventArgs e)
        {
            var viewcell = sender as StackLayout;
            var row      = viewcell.BindingContext as CRow;

            await viewcell.ScaleTo(1.2, 50, Easing.Linear);

            await viewcell.ScaleTo(1, 50, Easing.Linear);

            if ((bool)docconverter.Convert(row.Items[0].UID, null, null, null))
            {
                if (plataform.IsOnline)
                {
                    plataform.ShowProgressMessage(Services.TranslateExtension.TranslateText("downloading_documents"), true);
                    //string[] filename_andtype = await DownloadDocument(row.Items[0].UID);
                    CDocument filename_andtype = await DownloadDocument(row.Items[0].UID);

                    if (filename_andtype != null && !string.IsNullOrEmpty(filename_andtype.FileName))
                    {
                        cachedb.CacheDocumentFilePath(filename_andtype.FileName, filename_andtype.MimeType, row.Items[0].UID, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID, filename_andtype.Name, filename_andtype.Description, filename_andtype.Picture);
                    }
                    if (filename_andtype == null)
                    {
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("document_not_found"));
                    }
                    if (string.IsNullOrEmpty(filename_andtype.FileName))
                    {
                        // Can happen in emulator. When folder /SDCard/Storage/Download not exists.
                        plataform.ShowToast(Services.TranslateExtension.TranslateText("save_not_possible"));
                    }

                    plataform.HideProgressMessage();
                }
                else
                {
                    string[] path = cachedb.GetDocumentFilePath(row.Items[0].UID, ProjectData.SelectedProject.UID, ProjectData.SelectedLayer.UID);
                    if (path != null && path[0] != "")
                    {
                        bool result = await plataform.OpenFile(path[0], path[1]);
                    }
                    //else doc not found in cache
                }
            }
            else if ((bool)devconverter.Convert(row.Items[0].UID, null, null, null))
            {
                // open device properties

                if (m_Page != null)
                {
                    CSystemObject sysobj;
                    try
                    {
                        sysobj = await m_ComosWeb.GetObject(ProjectData.SelectedLayer, row.Items[0].UID, ProjectData.SelectedLanguage.LCID);
                    }
                    catch (Exception ex)
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Error al cargar objetos de Comos Web: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));

                        return;
                    }

                    if (sysobj != null)
                    {
                        CObject o = new CObject()
                        {
                            ClassType       = sysobj.SystemType,
                            Description     = sysobj.Description,
                            IsClientPicture = sysobj.IsClientPicture,
                            Name            = sysobj.Name,
                            UID             = sysobj.UID,
                            OverlayUID      = ProjectData.SelectedLayer.UID,
                            Picture         = sysobj.Picture,
                            ProjectUID      = ProjectData.SelectedProject.ProjectUID,
                            SystemFullName  = sysobj.Name,
                        };
                        PageSpecifications page = new PageSpecifications(ProjectData.SelectedDB.Key, o, ProjectData.SelectedLanguage.LCID);

                        await m_Page.Navigation.PushAsync(page);
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = @"PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*";
            dlg.RestoreDirectory = true;

            String FileName = (dlg.ShowDialog() == DialogResult.OK) ? dlg.FileName : string.Empty;

            if (FileName == string.Empty) return;

            ImageEdit currentIe = (ImageEdit)(new Utils().FindControlRecursive(this.tabControlMain.SelectedTab, "ieMain"));

            if (currentIe == null)
            {
                return;                     // TODO: error handling
            }

            ocr = currentIe.GetOCR();

            if (ocr == null) {
                return;
            }

            ocr.Export(FileName);
        }
Exemplo n.º 11
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            ImageEdit currentIe = (ImageEdit)(new Utils().FindControlRecursive(this.tabControlMain.SelectedTab, "ieMain"));

            if (currentIe == null) {
                return;                     // TODO: error handling
            }

            if (mImage != null && !string.IsNullOrEmpty(currentIe.ImagePath)) {
                ocr = null;
                ocr = currentIe.GetOCR();// new CDocument();

                if (ocr == null) {
                    return;             // TODO: error handling
                }

                progressBar1.Value = 0;
                //listBox1.Items.Clear();

                ocr.OcrDone = new CDocument.OcrDoneHandler(Done);
                ocr.ProgressEvent += new CDocument.ProgressHandler(ocrProgressEvent);
                currentIe.GetOCR().OCRopusLayoutAnalysis();
            }
        }
Exemplo n.º 12
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ImageEdit currentIe = (ImageEdit)(new Utils().FindControlRecursive(this.tabControlMain.SelectedTab, "ieMain"));

            if (currentIe == null) {
                return;                     // TODO: error handling
            }
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = @"OCR Files (*.ocr)|*.ocr|All Files (*.*)|*.*";
            dlg.RestoreDirectory = true;

            String FileName = (dlg.ShowDialog() == DialogResult.OK) ? dlg.FileName : string.Empty;

            if (FileName == string.Empty) return;

            ocr = currentIe.Load(FileName);
            currentIe.Refresh();
        }
Exemplo n.º 13
0
 public void SetOCR( CDocument ocr )
 {
     _ocr = ocr;
 }
Exemplo n.º 14
0
 public CDocument Load(string filePath)
 {
     _ocr = CDocument.Load(filePath);
     _imagepath = _ocr.ImagePath;
     _image = Image.FromFile(_ocr.ImagePath);
     UpdateScaleFactor();
     Invalidate();
     return _ocr;
 }
Exemplo n.º 15
0
 public void Close()
 {
     _ocr = null;
     _imagepath = string.Empty;
     _showcolumns = true;
     _showparagraphs = true;
     _showlines = true;
     _showcharacters = true;
     _image = null;
     UpdateScaleFactor();
     Invalidate();
 }