Пример #1
0
        private static void ConsumeType(Type t, ProcessObject proc)
        {
            ConstructorInfo ctor = t.GetConstructor(new Type[] { });

            if (ctor == null)
            {
                return;
            }

            object obj;

            try
            {
                obj = ctor.Invoke(new object[] { });
            }
            catch (Exception)
            {
                return;
            }

            if (obj == null)
            {
                return;
            }

            proc(obj);
        }
Пример #2
0
        private static void ConsumeType(Type t, ProcessObject proc)
        {
            ConstructorInfo ctor = t.GetConstructor(new Type[] { });

            if (ctor == null)
            {
                return;
            }

            object obj = null;

            try
            {
                obj = ctor.Invoke(new object[] { });
            }
            catch (Exception e)
            {
                Diagnostics.ExceptionLogging.LogException(e);
            }

            if (obj != null)
            {
                proc(obj);
            }
        }
Пример #3
0
 /**
  * @param po
  * @throws PipelineException
  */
 private void Write(IWorkerContext context, ProcessObject po) {
     MapContext mp = (MapContext)GetLocalContext(context);
     if (po.ContainsWritable()) {
         Document doc = (Document) mp[DOCUMENT];
         bool continuousWrite = (bool) mp[CONTINUOUS];
         IWritable writable = null;
         while (null != (writable = po.Poll())) {
             if (writable is WritableElement) {
                 foreach (IElement e in ((WritableElement) writable).Elements()) {
                     try {
                         if (!doc.Add(e) && LOG.IsLogging(Level.TRACE)) {
                             LOG.Trace(String.Format(
                                     LocaleMessages.GetInstance().GetMessage(LocaleMessages.ELEMENT_NOT_ADDED),
                                     e.ToString()));
                         }
                     } catch (DocumentException e1) {
                         if (!continuousWrite) {
                             throw new PipelineException(e1);
                         } else {
                             LOG.Error(
                                     LocaleMessages.GetInstance().GetMessage(LocaleMessages.ELEMENT_NOT_ADDED_EXC),
                                     e1);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #4
0
        public long UpdateProcess(ProcessObject process)
        {
            try
            {
                if (process == null)
                {
                    return(-2);
                }

                var processEntity = ModelMapper.Map <ProcessObject, Process>(process);
                if (processEntity == null || processEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.Processes.Attach(processEntity);
                    db.Entry(processEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(process.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
        public void TestSerializeAndDeserializeProcessObject()
        {
            var po         = ProcessObject.FromProcess(Process.GetCurrentProcess());
            var serialized = JsonUtils.Dehydrate(po);

            Assert.IsTrue(serialized == JsonUtils.Dehydrate(JsonUtils.Hydrate(serialized, RESULT_TYPE.PROCESS)));
        }
Пример #6
0
        public void TestOfTests()
        {
            var app = ProcessObject.Resolve <IDemoApp>();

            app.TestBottomUp();
            app.WritePdfTree("TestBottomUp.pdf");
        }
    public void UpdateProcesses(Dictionary <int, ProcessManager.ProcessData> processes)
    {
        foreach (KeyValuePair <int, ProcessManager.ProcessData> process in processes)
        {
            if (!objects.ContainsKey(process.Key))
            {
                Debug.Log("Create object for [" + playerId + " : " + process.Key + "] " + process.Value.name);
                GameObject gameObject = Instantiate(processObjectPrefab);
                gameObject.name               = "[" + playerId + " : " + process.Key + "] " + process.Value.name;
                gameObject.transform.parent   = this.transform;
                gameObject.transform.position = new Vector3(Random.Range(-50.0F, 50.0F), 1F, Random.Range(-50.0F, 50.0F));
                ProcessObject processObject = gameObject.GetComponent <ProcessObject>();
                processObject.playerId  = playerId;
                processObject.processId = process.Key;
                processObject.color     = color;
                objects.Add(process.Key, gameObject);
            }
            objects[process.Key].GetComponent <ProcessObject>().UpdateProcess(process.Value);
        }
        List <int> toRemove = new List <int>();

        foreach (KeyValuePair <int, GameObject> pair in objects)
        {
            if (!processes.ContainsKey(pair.Key))
            {
                GameObject.Destroy(pair.Value);
                toRemove.Add(pair.Key);
            }
        }
        foreach (int key in toRemove)
        {
            objects.Remove(key);
        }
    }
Пример #8
0
        /// <summary>
        /// 生成文章审批路径html描述
        /// </summary>
        /// <param name="article"></param>
        /// <param name="targetSite"></param>
        /// <returns></returns>
        public string CreateArticleFlowPathHtml(Article article, string targetSite)
        {
            Processing    p  = GetArticleProcess(article);
            ProcessObject po = (ProcessObject)article;

            return(CreateFlowPathHtml(po, p, targetSite));;
        }
Пример #9
0
        public void MainWindowTests()
        {
            var app = ProcessObject.Resolve <IDemoApp>();

            app.Goto <IMainWindow>().Test();
            app.WritePdfTree();
        }
Пример #10
0
	    /*
	     * (non-Javadoc)
	     *
	     * @see com.itextpdf.tool.xml.pipeline.Pipeline#open(com.itextpdf.tool.
	     * xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
	     */
	    public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po) {
		    SvgPipelineContext hcc = (SvgPipelineContext) GetLocalContext(context);
		    try {
			    ITagProcessor tp = hcc.ResolveProcessor(t.Name, t.Name);
			    if (tp.IsStackOwner()) {
				    hcc.AddFirst(new StackKeeper(t));
			    }
			    IList<IElement> content = tp.StartElement(context, t);
			    if (content.Count > 0) {
				    if (tp.IsStackOwner()) {
					    StackKeeper peek;
					    try {
						    peek = hcc.Peek();
						    foreach (IElement elem in content) {
							    peek.Add(elem);
						    }
					    } catch (NoStackException e) {
						    throw new PipelineException(String.Format(LocaleMessages.STACK_404, t.ToString()), e);
					    }
				    } else {
					    if(!hcc.IsDefinition()){
						    foreach (IElement elem in content) {
							    po.Add((Graphic)elem);
						    }
					    }
				    }
			    }
		    } catch (NoTagProcessorException e) {
			    if (!hcc.AcceptUnknown()) {
				    throw e;
			    }
		    }
		    return GetNext();
	    }
Пример #11
0
        /// <summary>
        /// 生成反馈审批路径html描述
        /// </summary>
        /// <param name="advice"></param>
        /// <param name="targetSite"></param>
        /// <returns></returns>
        public string CreateAdviceFlowPathHtml(Advice advice, string targetSite)
        {
            Processing    p  = GetAdviceProcess(advice);
            ProcessObject po = (ProcessObject)advice;

            return(CreateFlowPathHtml(po, p, targetSite));;
        }
Пример #12
0
        public long AddProcess(ProcessObject process)
        {
            try
            {
                if (process == null)
                {
                    return(-2);
                }

                var processEntity = ModelMapper.Map <ProcessObject, Process>(process);
                if (processEntity == null || string.IsNullOrEmpty(processEntity.Name))
                {
                    return(-2);
                }
                using (var db = new ImportPermitEntities())
                {
                    var returnStatus = db.Processes.Add(processEntity);
                    db.SaveChanges();
                    return(returnStatus.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Пример #13
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.pipeline.IPipeline#close(com.itextpdf.tool
         * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
        {
            HtmlPipelineContext hcc = (HtmlPipelineContext)GetLocalContext(context);
            ITagProcessor       tp;

            try {
                if (t.LastMarginBottom != null)
                {
                    hcc.GetMemory()[HtmlPipelineContext.LAST_MARGIN_BOTTOM] = t.LastMarginBottom;
                }
                else
                {
                    hcc.GetMemory().Remove(HtmlPipelineContext.LAST_MARGIN_BOTTOM);
                }
                tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
                IList <IElement> elems = null;
                if (tp.IsStackOwner())
                {
                    // remove the element from the StackKeeper Queue if end tag is
                    // found
                    StackKeeper tagStack;
                    try {
                        tagStack = hcc.Poll();
                    } catch (NoStackException e) {
                        throw new PipelineException(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.STACK_404), t.ToString()), e);
                    }
                    elems = tp.EndElement(context, t, tagStack.GetElements());
                }
                else
                {
                    elems = tp.EndElement(context, t, hcc.CurrentContent());
                    hcc.CurrentContent().Clear();
                }
                if (elems.Count > 0)
                {
                    StackKeeper stack = hcc.Peek();

                    if (stack != null)
                    {
                        foreach (IElement elem in elems)
                        {
                            stack.Add(elem);
                        }
                    }
                    else
                    {
                        WritableElement writableElement = new WritableElement();
                        po.Add(writableElement);
                        writableElement.AddAll(elems);
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
Пример #14
0
        public ActionResult EditProcess(ProcessObject process)
        {
            var gVal = new GenericValidator();

            try
            {
                //if (!ModelState.IsValid)
                //{
                //    gVal.Code = -1;
                //    gVal.Error = "Plese provide all required fields and try again.";
                //    return Json(gVal, JsonRequestBehavior.AllowGet);
                //}

                if (string.IsNullOrEmpty(process.Name.Trim()))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please provide Process.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_Process"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldProcess = Session["_Process"] as ProcessObject;

                if (oldProcess == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                oldProcess.Name = process.Name.Trim();

                var docStatus = new ProcessServices().UpdateProcess(oldProcess);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Process information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldProcess.Id;
                gVal.Error = "Process information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Process information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public void WhenTryingToFindControlObjectWithGenericArgument_CorrectTypeIsReturned()
        {
            // during resolve it should not hit unrelated types like DialogControlObject
            var expected = new ProcessObject().Find <ListBoxControlObject <IListDataTemplateObject> >();
            var proc     = new ProcessObject().Find <IListBoxControlObject <IListDataTemplateObject> >();

            Assert.AreEqual(expected.GetType(), proc.GetType());
            Assert.AreEqual(typeof(ListDataTemplateObject), proc.Value.GetType());
        }
Пример #16
0
 public void Init()
 {
     if (app == null)
     {
         var pageObjectImpl = Path.GetFullPath(@".\Trumpf.Coparoo.Desktop.DemoApp.exe");
         System.Reflection.Assembly.LoadFile(pageObjectImpl);
         app = ProcessObject.Resolve <IDemoApp>();
     }
 }
Пример #17
0
        public void ClickTypedInterfaceButton()
        {
            IDemoApp app = ProcessObject.Resolve <IDemoApp>();

            app.Configuration.WaitTimeout         = TimeSpan.FromMinutes(1);
            app.Configuration.PositiveWaitTimeout = TimeSpan.FromMilliseconds(500);
            app.On <IMainWindow>().VisibleOnScreen.WaitFor(TimeSpan.FromMinutes(1));
            app.On <IMainWindow>().TypedButton.Click();
        }
Пример #18
0
        public void WhenTheResolveMethodIsCalledWithAnInterface_ThenTheCorrectRootObjectIsReturned()
        {
            // Act
            var rootObject = ProcessObject.Resolve <IA>();

            // Check
            Assert.AreEqual(typeof(A), rootObject.GetType());
            Assert.IsTrue(rootObject is IA);
        }
Пример #19
0
    void OnCollisionEnter(Collision collision)
    {
        ProcessObject processObject = collision.gameObject.GetComponent <ProcessObject> ();

        if (processObject != null)
        {
            GameObject.Find("ProcessManager").GetComponent <ProcessManager>().KillProcess(processObject);
        }
    }
Пример #20
0
        private static void AlternatingCuttingCurve(ProcessObject processObject, Curve curve, double d)
        {
            var par = processObject.ProcessingParams;
            // s - текущее смещение от кривой контура детали curve
            // d - заданная величина смещения
            var s = par.Depth > 0
                ? (par.DepthAll > d ? par.DepthAll : d)
                : d;

            s -= par.Depth;
            if (s < d)
            {
                s = d;
            }
            var direction   = processObject.Direction;
            var isFirstPass = true;

            do
            {
                if (!IsCalculation)
                {
                    return;
                }
                if (!isFirstPass)
                {
                    s -= par.Depth;
                    if (s < d)
                    {
                        s = d;
                    }
                    direction = -direction;
                }

                var      s1            = Settings.WithCompensation ? s : s + processObject.Tool.Diameter.Value / 2;
                Curve    toolpathCurve = AutocadUtils.GetOffsetCopy(curve, processObject.Curve.OutsideSign * s1);
                ObjectId toolObjectId  = AutocadUtils.CreateToolCurve(s, toolpathCurve.StartPoint.Z, processObject.Tool.Thickness);

                Feed(toolpathCurve, direction, processObject.Curve.OutsideSign, par, isFirstPass);

                List <ProcessingAction> actions = new List <ProcessingAction>();
                if (processObject.Curve.Type == CurveType.Polyline || processObject.Curve.Type == CurveType.Circle)
                {
                    actions = Machine.Cutting(AutocadUtils.Explode(toolpathCurve, direction == -1), par.GreatSpeed);
                }
                else
                {
                    actions.Add(Machine.Cutting(toolpathCurve, par.GreatSpeed));
                }

                actions.ForEach(p => p.ToolObjectId = toolObjectId);

                Retract(toolpathCurve, direction, processObject.Curve.OutsideSign, par);

                isFirstPass = false;
            }while (s > d);
        }
Пример #21
0
        public OptionResult Perform(ProcessObject onProcess)
        {
            if (!Initialize())
            {
                return(OptionResult.Failure);
            }

            Perform(GetObjects(Common.Localize(LocalizeKey + ":Header")), onProcess);
            return(OptionResult.SuccessRetain);
        }
Пример #22
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.pipeline.IPipeline#open(com.itextpdf.tool.
         * xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
        {
            HtmlPipelineContext hcc = (HtmlPipelineContext)GetLocalContext(context);

            try {
                Object lastMarginBottom = null;
                if (hcc.GetMemory().TryGetValue(HtmlPipelineContext.LAST_MARGIN_BOTTOM, out lastMarginBottom))
                {
                    t.LastMarginBottom = lastMarginBottom;
                    hcc.GetMemory().Remove(HtmlPipelineContext.LAST_MARGIN_BOTTOM);
                }
                ITagProcessor tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
                if (tp.IsStackOwner())
                {
                    hcc.AddFirst(new StackKeeper(t));
                }
                IList <IElement> content = tp.StartElement(context, t);
                if (content.Count > 0)
                {
                    if (tp.IsStackOwner())
                    {
                        StackKeeper peek;
                        try {
                            peek = hcc.Peek();
                            foreach (IElement elem in content)
                            {
                                peek.Add(elem);
                            }
                        } catch (NoStackException e) {
                            throw new PipelineException(String.Format(LocaleMessages.STACK_404, t.ToString()), e);
                        }
                    }
                    else
                    {
                        foreach (IElement elem in content)
                        {
                            hcc.CurrentContent().Add(elem);
                            if (elem.Type == Element.BODY)
                            {
                                WritableElement writableElement = new WritableElement();
                                writableElement.Add(elem);
                                po.Add(writableElement);
                                hcc.CurrentContent().Remove(elem);
                            }
                        }
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
Пример #23
0
        public void WhenAGenericInterfaceIsSearchedFor_ThenToCorrenspondingGenericImplementationIsResolved()
        {
            // Act
            var     rootObject = ProcessObject.Resolve <IA>();
            IG <IF> control    = rootObject.Find <IG <IF> >();
            IF      item       = control.Item;

            // Check
            Assert.AreEqual(typeof(G <IF>), control.GetType());
            Assert.AreEqual(typeof(F), control.Item.GetType());
        }
Пример #24
0
 public ProcessLineViewModel(ProcessObject processObject, string objectName)
     : base(processObject)
 {
     ObjectName   = objectName ?? ("Отрезок" + ++_no);
     _processLine = new Line(); //processObject.ProcessCurve as Line;
     if (_processLine == null)
     {
         throw new Exception("Ошибка приведения к линии");
     }
     //_toolpathLine = processObject.ToolpathCurve as Line;
 }
Пример #25
0
        protected void Perform(List <Item> selection, ProcessObject onProcess)
        {
            if ((selection != null) && (selection.Count > 0))
            {
                string msg = null;
                if (selection.Count == 1)
                {
                    msg = Common.Localize(LocalizeKey + ":Single", false, new object[] { selection[0].Name });
                }
                else
                {
                    msg = Common.Localize(LocalizeKey + ":Multiple", false, new object[] { selection.Count });
                }

                if (AcceptCancelDialog.Show(msg))
                {
                    int changed = 0;

                    Dictionary <IGameObject, bool> objs = new Dictionary <IGameObject, bool>();

                    foreach (Item subitem in selection)
                    {
                        Item item = subitem as Item;

                        foreach (IGameObject obj in item.mObjects)
                        {
                            if (objs.ContainsKey(obj))
                            {
                                continue;
                            }

                            objs.Add(obj, true);
                        }
                    }

                    foreach (IGameObject obj in objs.Keys)
                    {
                        try
                        {
                            if (onProcess(obj))
                            {
                                changed++;
                            }
                        }
                        catch
                        { }
                    }

                    StyledNotification.Format format = new StyledNotification.Format(Common.Localize(LocalizeKey + ":Success", false, new object[] { changed }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage);
                    format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
                    StyledNotification.Show(format);
                }
            }
        }
Пример #26
0
 public void KillProcess(ProcessObject processObject)
 {
     if (processObject.playerId == 0)
     {
         KillLocalProcess(processObject.processId);
     }
     else
     {
         KillRemoteProcess(processObject.playerId, processObject.processId);
     }
 }
 /**
  * Called in <code>open</code>, <code>content</code> and <code>close</code> to pass the {@link Writable}s to the handler
  * @param po
  */
 private void Consume(IWorkerContext context, ProcessObject po)
 {
     if (po.ContainsWritable())
     {
         IWritable w = null;
         while (null != (w = po.Poll()))
         {
             handler.Add(w);
         }
     }
 }
Пример #28
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.pipeline.Pipeline#close(com.itextpdf.tool
         * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
        {
            SvgPipelineContext hcc = (SvgPipelineContext)GetLocalContext(context);
            ITagProcessor      tp;
            IList <IElement>   elements = null;

            try {
                tp = hcc.ResolveProcessor(t.Name, t.NameSpace);

                if (tp.IsStackOwner())
                {
                    // remove the element from the StackKeeper Queue if end tag is found
                    StackKeeper tagStack;
                    try {
                        tagStack = hcc.Poll();
                    } catch (NoStackException e) {
                        throw new PipelineException(String.Format(
                                                        LocaleMessages.GetInstance().GetMessage(LocaleMessages.STACK_404), t.ToString()), e);
                    }
                    elements = tp.EndElement(context, t, tagStack.GetElements());
                }
                else
                {
                    elements = tp.EndElement(context, t, hcc.CurrentContent());
                    hcc.CurrentContent().Clear();
                }

                if (elements != null && elements.Count > 0)
                {
                    try {
                        StackKeeper stack = hcc.Peek();
                        foreach (IElement elem in elements)
                        {
                            stack.Add(elem);
                        }
                    } catch (NoStackException) {
                        //don't write definities, part of defs
                        if (!hcc.IsDefinition())
                        {
                            foreach (IElement elem in elements)
                            {
                                po.Add((IWritable)elem);
                            }
                        }
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
Пример #29
0
 public ProcessArcViewModel(ProcessObject processObject, string objectName)
     : base(processObject)
 {
     ObjectName  = objectName ?? ("Дуга" + ++_no);
     _processArc = new Arc(); //processObject.ProcessCurve as Arc;
     if (_processArc == null)
     {
         throw new Exception("Ошибка приведения к дуге");
     }
     //_toolpathArc = processObject.ToolpathCurve as Arc;
 }
Пример #30
0
        public void SetUp()
        {
            lst = new List <IWritable>();
            IElementHandler elemH = new CustomElementHandler();

            p        = new ElementHandlerPipeline(elemH, null);
            po       = new ProcessObject();
            writable = new WritableElement(new Chunk("aaaaa"));
            po.Add(writable);
            context = new WorkerContextImpl();
            p.Init(context);
        }
Пример #31
0
 public long UpdateProcess(ProcessObject process)
 {
     try
     {
         return(_processManager.UpdateProcess(process));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Пример #32
0
        /**
         * @param po
         * @throws PipelineException
         */

        //lijst met graphische elementen (en andere?)
        private void Write(IWorkerContext context, ProcessObject po, Tag t)
        {
            //MapContext mp = GetLocalContext(context);
            if (po.ContainsWritable()) {
                //Document doc = (Document) mp.Get(DOCUMENT);
                //bool continuousWrite = (Boolean) mp.Get(CONTINUOUS);
                IWritable writable = null;
                while (null != (writable = po.Poll())) {
                    if (writable is Graphic) {
                        ((Graphic)writable).Draw(template, t.CSS);
                        if (writable is Svg) {
                            Svg svg = (Svg)writable;
                            text.Rectangle viewBox = svg.ViewBox;
                            template.BoundingBox = new text.Rectangle(viewBox.Width, viewBox.Height);
                        }
                    }
                }
            }
        }
Пример #33
0
 /*
  * (non-Javadoc)
  *
  * @see com.itextpdf.tool.xml.pipeline.IPipeline#open(com.itextpdf.tool.
  * xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
  */
 public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
 {
     ((ObjectContext<ICSSResolver>)GetLocalContext(context)).Get().ResolveStyles(t);
     return GetNext();
 }
Пример #34
0
	    /*
	     * (non-Javadoc)
	     *
	     * @see com.itextpdf.tool.xml.pipeline.Pipeline#content(com.itextpdf.tool
	     * .xml.Tag, java.lang.String, com.itextpdf.tool.xml.pipeline.ProcessObject)
	     */
	    public override IPipeline Content(IWorkerContext context, Tag t, String text, ProcessObject po)
			    {
		    SvgPipelineContext hcc = (SvgPipelineContext)GetLocalContext(context);
		    ITagProcessor tp;
		    try {
			    tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
    //			String ctn = null;
    //			if (null != hcc.CharSet()) {
    //				try {
    //					ctn = new String(b, hcc.CharSet().Name());
    //				} catch (UnsupportedEncodingException e) {
    //					throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(
    //							LocaleMessages.UNSUPPORTED_CHARSET), e);
    //				}
    //			} else {
    //				ctn = new String(b);
    //			}
    			
			    IList<IElement> elements = tp.Content(context, t, text);		
    			
			    if (elements.Count > 0) {
				    StackKeeper peek;
				    try {
					    peek = hcc.Peek();
					    foreach (IElement e in elements) {
						    peek.Add(e);
					    }
				    } catch (NoStackException) {
					    if(!hcc.IsDefinition()){
						    foreach (IElement elem in elements) {
							    po.Add((IWritable)elem);
						    }
					    }
    //					po.Add(writableElement);
				    }
			    }
		    } catch (NoTagProcessorException e) {
			    if (!hcc.AcceptUnknown()) {
				    throw e;
			    }
		    }
		    return GetNext();
	    }	
 public MyCommand(ProcessObject po)
 {
     m_ProcessObject = po;
 }
Пример #36
0
	    /*
	     * (non-Javadoc)
	     *
	     * @see com.itextpdf.tool.xml.pipeline.Pipeline#close(com.itextpdf.tool
	     * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
	     */
	    public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po) {
		    SvgPipelineContext hcc = (SvgPipelineContext) GetLocalContext(context);
		    ITagProcessor tp;
		    IList<IElement> elements = null;
		    try {
			    tp = hcc.ResolveProcessor(t.Name, t.NameSpace);

			    if (tp.IsStackOwner()) {
				    // remove the element from the StackKeeper Queue if end tag is found
				    StackKeeper tagStack;
				    try {
					    tagStack = hcc.Poll();
				    } catch (NoStackException e) {
					    throw new PipelineException(String.Format(
							    LocaleMessages.GetInstance().GetMessage(LocaleMessages.STACK_404), t.ToString()), e);
				    }
				    elements = tp.EndElement(context, t, tagStack.GetElements());
			    } else {
				    elements = tp.EndElement(context, t, hcc.CurrentContent());				
				    hcc.CurrentContent().Clear();				
			    }
    			
			    if (elements != null && elements.Count > 0) {
				    try {
					    StackKeeper stack = hcc.Peek();
					    foreach (IElement elem in elements) {
						    stack.Add(elem);
					    }
				    } catch (NoStackException) {
					    //don't write definities, part of defs
					    if(!hcc.IsDefinition()){
						    foreach (IElement elem in elements) {
							    po.Add((IWritable)elem);
						    }		
					    }					
				    }
			    }
		    } catch (NoTagProcessorException e) {
			    if (!hcc.AcceptUnknown()) {
				    throw e;
			    }
		    }
		    return GetNext();
	    }
Пример #37
0
        protected void Perform(List<Item> selection, ProcessObject onProcess)
        {
            if ((selection != null) && (selection.Count > 0))
            {
                string msg = null;
                if (selection.Count == 1)
                {
                    msg = Common.Localize(LocalizeKey + ":Single", false, new object[] { selection[0].Name });
                }
                else
                {
                    msg = Common.Localize(LocalizeKey + ":Multiple", false, new object[] { selection.Count });
                }

                if (AcceptCancelDialog.Show(msg))
                {
                    int changed = 0;

                    Dictionary<IGameObject, bool> objs = new Dictionary<IGameObject, bool>();

                    foreach (Item subitem in selection)
                    {
                        Item item = subitem as Item;

                        foreach (IGameObject obj in item.mObjects)
                        {
                            if (objs.ContainsKey(obj)) continue;

                            objs.Add(obj, true);
                        }
                    }

                    foreach (IGameObject obj in objs.Keys)
                    {
                        try
                        {
                            if (onProcess(obj))
                            {
                                changed++;
                            }
                        }
                        catch
                        { }
                    }

                    StyledNotification.Format format = new StyledNotification.Format(Common.Localize(LocalizeKey + ":Success", false, new object[] { changed }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage);
                    format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
                    StyledNotification.Show(format);
                }
            }
        }
Пример #38
0
 /**
  * Just calls getNext.
  *
  */
 public virtual IPipeline Close(IWorkerContext context, Tag t, ProcessObject po) {
     return GetNext();
 }
Пример #39
0
 /**
  * Just calls getNext.
  *
  */
 public virtual IPipeline Content(IWorkerContext ctx, Tag currentTag,  string text, ProcessObject po) {
     return GetNext();
 }
Пример #40
0
 /*
  * (non-Javadoc)
  *
  * @see com.itextpdf.tool.xml.pipeline.Pipeline#content(com.itextpdf.tool
  * .xml.Tag, java.lang.String, com.itextpdf.tool.xml.pipeline.ProcessObject)
  */
 public override IPipeline Content(IWorkerContext context, Tag currentTag, String text, ProcessObject po)
 {
     Write(context, po, currentTag);
     return GetNext();
 }
Пример #41
0
 /*
  * (non-Javadoc)
  *
  * @see com.itextpdf.tool.xml.pipeline.Pipeline#close(com.itextpdf.tool
  * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
  */
 public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
 {
     Write(context, po, t);
     //writer.GetDirectContent().RestoreState();
     return GetNext();
 }
Пример #42
0
		private static void ConsumeType(Type t, ProcessObject proc)
		{
			ConstructorInfo ctor = t.GetConstructor(new Type[] { });
			if (ctor == null)
				return;

			object obj;
			try
			{
				obj = ctor.Invoke(new object[] { });
			}
			catch (Exception)
			{
				return;
			}

			if (obj == null)
				return;

			proc(obj);
		}
Пример #43
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.pipeline.Pipeline#open(com.itextpdf.tool.
         * xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
        {
            IDictionary<String, String> attributes = t.Attributes;
            if (attributes != null) {
                String transform;
                if (attributes.TryGetValue("transform", out transform) && transform != null)
                {
                    Matrix matrix = TransformationMatrix.GetTransformationMatrix(transform);
                    if (matrix != null) {
                        template.ConcatCTM(matrix);
                    }
                }
            }
            Write(context, po, t);

            return GetNext();
        }
Пример #44
0
        public OptionResult Perform(ProcessObject onProcess)
        {
            if (!Initialize()) return OptionResult.Failure;

            Perform(GetObjects(Common.Localize(LocalizeKey + ":Header")), onProcess);
            return OptionResult.SuccessRetain;
        }